@getsoren/shared-module 2.55.0 → 2.57.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -66,6 +66,7 @@ export declare const CLIENT_EVENTS: {
66
66
  immobilisation: {
67
67
  closesOnSubmit: true;
68
68
  dates: "range";
69
+ hasOptionalAmount: true;
69
70
  id: string;
70
71
  price: "credit";
71
72
  reason: string;
@@ -175,6 +176,7 @@ export declare const CLIENT_EVENTS: {
175
176
  closesOnSubmit: true;
176
177
  dates: "single";
177
178
  dayHint: "request";
179
+ hasOptionalAmount: true;
178
180
  hasTitle: true;
179
181
  id: string;
180
182
  price: "amount";
@@ -193,6 +195,7 @@ export declare const CLIENT_EVENTS: {
193
195
  };
194
196
  weather: {
195
197
  dates: "range";
198
+ hasOptionalAmount: true;
196
199
  id: string;
197
200
  price: "credit";
198
201
  questions: {
@@ -29,7 +29,7 @@ declare const useEventDeclaration: ({ funnel, countBillableDays, dailyPrice, las
29
29
  reset: () => void;
30
30
  selectAmountGate: (isYes: boolean) => void;
31
31
  selectEvent: (selected: EventDefinition) => void;
32
- selectGroup: (selected: FunnelGroup) => void;
32
+ selectGroup: (selected: FunnelGroup, given?: Partial<EventAnswers>) => void;
33
33
  selectReason: (reason: string) => void;
34
34
  setAnswers: (changes: Partial<EventAnswers>) => void;
35
35
  showsReBillRatio: boolean;
@@ -48,6 +48,8 @@ export interface EventDefinition {
48
48
  hasIntervention?: boolean;
49
49
  price?: EventPriceRule;
50
50
  amountGate?: EventAmountGate;
51
+ /** The amount asked can be left empty: the event is then declared without one. */
52
+ hasOptionalAmount?: boolean;
51
53
  /** Bills hours over the period instead of days. */
52
54
  billingType?: "DELTA";
53
55
  /** Photos are the point of the event (`focus`), asked first (`first`) or not asked (`none`); optional otherwise. */
@@ -141,7 +143,10 @@ export type EventWorkflowValue = {
141
143
  export interface EventPayload {
142
144
  billingType: "DELTA" | "PER_DAY";
143
145
  bookingItemId: string | null;
144
- /** Sent even for a single day, so the backend skips the days the line does not bill. */
146
+ /**
147
+ * The days to bill, sent even for a single day, which the backend bills as one; null for a period the line bills no
148
+ * day of, which the backend refuses and dates from its value instead.
149
+ */
145
150
  dates: [string, string] | null;
146
151
  unitPrice: number | null;
147
152
  workflow: NativeEventWorkflow;
@@ -152,11 +157,16 @@ export interface EventPayload {
152
157
  }
153
158
  /** An event declared natively, read back from its values. */
154
159
  export interface DeclaredEvent {
160
+ /** The definition to show it with, and to edit it with when `editFunnel` is set. */
155
161
  event: EventDefinition;
156
162
  answers: EventAnswers;
157
163
  side: EventSide;
158
- /** False when the reader's funnel does not offer it (another team's, another side's): shown, not edited. */
159
- isOffered: boolean;
164
+ /**
165
+ * The funnel to edit it with: the reader's own when it asks the same answers, the supplier's for a supplier's event,
166
+ * which a client corrects before closing it. Unset when the reader only shows it (another team's event, a client's
167
+ * event read by a supplier).
168
+ */
169
+ editFunnel?: EventFunnel;
160
170
  }
161
171
  /** A key of the `eventDeclaration` namespace: a group of texts, then one of its texts. */
162
172
  export type EventTextKey = `${keyof EventTexts}.${string}`;
@@ -7,12 +7,15 @@ export interface EventAmounts {
7
7
  /** A credit only on days the line does not bill (weekend, bank holiday). */
8
8
  hasNothingToBill: boolean;
9
9
  }
10
- /** A number typed with either decimal separator (French keyboards type a comma), null when none is typed. */
10
+ /** A number typed with either decimal separator (French keyboards type a comma), null when it is not a plain decimal. */
11
11
  export declare const toDecimal: (text: string) => number | null;
12
- /** Null without a price, behind a gate answered no, or while nothing is typed; a credit, typed positive, is sent negative. */
12
+ /**
13
+ * Null without a price, behind a gate answered no, or while no amount is typed, zero being none; a credit, typed
14
+ * positive, is sent negative.
15
+ */
13
16
  export declare const getUnitPrice: (event: EventDefinition, answers: Pick<EventAnswers, "amount" | "amountGate">) => number | null;
14
17
  /**
15
- * What the event bills. `billableDays` counts the days of a period the line bills (the app knows its calendar);
16
- * a single day, or an event without a period, counts one.
18
+ * What the event bills. `billableDays` counts the days of a period the line bills (the app knows its calendar).
19
+ * A period of one day counts one whatever the calendar, as the backend bills it, and so does an event without a period.
17
20
  */
18
21
  export declare const getEventAmounts: (event: EventDefinition | undefined, answers: EventAnswers, billableDays: number) => EventAmounts;
@@ -0,0 +1 @@
1
+ export {};
@@ -8,6 +8,8 @@ interface BuildEventPayloadParams {
8
8
  bookingItemId?: string | null;
9
9
  /** False when the user sees no price, or a credit falls on no billed day. */
10
10
  withPrice: boolean;
11
+ /** Days of its period the order line bills, by the app's calendar (`getEventAmounts`); a period is billed when unknown. */
12
+ billableDays?: number;
11
13
  /** Sends the re-billing percentage with the amount, for the users asked it or keeping the one stored. */
12
14
  withReBillRatio?: boolean;
13
15
  }
@@ -23,5 +25,5 @@ export declare const isNativeEventWorkflow: (workflow: unknown) => workflow is N
23
25
  * The event as the backend stores it: the marker of its definition in place of a Treege tree, and one value per answer.
24
26
  * Dates and prices are also sent as fields, which the backend bills from; their values are what the timelines show.
25
27
  */
26
- declare const buildEventPayload: ({ funnel, event, answers, translate, bookingItemId, withPrice, withReBillRatio, }: BuildEventPayloadParams) => EventPayload;
28
+ declare const buildEventPayload: ({ funnel, event, answers, translate, bookingItemId, withPrice, billableDays, withReBillRatio, }: BuildEventPayloadParams) => EventPayload;
27
29
  export default buildEventPayload;
@@ -12,7 +12,8 @@ interface StoredEvent {
12
12
  /**
13
13
  * An event declared with this engine, read with the definition it was declared with: a tenant whose funnel changes
14
14
  * keeps reading its older events right. The reader edits it with its own definition when that one asks the same
15
- * answers, and only shows it otherwise (another team's, another side's). Undefined for a Treege event.
15
+ * answers, a client edits a supplier's with the supplier's questions, and the event is only shown otherwise (another
16
+ * team's, a client's read by a supplier). Undefined for a Treege event.
16
17
  */
17
18
  declare const readEvent: ({ workflow, workflowValues }: StoredEvent, readerFunnel: EventFunnel) => DeclaredEvent | undefined;
18
19
  export default readEvent;
package/dist/events.js CHANGED
@@ -69,6 +69,7 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
69
69
  immobilisation: {
70
70
  closesOnSubmit: !0,
71
71
  dates: "range",
72
+ hasOptionalAmount: !0,
72
73
  id: "immobilisation",
73
74
  price: "credit",
74
75
  reason: "immobilisation"
@@ -203,6 +204,7 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
203
204
  closesOnSubmit: !0,
204
205
  dates: "single",
205
206
  dayHint: "request",
207
+ hasOptionalAmount: !0,
206
208
  hasTitle: !0,
207
209
  id: "other_request",
208
210
  price: "amount"
@@ -221,6 +223,7 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
221
223
  },
222
224
  weather: {
223
225
  dates: "range",
226
+ hasOptionalAmount: !0,
224
227
  id: "weather",
225
228
  price: "credit",
226
229
  questions: { dates: "weatherDays" },
@@ -422,47 +425,47 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
422
425
  showsPrice: !0
423
426
  },
424
427
  side: "supplier"
425
- }, d = (e) => {
426
- let t = Number(e.trim().replace(",", "."));
427
- return e.trim() && Number.isFinite(t) ? t : null;
428
- }, f = (e, t) => {
429
- let n = d(t.amount);
430
- return !e.price || e.amountGate && !t.amountGate || n === null ? null : e.price === "credit" ? -Math.abs(n) : n;
431
- }, p = (e, t, n) => {
432
- let r = e ? f(e, t) : null, i = e?.dates === "range" ? n : 1;
428
+ }, d = /^-?(\d+\.?\d*|\.\d+)$/, f = (e) => {
429
+ let t = e.trim().replace(",", ".");
430
+ return d.test(t) ? Number(t) : null;
431
+ }, p = (e, t) => {
432
+ let n = f(t.amount);
433
+ return !e.price || e.amountGate && !t.amountGate || !n ? null : e.price === "credit" ? -Math.abs(n) : n;
434
+ }, m = (e, t, n) => {
435
+ let { fromDate: r, toDate: i } = t.dates, a = e ? p(e, t) : null, o = e?.dates === "range" && r !== i ? n : 1;
433
436
  return {
434
- billableDays: i,
435
- hasNothingToBill: e?.price === "credit" && i === 0,
436
- total: r === null ? null : r * i,
437
- unitPrice: r
437
+ billableDays: o,
438
+ hasNothingToBill: e?.price === "credit" && o === 0,
439
+ total: a === null ? null : a * o,
440
+ unitPrice: a
438
441
  };
439
- }, m = ({ groups: e, events: t }) => e.flatMap((e) => {
442
+ }, h = ({ groups: e, events: t }) => e.flatMap((e) => {
440
443
  let n = t.filter(({ id: t }) => e.events.includes(t));
441
444
  return n.length ? [{
442
445
  ...e,
443
446
  events: n
444
447
  }] : [];
445
- }), h = (e, t) => e.endDates?.[t], g = (e, t, n, r) => [
448
+ }), g = (e, t) => e.endDates?.[t], _ = (e, t, n, r) => [
446
449
  "kind",
447
450
  ...(e?.events.length ?? 0) > 1 ? ["event"] : [],
448
451
  ...t?.reasons?.length ? ["reason"] : [],
449
- ...t?.dates || t && h(t, n.reason) ? ["dates"] : [],
452
+ ...t?.dates || t && g(t, n.reason) ? ["dates"] : [],
450
453
  ...t?.checks?.length ? ["checks"] : [],
451
454
  ...t?.hasTitle || t?.fields?.length ? ["fields"] : [],
452
455
  ...r && t?.price && t.amountGate ? ["amountGate"] : [],
453
456
  ...r && t?.price && (!t.amountGate || n.amountGate) ? ["amount"] : [],
454
457
  ...t ? ["details"] : []
455
- ], _ = (e, t, n = !1) => e.find((e) => e !== "kind" && e !== "event" && (n || e !== "reason" || !t.reason)) ?? "details", v = (e, t, n) => {
458
+ ], v = (e, t, n = !1) => e.find((e) => e !== "kind" && e !== "event" && (n || e !== "reason" || !t.reason)) ?? "details", y = (e, t, n) => {
456
459
  switch (e) {
457
460
  case "reason": return !!n.reason;
458
461
  case "dates": return !!(n.dates.fromDate && n.dates.toDate);
459
462
  case "fields": return (!t.hasTitle || !!n.title.trim()) && (t.fields ?? []).every(({ name: e, required: t }) => !t || !!n.fields[e]?.trim());
460
463
  case "amountGate": return n.amountGate !== void 0;
461
- case "amount": return !!f(t, n);
464
+ case "amount": return !!t.hasOptionalAmount || p(t, n) !== null;
462
465
  default: return !0;
463
466
  }
464
- }, y = (e, t) => e.hasTitle ? t.title.trim() : e.reasonDetail ? e.reason ?? "" : t.reason || (e.reason ?? ""), b = (e, t, n) => {
465
- let r = y(e, t);
467
+ }, b = (e, t) => e.hasTitle ? t.title.trim() : e.reasonDetail ? e.reason ?? "" : t.reason || (e.reason ?? ""), x = (e, t, n) => {
468
+ let r = b(e, t);
466
469
  if (e.hasTitle) return {
467
470
  label: n("values.title"),
468
471
  name: a.reason,
@@ -481,8 +484,8 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
481
484
  value: r
482
485
  }
483
486
  };
484
- }, x = (e, { dates: { fromDate: t, toDate: n }, reason: r }, i) => {
485
- let o = h(e, r);
487
+ }, S = (e, { dates: { fromDate: t, toDate: n }, reason: r }, i) => {
488
+ let o = g(e, r);
486
489
  return t && n ? o ? [{
487
490
  label: i(`values.${o.name}`),
488
491
  name: o.name,
@@ -499,18 +502,18 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
499
502
  type: "date",
500
503
  value: t
501
504
  }] : [] : [];
502
- }, S = (e, t) => {
503
- let n = e === "number" ? d(t) : null;
505
+ }, C = (e, t) => {
506
+ let n = e === "number" ? f(t) : null;
504
507
  return n === null ? t.trim() : String(n);
505
- }, C = "dedicated", w = (e, t) => ({
508
+ }, w = "dedicated", T = (e, t) => ({
506
509
  eventId: t,
507
- funnel: C,
510
+ funnel: w,
508
511
  side: e,
509
512
  source: r,
510
513
  version: 2
511
- }), T = (e) => typeof e == "object" && !!e && "source" in e && e.source === "soren-event" && "eventId" in e && typeof e.eventId == "string", E = ({ funnel: e, event: t, answers: n, translate: i, bookingItemId: o, withPrice: s, withReBillRatio: c = e.pricing.asksReBillRatio }) => {
512
- let { fromDate: l, toDate: u } = n.dates, p = !!(t.dates && l && u), m = s ? f(t, n) : null, h = d(n.reBillRatio), g = n.description.trim(), _ = t.billingType === "DELTA", v = d(n.fields.quantity ?? ""), y = [
513
- b(t, n, i),
514
+ }), E = (e) => typeof e == "object" && !!e && "source" in e && e.source === "soren-event" && "eventId" in e && typeof e.eventId == "string", D = ({ funnel: e, event: t, answers: n, translate: i, bookingItemId: o, withPrice: s, billableDays: c, withReBillRatio: l = e.pricing.asksReBillRatio }) => {
515
+ let { fromDate: u, toDate: d } = n.dates, m = !!(t.dates && u && d) && c !== 0, h = s ? p(t, n) : null, g = f(n.reBillRatio), _ = n.description.trim(), v = t.billingType === "DELTA", y = f(n.fields.quantity ?? ""), b = [
516
+ x(t, n, i),
514
517
  ...t.reasonDetail && n.reason ? [{
515
518
  label: i(`values.${t.reasonDetail}`),
516
519
  name: t.reasonDetail,
@@ -520,13 +523,13 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
520
523
  value: n.reason
521
524
  }
522
525
  }] : [],
523
- ...x(t, n, i),
524
- ...g ? [{
526
+ ...S(t, n, i),
527
+ ..._ ? [{
525
528
  label: i("values.description"),
526
529
  name: a.description,
527
530
  tag: "description",
528
531
  type: "text",
529
- value: g
532
+ value: _
530
533
  }] : [],
531
534
  ...(t.checks ?? []).map((e) => ({
532
535
  label: i(`checks.${e}`),
@@ -538,7 +541,7 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
538
541
  label: i(`fields.${e}`),
539
542
  name: e,
540
543
  type: t,
541
- value: S(t, n.fields[e])
544
+ value: C(t, n.fields[e])
542
545
  })),
543
546
  ...t.hasIntervention ? [{
544
547
  label: i("values.intervention"),
@@ -546,24 +549,24 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
546
549
  type: "checkbox",
547
550
  value: n.intervention
548
551
  }] : [],
549
- ...m === null ? [] : [{
552
+ ...h === null ? [] : [{
550
553
  label: i("values.amount"),
551
554
  name: a.unitPrice,
552
555
  type: "number",
553
- value: String(m)
556
+ value: String(h)
554
557
  }],
555
- ...c && m !== null && h !== null ? [{
558
+ ...l && h !== null && g !== null ? [{
556
559
  label: i("values.re_bill_ratio"),
557
560
  name: a.reBillRatio,
558
561
  type: "number",
559
- value: String(h)
562
+ value: String(g)
560
563
  }] : []
561
564
  ];
562
565
  return {
563
- billingType: _ ? "DELTA" : "PER_DAY",
566
+ billingType: v ? "DELTA" : "PER_DAY",
564
567
  bookingItemId: o || null,
565
- dates: p ? [l, u] : null,
566
- unitPrice: m,
568
+ dates: m ? [u, d] : null,
569
+ unitPrice: h,
567
570
  workflow: {
568
571
  eventId: t.id,
569
572
  funnel: e.id,
@@ -571,14 +574,14 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
571
574
  source: r,
572
575
  version: 2
573
576
  },
574
- workflowValues: y,
575
- ..._ && {
577
+ workflowValues: b,
578
+ ...v && {
576
579
  priceUnit: "EUR",
577
580
  qtyUnit: "HOURS",
578
- quantity: v
581
+ quantity: y
579
582
  }
580
583
  };
581
- }, D = {
584
+ }, O = {
582
585
  amount: "",
583
586
  checks: {},
584
587
  dates: {
@@ -591,51 +594,51 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
591
594
  reason: "",
592
595
  reBillRatio: "",
593
596
  title: ""
594
- }, O = ({ funnel: n, countBillableDays: r, dailyPrice: i, lastReBillRatio: a = "", isEditing: o = !1 }) => {
595
- let [s, c] = t(), [l, u] = t(), [d, f] = t("kind"), [h, y] = t(D), [b, x] = t(!1), S = e(() => m(n), [n]), C = S.find(({ id: e }) => e === s), w = C?.events.find(({ id: e }) => e === l), { showsPrice: T, asksReBillRatio: O } = n.pricing, k = p(w, h, w?.dates === "range" ? r(h.dates) : 1), A = T && !!w?.price, j = A && !k.hasNothingToBill, M = g(C, w, h, j), N = M[M.indexOf(d) - 1], P = (e) => y((t) => ({
597
+ }, k = ({ funnel: n, countBillableDays: r, dailyPrice: i, lastReBillRatio: a = "", isEditing: o = !1 }) => {
598
+ let [s, c] = t(), [l, u] = t(), [d, f] = t("kind"), [p, g] = t(O), [b, x] = t(!1), S = e(() => h(n), [n]), C = S.find(({ id: e }) => e === s), w = C?.events.find(({ id: e }) => e === l), { showsPrice: T, asksReBillRatio: E } = n.pricing, k = m(w, p, w?.dates === "range" ? r(p.dates) : 1), A = T && !!w?.price, j = A && !k.hasNothingToBill, M = _(C, w, p, j), N = M[M.indexOf(d) - 1], P = (e) => g((t) => ({
596
599
  ...t,
597
600
  ...e
598
601
  })), F = (e) => e.price === "credit" && i ? String(Math.abs(i)) : "", I = (e, t) => {
599
- let n = g(C, w, t, j);
602
+ let n = _(C, w, t, j);
600
603
  return n[n.indexOf(e) + 1] ?? "details";
601
604
  }, L = () => {
602
- c(void 0), u(void 0), f("kind"), y(D), x(!1);
605
+ c(void 0), u(void 0), f("kind"), g(O), x(!1);
603
606
  }, R = (e, t, n = {}) => {
604
607
  let r = {
605
- ...D,
608
+ ...O,
606
609
  amount: F(t),
607
610
  reason: t.reasons?.length ? "" : t.reason ?? "",
608
- reBillRatio: O ? a : "",
611
+ reBillRatio: E ? a : "",
609
612
  ...n
610
613
  };
611
- c(e.id), u(t.id), y(r), f(_(g(e, t, r, T && !!t.price), r, o));
614
+ c(e.id), u(t.id), g(r), f(v(_(e, t, r, T && !!t.price), r, o));
612
615
  }, z = ({ eventId: e, answers: t }) => {
613
616
  let n = S.find(({ events: t }) => t.some(({ id: t }) => t === e)), r = n?.events.find(({ id: t }) => t === e);
614
617
  return n && r ? (R(n, r, t), x(!0), !0) : !1;
615
- }, B = (e) => {
618
+ }, B = (e, t) => {
616
619
  if (e.events.length === 1) {
617
- R(e, e.events[0]);
620
+ R(e, e.events[0], t);
618
621
  return;
619
622
  }
620
623
  c(e.id), u(void 0), f("event");
621
624
  }, V = (e) => {
622
625
  C && R(C, e);
623
- }, H = () => f(I(d, h)), U = (e) => {
624
- let t = w?.endDates && e !== h.reason ? {
625
- dates: D.dates,
626
+ }, H = () => f(I(d, p)), U = (e) => {
627
+ let t = w?.endDates && e !== p.reason ? {
628
+ dates: O.dates,
626
629
  reason: e
627
630
  } : { reason: e }, n = {
628
- ...h,
631
+ ...p,
629
632
  ...t
630
633
  };
631
634
  P(t), f(I("reason", n));
632
635
  }, W = (e) => {
633
636
  let t = {
634
- amount: e && w ? h.amount || F(w) : "",
637
+ amount: e && w ? p.amount || F(w) : "",
635
638
  amountGate: e
636
639
  };
637
640
  P(t), f(I("amountGate", {
638
- ...h,
641
+ ...p,
639
642
  ...t
640
643
  }));
641
644
  }, G = () => {
@@ -644,22 +647,23 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
644
647
  return;
645
648
  }
646
649
  f(N);
647
- }, K = !!w && M.every((e) => v(e, w, h)), q = o && !T && !k.hasNothingToBill;
650
+ }, K = !!w && M.every((e) => y(e, w, p)), q = o && !T && !k.hasNothingToBill;
648
651
  return {
649
652
  amounts: k,
650
- answers: h,
653
+ answers: p,
651
654
  asksAmount: j,
652
- buildPayload: (e, t) => w && K ? E({
653
- answers: h,
655
+ buildPayload: (e, t) => w && K ? D({
656
+ answers: p,
657
+ billableDays: k.billableDays,
654
658
  bookingItemId: t,
655
659
  event: w,
656
660
  funnel: n,
657
661
  translate: e,
658
662
  withPrice: j || q,
659
- withReBillRatio: O || q
663
+ withReBillRatio: E || o
660
664
  }) : void 0,
661
665
  canGoBack: d !== "kind" && !(b && (N === "kind" || N === "event")),
662
- canGoNext: !!w && v(d, w, h),
666
+ canGoNext: !!w && y(d, w, p),
663
667
  event: w,
664
668
  goBack: G,
665
669
  goNext: H,
@@ -673,12 +677,12 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
673
677
  selectGroup: B,
674
678
  selectReason: U,
675
679
  setAnswers: P,
676
- showsReBillRatio: O && A,
680
+ showsReBillRatio: E && A,
677
681
  startPrefill: z,
678
682
  step: d,
679
683
  steps: M
680
684
  };
681
- }, k = {
685
+ }, A = {
682
686
  ar: {
683
687
  checks: {
684
688
  ce_conformity: "تم التحقق من شهادة أو إقرار CE",
@@ -1806,7 +1810,7 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
1806
1810
  title: "Título do evento"
1807
1811
  }
1808
1812
  }
1809
- }, A = ["companion", "operative"], j = {
1813
+ }, j = ["companion", "operative"], M = {
1810
1814
  ...s,
1811
1815
  breakage: {
1812
1816
  ...s.breakage,
@@ -1844,7 +1848,7 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
1844
1848
  ...s.robbery,
1845
1849
  reasons: ["robbery_machine", "robbery_option"]
1846
1850
  }
1847
- }, M = [
1851
+ }, N = [
1848
1852
  "n1_control",
1849
1853
  "other_request",
1850
1854
  "breakdown",
@@ -1862,13 +1866,13 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
1862
1866
  "hours_record",
1863
1867
  "robbery",
1864
1868
  "other"
1865
- ], N = [
1869
+ ], P = [
1866
1870
  "n1_control",
1867
1871
  "n3_control",
1868
1872
  "machine_assignment",
1869
1873
  "operator_change",
1870
1874
  "hours_record"
1871
- ], P = [
1875
+ ], F = [
1872
1876
  c.controls,
1873
1877
  c.admin_request,
1874
1878
  c.machine_problem,
@@ -1877,60 +1881,68 @@ var n = "eventDeclaration", r = "soren-event", i = 2, a = {
1877
1881
  c.delivery,
1878
1882
  c.documents,
1879
1883
  c.other
1880
- ], F = {
1881
- events: M.map((e) => j[e]),
1882
- groups: P,
1884
+ ], I = {
1885
+ events: N.map((e) => M[e]),
1886
+ groups: F,
1883
1887
  id: "bouygues",
1884
1888
  pricing: {
1885
1889
  asksReBillRatio: !0,
1886
1890
  showsPrice: !0
1887
1891
  },
1888
1892
  side: "client"
1889
- }, I = {
1890
- events: M.filter((e) => !N.includes(e)).map((e) => j[e]),
1891
- groups: P,
1893
+ }, L = {
1894
+ events: N.filter((e) => !P.includes(e)).map((e) => M[e]),
1895
+ groups: F,
1892
1896
  id: "bouyguesField",
1893
1897
  pricing: {
1894
1898
  asksReBillRatio: !1,
1895
1899
  showsPrice: !1
1896
1900
  },
1897
1901
  side: "client"
1898
- }, L = [{
1899
- funnels: [F, I],
1900
- getFunnel: (e) => A.includes(e ?? "") ? I : F,
1902
+ }, R = [{
1903
+ funnels: [I, L],
1904
+ getFunnel: (e) => j.includes(e ?? "") ? L : I,
1901
1905
  tenants: ["bouygues"]
1902
- }], R = [
1906
+ }], z = [
1903
1907
  l,
1904
1908
  u,
1905
- ...L.flatMap(({ funnels: e }) => e)
1906
- ], z = ({ side: e, tenantName: t, roleName: n }) => e === "supplier" ? u : L.find(({ tenants: e }) => e.includes(t ?? ""))?.getFunnel(n) ?? l, B = (e) => R.find((t) => t.id === e), V = 10, H = (e) => typeof e == "object" && e && "value" in e ? H(e.value) : typeof e == "string" || typeof e == "number" ? String(e) : "", U = (e) => e === !0 || e === "true", W = (e, t) => {
1907
- let n = (e) => t.find((t) => t.name === e)?.value, r = H(t.find(({ tag: e }) => e === "reason")?.value), i = e.hasTitle ? "" : H(e.reasonDetail ? n(e.reasonDetail) : r), o = n(a.dates), [s = "", c = ""] = Array.isArray(o) ? o.map(H) : [], l = H(n(h(e, i)?.name ?? a.date)), u = Number(H(n(a.unitPrice)) || NaN), d = Number.isFinite(u);
1909
+ ...R.flatMap(({ funnels: e }) => e)
1910
+ ], B = ({ side: e, tenantName: t, roleName: n }) => e === "supplier" ? u : R.find(({ tenants: e }) => e.includes(t ?? ""))?.getFunnel(n) ?? l, V = (e) => z.find((t) => t.id === e), H = 10, U = (e) => typeof e == "object" && e && "value" in e ? U(e.value) : typeof e == "string" || typeof e == "number" ? String(e) : "", W = (e) => e === !0 || e === "true", G = (e, t) => {
1911
+ let n = (e) => t.find((t) => t.name === e)?.value, r = U(t.find(({ tag: e }) => e === "reason")?.value), i = t.find(({ tag: e }) => e === "description")?.value ?? n(a.description), o = e.hasTitle ? "" : U(e.reasonDetail ? n(e.reasonDetail) : r), s = n(a.dates), [c = "", l = ""] = Array.isArray(s) ? s.map(U) : [], u = U(n(g(e, o)?.name ?? a.date)), d = Number(U(n(a.unitPrice)) || NaN), f = Number.isFinite(d);
1908
1912
  return {
1909
- amount: d ? String(e.price === "credit" ? Math.abs(u) : u) : "",
1910
- ...e.amountGate && { amountGate: d },
1911
- checks: Object.fromEntries((e.checks ?? []).map((e) => [e, U(n(e))])),
1913
+ amount: f ? String(e.price === "credit" ? Math.abs(d) : d) : "",
1914
+ ...e.amountGate && { amountGate: f },
1915
+ checks: Object.fromEntries((e.checks ?? []).map((e) => [e, W(n(e))])),
1912
1916
  dates: {
1913
- fromDate: (s || l).slice(0, V),
1914
- toDate: (c || l).slice(0, V)
1915
- },
1916
- description: H(n(a.description)),
1917
- fields: Object.fromEntries((e.fields ?? []).map(({ name: e }) => [e, H(n(e))])),
1918
- intervention: U(n(a.intervention)),
1919
- reason: i,
1920
- reBillRatio: H(n(a.reBillRatio)),
1917
+ fromDate: (c || u).slice(0, H),
1918
+ toDate: (l || u).slice(0, H)
1919
+ },
1920
+ description: U(i),
1921
+ fields: Object.fromEntries((e.fields ?? []).map(({ name: e }) => [e, U(n(e))])),
1922
+ intervention: W(n(a.intervention)),
1923
+ reason: o,
1924
+ reBillRatio: U(n(a.reBillRatio)),
1921
1925
  title: e.hasTitle ? r : ""
1922
1926
  };
1923
- }, G = (e, t, { reason: n }) => e.reasonDetail === t.reasonDetail && !!e.hasTitle == !!t.hasTitle && (!!e.hasTitle || !!e.reasonDetail || (e.reasons?.includes(n) ?? n === e.reason)), K = ({ workflow: e, workflowValues: t }, n) => {
1924
- if (!T(e)) return;
1925
- let r = n.side === e.side ? n.events.find(({ id: t }) => t === e.eventId) : void 0, i = B(e.funnel)?.events.find(({ id: t }) => t === e.eventId) ?? r;
1926
- if (!i) return;
1927
- let a = W(i, t ?? []), o = r && G(r, i, a) ? r : void 0;
1928
- return {
1929
- answers: a,
1930
- event: o ?? i,
1931
- isOffered: !!o,
1927
+ }, K = (e, t, { reason: n }) => e.reasonDetail === t.reasonDetail && !!e.hasTitle == !!t.hasTitle && (!!e.hasTitle || !!e.reasonDetail || (e.reasons?.includes(n) ?? n === e.reason)), q = (e, t) => e === "client" && t === "supplier", J = ({ workflow: e, workflowValues: t }, n) => {
1928
+ if (!E(e)) return;
1929
+ let r = V(e.funnel), i = n.side === e.side ? n.events.find(({ id: t }) => t === e.eventId) : void 0, a = r?.events.find(({ id: t }) => t === e.eventId) ?? i;
1930
+ if (!a) return;
1931
+ let o = G(a, t ?? []);
1932
+ return i && K(i, a, o) ? {
1933
+ answers: o,
1934
+ editFunnel: n,
1935
+ event: i,
1936
+ side: e.side
1937
+ } : {
1938
+ answers: o,
1939
+ editFunnel: r && q(n.side, e.side) ? {
1940
+ ...r,
1941
+ pricing: n.pricing
1942
+ } : void 0,
1943
+ event: a,
1932
1944
  side: e.side
1933
1945
  };
1934
1946
  };
1935
1947
  //#endregion
1936
- export { s as CLIENT_EVENTS, c as CLIENT_GROUPS, C as DEDICATED_FUNNEL, l as DEFAULT_CLIENT_FUNNEL, k as EVENT_LOCALES, n as EVENT_NAMESPACE, o as INVENTORY_ID, r as NATIVE_EVENT_SOURCE, i as NATIVE_EVENT_VERSION, u as SUPPLIER_FUNNEL, a as VALUE_NAMES, E as buildEventPayload, B as findEventFunnel, w as getDedicatedEventWorkflow, h as getEndDate, p as getEventAmounts, z as getEventFunnel, _ as getFirstQuestion, m as getFunnelGroups, y as getReason, g as getSteps, f as getUnitPrice, T as isNativeEventWorkflow, v as isStepAnswered, K as readEvent, d as toDecimal, O as useEventDeclaration };
1948
+ export { s as CLIENT_EVENTS, c as CLIENT_GROUPS, w as DEDICATED_FUNNEL, l as DEFAULT_CLIENT_FUNNEL, A as EVENT_LOCALES, n as EVENT_NAMESPACE, o as INVENTORY_ID, r as NATIVE_EVENT_SOURCE, i as NATIVE_EVENT_VERSION, u as SUPPLIER_FUNNEL, a as VALUE_NAMES, D as buildEventPayload, V as findEventFunnel, T as getDedicatedEventWorkflow, g as getEndDate, m as getEventAmounts, B as getEventFunnel, v as getFirstQuestion, h as getFunnelGroups, b as getReason, _ as getSteps, p as getUnitPrice, E as isNativeEventWorkflow, y as isStepAnswered, J as readEvent, f as toDecimal, k as useEventDeclaration };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getsoren/shared-module",
3
- "version": "2.55.0",
3
+ "version": "2.57.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "types": "./dist/main.d.ts",
@@ -85,7 +85,7 @@
85
85
  "react": "^17.0.0 || ^18.0.0 || ^19.0.0",
86
86
  "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0",
87
87
  "react-i18next": "*",
88
- "react-router": "*"
88
+ "react-router": "^7.0.0"
89
89
  },
90
90
  "peerDependenciesMeta": {
91
91
  "@amplitude/analytics-browser": {