@movalib/movalib-commons 1.59.13 → 1.59.15

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.
Files changed (46) hide show
  1. package/.env.development +2 -0
  2. package/devIndex.tsx +1 -1
  3. package/dist/devIndex.js +1 -1
  4. package/dist/index.d.ts +6 -3
  5. package/dist/index.js +14 -4
  6. package/dist/src/components/LinkedDocumentDialog.d.ts +11 -0
  7. package/dist/src/components/LinkedDocumentDialog.js +55 -0
  8. package/dist/src/{VehicleFullCard.d.ts → components/vehicle/VehicleFullCard.d.ts} +5 -2
  9. package/dist/src/{VehicleFullCard.js → components/vehicle/VehicleFullCard.js} +44 -22
  10. package/dist/src/components/vehicle/VehiclePlateField.d.ts +8 -0
  11. package/dist/src/components/vehicle/VehiclePlateField.js +122 -0
  12. package/dist/src/helpers/CookieUtils.js +2 -1
  13. package/dist/src/helpers/Enums.d.ts +10 -1
  14. package/dist/src/helpers/Enums.js +10 -1
  15. package/dist/src/helpers/Tools.d.ts +1 -0
  16. package/dist/src/helpers/Tools.js +10 -1
  17. package/dist/src/models/Garage.d.ts +2 -0
  18. package/dist/src/services/AuthenticationService.js +2 -0
  19. package/dist/src/services/GarageService.d.ts +8 -4
  20. package/dist/src/services/GarageService.js +75 -45
  21. package/dist/src/services/UserConnected.d.ts +9 -0
  22. package/dist/src/services/UserConnected.js +59 -0
  23. package/dist/src/services/UserService.d.ts +1 -1
  24. package/dist/src/services/VehicleService.d.ts +3 -0
  25. package/dist/src/services/VehicleService.js +22 -0
  26. package/dist/src/style/styled.d.ts +17 -0
  27. package/dist/src/style/styled.js +68 -0
  28. package/dist/src/style/styled.ts +70 -0
  29. package/index.ts +8 -3
  30. package/package.json +3 -2
  31. package/src/VehiclePlateField.tsx +1 -0
  32. package/src/components/LinkedDocumentDialog.tsx +200 -0
  33. package/src/components/vehicle/VehicleFullCard.tsx +549 -0
  34. package/src/components/vehicle/VehiclePlateField.tsx +164 -0
  35. package/src/helpers/CookieUtils.ts +2 -1
  36. package/src/helpers/Enums.ts +12 -1
  37. package/src/helpers/Tools.ts +5 -0
  38. package/src/models/Event.ts +1 -1
  39. package/src/models/Garage.ts +2 -0
  40. package/src/services/AuthenticationService.ts +2 -1
  41. package/src/services/GarageService.ts +557 -390
  42. package/src/services/UserConnected.ts +56 -0
  43. package/src/services/UserService.ts +1 -1
  44. package/src/services/VehicleService.ts +25 -0
  45. package/src/style/styled.ts +70 -0
  46. package/src/VehicleFullCard.tsx +0 -503
@@ -9,6 +9,7 @@ export declare const isSafariOniOS: () => boolean;
9
9
  export declare const FR_WEEK_DAYS: string[];
10
10
  export declare const getDayOfWeekLabel: (day: DayOfWeek) => string | undefined;
11
11
  export declare const getDayOfWeekIndex: (day: DayOfWeek) => number;
12
+ export declare const iAmOwner: (ownreId: number) => boolean;
12
13
  export declare const formatPhoneNumber: (phoneNumber: string) => string;
13
14
  export declare const getFormattedSchedule: (schedule: Schedule | null, dayIndex: number) => string;
14
15
  export declare const getFormattedIntervals: (intervals: MovaInterval[]) => string | undefined;
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateField = exports.formatVehicleTireStr = exports.formatVehicleTire = exports.formatFrenchVehiclePlate = exports.isEmpty = exports.flexCenter = exports.flexEnd = exports.getApplicationShortLabel = exports.capitalizeFirstLetter = exports.flexLeftRow = exports.getFrenchDayLabel = exports.getDayOfWeek = exports.findScheduleByDayOfWeek = exports.formatTime = exports.getFormattedIntervals = exports.getFormattedSchedule = exports.formatPhoneNumber = exports.getDayOfWeekIndex = exports.getDayOfWeekLabel = exports.FR_WEEK_DAYS = exports.isSafariOniOS = exports.flexStart = exports.getApplicationsShortLabels = void 0;
6
+ exports.validateField = exports.formatVehicleTireStr = exports.formatVehicleTire = exports.formatFrenchVehiclePlate = exports.isEmpty = exports.flexCenter = exports.flexEnd = exports.getApplicationShortLabel = exports.capitalizeFirstLetter = exports.flexLeftRow = exports.getFrenchDayLabel = exports.getDayOfWeek = exports.findScheduleByDayOfWeek = exports.formatTime = exports.getFormattedIntervals = exports.getFormattedSchedule = exports.formatPhoneNumber = exports.iAmOwner = exports.getDayOfWeekIndex = exports.getDayOfWeekLabel = exports.FR_WEEK_DAYS = exports.isSafariOniOS = exports.flexStart = exports.getApplicationsShortLabels = void 0;
4
7
  var Enums_1 = require("./Enums");
