@movalib/movalib-commons 1.0.30 → 1.0.32

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.
package/dist/index.d.ts CHANGED
@@ -11,6 +11,7 @@ export { default as Vehicle } from './src/models/Vehicle';
11
11
  export { default as Document } from './src/models/Document';
12
12
  export { default as Garage } from './src/models/Garage';
13
13
  export { default as Schedule } from './src/models/Schedule';
14
+ export { default as Event } from './src/models/Event';
14
15
  export type { MovaFormField, MovaLoginForm, MovaUserSignUpForm, MovaInterval } from './src/helpers/Types';
15
16
  export { validateField } from './src/helpers/Tools';
16
- export { RoleType, MovaAppType, DayOfWeek } from './src/helpers/Enums';
17
+ export { RoleType, MovaAppType, DayOfWeek, EventState, EventType } from './src/helpers/Enums';
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
5
  };
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.DayOfWeek = exports.MovaAppType = exports.RoleType = exports.validateField = exports.Schedule = exports.Garage = exports.Document = exports.Vehicle = exports.Address = exports.Role = exports.User = exports.MovaCopyright = exports.MovaSignUp = exports.MovaLogin = exports.MovaSnackbar = exports.TestButton = exports.VehiclePlateField = void 0;
7
+ exports.EventType = exports.EventState = exports.DayOfWeek = exports.MovaAppType = exports.RoleType = exports.validateField = exports.Event = exports.Schedule = exports.Garage = exports.Document = exports.Vehicle = exports.Address = exports.Role = exports.User = exports.MovaCopyright = exports.MovaSignUp = exports.MovaLogin = exports.MovaSnackbar = exports.TestButton = exports.VehiclePlateField = void 0;
8
8
  // Export des composants
9
9
  var VehiclePlateField_1 = require("./src/VehiclePlateField");
10
10
  Object.defineProperty(exports, "VehiclePlateField", { enumerable: true, get: function () { return __importDefault(VehiclePlateField_1).default; } });
@@ -33,6 +33,8 @@ var Garage_1 = require("./src/models/Garage");
33
33
  Object.defineProperty(exports, "Garage", { enumerable: true, get: function () { return __importDefault(Garage_1).default; } });
34
34
  var Schedule_1 = require("./src/models/Schedule");
35
35
  Object.defineProperty(exports, "Schedule", { enumerable: true, get: function () { return __importDefault(Schedule_1).default; } });
36
+ var Event_1 = require("./src/models/Event");
37
+ Object.defineProperty(exports, "Event", { enumerable: true, get: function () { return __importDefault(Event_1).default; } });
36
38
  // Export des méthodes utilitaires
37
39
  var Tools_1 = require("./src/helpers/Tools");
38
40
  Object.defineProperty(exports, "validateField", { enumerable: true, get: function () { return Tools_1.validateField; } });
@@ -41,3 +43,5 @@ var Enums_1 = require("./src/helpers/Enums");
41
43
  Object.defineProperty(exports, "RoleType", { enumerable: true, get: function () { return Enums_1.RoleType; } });
42
44
  Object.defineProperty(exports, "MovaAppType", { enumerable: true, get: function () { return Enums_1.MovaAppType; } });
43
45
  Object.defineProperty(exports, "DayOfWeek", { enumerable: true, get: function () { return Enums_1.DayOfWeek; } });
