@movalib/movalib-commons 1.59.3 → 1.59.5

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.
@@ -33,6 +33,7 @@ var theme_1 = __importDefault(require("../theme")); // Import du thème personna
33
33
  var Enums_1 = require("./helpers/Enums");
34
34
  var Logger_1 = __importDefault(require("./helpers/Logger"));
35
35
  var Tools_1 = require("./helpers/Tools");
36
+ var DateUtils_1 = require("./helpers/DateUtils");
36
37
  var ContentCopy_1 = __importDefault(require("@mui/icons-material/ContentCopy"));
37
38
  var initialSchedules = [
38
39
  { day: Enums_1.DayOfWeek.MONDAY, checked: false, allDay: false, intervals: [{ startTime: null, endTime: null, countryCode: Enums_1.CountryCode.FR, error: null }] },
@@ -147,8 +148,8 @@ var ScheduleFields = function (_a) {
147
148
  newSchedule[dayIndex].intervals[intervalIndex].error = validateIntervals(newSchedule[dayIndex].intervals);
148
149
  }
149
150
  setSchedule(newSchedule);
150
- if (type === 'endTime') {
151
- // On invoque la callback de mise à jour uniquement sur l'intervalle de fin
151
+ if (type === 'endTime' || (type === 'startTime' && (0, DateUtils_1.isValidDate)(newSchedule[dayIndex].intervals[intervalIndex].endTime))) {
152
+ // On invoque la callback de mise à jour sur les deux intervalles, toutefois on contrôle que l'intervalle de fin est alimentée
152
153
  onChange(newSchedule);
153
154
  }
154
155
  };
@@ -188,7 +189,7 @@ var ScheduleFields = function (_a) {
188
189
  onChange(newSchedule);
189
190
  setSchedule(newSchedule);
190
191
  }; };
