@getsoren/shared-module 2.54.0 → 2.55.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.
@@ -0,0 +1,245 @@
1
+ import { EventFunnel } from '../types';
2
+ /**
3
+ * Events a client declares, as every tenant asks them. A tenant offers some of them in its own order, and may word
4
+ * or detail one its own way (`tenants/`).
5
+ */
6
+ export declare const CLIENT_EVENTS: {
7
+ breakage: {
8
+ amountGate: "known";
9
+ dates: "single";
10
+ dayHint: "breakage";
11
+ hasIntervention: true;
12
+ id: string;
13
+ price: "amount";
14
+ questions: {
15
+ reason: "breakageKind";
16
+ };
17
+ reason: string;
18
+ };
19
+ breakdown: {
20
+ amountGate: "known";
21
+ dates: "range";
22
+ hasIntervention: true;
23
+ id: string;
24
+ price: "credit";
25
+ questions: {
26
+ dates: "breakdownDays";
27
+ reason: "breakdownKind";
28
+ };
29
+ reason: string;
30
+ };
31
+ delivery_problem: {
32
+ amountGate: "known";
33
+ dates: "single";
34
+ dayHint: "deliveryProblem";
35
+ id: string;
36
+ price: "amount";
37
+ questions: {
38
+ reason: "deliveryProblemKind";
39
+ };
40
+ reasons: string[];
41
+ };
42
+ document_conformity: {
43
+ id: string;
44
+ questions: {
45
+ reason: "documentKind";
46
+ };
47
+ reason: string;
48
+ reasons: string[];
49
+ };
50
+ hours_record: {
51
+ billingType: "DELTA";
52
+ closesOnSubmit: true;
53
+ dates: "range";
54
+ fields: ({
55
+ name: "quantity";
56
+ required: true;
57
+ type: "number";
58
+ } | {
59
+ name: "hours_record_number";
60
+ type: "text";
61
+ required?: undefined;
62
+ })[];
63
+ id: string;
64
+ reason: string;
65
+ };
66
+ immobilisation: {
67
+ closesOnSubmit: true;
68
+ dates: "range";
69
+ id: string;
70
+ price: "credit";
71
+ reason: string;
72
+ };
73
+ inventory: {
74
+ closesOnSubmit: true;
75
+ id: string;
76
+ photos: "focus";
77
+ reason: string;
78
+ };
79
+ machine_assignment: {
80
+ closesOnSubmit: true;
81
+ fields: ({
82
+ name: "assigned_machine";
83
+ type: "text";
84
+ } | {
85
+ name: "model";
86
+ type: "text";
87
+ } | {
88
+ name: "supplier_reference";
89
+ type: "text";
90
+ } | {
91
+ name: "serial_number";
92
+ type: "text";
93
+ } | {
94
+ name: "code";
95
+ type: "text";
96
+ })[];
97
+ id: string;
98
+ reason: string;
99
+ };
100
+ material_usage: {
101
+ amountGate: "known";
102
+ dates: "single";
103
+ dayHint: "problem";
104
+ id: string;
105
+ price: "amount";
106
+ questions: {
107
+ reason: "materialUsageKind";
108
+ };
109
+ reason: string;
110
+ };
111
+ n1_control: {
112
+ checks: ("ce_conformity" | "maintenance_log" | "operator_skills" | "vgp_control")[];
113
+ closesOnSubmit: true;
114
+ id: string;
115
+ reason: string;
116
+ };
117
+ n2_control: {
118
+ checks: ("documents_on_delivery" | "expected_operator" | "machine_good_condition" | "machine_matches_order")[];
119
+ dates: "single";
120
+ dayHint: "control";
121
+ id: string;
122
+ photos: "focus";
123
+ reason: string;
124
+ };
125
+ n3_control: {
126
+ checks: ("ce_declaration" | "ce_plate" | "last_inspection_report" | "machine_compliant" | "operator_papers" | "operator_present" | "user_manual")[];
127
+ closesOnSubmit: true;
128
+ dates: "single";
129
+ dayHint: "control";
130
+ fields: ({
131
+ name: "site_escort";
132
+ type: "text";
133
+ required?: undefined;
134
+ } | {
135
+ name: "serial_number";
136
+ required: true;
137
+ type: "text";
138
+ } | {
139
+ name: "inspector_opinion";
140
+ required: true;
141
+ type: "text";
142
+ })[];
143
+ id: string;
144
+ reason: string;
145
+ };
146
+ operator_change: {
147
+ closesOnSubmit: true;
148
+ dates: "single";
149
+ dayHint: "operatorChange";
150
+ fields: {
151
+ name: "new_operator_name";
152
+ required: true;
153
+ type: "text";
154
+ }[];
155
+ id: string;
156
+ reason: string;
157
+ };
158
+ other: {
159
+ amountGate: "known";
160
+ dates: "single";
161
+ dayHint: "event";
162
+ hasTitle: true;
163
+ id: string;
164
+ price: "amount";
165
+ };
166
+ other_material: {
167
+ amountGate: "known";
168
+ dates: "single";
169
+ dayHint: "problem";
170
+ hasTitle: true;
171
+ id: string;
172
+ price: "amount";
173
+ };
174
+ other_request: {
175
+ closesOnSubmit: true;
176
+ dates: "single";
177
+ dayHint: "request";
178
+ hasTitle: true;
179
+ id: string;
180
+ price: "amount";
181
+ };
182
+ robbery: {
183
+ amountGate: "known";
184
+ dates: "single";
185
+ dayHint: "robbery";
186
+ id: string;
187
+ price: "amount";
188
+ questions: {
189
+ dates: "robberyDay";
190
+ reason: "robberyKind";
191
+ };
192
+ reason: string;
193
+ };
194
+ weather: {
195
+ dates: "range";
196
+ id: string;
197
+ price: "credit";
198
+ questions: {
199
+ dates: "weatherDays";
200
+ };
201
+ reason: string;
202
+ };
203
+ };
204
+ export type ClientEventId = keyof typeof CLIENT_EVENTS;
205
+ /** Families of the client's first step; a funnel keeps those it offers events of. */
206
+ export declare const CLIENT_GROUPS: {
207
+ admin_request: {
208
+ events: "other_request"[];
209
+ id: "admin_request";
210
+ };
211
+ controls: {
212
+ events: ("n1_control" | "n2_control" | "n3_control")[];
213
+ id: "controls";
214
+ };
215
+ delivery: {
216
+ events: "delivery_problem"[];
217
+ id: "delivery";
218
+ };
219
+ documents: {
220
+ events: "document_conformity"[];
221
+ id: "documents";
222
+ };
223
+ inventory: {
224
+ events: "inventory"[];
225
+ id: "inventory";
226
+ };
227
+ machine_problem: {
228
+ events: ("breakage" | "robbery" | "breakdown" | "material_usage" | "other_material")[];
229
+ id: "machine_problem";
230
+ };
231
+ operator_machine: {
232
+ events: ("hours_record" | "machine_assignment" | "operator_change")[];
233
+ id: "operator_machine";
234
+ };
235
+ other: {
236
+ events: "other"[];
237
+ id: "other";
238
+ };
239
+ stoppage: {
240
+ events: ("immobilisation" | "weather")[];
241
+ id: "stoppage";
242
+ };
243
+ };
244
+ /** What a client declares when its tenant has no funnel of its own. */
245
+ export declare const DEFAULT_CLIENT_FUNNEL: EventFunnel;
@@ -0,0 +1,3 @@
1
+ import { EventFunnel } from '../types';
2
+ /** What a supplier declares on an order, most declared first, the rarest under Other. */
3
+ export declare const SUPPLIER_FUNNEL: EventFunnel;
@@ -0,0 +1,16 @@
1
+ import { NativeEventWorkflow } from './types';
2
+ /** i18next namespace of the texts under `locales/`, which each app registers. */
3
+ export declare const EVENT_NAMESPACE = "eventDeclaration";
4
+ export declare const NATIVE_EVENT_SOURCE: NativeEventWorkflow["source"];
5
+ export declare const NATIVE_EVENT_VERSION: NativeEventWorkflow["version"];
6
+ /** Value names the backend reads: the reason by its tag, dates and prices to bill, end dates to move the line. */
7
+ export declare const VALUE_NAMES: {
8
+ readonly date: "date";
9
+ readonly dates: "dates";
10
+ readonly description: "description";
11
+ readonly intervention: "intervention";
12
+ readonly reason: "reason";
13
+ readonly reBillRatio: "re_bill_ratio";
14
+ readonly unitPrice: "unitPrice";
15
+ };
16
+ export declare const INVENTORY_ID = "inventory";
@@ -0,0 +1,40 @@
1
+ import { EventAnswers, EventDates, EventDefinition, EventFunnel, EventPrefill, EventStep, EventTranslate } from '../../types';
2
+ import { FunnelGroup } from '../../utils/steps/steps';
3
+ export interface UseEventDeclarationParams {
4
+ funnel: EventFunnel;
5
+ /** Days of a period the order line bills, by the app's calendar. */
6
+ countBillableDays: (dates: EventDates) => number;
7
+ /** Daily price of the order line, which a credit starts from. */
8
+ dailyPrice?: number | null;
9
+ /** Re-billing percentage last used on the order, which every event of a line shares. */
10
+ lastReBillRatio?: string;
11
+ /** An edit asks every question again, the reason included. */
12
+ isEditing?: boolean;
13
+ }
14
+ /** The declaration of an event, step by step, whatever renders it. */
15
+ declare const useEventDeclaration: ({ funnel, countBillableDays, dailyPrice, lastReBillRatio, isEditing, }: UseEventDeclarationParams) => {
16
+ amounts: import('../../utils/amounts/amounts').EventAmounts;
17
+ answers: EventAnswers;
18
+ asksAmount: boolean;
19
+ buildPayload: (translate: EventTranslate, bookingItemId?: string | null) => import('../../types').EventPayload | undefined;
20
+ canGoBack: boolean;
21
+ canGoNext: boolean;
22
+ event: EventDefinition | undefined;
23
+ goBack: () => void;
24
+ goNext: () => void;
25
+ group: FunnelGroup | undefined;
26
+ groups: FunnelGroup[];
27
+ isComplete: boolean;
28
+ isPriced: boolean;
29
+ reset: () => void;
30
+ selectAmountGate: (isYes: boolean) => void;
31
+ selectEvent: (selected: EventDefinition) => void;
32
+ selectGroup: (selected: FunnelGroup) => void;
33
+ selectReason: (reason: string) => void;
34
+ setAnswers: (changes: Partial<EventAnswers>) => void;
35
+ showsReBillRatio: boolean;
36
+ startPrefill: ({ eventId: prefilledId, answers: given }: EventPrefill) => boolean;
37
+ step: EventStep;
38
+ steps: EventStep[];
39
+ };
40
+ export default useEventDeclaration;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Entry point `@getsoren/shared-module/events`: the events a client or a supplier declares on an order, without
3
+ * Treege. Pure data and logic shared by the back offices and the mobile app, which each render their own steps.
4
+ */
5
+ export * from './catalog/clientEvents';
6
+ export * from './catalog/supplierEvents';
7
+ export * from './constants';
8
+ export * from './hooks/useEventDeclaration/useEventDeclaration';
9
+ export { default as useEventDeclaration } from './hooks/useEventDeclaration/useEventDeclaration';
10
+ export type { EventTexts } from './locales/fr';
11
+ export { EVENT_LOCALES } from './locales/locales';
12
+ export * from './tenants';
13
+ export type * from './types';
14
+ export * from './utils/amounts/amounts';
15
+ export * from './utils/payload/payload';
16
+ export { default as buildEventPayload } from './utils/payload/payload';
17
+ export * from './utils/readEvent/readEvent';
18
+ export { default as readEvent } from './utils/readEvent/readEvent';
19
+ export * from './utils/steps/steps';
@@ -0,0 +1,3 @@
1
+ import { EventTexts } from './fr';
2
+ declare const EVENTS_AR: EventTexts;
3
+ export default EVENTS_AR;
@@ -0,0 +1,3 @@
1
+ import { EventTexts } from './fr';
2
+ declare const EVENTS_DE: EventTexts;
3
+ export default EVENTS_DE;
@@ -0,0 +1,3 @@
1
+ import { EventTexts } from './fr';
2
+ declare const EVENTS_EN: EventTexts;
3
+ export default EVENTS_EN;
@@ -0,0 +1,3 @@
1
+ import { EventTexts } from './fr';
2
+ declare const EVENTS_ES: EventTexts;
3
+ export default EVENTS_ES;
@@ -0,0 +1,166 @@
1
+ declare const EVENTS_FR: {
2
+ readonly checks: {
3
+ readonly ce_conformity: "Certificat ou déclaration CE vérifié";
4
+ readonly ce_declaration: "Déclaration de conformité CE présente";
5
+ readonly ce_plate: "Plaque CE présente";
6
+ readonly documents_on_delivery: "Documents présents à la livraison";
7
+ readonly expected_operator: "L'opérateur est celui prévu";
8
+ readonly last_inspection_report: "Dernier rapport de vérification à jour";
9
+ readonly machine_compliant: "Matériel conforme";
10
+ readonly machine_good_condition: "Matériel livré en bon état";
11
+ readonly machine_matches_order: "Matériel conforme à la commande";
12
+ readonly maintenance_log: "Carnet de maintenance vérifié";
13
+ readonly operator_papers: "Papiers de l'opérateur présents";
14
+ readonly operator_present: "Opérateur présent";
15
+ readonly operator_skills: "Compétences de l'opérateur vérifiées (CACES, visite médicale…)";
16
+ readonly user_manual: "Notice d'instructions du constructeur présente";
17
+ readonly vgp_control: "VGP vérifiées";
18
+ };
19
+ readonly dayHints: {
20
+ readonly breakage: "Jour de la casse";
21
+ readonly control: "Jour du contrôle";
22
+ readonly deliveryProblem: "Jour du problème de livraison";
23
+ readonly event: "Jour de l'événement";
24
+ readonly lastDay: "Dernier jour d'utilisation";
25
+ readonly newEnd: "Nouvelle fin";
26
+ readonly operatorChange: "Premier jour du nouvel opérateur";
27
+ readonly problem: "Jour du problème";
28
+ readonly request: "Jour de la demande";
29
+ readonly robbery: "Jour où le vol a été constaté";
30
+ };
31
+ readonly events: {
32
+ readonly breakage: "Casse";
33
+ readonly breakdown: "Panne";
34
+ readonly delivery_problem: "Livraison ou reprise";
35
+ readonly document_conformity: "Documents non conformes";
36
+ readonly end_booking: "Fin ou prolongation";
37
+ readonly hours_record: "Relevé d'heures";
38
+ readonly immobilisation: "Immobilisation";
39
+ readonly inventory: "État des lieux";
40
+ readonly machine_assignment: "Affectation machine";
41
+ readonly machine_problem: "Problème machine";
42
+ readonly material_usage: "Matériel inadapté";
43
+ readonly n1_control: "Contrôle N1 des documents";
44
+ readonly n2_control: "Contrôle N2 à la livraison";
45
+ readonly n3_control: "Contrôle N3";
46
+ readonly operator_change: "Changement d'opérateur";
47
+ readonly other: "Autre";
48
+ readonly other_material: "Autre problème matériel";
49
+ readonly other_request: "Demande administrative";
50
+ readonly robbery: "Vol";
51
+ readonly stoppage: "Immobilisation ou intempéries";
52
+ readonly weather: "Intempéries";
53
+ };
54
+ readonly fields: {
55
+ readonly assigned_machine: "Machine affectée";
56
+ readonly code: "Code";
57
+ readonly hours_record_number: "Numéro du bon d'heures";
58
+ readonly inspector_opinion: "Avis du contrôleur";
59
+ readonly model: "Modèle";
60
+ readonly new_operator_name: "Nom du nouvel opérateur";
61
+ readonly quantity: "Nombre d'heures effectuées";
62
+ readonly serial_number: "Numéro de série";
63
+ readonly site_escort: "Accompagnateur chantier";
64
+ readonly supplier_reference: "Référence interne du loueur";
65
+ };
66
+ readonly groupQuestions: {
67
+ readonly controls: "Quel contrôle ?";
68
+ readonly machine_problem: "Quel problème sur la machine ?";
69
+ readonly operator_machine: "Que voulez-vous enregistrer ?";
70
+ readonly stoppage: "Pourquoi la machine est-elle arrêtée ?";
71
+ };
72
+ readonly groups: {
73
+ readonly admin_request: "Demande administrative";
74
+ readonly controls: "Contrôle";
75
+ readonly delivery: "Livraison ou reprise";
76
+ readonly documents: "Documents non conformes";
77
+ readonly end_booking: "Fin ou prolongation";
78
+ readonly inventory: "État des lieux";
79
+ readonly machine_problem: "Problème machine";
80
+ readonly operator_machine: "Opérateur et machine";
81
+ readonly other: "Autre";
82
+ readonly stoppage: "Intempéries ou immobilisation";
83
+ };
84
+ readonly questions: {
85
+ readonly amount: "Quel montant ?";
86
+ readonly billedAmount: "Quel montant facturer ?";
87
+ readonly breakageKind: "Quel type de casse ?";
88
+ readonly breakdownDays: "Quels sont les jours de panne ?";
89
+ readonly breakdownKind: "Quel type de panne ?";
90
+ readonly checks: "Qu'avez-vous vérifié ?";
91
+ readonly comment: "Un mot pour le client ?";
92
+ readonly credit: "Combien déduire de la location ?";
93
+ readonly dailyCredit: "Combien déduire par jour ?";
94
+ readonly day: "Quel jour ?";
95
+ readonly deliveryProblemKind: "Que s'est-il passé ?";
96
+ readonly details: "Quelque chose à ajouter ?";
97
+ readonly documentKind: "Quel document pose problème ?";
98
+ readonly endKind: "Que souhaitez-vous faire ?";
99
+ readonly fields: "Complétez les informations";
100
+ readonly inventoryKind: "Quel état des lieux ?";
101
+ readonly isBilled: "Faut-il facturer un montant ?";
102
+ readonly lastDay: "Quel est le dernier jour d'utilisation ?";
103
+ readonly machineProblemKind: "Quel problème sur la machine ?";
104
+ readonly materialUsageKind: "Quel est le problème ?";
105
+ readonly newEnd: "Jusqu'à quand prolonger ?";
106
+ readonly period: "Sur quels jours ?";
107
+ readonly photos: "Quelles photos joindre ?";
108
+ readonly priceKnown: "Avez-vous déjà le montant du loueur ?";
109
+ readonly robberyDay: "Quand avez-vous constaté le vol ?";
110
+ readonly robberyKind: "Qu'est-ce qui a été volé ?";
111
+ readonly stoppageKind: "Pourquoi la machine est-elle arrêtée ?";
112
+ readonly title: "Quel titre donner à l'événement ?";
113
+ readonly weatherDays: "Sur quels jours a eu lieu l'intempérie ?";
114
+ readonly whatHappened: "Que s'est-il passé ?";
115
+ };
116
+ readonly reasons: {
117
+ readonly booking_end: "Terminer la location";
118
+ readonly booking_extension: "Prolonger la location";
119
+ readonly break_repair: "Casses importantes";
120
+ readonly breakdown: "Panne";
121
+ readonly breakdown_electric: "Panne électrique";
122
+ readonly breakdown_engine: "Panne moteur";
123
+ readonly breakdown_mecanic: "Panne mécanique";
124
+ readonly breakdown_other: "Autre panne";
125
+ readonly damages_third_parties: "Sinistre-juridique";
126
+ readonly delay_in_delivery: "Retard de livraison";
127
+ readonly forgetting_recover: "Oubli de récupération";
128
+ readonly immobilisation: "Immobilisation";
129
+ readonly incompetent_operator: "Opérateur incompétent";
130
+ readonly inventory_departure: "Départ du matériel";
131
+ readonly inventory_reception: "Retour du matériel";
132
+ readonly keys: "Clé/Code : perte/non-communiqué";
133
+ readonly machine: "Document machine non conforme";
134
+ readonly missing_accessory: "Accessoire manquant";
135
+ readonly no_show: "Livraison non effectuée";
136
+ readonly operator: "Document opérateur non conforme";
137
+ readonly other: "Autre évènement";
138
+ readonly other_delivery: "Problème livraison";
139
+ readonly quality_issue: "Mauvais état matériel";
140
+ readonly robbery_article: "Vol machine";
141
+ readonly robbery_machine: "Vol machine";
142
+ readonly robbery_option: "Vol accessoire";
143
+ readonly undeclared_use: "Utilisation non déclarée";
144
+ readonly weather: "Intempéries";
145
+ readonly wrong_machine: "Erreur Matériel";
146
+ };
147
+ readonly values: {
148
+ readonly amount: "Montant";
149
+ readonly date: "Date";
150
+ readonly dates: "Période";
151
+ readonly description: "Commentaire";
152
+ readonly document_type: "Type de document";
153
+ readonly final_toDate: "Dernier jour d'utilisation";
154
+ readonly intervention: "Le loueur doit intervenir sur place";
155
+ readonly inventory_type: "Type d'état des lieux";
156
+ readonly new_toDate: "Nouvelle date de fin";
157
+ readonly re_bill_ratio: "Refacturation";
158
+ readonly reason: "Motif";
159
+ readonly title: "Titre de l'événement";
160
+ };
161
+ };
162
+ /** The texts every language gives, keyed as in French. */
163
+ export type EventTexts = {
164
+ [Group in keyof typeof EVENTS_FR]: Record<keyof (typeof EVENTS_FR)[Group], string>;
165
+ };
166
+ export default EVENTS_FR;
@@ -0,0 +1,3 @@
1
+ import { EventTexts } from './fr';
2
+ declare const EVENTS_IT: EventTexts;
3
+ export default EVENTS_IT;
@@ -0,0 +1,3 @@
1
+ import { EventTexts } from './fr';
2
+ /** Texts of the `eventDeclaration` namespace by language, which each app adds to its i18next resources. */
3
+ export declare const EVENT_LOCALES: Record<"ar" | "de" | "en" | "es" | "fr" | "it" | "pt", EventTexts>;
@@ -0,0 +1,3 @@
1
+ import { EventTexts } from './fr';
2
+ declare const EVENTS_PT: EventTexts;
3
+ export default EVENTS_PT;
@@ -0,0 +1,3 @@
1
+ import { TenantEventFunnels } from '../../types';
2
+ declare const BOUYGUES_EVENT_FUNNELS: TenantEventFunnels;
3
+ export default BOUYGUES_EVENT_FUNNELS;
@@ -0,0 +1,11 @@
1
+ import { EventFunnel, EventSide } from '../types';
2
+ interface GetEventFunnelParams {
3
+ side: EventSide;
4
+ tenantName?: string | null;
5
+ roleName?: string | null;
6
+ }
7
+ /** What this user declares: suppliers share one funnel, a client gets its tenant's, the default one otherwise. */
8
+ export declare const getEventFunnel: ({ side, tenantName, roleName }: GetEventFunnelParams) => EventFunnel;
9
+ /** The funnel an event was declared with, to read it back whoever reads it. */
10
+ export declare const findEventFunnel: (id: string) => EventFunnel | undefined;
11
+ export {};
@@ -0,0 +1 @@
1
+ export {};