46
+ Object.defineProperty(exports, "EventState", { enumerable: true, get: function () { return Enums_1.EventState; } });
47
+ Object.defineProperty(exports, "EventType", { enumerable: true, get: function () { return Enums_1.EventType; } });
@@ -1,3 +1,36 @@
1
+ export declare enum EventState {
2
+ /**
3
+ * Nouvelle demande de rendez-vous (origine client OU centre)
4
+ */
5
+ NEW = "NEW",
6
+ /**
7
+ * Accepté (rendez-vous accepté par le centre)
8
+ * Note : il s'agit du statut par défaut en cas de création du rendez-vous par le centre
9
+ */
10
+ ACCEPTED = "ACCEPTED",
11
+ /**
12
+ * Planifé (rendez-vous planifié, devis accepté par le client le cas échéant)
13
+ * Note : si l'acceptation du devis n'est pas obligatoire pour le centre,
14
+ * le rendez-vous passe directement à l'état 'SCHEDULED' lorsqu'il est confirmé
15
+ */
16
+ SCHEDULED = "SCHEDULED",
17
+ /**
18
+ * Complété (les pièces sont disponibles, état de validation supplémentaire indicatif pour le centre)
19
+ */
20
+ COMPLETED = "COMPLETED",
21
+ /**
22
+ * Le rendez-vous est clôturé
23
+ */
24
+ DONE = "DONE",
25
+ /**
26
+ * Le rendez-vous a été annulé (par le centre ou le client)
27
+ */
28
+ CANCELLED = "CANCELLED"
29
+ }
30
+ export declare enum EventType {
31
+ APPOINTMENT = "APPOINTMENT",
32
+ UNAVAILABILITY = "UNAVAILABILITY"
33
+ }
1
34
  export declare enum DayOfWeek {
2
35
  MONDAY = "MONDAY",
3
36
  TUESDAY = "TUESDAY",
@@ -1,6 +1,41 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RoleType = exports.MovaAppType = exports.DocumentType = exports.DayOfWeek = void 0;
3
+ exports.RoleType = exports.MovaAppType = exports.DocumentType = exports.DayOfWeek = exports.EventType = exports.EventState = void 0;
4
+ var EventState;
5
+ (function (EventState) {
6
+ /**
7
+ * Nouvelle demande de rendez-vous (origine client OU centre)
8
+ */
9
+ EventState["NEW"] = "NEW";
10
+ /**
11
+ * Accepté (rendez-vous accepté par le centre)
12
+ * Note : il s'agit du statut par défaut en cas de création du rendez-vous par le centre
13
+ */
14
+ EventState["ACCEPTED"] = "ACCEPTED";
15
+ /**
16
+ * Planifé (rendez-vous planifié, devis accepté par le client le cas échéant)
17
+ * Note : si l'acceptation du devis n'est pas obligatoire pour le centre,
18
+ * le rendez-vous passe directement à l'état 'SCHEDULED' lorsqu'il est confirmé
19
+ */
20
+ EventState["SCHEDULED"] = "SCHEDULED";
21
+ /**
22
+ * Complété (les pièces sont disponibles, état de validation supplémentaire indicatif pour le centre)
23
+ */
24
+ EventState["COMPLETED"] = "COMPLETED";
25
+ /**
26
+ * Le rendez-vous est clôturé
27
+ */
28
+ EventState["DONE"] = "DONE";
29
+ /**
30
+ * Le rendez-vous a été annulé (par le centre ou le client)
31
+ */
32
+ EventState["CANCELLED"] = "CANCELLED";
33
+ })(EventState = exports.EventState || (exports.EventState = {}));
34
+ var EventType;
35
+ (function (EventType) {
36
+ EventType["APPOINTMENT"] = "APPOINTMENT";
37
+ EventType["UNAVAILABILITY"] = "UNAVAILABILITY";
38
+ })(EventType = exports.EventType || (exports.EventType = {}));
4
39
  var DayOfWeek;
5
40
  (function (DayOfWeek) {
6
41
  DayOfWeek["MONDAY"] = "MONDAY";
@@ -0,0 +1,14 @@
1
+ import Address from "./Address";
2
+ import User from "./User";
3
+ import Vehicle from "./Vehicle";
4
+ export default class Customer extends User {
5
+ vehicles: Vehicle[];
6
+ turnover: {
7
+ key: string;
8
+ value: number;
9
+ }[];
10
+ constructor(id: string, roles: string[] | undefined, firstname: string | undefined, lastname: string | undefined, avatar: string | undefined, addresses: Address[] | undefined, vehicles: Vehicle[], email: string | undefined, turnover: {
11
+ key: string;
12
+ value: number;
13
+ }[]);
14
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ var User_1 = __importDefault(require("./User"));
22
+ var Customer = /** @class */ (function (_super) {
23
+ __extends(Customer, _super);
24
+ function Customer(id, roles, firstname, lastname, avatar, addresses, vehicles, email, turnover) {
25
+ if (roles === void 0) { roles = []; }
26
+ if (firstname === void 0) { firstname = ''; }
27
+ if (lastname === void 0) { lastname = ''; }
28
+ if (avatar === void 0) { avatar = ''; }
29
+ if (addresses === void 0) { addresses = []; }
30
+ if (email === void 0) { email = ''; }
31
+ var _this = _super.call(this, id, roles, firstname, lastname, avatar, email) || this;
32
+ _this.vehicles = vehicles;
33
+ _this.turnover = turnover;
34
+ return _this;
35
+ }
36
+ return Customer;
37
+ }(User_1.default));
38
+ exports.default = Customer;
@@ -0,0 +1,55 @@
1
+ import User from "./User";
2
+ import { EventState, EventType } from "../helpers/Enums";
3
+ import Prestation from "./Prestation";
4
+ import Customer from "./Customer";
5
+ import Vehicle from "./Vehicle";
6
+ export default class Event {
7
+ id: string;
8
+ ownerId: number;
9
+ type: EventType;
10
+ title: string;
11
+ garageName: string;
12
+ startDate?: Date;
13
+ endDate?: Date;
14
+ state: EventState;
15
+ prestations?: Prestation[];
16
+ /**
17
+ * Un tableau d'invités, dans notre cas d'usage nous n'aurons qu'un invité de type Client
18
+ */
19
+ guestsId?: string[];
20
+ guests?: User[];
21
+ customer?: Customer;
22
+ vehicle?: Vehicle;
23
+ vehicleId?: number;
24
+ /**
25
+ * Une liste de ressources affectées à l'événement, dans notre cas il s'agira de un ou plusieurs Techniciens
26
+ */
27
+ resources?: number[];
28
+ notes?: string;
29
+ /**
30
+ * Eventuel numéro de devis rattaché à l'évent
31
+ */
32
+ quoteId?: number;
33
+ /**
34
+ * MVP : pour l'instant les références sont transmises sous cette forme classique
35
+ */
36
+ originReferences?: [string, string][];
37
+ constructor({ id, notes, ownerId, type, title, garageName, state, startDate, endDate, prestations, guestsId, vehicleId, quoteId, originReferences }: {
38
+ id: string;
39
+ notes?: string;
40
+ ownerId: number;
41
+ type: EventType;
42
+ title: string;
43
+ garageName: string;
44
+ state: EventState;
45
+ startDate?: Date;
46
+ endDate?: Date;
47
+ prestations?: Prestation[];
48
+ guestsId?: string[];
49
+ vehicleId?: number;
50
+ quoteId?: number;
51
+ originReferences?: [string, string][];
52
+ });
53
+ static getOriginReferences(event: Event): string | undefined;
54
+ static getServicesList(event: Event): string[];
55
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var Event = /** @class */ (function () {
4
+ function Event(_a) {
5
+ var id = _a.id, notes = _a.notes, ownerId = _a.ownerId, type = _a.type, title = _a.title, garageName = _a.garageName, state = _a.state, startDate = _a.startDate, endDate = _a.endDate, prestations = _a.prestations, guestsId = _a.guestsId, vehicleId = _a.vehicleId, quoteId = _a.quoteId, originReferences = _a.originReferences;
6
+ this.id = id;
7
+ this.notes = notes;
8
+ this.ownerId = ownerId;
9
+ this.type = type;
10
+ this.title = title;
11
+ this.garageName = garageName;
12
+ this.state = state;
13
+ this.startDate = startDate ? new Date(startDate) : undefined;
14
+ this.endDate = endDate ? new Date(endDate) : undefined;
15
+ this.prestations = prestations;
16
+ this.guestsId = guestsId;
17
+ this.vehicleId = vehicleId;
18
+ this.quoteId = quoteId;
19
+ this.originReferences = originReferences;
20
+ }
21
+ Event.getOriginReferences = function (event) {
22
+ var _a;
23
+ var list = '';
24
+ if (event.originReferences && event.originReferences.length !== 0) {
25
+ (_a = event.originReferences) === null || _a === void 0 ? void 0 : _a.forEach(function (reference) {
26
+ list = "".concat(reference[0], " : ").concat(reference[1]);
27
+ });
28
+ }
29
+ return list;
30
+ };
31
+ Event.getServicesList = function (event) {
32
+ if (event && event.prestations) {
33
+ console.log(event.prestations.map(function (n) { return n.name; }));
34
+ return event.prestations.map(function (n) { return n.name; });
35
+ }
36
+ return [];
37
+ };
38
+ return Event;
39
+ }());
40
+ exports.default = Event;
package/index.ts CHANGED
@@ -16,6 +16,7 @@ export { default as Vehicle } from './src/models/Vehicle';
16
16
  export { default as Document } from './src/models/Document';
17
17
  export { default as Garage } from './src/models/Garage';
18
18
  export { default as Schedule } from './src/models/Schedule';
19
+ export { default as Event } from './src/models/Event';
19
20
 
20
21
  // Export des types
21
22
  export type { MovaFormField, MovaLoginForm, MovaUserSignUpForm, MovaInterval } from './src/helpers/Types';
@@ -24,4 +25,4 @@ export type { MovaFormField, MovaLoginForm, MovaUserSignUpForm, MovaInterval } f
24
25
  export { validateField } from './src/helpers/Tools';
25
26
 
26
27
  // Export des enums
27
- export { RoleType, MovaAppType, DayOfWeek } from './src/helpers/Enums';
28
+ export { RoleType, MovaAppType, DayOfWeek, EventState, EventType } from './src/helpers/Enums';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@movalib/movalib-commons",
3
- "version": "1.0.30",
3
+ "version": "1.0.32",
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",
@@ -1,3 +1,38 @@
1
+ export enum EventState {
2
+ /**
3
+ * Nouvelle demande de rendez-vous (origine client OU centre)
4
+ */
5
+ NEW = "NEW",
6
+ /**
7
+ * Accepté (rendez-vous accepté par le centre)
8
+ * Note : il s'agit du statut par défaut en cas de création du rendez-vous par le centre
9
+ */
10
+ ACCEPTED = "ACCEPTED",
11
+ /**
12
+ * Planifé (rendez-vous planifié, devis accepté par le client le cas échéant)
13
+ * Note : si l'acceptation du devis n'est pas obligatoire pour le centre,
14
+ * le rendez-vous passe directement à l'état 'SCHEDULED' lorsqu'il est confirmé
15
+ */
16
+ SCHEDULED = "SCHEDULED",
17
+ /**
18
+ * Complété (les pièces sont disponibles, état de validation supplémentaire indicatif pour le centre)
19
+ */
20
+ COMPLETED = "COMPLETED",
21
+ /**
22
+ * Le rendez-vous est clôturé
23
+ */
24
+ DONE = "DONE",
25
+ /**
26
+ * Le rendez-vous a été annulé (par le centre ou le client)
27
+ */
28
+ CANCELLED = "CANCELLED"
29
+ }
30
+
31
+ export enum EventType {
32
+ APPOINTMENT = "APPOINTMENT",
33
+ UNAVAILABILITY = "UNAVAILABILITY"
34
+ }
35
+
1
36
  export enum DayOfWeek {
2
37
  MONDAY = "MONDAY",
3
38
  TUESDAY = "TUESDAY",
@@ -0,0 +1,28 @@
1
+ import Address from "./Address";
2
+ import User from "./User";
3
+ import Vehicle from "./Vehicle";
4
+
5
+
6
+ export default class Customer extends User {
7
+
8
+ // Properties
9
+ vehicles: Vehicle[];
10
+ turnover: { key: string, value: number }[];
11
+
12
+ constructor(
13
+ id: string,
14
+ roles: string[] = [],
15
+ firstname: string = '',
16
+ lastname: string = '',
17
+ avatar: string = '',
18
+ addresses : Address[] = [],
19
+ vehicles: Vehicle[],
20
+ email: string = '',
21
+ turnover: { key: string, value: number }[]) {
22
+
23
+ super(id, roles, firstname, lastname, avatar, email);
24
+
25
+ this.vehicles = vehicles;
26
+ this.turnover = turnover;
27
+ }
28
+ }
@@ -0,0 +1,82 @@
1
+ import User from "./User";
2
+ import { EventState, EventType } from "../helpers/Enums";
3
+ import Prestation from "./Prestation";
4
+ import Customer from "./Customer";
5
+ import Vehicle from "./Vehicle";
6
+
7
+ export default class Event {
8
+
9
+ // Properties
10
+ id: string; //UUID
11
+ ownerId: number;
12
+ type: EventType;
13
+ title: string;
14
+ garageName: string;
15
+ startDate?: Date;
16
+ endDate?: Date;
17
+ state: EventState;
18
+ prestations?: Prestation[];
19
+ /**
20
+ * Un tableau d'invités, dans notre cas d'usage nous n'aurons qu'un invité de type Client
21
+ */
22
+ guestsId?: string[];
23
+ guests?: User[];
24
+ customer?: Customer;
25
+ vehicle?: Vehicle;
26
+ vehicleId?: number;
27
+ /**
28
+ * Une liste de ressources affectées à l'événement, dans notre cas il s'agira de un ou plusieurs Techniciens
29
+ */
30
+ resources?: number[];
31
+ notes?: string;
32
+ /**
33
+ * Eventuel numéro de devis rattaché à l'évent
34
+ */
35
+ quoteId?: number;
36
+
37
+ /**
38
+ * MVP : pour l'instant les références sont transmises sous cette forme classique
39
+ */
40
+ originReferences?: [string, string][];
41
+
42
+ constructor({ id, notes, ownerId, type, title, garageName, state, startDate, endDate, prestations, guestsId, vehicleId, quoteId, originReferences }
43
+ : { id: string; notes?: string; ownerId: number; type : EventType; title: string; garageName: string;
44
+ state: EventState; startDate?: Date; endDate?: Date, prestations?: Prestation[],
45
+ guestsId?: string[], vehicleId?: number, quoteId?: number, originReferences?: [string, string][]})
46
+ {
47
+ this.id = id;
48
+ this.notes = notes;
49
+ this.ownerId = ownerId;
50
+ this.type = type;
51
+ this.title = title;
52
+ this.garageName = garageName;
53
+ this.state = state;
54
+ this.startDate = startDate ? new Date(startDate) : undefined;
55
+ this.endDate = endDate ? new Date(endDate) : undefined;
56
+ this.prestations = prestations;
57
+ this.guestsId = guestsId;
58
+ this.vehicleId = vehicleId;
59
+ this.quoteId = quoteId;
60
+ this.originReferences = originReferences;
61
+ }
62
+
63
+ static getOriginReferences(event: Event) : string | undefined {
64
+ let list:string = '';
65
+
66
+ if(event.originReferences && event.originReferences.length !== 0){
67
+ event.originReferences?.forEach(reference => {
68
+ list = `${reference[0]} : ${reference[1]}`;
69
+ })
70
+ }
71
+ return list;
72
+ }
73
+
74
+ static getServicesList(event: Event) : string[] {
75
+ if(event && event.prestations) {
76
+ console.log(event.prestations.map(n => n.name));
77
+ return event.prestations.map(n => n.name);
78
+ }
79
+
80
+ return [];
81
+ }
82
+ }