@movalib/movalib-commons 1.1.53 → 1.1.55

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.
@@ -63,8 +63,8 @@ var request = function (options) {
63
63
  }
64
64
  break;
65
65
  case Enums_1.MovaAppType.GARAGE:
66
- if ((0, CookieUtils_1.readCookie)(CookieUtils_1.COOKIE_GARAGE_TOKEN)) {
67
- headers.append('Authorization', 'Bearer ' + (0, CookieUtils_1.readCookie)(CookieUtils_1.COOKIE_GARAGE_TOKEN));
66
+ if ((0, CookieUtils_1.readCookie)(CookieUtils_1.COOKIE_PRO_TOKEN)) {
67
+ headers.append('Authorization', 'Bearer ' + (0, CookieUtils_1.readCookie)(CookieUtils_1.COOKIE_PRO_TOKEN));
68
68
  }
69
69
  break;
70
70
  }
@@ -1,4 +1,4 @@
1
- export declare const COOKIE_GARAGE_TOKEN: string;
1
+ export declare const COOKIE_PRO_TOKEN: string;
2
2
  export declare const COOKIE_INDIVIDUAL_TOKEN: string;
3
3
  export declare const COOKIE_DEFAULT_EXPIRES: number;
4
4
  export declare const createCookie: (name: string, value: string) => void;
@@ -3,9 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.readCookie = exports.deleteCookie = exports.createCookie = exports.COOKIE_DEFAULT_EXPIRES = exports.COOKIE_INDIVIDUAL_TOKEN = exports.COOKIE_GARAGE_TOKEN = void 0;
6
+ exports.readCookie = exports.deleteCookie = exports.createCookie = exports.COOKIE_DEFAULT_EXPIRES = exports.COOKIE_INDIVIDUAL_TOKEN = exports.COOKIE_PRO_TOKEN = void 0;
7
7
  var js_cookie_1 = __importDefault(require("js-cookie"));
8
- exports.COOKIE_GARAGE_TOKEN = 'movalibGarageToken';
8
+ exports.COOKIE_PRO_TOKEN = 'movalibProToken';
9
9
  exports.COOKIE_INDIVIDUAL_TOKEN = 'movalibIndividualToken';
10
10
  exports.COOKIE_DEFAULT_EXPIRES = 7;