191
- return ((0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ container: true, spacing: 1, sx: { minWidth: '650px', maxWidth: '800px' } }, { children: schedule.map(function (daySchedule, dayIndex) { return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 2 }, { children: (0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(material_1.Checkbox, { checked: daySchedule.checked, onChange: handleDayChecked(dayIndex) }), label: (0, Tools_1.getDayOfWeekLabel)(daySchedule.day) }) }), dayIndex + 1), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 7 }, { children: daySchedule.intervals.map(function (interval, intervalIndex) { return ((0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, style: { paddingTop: intervalIndex > 0 ? theme_1.default.spacing(1) : 0 } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 6, sx: { textAlign: 'center' } }, { children: (0, jsx_runtime_1.jsx)(x_date_pickers_1.TimePicker, { views: ['hours', 'minutes'], minutesStep: timePickerStep !== null && timePickerStep !== void 0 ? timePickerStep : 30, disabled: !daySchedule.checked, value: interval.startTime, formatDensity: 'dense', closeOnSelect: false, onAccept: handleIntervalChange(dayIndex, intervalIndex, 'startTime'), slotProps: {
192
+ return ((0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ container: true, spacing: 1, sx: { minWidth: '650px', maxWidth: '800px' } }, { children: schedule.map(function (daySchedule, dayIndex) { return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 2 }, { children: (0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(material_1.Checkbox, { checked: daySchedule.checked, onChange: handleDayChecked(dayIndex) }), label: (0, Tools_1.getDayOfWeekLabel)(daySchedule.day) }) }), dayIndex + 1), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 7 }, { children: daySchedule.intervals.map(function (interval, intervalIndex) { return ((0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, style: { paddingTop: intervalIndex > 0 ? theme_1.default.spacing(1) : 0 } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 6, sx: { textAlign: 'center' } }, { children: (0, jsx_runtime_1.jsx)(x_date_pickers_1.TimePicker, { views: ['hours', 'minutes'], minutesStep: timePickerStep !== null && timePickerStep !== void 0 ? timePickerStep : 30, disabled: !daySchedule.checked, value: interval.startTime, formatDensity: 'dense', closeOnSelect: false, onChange: handleIntervalChange(dayIndex, intervalIndex, 'startTime'), slotProps: {
192
193
  textField: {
193
194
  size: 'small',
194
195
  sx: {
@@ -200,7 +201,7 @@ var ScheduleFields = function (_a) {
200
201
  actionBar: {
201
202
  sx: { display: 'none' },
202
203
  },
203
- } }) }), (intervalIndex + 1) * Math.random()), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 6, sx: { display: 'contents' } }, { children: (0, jsx_runtime_1.jsx)(x_date_pickers_1.TimePicker, { minutesStep: timePickerStep !== null && timePickerStep !== void 0 ? timePickerStep : 30, disabled: !(interval.startTime instanceof Date), value: interval.endTime, formatDensity: 'dense', onAccept: handleIntervalChange(dayIndex, intervalIndex, 'endTime'), closeOnSelect: false, slotProps: {
204
+ } }) }), (intervalIndex + 1) * Math.random()), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 6, sx: { display: 'contents' } }, { children: (0, jsx_runtime_1.jsx)(x_date_pickers_1.TimePicker, { minutesStep: timePickerStep !== null && timePickerStep !== void 0 ? timePickerStep : 30, disabled: !(interval.startTime instanceof Date), value: interval.endTime, formatDensity: 'dense', onChange: handleIntervalChange(dayIndex, intervalIndex, 'endTime'), closeOnSelect: false, slotProps: {
204
205
  textField: {
205
206
  size: 'small',
206
207
  sx: {
@@ -1,5 +1,6 @@
1
1
  /// <reference types="date-fns" />
2
2
  import { DateFormatTypes } from './Enums';
3
+ export declare function isValidDate(date: unknown): date is Date;
3
4
  export declare const countryTimeZones: {
4
5
  [key: string]: string;
5
6
  };
@@ -1,10 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getLongFormattedDateTime = exports.formatDateByCountryCode = exports.toUTCToLocaleDate = exports.countryTimeZones = void 0;
3
+ exports.getLongFormattedDateTime = exports.formatDateByCountryCode = exports.toUTCToLocaleDate = exports.countryTimeZones = exports.isValidDate = void 0;
4
4
  var date_fns_tz_1 = require("date-fns-tz");
5
5
  var locale_1 = require("date-fns/locale");
6
6
  var Enums_1 = require("./Enums");
7
7
  var Tools_1 = require("./Tools");
8
+ function isValidDate(date) {
9
+ return date instanceof Date && !isNaN(date.getTime());
10
+ }
11
+ exports.isValidDate = isValidDate;
8
12
  // Tableau de correspondance entre les codes de pays et les fuseaux horaires
9
13
  exports.countryTimeZones = {
10
14
  'FR': 'Europe/Paris',
@@ -8,6 +8,7 @@ export default class GarageService {
8
8
  static deleteEventEmployee(garageId: string, eventId: string): Promise<APIResponse<string>>;
9
9
  static updateEventEmployee(garageId: string, eventId: string, employeeId: string): Promise<APIResponse<string>>;
10
10
  static updateColorPrestationCategory(garageId: string, categoryCode: string, color: string): Promise<APIResponse<string>>;
11
+ static updateGarageEventColor(garageId: string, eventId: string, color: string): Promise<APIResponse<string>>;
11
12
  static updateVehicleGarageEvent(garageId: string, eventId: string, req: any): Promise<APIResponse<string>>;
12
13
  static sendGarageMandate(garageId: string): Promise<APIResponse<string>>;
13
14
  static getGarageAllData(garageId: string): Promise<APIResponse<Garage>>;
@@ -53,6 +53,14 @@ var GarageService = /** @class */ (function () {
53
53
  body: JSON.stringify({ color: color })
54
54
  });
55
55
  };
56
+ GarageService.updateGarageEventColor = function (garageId, eventId, color) {
57
+ return (0, ApiHelper_1.request)({
58
+ url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/event/").concat(eventId, "/color"),
59
+ method: Enums_1.APIMethod.PATCH,
60
+ appType: Enums_1.MovaAppType.GARAGE,
61
+ body: JSON.stringify({ color: color })
62
+ });
63
+ };
56
64
  GarageService.updateVehicleGarageEvent = function (garageId, eventId, req) {
57
65
  return (0, ApiHelper_1.request)({
58
66
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/event/").concat(eventId, "/vehicle"),
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@movalib/movalib-commons",
3
- "version": "1.59.3",
3
+ "version": "1.59.5",
4
4
  "description": "Bibliothèque d'objets communs à l'ensemble des projets React de Movalib",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "private": false,
8
8
  "scripts": {
9
- "start": "webpack-dev-server --entry ./devIndex.tsx --open",
9
+ "start": "webpack-dev-server --entry ./devIndex.tsx --open --https",
10
10
  "build": "rm -rf dist && tsc && npm run copy-assets",
11
11
  "copy-assets": "cp -r src/assets/ dist/src/assets/ && cp -r src/style/ dist/src/style/",
12
12
  "test": "echo \"Error: no test specified\" && exit 1",
@@ -9,7 +9,7 @@ import Schedule from './models/Schedule';
9
9
  import { CountryCode, DayOfWeek } from './helpers/Enums';
10
10
  import Logger from './helpers/Logger';
11
11
  import { flexCenter, getDayOfWeekIndex, getDayOfWeekLabel } from './helpers/Tools';
12
- import { toUTCToLocaleDate } from './helpers/DateUtils';
12
+ import { isValidDate, toUTCToLocaleDate } from './helpers/DateUtils';
13
13
  import ContentCopyIcon from '@mui/icons-material/ContentCopy';
14
14
 
15
15
 
@@ -160,7 +160,7 @@ const ScheduleFields: FunctionComponent<ScheduleFieldsProps> = ({ timePickerStep
160
160
 
161
161
  const handleIntervalChange = (dayIndex: number, intervalIndex: number, type: 'startTime' | 'endTime') =>
162
162
  (newValue: "" | Date | null) => {
163
-
163
+
164
164
  const newSchedule = [...schedule];
165
165
 
166
166
  newSchedule[dayIndex].intervals[intervalIndex][type] = newValue!;
@@ -180,8 +180,8 @@ const ScheduleFields: FunctionComponent<ScheduleFieldsProps> = ({ timePickerStep
180
180
 
181
181
  setSchedule(newSchedule);
182
182
 
183
- if(type === 'endTime'){
184
- // On invoque la callback de mise à jour uniquement sur l'intervalle de fin
183
+ if(type === 'endTime' || (type === 'startTime' && isValidDate(newSchedule[dayIndex].intervals[intervalIndex].endTime))){
184
+ // On invoque la callback de mise à jour sur les deux intervalles, toutefois on contrôle que l'intervalle de fin est alimentée
185
185
  onChange(newSchedule);
186
186
  }
187
187
 
@@ -264,7 +264,7 @@ const ScheduleFields: FunctionComponent<ScheduleFieldsProps> = ({ timePickerStep
264
264
  value={interval.startTime}
265
265
  formatDensity='dense'
266
266
  closeOnSelect={false}
267
- onAccept={handleIntervalChange(dayIndex, intervalIndex, 'startTime')}
267
+ onChange={handleIntervalChange(dayIndex, intervalIndex, 'startTime')}
268
268
  slotProps={{
269
269
  textField: {
270
270
  size: 'small',
@@ -286,7 +286,7 @@ const ScheduleFields: FunctionComponent<ScheduleFieldsProps> = ({ timePickerStep
286
286
  disabled={!(interval.startTime instanceof Date)}
287
287
  value={interval.endTime}
288
288
  formatDensity='dense'
289
- onAccept={handleIntervalChange(dayIndex, intervalIndex, 'endTime')}
289
+ onChange={handleIntervalChange(dayIndex, intervalIndex, 'endTime')}
290
290
  closeOnSelect={false}
291
291
  slotProps={{
292
292
  textField: {
@@ -3,6 +3,10 @@ import { fr } from 'date-fns/locale';
3
3
  import { DateFormatTypes } from './Enums';
4
4
  import { capitalizeFirstLetter } from './Tools';
5
5
 
6
+ export function isValidDate(date: unknown): date is Date {
7
+ return date instanceof Date && !isNaN(date.getTime());
8
+ }
9
+
6
10
  // Tableau de correspondance entre les codes de pays et les fuseaux horaires
7
11
  export const countryTimeZones: { [key: string]: string } = {
8
12
  'FR': 'Europe/Paris',
@@ -47,7 +47,14 @@ export default class GarageService {
47
47
  body: JSON.stringify({ color })
48
48
  });
49
49
  }
50
-
50
+ static updateGarageEventColor(garageId: string, eventId: string, color: string): Promise<APIResponse<string>> {
51
+ return request({
52
+ url: `${API_BASE_URL}/garage/${garageId}/event/${eventId}/color`,
53
+ method: APIMethod.PATCH,
54
+ appType: MovaAppType.GARAGE,
55
+ body: JSON.stringify({ color })
56
+ });
57
+ }
51
58
  static updateVehicleGarageEvent(garageId: string, eventId: string, req: any): Promise<APIResponse<string>> {
52
59
 
53
60
  return request({
package/webpack.config.js CHANGED
@@ -41,4 +41,13 @@ module.exports = {
41
41
  'process.env.REACT_APP_MOVALIB_APP_URL': JSON.stringify(process.env.REACT_APP_MOVALIB_APP_URL)
42
42
  }),
43
43
  ],
44
+
45
+ devServer: {
46
+ https: {
47
+ cert: path.resolve(__dirname, '/Users/Dimitri/localhost.pem'),
48
+ key: path.resolve(__dirname, '/Users/Dimitri/localhost-key.pem'),
49
+ },
50
+ open: true,
51
+ port: 8080, // ou un autre port si nécessaire
52
+ },
44
53
  };