meemup-library 1.5.78 → 1.5.80

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.
@@ -11,8 +11,8 @@ export default class ApiController {
11
11
  deviceIdentifier: string;
12
12
  }>;
13
13
  fetchRequest(url: string, method: string, body?: any, headers?: object, authorization?: boolean, timeout?: number): Promise<IAnswer>;
14
- fetchSuccess(response: any): IAnswer;
15
- fetchError(error: any, message?: string): IAnswer;
14
+ fetchSuccess(response: any, status: number): IAnswer;
15
+ fetchError(error: any, message: string | undefined, status: number): IAnswer;
16
16
  patchWithAuth: (url: string, body?: any, headers?: any) => Promise<IAnswer>;
17
17
  postWithAuth: (url: string, body?: any, headers?: any) => Promise<IAnswer>;
18
18
  putWithAuth: (url: string, body: any, headers?: any) => Promise<IAnswer>;
@@ -7,119 +7,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- // import axios, {AxiosError, AxiosInstance, AxiosResponse} from "axios";
11
- // export default class ApiController {
12
- //
13
- //
14
- // account: IAccount | IDriverAccount;
15
- //
16
- // constructor(account: IAccount | IDriverAccount) {
17
- // this.account = account;
18
- // }
19
- //
20
- // async defaultHeader(authorization: boolean = true) {
21
- //
22
- // return {
23
- // companyId: this.getCompanyId(),
24
- // ...authorization ? {Authorization: "Bearer " + this.account.token} : {}
25
- // };
26
- // }
27
- //
28
- // async createInstance(header: object = {}, authorization: boolean = true, timeout: number = 15000) {
29
- //
30
- // let data: any = await this.defaultHeader(authorization);
31
- //
32
- // return axios.create({
33
- // withCredentials: true,
34
- // timeout: timeout,
35
- // headers: {
36
- // ...data,
37
- // ...header
38
- // }
39
- // });
40
- //
41
- // }
42
- //
43
- // fetchSuccess(response: AxiosResponse, init: any = {}): IAnswer {
44
- // if (response.status === 200) {
45
- // if (response.data.success === true) {
46
- // return response.data;
47
- // }
48
- // if (response.data.message === "company not found") {
49
- // //TODO need fix
50
- // return response.data;
51
- // }
52
- // } else if (response.status === 401) {
53
- // //TODO need fix
54
- // return response.data;
55
- // // window.location.replace(rootPath.signIn);
56
- // }
57
- // return {
58
- // ...response.data,
59
- // data: init
60
- // };
61
- // }
62
- //
63
- // fetchError(error: AxiosError, initMessage = null): IAnswer {
64
- //
65
- //
66
- // // console.log("error : ", error);
67
- //
68
- // const message = error.message === "Network Error" ? "Please check your internet connection!" : error.message;
69
- //
70
- //
71
- // return {
72
- // success: false,
73
- // data: null,
74
- // exception: initMessage ? initMessage : message,
75
- // message: initMessage ? initMessage : message
76
- // };
77
- // }
78
- //
79
- // async postWithAuth(url: string, body: any = {}, header: any = {}): Promise<IAnswer> {
80
- // // console.log("POST");
81
- // const ax: any = await this.createInstance(header, true);
82
- //
83
- // return ax.post(url, body).then(this.fetchSuccess).catch(this.fetchError);
84
- //
85
- // }
86
- //
87
- // async putWithAuth(url: string, body: any, header: any = {}): Promise<IAnswer> {
88
- // // console.log("PUT");
89
- // const ax: any = await this.createInstance(header, true, 8000);
90
- // return ax.put(url, body).then(this.fetchSuccess).catch(this.fetchError);
91
- // }
92
- //
93
- // async getWithAuth(url: string, header: any = {}): Promise<IAnswer> {
94
- // // console.log("GET");
95
- // const ax: AxiosInstance = await this.createInstance(header, true);
96
- // return ax.get(url).then(this.fetchSuccess).catch(this.fetchError);
97
- //
98
- // }
99
- //
100
- // async get(url: string, header: any = {}): Promise<IAnswer> {
101
- // // console.log("GET");
102
- // const ax: any = await this.createInstance(header, false);
103
- // return ax.get(url).then(this.fetchSuccess).catch(this.fetchError);
104
- // }
105
- //
106
- // async deleteWithAuth(url: string, header: any = {}): Promise<IAnswer> {
107
- // // console.log("DELETE");
108
- // const ax: any = await this.createInstance(header, true);
109
- // return ax.delete(url).then(this.fetchSuccess).catch(this.fetchError);
110
- // }
111
- //
112
- // private getCompanyId = (): string => {
113
- //
114
- // const account: any = {...this.account};
115
- //
116
- // if (account.companyId)
117
- // return account.companyId + "";
118
- //
119
- // return account.company.id + "";
120
- // }
121
- //
122
- // }
123
10
  export default class ApiController {
124
11
  constructor(account) {
125
12
  this.account = account;
@@ -161,30 +48,31 @@ export default class ApiController {
161
48
  clearTimeout(timeoutId);
162
49
  const data = yield response.json();
163
50
  if (response.ok) {
164
- return this.fetchSuccess(data);
51
+ return this.fetchSuccess(data, response.status);
165
52
  }
166
53
  else {
167
- return this.fetchError(data, response.statusText);
54
+ return this.fetchError(data, response.statusText, response.status);
168
55
  }
169
56
  }
170
57
  catch (error) {
171
58
  clearTimeout(timeoutId);
172
- return this.fetchError(error, "Network Error");
59
+ return this.fetchError(error, "Network Error", -1);
173
60
  }
174
61
  });