11
11
  var createCookie = function (name, value) {
@@ -60,7 +60,7 @@ var AuthenticationService = /** @class */ (function () {
60
60
  switch (appType) {
61
61
  case Enums_1.MovaAppType.GARAGE:
62
62
  url = "".concat(ApiHelper_1.API_BASE_URL, "/garage/login");
63
- tokenCookie = CookieUtils_1.COOKIE_GARAGE_TOKEN;
63
+ tokenCookie = CookieUtils_1.COOKIE_PRO_TOKEN;
64
64
  break;
65
65
  case Enums_1.MovaAppType.INDIVIDUAL:
66
66
  url = "".concat(ApiHelper_1.API_BASE_URL, "/login");
@@ -81,7 +81,7 @@ var AuthenticationService = /** @class */ (function () {
81
81
  if (!tokenResponse.success) return [3 /*break*/, 3];
82
82
  Logger_1.default.info(tokenResponse);
83
83
  (0, CookieUtils_1.createCookie)(tokenCookie, tokenResponse.data.accessToken);
84
- return [4 /*yield*/, UserService_1.default.getCurrentUser()];
84
+ return [4 /*yield*/, UserService_1.default.getCurrentUser(appType)];
85
85
  case 2:
86
86
  userResponse = _a.sent();
87
87
  if (!userResponse || !userResponse.success) {
@@ -1,6 +1,7 @@
1
1
  import { APIResponse } from "../helpers/ApiHelper";
2
2
  import Garage from "../models/Garage";
3
3
  export default class GarageService {
4
+ static activateGarage(garageId: string): Promise<APIResponse<string>>;
4
5
  static salesSignUp(formData: FormData): Promise<APIResponse<number>>;
5
6
  static sendNewEventQuote(garageId: string, eventId: string, formData: FormData): Promise<APIResponse<string>>;
6
7
  static sendCustomerReminder(garageId: string, eventId: string, message: string): Promise<APIResponse<string>>;
@@ -5,6 +5,13 @@ var Enums_1 = require("../helpers/Enums");
5
5
  var GarageService = /** @class */ (function () {
6
6
  function GarageService() {
7
7
  }
8
+ GarageService.activateGarage = function (garageId) {
9
+ return (0, ApiHelper_1.request)({
10
+ url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/activate"),
11
+ method: Enums_1.APIMethod.PATCH,
12
+ appType: Enums_1.MovaAppType.GARAGE
13
+ });
14
+ };
8
15
  GarageService.salesSignUp = function (formData) {
9
16
  return (0, ApiHelper_1.request)({
10
17
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/sales-signup"),
@@ -1,11 +1,14 @@
1
1
  import { APIResponse } from "../helpers/ApiHelper";
2
+ import { MovaAppType } from "../helpers/Enums";
3
+ import Garage from "../models/Garage";
2
4
  import User from "../models/User";
3
5
  export default class UserService {
6
+ static getSalesGarages(salesId: string): Promise<APIResponse<Garage[]>>;
4
7
  static validateAccount(req: any): Promise<APIResponse<string>>;
5
8
  /**
6
9
  * @param email
7
10
  * @param password
8
11
  * @returns
9
12
  */
10
- static getCurrentUser(): Promise<APIResponse<User>>;
13
+ static getCurrentUser(appType: MovaAppType): Promise<APIResponse<User>>;
11
14
  }
@@ -45,6 +45,13 @@ var Logger_1 = __importDefault(require("../helpers/Logger"));
45
45
  var UserService = /** @class */ (function () {
46
46
  function UserService() {
47
47
  }
48
+ UserService.getSalesGarages = function (salesId) {
49
+ return (0, ApiHelper_1.request)({
50
+ url: "".concat(ApiHelper_1.API_BASE_URL, "/sales/").concat(salesId, "/garages"),
51
+ method: Enums_1.APIMethod.GET,
52
+ appType: Enums_1.MovaAppType.GARAGE
53
+ });
54
+ };
48
55
  UserService.validateAccount = function (req) {
49
56
  return (0, ApiHelper_1.request)({
50
57
  url: "".concat(ApiHelper_1.API_BASE_URL, "/user/validate-account"),
@@ -58,7 +65,7 @@ var UserService = /** @class */ (function () {
58
65
  * @param password
59
66
  * @returns
60
67
  */
61
- UserService.getCurrentUser = function () {
68
+ UserService.getCurrentUser = function (appType) {
62
69
  return __awaiter(this, void 0, void 0, function () {
63
70
  var error_1;
64
71
  return __generator(this, function (_a) {
@@ -68,7 +75,7 @@ var UserService = /** @class */ (function () {
68
75
  return [4 /*yield*/, (0, ApiHelper_1.request)({
69
76
  url: "".concat(ApiHelper_1.API_BASE_URL, "/user/me"),
70
77
  method: Enums_1.APIMethod.GET,
71
- appType: Enums_1.MovaAppType.INDIVIDUAL
78
+ appType: appType
72
79
  })];
73
80
  case 1: return [2 /*return*/, _a.sent()];
74
81
  case 2:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@movalib/movalib-commons",
3
- "version": "1.1.53",
3
+ "version": "1.1.55",
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,5 +1,5 @@
1
1
  import { APIMethod, MovaAppType } from "./Enums";
2
- import { COOKIE_GARAGE_TOKEN, COOKIE_INDIVIDUAL_TOKEN, readCookie } from "./CookieUtils";
2
+ import { COOKIE_PRO_TOKEN, COOKIE_INDIVIDUAL_TOKEN, readCookie } from "./CookieUtils";
3
3
  import Logger from "./Logger";
4
4
  import { useHistory } from "react-router-dom";
5
5
 
@@ -84,8 +84,8 @@ export const request = (options:APIRequest): Promise<APIResponse<any>> => {
84
84
  break;
85
85
 
86
86
  case MovaAppType.GARAGE:
87
- if(readCookie(COOKIE_GARAGE_TOKEN)) {
88
- headers.append('Authorization', 'Bearer ' + readCookie(COOKIE_GARAGE_TOKEN))
87
+ if(readCookie(COOKIE_PRO_TOKEN)) {
88
+ headers.append('Authorization', 'Bearer ' + readCookie(COOKIE_PRO_TOKEN))
89
89
  }
90
90
  break;
91
91
  }
@@ -1,6 +1,6 @@
1
1
  import Cookies from "js-cookie";
2
2
 
3
- export const COOKIE_GARAGE_TOKEN: string = 'movalibGarageToken';
3
+ export const COOKIE_PRO_TOKEN: string = 'movalibProToken';
4
4
  export const COOKIE_INDIVIDUAL_TOKEN: string = 'movalibIndividualToken';
5
5
  export const COOKIE_DEFAULT_EXPIRES: number = 7;
6
6
 
@@ -1,5 +1,5 @@
1
1
  import { APIResponse, API_BASE_URL, request } from "../helpers/ApiHelper";
2
- import { COOKIE_GARAGE_TOKEN, COOKIE_INDIVIDUAL_TOKEN, createCookie } from "../helpers/CookieUtils";
2
+ import { COOKIE_PRO_TOKEN, COOKIE_INDIVIDUAL_TOKEN, createCookie } from "../helpers/CookieUtils";
3
3
  import { APIMethod, MovaAppType } from "../helpers/Enums";
4
4
  import Logger from "../helpers/Logger";
5
5
  import User from "../models/User";
@@ -19,7 +19,7 @@ export default class AuthenticationService {
19
19
  switch(appType){
20
20
  case MovaAppType.GARAGE:
21
21
  url = `${API_BASE_URL}/garage/login`;
22
- tokenCookie = COOKIE_GARAGE_TOKEN;
22
+ tokenCookie = COOKIE_PRO_TOKEN;
23
23
  break;
24
24
  case MovaAppType.INDIVIDUAL:
25
25
  url = `${API_BASE_URL}/login`;
@@ -44,7 +44,7 @@ export default class AuthenticationService {
44
44
  createCookie(tokenCookie, tokenResponse.data.accessToken);
45
45
 
46
46
  // Si le login est un succès, on renvoie les infos de l'utilisateur connecté
47
- let userResponse = await UserService.getCurrentUser();
47
+ let userResponse = await UserService.getCurrentUser(appType);
48
48
 
49
49
  if(!userResponse || !userResponse.success) {
50
50
  const errorMsg = 'Erreur au chargement de votre profil';
@@ -4,6 +4,15 @@ import Garage from "../models/Garage";
4
4
 
5
5
  export default class GarageService {
6
6
 
7
+ static activateGarage(garageId: string): Promise<APIResponse<string>> {
8
+
9
+ return request({
10
+ url: `${API_BASE_URL}/garage/${garageId}/activate`,
11
+ method: APIMethod.PATCH,
12
+ appType: MovaAppType.GARAGE
13
+ });
14
+ }
15
+
7
16
  static salesSignUp(formData: FormData): Promise<APIResponse<number>> {
8
17
  return request({
9
18
  url: `${API_BASE_URL}/garage/sales-signup`,
@@ -1,10 +1,19 @@
1
1
  import { APIResponse, API_BASE_URL, request } from "../helpers/ApiHelper";
2
2
  import { APIMethod, MovaAppType } from "../helpers/Enums";
3
3
  import Logger from "../helpers/Logger";
4
+ import Garage from "../models/Garage";
4
5
  import User from "../models/User";
5
6
 
6
7
  export default class UserService {
7
8
 
9
+ static getSalesGarages(salesId: string,): Promise<APIResponse<Garage[]>> {
10
+ return request({
11
+ url: `${API_BASE_URL}/sales/${salesId}/garages`,
12
+ method: APIMethod.GET,
13
+ appType: MovaAppType.GARAGE
14
+ });
15
+ }
16
+
8
17
  static validateAccount(req: any): Promise<APIResponse<string>> {
9
18
  return request({
10
19
  url: `${API_BASE_URL}/user/validate-account`,
@@ -19,12 +28,12 @@ export default class UserService {
19
28
  * @param password
20
29
  * @returns
21
30
  */
22
- static async getCurrentUser(): Promise<APIResponse<User>> {
31
+ static async getCurrentUser(appType: MovaAppType): Promise<APIResponse<User>> {
23
32
  try {
24
33
  return await request({
25
34
  url: `${API_BASE_URL}/user/me`,
26
35
  method: APIMethod.GET,
27
- appType: MovaAppType.INDIVIDUAL
36
+ appType: appType
28
37
  });
29
38
  } catch (error) {
30
39
  Logger.error('Error occurred during getting user:', error);