8
+ var UserConnected_1 = __importDefault(require("../services/UserConnected"));
5
9
  var getApplicationsShortLabels = function (applications) {
6
10
  if (!applications) {
7
11
  return '';
@@ -38,6 +42,11 @@ var getDayOfWeekIndex = function (day) {
38
42
  return -1;
39
43
  };
40
44
  exports.getDayOfWeekIndex = getDayOfWeekIndex;
45
+ var iAmOwner = function (ownreId) {
46
+ var _a;
47
+ return ownreId === ((_a = UserConnected_1.default.getInstance().me) === null || _a === void 0 ? void 0 : _a.id);
48
+ };
49
+ exports.iAmOwner = iAmOwner;
41
50
  var formatPhoneNumber = function (phoneNumber) {
42
51
  var formattedNumber = "";
43
52
  if (phoneNumber) {
@@ -49,5 +49,7 @@ export default class Garage {
49
49
  defaultView?: string;
50
50
  loanerVehicleActive?: boolean;
51
51
  loanerVehicleRequestActive?: boolean;
52
+ paymentAuthorizationActive?: boolean;
53
+ paymentAuthorizationMinDowntime?: number;
52
54
  constructor(id: string, adminId: string, name: string, address: Address, workforce: number, prestations: Prestation[], schedules: Schedule[], contactPhone: string, prestationCategories: CategoryPrestation[], vehicles?: VehicleGarage[], contactEmail?: string, logo?: string, suppliers?: Supplier[], documents?: Document[], subscriptions?: Subscription[], loanerVehicleActive?: boolean, loanerVehicleRequestActive?: boolean, subscription?: Subscription, partialWorkforce?: number);
53
55
  }
@@ -43,6 +43,7 @@ var ApiHelper_1 = require("../helpers/ApiHelper");
43
43
  var CookieUtils_1 = require("../helpers/CookieUtils");
44
44
  var Enums_1 = require("../helpers/Enums");
45
45
  var Logger_1 = __importDefault(require("../helpers/Logger"));
46
+ var UserConnected_1 = __importDefault(require("./UserConnected"));
46
47
  var UserService_1 = __importDefault(require("./UserService"));
47
48
  var AuthenticationService = /** @class */ (function () {
48
49
  function AuthenticationService() {
@@ -110,6 +111,7 @@ var AuthenticationService = /** @class */ (function () {
110
111
  Logger_1.default.error(errorMsg);
111
112
  return [2 /*return*/, { success: false, error: errorMsg }];
112
113
  }
114
+ UserConnected_1.default.getInstance().me = userResponse.data;
113
115
  return [2 /*return*/, { success: true, data: userResponse.data }];
114
116
  case 3: return [2 /*return*/, tokenResponse];
115
117
  case 4: return [3 /*break*/, 6];
@@ -3,6 +3,8 @@ import Employee from "../models/Employee";
3
3
  import Garage from "../models/Garage";
4
4
  import { AddCustomerVehicleParams, DeleteCustomerVehicleParams } from "./GarageService.types";
5
5
  export default class GarageService {
6
+ static updatePaymentAuthorization(garageId: string, req: any): Promise<APIResponse<string>>;
7
+ static toogleGaragePaymentAuthorization(garageId: string): Promise<APIResponse<string>>;
6
8
  static toogleEventVehicleReceived(garageId: string, eventId: string): Promise<APIResponse<string>>;
7
9
  static setOrderedEvent(garageId: string, eventId: string, req: any): Promise<APIResponse<string>>;
8
10
  static deleteEventEmployee(garageId: string, eventId: string): Promise<APIResponse<string>>;
@@ -10,6 +12,8 @@ export default class GarageService {
10
12
  static updateColorPrestationCategory(garageId: string, categoryCode: string, color: string): Promise<APIResponse<string>>;
11
13
  static updateGarageEventColor(garageId: string, eventId: string, color: string): Promise<APIResponse<string>>;
12
14
  static updateVehicleGarageEvent(garageId: string, eventId: string, req: any): Promise<APIResponse<string>>;
15
+ static uploadEventDocument(garageId: string, eventId: string, req: FormData): Promise<APIResponse<string>>;
16
+ static deleteEventDocument(garageId: string, eventId: string, docId: string): Promise<APIResponse<string>>;
13
17
  static sendGarageMandate(garageId: string): Promise<APIResponse<string>>;
14
18
  static getGarageAllData(garageId: string): Promise<APIResponse<Garage>>;
15
19
  static createGaragePrestationRequest(garageId: string, req: any): Promise<APIResponse<string>>;
@@ -39,23 +43,23 @@ export default class GarageService {
39
43
  static createGarageSupplier(garageId: string, req: any): Promise<APIResponse<string>>;
40
44
  static updateGarageSupplier(garageId: string, supplierId: number, req: any): Promise<APIResponse<string>>;
41
45
  static updateGarage(garageId: string, req: any): Promise<APIResponse<string>>;
42
- static getAdministratedGarages({ garageId }: {
46
+ static getAdministratedGarages({ garageId, }: {
43
47
  garageId: string;
44
48
  }): Promise<APIResponse<Garage>>;
45
49
  static sendGarageSupportRequest(garageId: string, req: {
46
50
  message: string;
47
51
  }): Promise<APIResponse<string>>;
48
52
  static addCustomerVehicle({ garageId, customerId, ...payload }: AddCustomerVehicleParams): Promise<APIResponse<string>>;
49
- static deleteCustomerVehicle({ garageId, customerId, vehicleId }: DeleteCustomerVehicleParams): Promise<APIResponse<string>>;
53
+ static deleteCustomerVehicle({ garageId, customerId, vehicleId, }: DeleteCustomerVehicleParams): Promise<APIResponse<string>>;
50
54
  static toogleGarageLoanerVehicleRequest(garageId: string, req: any): Promise<APIResponse<string>>;
51
55
  static toogleGarageLoanerVehicle(garageId: string): Promise<APIResponse<string>>;
52
- static addGarageVehicle({ garageId, req }: {
56
+ static addGarageVehicle({ garageId, req, }: {
53
57
  garageId: string;
54
58
  req: {
55
59
  plate: string;
56
60
  };
57
61
  }): Promise<APIResponse<string>>;
58
- static deleteGarageVehicle({ garageId, vehicleId }: {
62
+ static deleteGarageVehicle({ garageId, vehicleId, }: {
59
63
  garageId: string;
60
64
  vehicleId: number;
61
65
  }): Promise<APIResponse<string>>;
@@ -16,11 +16,26 @@ var Enums_1 = require("../helpers/Enums");
16
16
  var GarageService = /** @class */ (function () {
17
17
  function GarageService() {
18
18
  }
19
+ GarageService.updatePaymentAuthorization = function (garageId, req) {
20
+ return (0, ApiHelper_1.request)({
21
+ url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/settings/payment-authorization/update"),
22
+ method: Enums_1.APIMethod.PATCH,
23
+ appType: Enums_1.MovaAppType.GARAGE,
24
+ body: JSON.stringify(req),
25
+ });
26
+ };
27
+ GarageService.toogleGaragePaymentAuthorization = function (garageId) {
28
+ return (0, ApiHelper_1.request)({
29
+ url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/settings/payment-authorization"),
30
+ method: Enums_1.APIMethod.PATCH,
31
+ appType: Enums_1.MovaAppType.GARAGE,
32
+ });
33
+ };
19
34
  GarageService.toogleEventVehicleReceived = function (garageId, eventId) {
20
35
  return (0, ApiHelper_1.request)({
21
36
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/events/").concat(eventId, "/vehicle-received"),
22
37
  method: Enums_1.APIMethod.PATCH,
23
- appType: Enums_1.MovaAppType.GARAGE
38
+ appType: Enums_1.MovaAppType.GARAGE,
24
39
  });
25
40
  };
26
41
  GarageService.setOrderedEvent = function (garageId, eventId, req) {
@@ -28,21 +43,21 @@ var GarageService = /** @class */ (function () {
28
43
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/events/").concat(eventId, "/ordered"),
29
44
  method: Enums_1.APIMethod.POST,
30
45
  appType: Enums_1.MovaAppType.GARAGE,
31
- body: JSON.stringify(req)
46
+ body: JSON.stringify(req),
32
47
  });
33
48
  };
34
49
  GarageService.deleteEventEmployee = function (garageId, eventId) {
35
50
  return (0, ApiHelper_1.request)({
36
51
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/event/").concat(eventId, "/employees"),
37
52
  method: Enums_1.APIMethod.DELETE,
38
- appType: Enums_1.MovaAppType.GARAGE
53
+ appType: Enums_1.MovaAppType.GARAGE,
39
54
  });
40
55
  };
41
56
  GarageService.updateEventEmployee = function (garageId, eventId, employeeId) {
42
57
  return (0, ApiHelper_1.request)({
43
58
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/event/").concat(eventId, "/employees/").concat(employeeId),
44
59
  method: Enums_1.APIMethod.PATCH,
45
- appType: Enums_1.MovaAppType.GARAGE
60
+ appType: Enums_1.MovaAppType.GARAGE,
46
61
  });
47
62
  };
48
63
  GarageService.updateColorPrestationCategory = function (garageId, categoryCode, color) {
@@ -69,18 +84,33 @@ var GarageService = /** @class */ (function () {
69
84
  body: JSON.stringify(req)
70
85
  });
71
86
  };
87
+ GarageService.uploadEventDocument = function (garageId, eventId, req) {
88
+ return (0, ApiHelper_1.request)({
89
+ url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/event/").concat(eventId, "/documents"),
90
+ method: Enums_1.APIMethod.POST,
91
+ appType: Enums_1.MovaAppType.GARAGE,
92
+ body: req
93
+ });
94
+ };
95
+ GarageService.deleteEventDocument = function (garageId, eventId, docId) {
96
+ return (0, ApiHelper_1.request)({
97
+ url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/event/").concat(eventId, "/documents/").concat(docId),
98
+ appType: Enums_1.MovaAppType.GARAGE,
99
+ method: Enums_1.APIMethod.DELETE,
100
+ });
101
+ };
72
102
  GarageService.sendGarageMandate = function (garageId) {
73
103
  return (0, ApiHelper_1.request)({
74
104
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/subscription-mandate"),
75
105
  method: Enums_1.APIMethod.POST,
76
- appType: Enums_1.MovaAppType.GARAGE
106
+ appType: Enums_1.MovaAppType.GARAGE,
77
107
  });
78
108
  };
79
109
  GarageService.getGarageAllData = function (garageId) {
80
110
  return (0, ApiHelper_1.request)({
81
111
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/all-data"),
82
112
  method: Enums_1.APIMethod.GET,
83
- appType: Enums_1.MovaAppType.GARAGE
113
+ appType: Enums_1.MovaAppType.GARAGE,
84
114
  });
85
115
  };
86
116
  GarageService.createGaragePrestationRequest = function (garageId, req) {
@@ -88,14 +118,14 @@ var GarageService = /** @class */ (function () {
88
118
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/prestations/request"),
89
119
  method: Enums_1.APIMethod.POST,
90
120
  appType: Enums_1.MovaAppType.GARAGE,
91
- body: JSON.stringify(req)
121
+ body: JSON.stringify(req),
92
122
  });
93
123
  };
94
124
  GarageService.getGarageSettings = function (garageId) {
95
125
  return (0, ApiHelper_1.request)({
96
126
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/settings"),
97
127
  method: Enums_1.APIMethod.GET,
98
- appType: Enums_1.MovaAppType.GARAGE
128
+ appType: Enums_1.MovaAppType.GARAGE,
99
129
  });
100
130
  };
101
131
  GarageService.uploadLogo = function (garageId, formData) {
@@ -103,35 +133,35 @@ var GarageService = /** @class */ (function () {
103
133
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/logo"),
104
134
  method: Enums_1.APIMethod.PATCH,
105
135
  appType: Enums_1.MovaAppType.GARAGE,
106
- body: formData
136
+ body: formData,
107
137
  });
108
138
  };
109
139
  GarageService.sendAppointmentVehicleAvailable = function (garageId, eventId) {
110
140
  return (0, ApiHelper_1.request)({
111
141
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/event/").concat(eventId, "/vehicle-available"),
112
142
  method: Enums_1.APIMethod.POST,
113
- appType: Enums_1.MovaAppType.GARAGE
143
+ appType: Enums_1.MovaAppType.GARAGE,
114
144
  });
115
145
  };
116
146
  GarageService.enableGaragePrestation = function (garageId, prestationId) {
117
147
  return (0, ApiHelper_1.request)({
118
148
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/prestations/").concat(prestationId, "/enable"),
119
149
  method: Enums_1.APIMethod.PATCH,
120
- appType: Enums_1.MovaAppType.GARAGE
150
+ appType: Enums_1.MovaAppType.GARAGE,
121
151
  });
122
152
  };
123
153
  GarageService.disableGaragePrestation = function (garageId, prestationId) {
124
154
  return (0, ApiHelper_1.request)({
125
155
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/prestations/").concat(prestationId, "/disable"),
126
156
  method: Enums_1.APIMethod.PATCH,
127
- appType: Enums_1.MovaAppType.GARAGE
157
+ appType: Enums_1.MovaAppType.GARAGE,
128
158
  });
129
159
  };
130
160
  GarageService.getEmployeeDetails = function (garageId, employeeId) {
131
161
  return (0, ApiHelper_1.request)({
132
162
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/employees/").concat(employeeId),
133
163
  method: Enums_1.APIMethod.GET,
134
- appType: Enums_1.MovaAppType.GARAGE
164
+ appType: Enums_1.MovaAppType.GARAGE,
135
165
  });
136
166
  };
137
167
  GarageService.updateGaragePrestation = function (garageId, prestationId, req) {
@@ -139,28 +169,28 @@ var GarageService = /** @class */ (function () {
139
169
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/prestations/").concat(prestationId),
140
170
  method: Enums_1.APIMethod.PATCH,
141
171
  appType: Enums_1.MovaAppType.GARAGE,
142
- body: JSON.stringify(req)
172
+ body: JSON.stringify(req),
143
173
  });
144
174
  };
145
175
  GarageService.deleteGarageEmployeePrestation = function (garageId, employeeId, prestationId) {
146
176
  return (0, ApiHelper_1.request)({
147
177
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/employees/").concat(employeeId, "/prestations/").concat(prestationId),
148
178
  method: Enums_1.APIMethod.DELETE,
149
- appType: Enums_1.MovaAppType.GARAGE
179
+ appType: Enums_1.MovaAppType.GARAGE,
150
180
  });
151
181
  };
152
182
  GarageService.createGarageEmployeePrestation = function (garageId, employeeId, prestationId) {
153
183
  return (0, ApiHelper_1.request)({
154
184
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/employees/").concat(employeeId, "/prestations/").concat(prestationId),
155
185
  method: Enums_1.APIMethod.POST,
156
- appType: Enums_1.MovaAppType.GARAGE
186
+ appType: Enums_1.MovaAppType.GARAGE,
157
187
  });
158
188
  };
159
189
  GarageService.deleteGarageEmployeeAbsence = function (garageId, employeeId, absenceId) {
160
190
  return (0, ApiHelper_1.request)({
161
191
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/employees/").concat(employeeId, "/absences/").concat(absenceId),
162
192
  method: Enums_1.APIMethod.DELETE,
163
- appType: Enums_1.MovaAppType.GARAGE
193
+ appType: Enums_1.MovaAppType.GARAGE,
164
194
  });
165
195
  };
166
196
  GarageService.createGarageEmployeeAbsence = function (garageId, employeeId, req) {
@@ -168,7 +198,7 @@ var GarageService = /** @class */ (function () {
168
198
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/employees/").concat(employeeId, "/absences"),
169
199
  method: Enums_1.APIMethod.POST,
170
200
  appType: Enums_1.MovaAppType.GARAGE,
171
- body: JSON.stringify(req)
201
+ body: JSON.stringify(req),
172
202
  });
173
203
  };
174
204
  GarageService.updateGarageEmployee = function (garageId, employeeId, req) {
@@ -176,7 +206,7 @@ var GarageService = /** @class */ (function () {
176
206
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/employees/").concat(employeeId),
177
207
  method: Enums_1.APIMethod.PATCH,
178
208
  appType: Enums_1.MovaAppType.GARAGE,
179
- body: JSON.stringify(req)
209
+ body: JSON.stringify(req),
180
210
  });
181
211
  };
182
212
  GarageService.updateGarageEmployeeSchedules = function (garageId, employeeId, req) {
@@ -184,14 +214,14 @@ var GarageService = /** @class */ (function () {
184
214
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/employees/").concat(employeeId, "/schedules"),
185
215
  method: Enums_1.APIMethod.PATCH,
186
216
  appType: Enums_1.MovaAppType.GARAGE,
187
- body: JSON.stringify(req)
217
+ body: JSON.stringify(req),
188
218
  });
189
219
  };
190
220
  GarageService.deleteGarageEmployee = function (garageId, employeeId) {
191
221
  return (0, ApiHelper_1.request)({
192
222
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/employees/").concat(employeeId),
193
223
  method: Enums_1.APIMethod.DELETE,
194
- appType: Enums_1.MovaAppType.GARAGE
224
+ appType: Enums_1.MovaAppType.GARAGE,
195
225
  });
196
226
  };
197
227
  GarageService.createGarageEmployee = function (garageId, req) {
@@ -199,21 +229,21 @@ var GarageService = /** @class */ (function () {
199
229
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/employees"),
200
230
  method: Enums_1.APIMethod.POST,
201
231
  appType: Enums_1.MovaAppType.GARAGE,
202
- body: JSON.stringify(req)
232
+ body: JSON.stringify(req),
203
233
  });
204
234
  };
205
235
  GarageService.getEmployees = function (garageId) {
206
236
  return (0, ApiHelper_1.request)({
207
237
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/employees"),
208
238
  method: Enums_1.APIMethod.GET,
209
- appType: Enums_1.MovaAppType.GARAGE
239
+ appType: Enums_1.MovaAppType.GARAGE,
210
240
  });
211
241
  };
212
242
  GarageService.activateGarage = function (garageId) {
213
243
  return (0, ApiHelper_1.request)({
214
244
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/activate"),
215
245
  method: Enums_1.APIMethod.PATCH,
216
- appType: Enums_1.MovaAppType.GARAGE
246
+ appType: Enums_1.MovaAppType.GARAGE,
217
247
  });
218
248
  };
219
249
  GarageService.salesSignUp = function (formData) {
@@ -221,7 +251,7 @@ var GarageService = /** @class */ (function () {
221
251
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/sales-signup"),
222
252
  method: Enums_1.APIMethod.POST,
223
253
  appType: Enums_1.MovaAppType.GARAGE,
224
- body: formData
254
+ body: formData,
225
255
  });
226
256
  };
227
257
  GarageService.sendNewEventQuote = function (garageId, eventId, formData) {
@@ -229,7 +259,7 @@ var GarageService = /** @class */ (function () {
229
259
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/event/").concat(eventId, "/quote"),
230
260
  method: Enums_1.APIMethod.PATCH,
231
261
  appType: Enums_1.MovaAppType.GARAGE,
232
- body: formData
262
+ body: formData,
233
263
  });
234
264
  };
235
265
  GarageService.sendCustomerReminder = function (garageId, eventId, message) {
@@ -237,7 +267,7 @@ var GarageService = /** @class */ (function () {
237
267
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/event/").concat(eventId, "/customer-reminder"),
238
268
  method: Enums_1.APIMethod.POST,
239
269
  appType: Enums_1.MovaAppType.GARAGE,
240
- body: message
270
+ body: message,
241
271
  });
242
272
  };
243
273
  GarageService.updateGarageEvent = function (garageId, eventId, req) {
@@ -245,7 +275,7 @@ var GarageService = /** @class */ (function () {
245
275
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/event/").concat(eventId),
246
276
  method: Enums_1.APIMethod.PATCH,
247
277
  appType: Enums_1.MovaAppType.GARAGE,
248
- body: JSON.stringify(req)
278
+ body: JSON.stringify(req),
249
279
  });
250
280
  };
251
281
  GarageService.sendSupplierRequest = function (garageId, eventId, req) {
@@ -253,14 +283,14 @@ var GarageService = /** @class */ (function () {
253
283
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/events/").concat(eventId, "/supplierRequest"),
254
284
  method: Enums_1.APIMethod.POST,
255
285
  appType: Enums_1.MovaAppType.GARAGE,
256
- body: JSON.stringify(req)
286
+ body: JSON.stringify(req),
257
287
  });
258
288
  };
259
289
  GarageService.deleteGarageSupplier = function (garageId, supplierId) {
260
290
  return (0, ApiHelper_1.request)({
261
291
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/suppliers/").concat(supplierId),
262
292
  method: Enums_1.APIMethod.DELETE,
263
- appType: Enums_1.MovaAppType.GARAGE
293
+ appType: Enums_1.MovaAppType.GARAGE,
264
294
  });
265
295
  };
266
296
  GarageService.createGarageSupplier = function (garageId, req) {
@@ -268,7 +298,7 @@ var GarageService = /** @class */ (function () {
268
298
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/suppliers"),
269
299
  method: Enums_1.APIMethod.POST,
270
300
  appType: Enums_1.MovaAppType.GARAGE,
271
- body: JSON.stringify(req)
301
+ body: JSON.stringify(req),
272
302
  });
273
303
  };
274
304
  GarageService.updateGarageSupplier = function (garageId, supplierId, req) {
@@ -276,7 +306,7 @@ var GarageService = /** @class */ (function () {
276
306
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/suppliers/").concat(supplierId),
277
307
  method: Enums_1.APIMethod.PATCH,
278
308
  appType: Enums_1.MovaAppType.GARAGE,
279
- body: JSON.stringify(req)
309
+ body: JSON.stringify(req),
280
310
  });
281
311
  };
282
312
  GarageService.updateGarage = function (garageId, req) {
@@ -284,7 +314,7 @@ var GarageService = /** @class */ (function () {
284
314
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId),
285
315
  method: Enums_1.APIMethod.PATCH,
286
316
  appType: Enums_1.MovaAppType.GARAGE,
287
- body: JSON.stringify(req)
317
+ body: JSON.stringify(req),
288
318
  });
289
319
  };
290
320
  GarageService.getAdministratedGarages = function (_a) {
@@ -292,7 +322,7 @@ var GarageService = /** @class */ (function () {
292
322
  return (0, ApiHelper_1.request)({
293
323
  url: "".concat(ApiHelper_1.API_BASE_URL, "/user/garage/").concat(garageId),
294
324
  method: Enums_1.APIMethod.GET,
295
- appType: Enums_1.MovaAppType.GARAGE
325
+ appType: Enums_1.MovaAppType.GARAGE,
296
326
  });
297
327
  };
298
328
  GarageService.sendGarageSupportRequest = function (garageId, req) {
@@ -300,7 +330,7 @@ var GarageService = /** @class */ (function () {
300
330
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/support-request"),
301
331
  method: Enums_1.APIMethod.POST,
302
332
  appType: Enums_1.MovaAppType.GARAGE,
303
- body: JSON.stringify(req)
333
+ body: JSON.stringify(req),
304
334
  });
305
335
  };
306
336
  GarageService.addCustomerVehicle = function (_a) {
@@ -309,7 +339,7 @@ var GarageService = /** @class */ (function () {
309
339
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/customers/").concat(customerId, "/vehicles"),
310
340
  method: Enums_1.APIMethod.POST,
311
341
  appType: Enums_1.MovaAppType.GARAGE,
312
- body: JSON.stringify(payload)
342
+ body: JSON.stringify(payload),
313
343
  });
314
344
  };
315
345
  GarageService.deleteCustomerVehicle = function (_a) {
@@ -325,7 +355,7 @@ var GarageService = /** @class */ (function () {
325
355
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/settings/loaner-vehicle-request"),
326
356
  method: Enums_1.APIMethod.PATCH,
327
357
  appType: Enums_1.MovaAppType.GARAGE,
328
- body: JSON.stringify(req)
358
+ body: JSON.stringify(req),
329
359
  });
330
360
  };
331
361
  GarageService.toogleGarageLoanerVehicle = function (garageId) {
@@ -341,7 +371,7 @@ var GarageService = /** @class */ (function () {
341
371
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/vehicle"),
342
372
  method: Enums_1.APIMethod.POST,
343
373
  appType: Enums_1.MovaAppType.GARAGE,
344
- body: JSON.stringify(req)
374
+ body: JSON.stringify(req),
345
375
  });
346
376
  };
347
377
  GarageService.deleteGarageVehicle = function (_a) {
@@ -349,35 +379,35 @@ var GarageService = /** @class */ (function () {
349
379
  return (0, ApiHelper_1.request)({
350
380
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/vehicle/").concat(vehicleId),
351
381
  method: Enums_1.APIMethod.DELETE,
352
- appType: Enums_1.MovaAppType.GARAGE
382
+ appType: Enums_1.MovaAppType.GARAGE,
353
383
  });
354
384
  };
355
385
  GarageService.getAllGarageVehicles = function (garageId) {
356
386
  return (0, ApiHelper_1.request)({
357
387
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/vehicles"),
358
388
  method: Enums_1.APIMethod.GET,
359
- appType: Enums_1.MovaAppType.GARAGE
389
+ appType: Enums_1.MovaAppType.GARAGE,
360
390
  });
361
391
  };
362
392
  GarageService.getOneGarageVehicle = function (garageId, vehicleId) {
363
393
  return (0, ApiHelper_1.request)({
364
394
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/vehicle/").concat(vehicleId),
365
395
  method: Enums_1.APIMethod.GET,
366
- appType: Enums_1.MovaAppType.GARAGE
396
+ appType: Enums_1.MovaAppType.GARAGE,
367
397
  });
368
398
  };
369
399
  GarageService.assignGarageVehicleEvent = function (garageId, eventId, vehicleId) {
370
400
  return (0, ApiHelper_1.request)({
371
401
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/event/").concat(eventId, "/vehicles/").concat(vehicleId),
372
402
  method: Enums_1.APIMethod.PATCH,
373
- appType: Enums_1.MovaAppType.GARAGE
403
+ appType: Enums_1.MovaAppType.GARAGE,
374
404
  });
375
405
  };
376
406
  GarageService.deassignGarageVehicleEvent = function (garageId, eventId) {
377
407
  return (0, ApiHelper_1.request)({
378
408
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/event/").concat(eventId, "/vehicles"),
379
409
  method: Enums_1.APIMethod.DELETE,
380
- appType: Enums_1.MovaAppType.GARAGE
410
+ appType: Enums_1.MovaAppType.GARAGE,
381
411
  });
382
412
  };
383
413
  // CSM
@@ -385,14 +415,14 @@ var GarageService = /** @class */ (function () {
385
415
  return (0, ApiHelper_1.request)({
386
416
  url: "".concat(ApiHelper_1.API_BASE_URL, "/csm/garages/list"),
387
417
  method: Enums_1.APIMethod.GET,
388
- appType: Enums_1.MovaAppType.GARAGE
418
+ appType: Enums_1.MovaAppType.GARAGE,
389
419
  });
390
420
  };
391
421
  GarageService.getOneGarageCsm = function (garageId) {
392
422
  return (0, ApiHelper_1.request)({
393
423
  url: "".concat(ApiHelper_1.API_BASE_URL, "/csm/garage/").concat(garageId),
394
424
  method: Enums_1.APIMethod.GET,
395
- appType: Enums_1.MovaAppType.GARAGE
425
+ appType: Enums_1.MovaAppType.GARAGE,
396
426
  });
397
427
  };
398
428
  return GarageService;
@@ -0,0 +1,9 @@
1
+ export default class UserConnected {
2
+ private static instance;
3
+ private _me;
4
+ private constructor();
5
+ static getInstance(): UserConnected;
6
+ get me(): any;
7
+ set me(user: any);
8
+ clearUser(): void;
9
+ }
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ var UserService_1 = __importDefault(require("./UserService"));
7
+ var UserConnected = /** @class */ (function () {
8
+ function UserConnected() {
9
+ var storedUser = localStorage.getItem('user');
10
+ this._me = storedUser ? JSON.parse(storedUser) : null;
11
+ }
12
+ UserConnected.getInstance = function () {
13
+ if (!UserConnected.instance) {
14
+ UserConnected.instance = new UserConnected();
15
+ }
16
+ return UserConnected.instance;
17
+ };
18
+ Object.defineProperty(UserConnected.prototype, "me", {
19
+ get: function () {
20
+ var _this = this;
21
+ if (!this._me) {
22
+ var storedUser = localStorage.getItem('user');
23
+ if (storedUser === undefined || storedUser === null || storedUser === 'undefined') {
24
+ UserService_1.default.getCurrentUser()
25
+ .then(function (response) {
26
+ localStorage.setItem('user', JSON.stringify(response.data));
27
+ _this._me = response.data;
28
+ return _this._me;
29
+ });
30
+ }
31
+ else {
32
+ this._me = JSON.parse(storedUser);
33
+ return this._me;
34
+ }
35
+ }
36
+ else {
37
+ return this._me;
38
+ }
39
+ },
40
+ set: function (user) {
41
+ this._me = user;
42
+ if (user) {
43
+ localStorage.setItem('user', JSON.stringify(user));
44
+ }
45
+ else {
46
+ localStorage.removeItem('user'); // Supprime les données si user est null ou undefined
47
+ }
48
+ },
49
+ enumerable: false,
50
+ configurable: true
51
+ });
52
+ UserConnected.prototype.clearUser = function () {
53
+ // Méthode pour effacer l'utilisateur
54
+ this._me = null;
55
+ localStorage.removeItem('user');
56
+ };
57
+ return UserConnected;
58
+ }());
59
+ exports.default = UserConnected;
@@ -19,5 +19,5 @@ export default class UserService {
19
19
  * @param password
20
20
  * @returns
21
21
  */
22
- static getCurrentUser(appType: MovaAppType): Promise<APIResponse<User>>;
22
+ static getCurrentUser(appType?: MovaAppType): Promise<APIResponse<User>>;
23
23
  }
@@ -3,5 +3,8 @@ import { MovaAppType } from "../helpers/Enums";
3
3
  import { EditVehicleParams } from "./VehicleService.types";
4
4
  export default class VehicleService {
5
5
  static getVehicleDescription(appType: MovaAppType, plate: string): Promise<APIResponse<string>>;
6
+ static getVehicleDocument(appType: MovaAppType, vehicleId: number): Promise<APIResponse<string>>;
7
+ static deleteVehicleDocument(appType: MovaAppType, vehicleId: number, documentId: string): Promise<APIResponse<string>>;
8
+ static uploadVehicleDocument(appType: MovaAppType, vehicleId: number, req: FormData): Promise<APIResponse<string>>;
6
9
  static editVehicle({ vehicleId, appType, ...payload }: EditVehicleParams): Promise<APIResponse<string>>;
7
10
  }
@@ -23,6 +23,28 @@ var VehicleService = /** @class */ (function () {
23
23
  appType: appType,
24
24
  });
25
25
  };
26
+ VehicleService.getVehicleDocument = function (appType, vehicleId) {
27
+ return (0, ApiHelper_1.request)({
28
+ url: "".concat(ApiHelper_1.API_BASE_URL, "/vehicle/").concat(vehicleId, "/document"),
29
+ method: Enums_1.APIMethod.GET,
30
+ appType: appType,
31
+ });
32
+ };
33
+ VehicleService.deleteVehicleDocument = function (appType, vehicleId, documentId) {
34
+ return (0, ApiHelper_1.request)({
35
+ url: "".concat(ApiHelper_1.API_BASE_URL, "/vehicle/").concat(vehicleId, "/documents/").concat(documentId),
36
+ method: Enums_1.APIMethod.DELETE,
37
+ appType: appType,
38
+ });
39
+ };
40
+ VehicleService.uploadVehicleDocument = function (appType, vehicleId, req) {
41
+ return (0, ApiHelper_1.request)({
42
+ url: "".concat(ApiHelper_1.API_BASE_URL, "/vehicle/").concat(vehicleId, "/documents"),
43
+ method: Enums_1.APIMethod.POST,
44
+ appType: appType,
45
+ body: req
46
+ });
47
+ };
26
48
  VehicleService.editVehicle = function (_a) {
27
49
  var vehicleId = _a.vehicleId, appType = _a.appType, payload = __rest(_a, ["vehicleId", "appType"]);
28
50
  return (0, ApiHelper_1.request)({