175
62
  }
176
- fetchSuccess(response) {
63
+ fetchSuccess(response, status) {
177
64
  if (response.success) {
178
- return response;
65
+ return Object.assign(Object.assign({}, response), { status });
179
66
  }
180
- return Object.assign(Object.assign({}, response), { data: null });
67
+ return Object.assign(Object.assign({}, response), { data: null, status });
181
68
  }
182
- fetchError(error, message = "Unknown Error") {
69
+ fetchError(error, message = "Unknown Error", status) {
183
70
  return {
184
71
  success: false,
185
72
  data: null,
186
73
  exception: (error === null || error === void 0 ? void 0 : error.message) || message,
187
- message: (error === null || error === void 0 ? void 0 : error.message) || message
74
+ message: (error === null || error === void 0 ? void 0 : error.message) || message,
75
+ status
188
76
  };
189
77
  }
190
78
  }
@@ -4,7 +4,7 @@ import IKitchenOrderDetail from "../interfaces/kds/IKitchenOrderDetail";
4
4
  import IKitchenTimes from "../interfaces/kds/IKitchenTimes";
5
5
  import IKitchenZone from "../interfaces/kds/IKitchenZone";
6
6
  import IKitchenOrderDetailItems from "../interfaces/kds/IKitchenOrderDetailItems";
7
- declare const _default: {
7
+ declare class _KitchenController {
8
8
  mergeOrders(list: IKitchenOrderDetail[], list2: IKitchenOrderDetail[]): IKitchenOrderDetail[];
9
9
  atLeastOneItemToShowInKitchen(list: IKitchenOrderDetailItems[]): boolean;
10
10
  filterOrderDetailReducer(orders: IKitchenOrderDetail[], setting: IKitchenScreenSetting): IKitchenOrderDetail[];
@@ -21,5 +21,6 @@ declare const _default: {
21
21
  calculateTotalPage(listLength: number, pageSize: number): number;
22
22
  getOrderTypeColor(orderType: EnumOrderType, setting: IKitchenScreenSetting): string;
23
23
  getOrderTypeLabel(orderType: EnumOrderType, orderTypeText: string): string;
24
- };
25
- export default _default;
24
+ }
25
+ declare const KitchenController: _KitchenController;
26
+ export default KitchenController;
@@ -2,9 +2,7 @@ import EnumOrderType from "../enums/EnumOrderType";
2
2
  import EnumKitchenScreenSortOrders from "../enums/EnumKitchenScreenSortOrders";
3
3
  import { initKitchenOrderDetail } from "../interfaces/kds/IKitchenOrderDetail";
4
4
  import ZoneController from "./ZoneController";
5
- export default new class KitchenController {
6
- // distinctOrders(list : IKitchenOrderDetail[]) {
7
- // }
5
+ class _KitchenController {
8
6
  mergeOrders(list, list2) {
9
7
  // let IdList = list2.map(i => i.id).filter((value, index, arr) => arr.indexOf(value) === index);
10
8
  // let new_list: IKitchenOrderDetail[] = [...list2, ...list.filter(i => !IdList.includes(i.id))];
@@ -132,10 +130,6 @@ export default new class KitchenController {
132
130
  let tik = this.dateToSecond(desiredDateTime) - this.dateToSecond(currentDateTime);
133
131
  return tik - ((kitchenTime + travelTime + 5) * 60) > 0; //5 min teloranse
134
132
  }
135
- // isAddvanceOrder(detail: IKitchenOrderDetail) {
136
- // let current = dayjs().format("YYYY-MM-DDTHH:mm:ss")
137
- // return detail.orderPreparationStartTime > current;
138
- // }
139
133
  sortOrders(orders, setting) {
140
134
  if (setting.sortAscending) {
141
135
  switch (setting.sortOrders) {
@@ -219,4 +213,6 @@ export default new class KitchenController {
219
213
  return "";
220
214
  }
221
215
  }
222
- }();
216
+ }
217
+ const KitchenController = new _KitchenController();
218
+ export default KitchenController;
@@ -3,6 +3,7 @@ interface IAnswer {
3
3
  exception: string | null;
4
4
  message: string;
5
5
  success: boolean;
6
+ status?: number;
6
7
  }
7
8
  export declare const initAnswer: IAnswer;
8
9
  export declare const initArrayAnswer: IAnswer;
@@ -2,6 +2,7 @@ export const initAnswer = {
2
2
  data: null,
3
3
  message: "",
4
4
  success: false,
5
- exception: null
5
+ exception: null,
6
+ status: 200,
6
7
  };
7
8
  export const initArrayAnswer = Object.assign(Object.assign({}, initAnswer), { data: [] });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "meemup-library",
3
- "version": "1.5.78",
3
+ "version": "1.5.80",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -11,7 +11,7 @@
11
11
  "remove:one": "rimraf dist",
12
12
  "remove:two": "rimraf ./src/dist",
13
13
  "test": "echo \"Error: no test specified\" && exit 1",
14
- "commit": "git add . && git commit -m \"version.1.5.78\" && git push origin "
14
+ "commit": "git add . && git commit -m \"version.1.5.80\" && git push origin "
15
15
  },
16
16
  "files": [
17
17
  "/dist"
@@ -26,4 +26,4 @@
26
26
  "dependencies": {
27
27
  "dayjs": "^1.11.13"
28
28
  }
29
- }
29
+ }