@longvansoftware/storefront-js-client 1.4.2 → 1.4.4

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.
@@ -138,6 +138,10 @@ exports.GET_PRODUCT_BY_ID_QUERY = (0, graphql_tag_1.gql) `
138
138
  id
139
139
  name
140
140
  values
141
+ valuesFull {
142
+ id
143
+ name
144
+ }
141
145
  }
142
146
  categories {
143
147
  id
@@ -258,6 +262,7 @@ exports.GET_SIMPLE_PRODUCTS_QUERY = (0, graphql_tag_1.gql) `
258
262
  sku
259
263
  shortDescription
260
264
  vat
265
+ subType
261
266
  qualify
262
267
  handle
263
268
  price
@@ -398,7 +403,11 @@ exports.GET_PRODUCT_OPTION = (0, graphql_tag_1.gql) `
398
403
  $storeChannel: String!
399
404
  $productId: String!
400
405
  ) {
401
- getProductOption(partnerId: $partnerId, storeChannel: $storeChannel, productId: $productId) {
406
+ getProductOption(
407
+ partnerId: $partnerId
408
+ storeChannel: $storeChannel
409
+ productId: $productId
410
+ ) {
402
411
  id
403
412
  name
404
413
  subType
@@ -414,11 +423,9 @@ exports.GET_PRODUCT_OPTION = (0, graphql_tag_1.gql) `
414
423
  }
415
424
  `;
416
425
  exports.GET_POLICY = (0, graphql_tag_1.gql) `
417
- query GetPolicy(
418
- $groupId: String!
419
- ) {
426
+ query GetPolicy($groupId: String!) {
420
427
  getPolicy(groupId: $groupId) {
421
428
  value
422
429
  }
423
- }
430
+ }
424
431
  `;
@@ -7,3 +7,4 @@ export declare const UPDATE_FAIL_ACTION_PROCESS_STATUS: import("graphql").Docume
7
7
  export declare const CREATE_SERVICE_TICKET: import("graphql").DocumentNode;
8
8
  export declare const CREATE_SERVICE_ACTION: import("graphql").DocumentNode;
9
9
  export declare const UPDATE_ATTR_VALUE: import("graphql").DocumentNode;
10
+ export declare const ADD_ACTION_ATTRIBUTE: import("graphql").DocumentNode;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UPDATE_ATTR_VALUE = exports.CREATE_SERVICE_ACTION = exports.CREATE_SERVICE_TICKET = exports.UPDATE_FAIL_ACTION_PROCESS_STATUS = exports.UPDATE_SUCCESS_ACTION_PROCESS_STATUS = exports.DELETE_ATTR_VALUE = exports.DELETE_SERVICE = exports.UPDATE_SERVICE = exports.CREATE_SERVICE = void 0;
3
+ exports.ADD_ACTION_ATTRIBUTE = exports.UPDATE_ATTR_VALUE = exports.CREATE_SERVICE_ACTION = exports.CREATE_SERVICE_TICKET = exports.UPDATE_FAIL_ACTION_PROCESS_STATUS = exports.UPDATE_SUCCESS_ACTION_PROCESS_STATUS = exports.DELETE_ATTR_VALUE = exports.DELETE_SERVICE = exports.UPDATE_SERVICE = exports.CREATE_SERVICE = void 0;
4
4
  const graphql_tag_1 = require("graphql-tag");
5
5
  exports.CREATE_SERVICE = (0, graphql_tag_1.gql) `
6
6
  mutation CreateService($partnerId: String!, $createModel: ServiceRequest!) {
@@ -267,3 +267,18 @@ exports.UPDATE_ATTR_VALUE = (0, graphql_tag_1.gql) `
267
267
  )
268
268
  }
269
269
  `;
270
+ exports.ADD_ACTION_ATTRIBUTE = (0, graphql_tag_1.gql) `
271
+ mutation AddActionAttribute(
272
+ $actionId: String!
273
+ $attributeName: String!
274
+ $attributeValue: String!
275
+ $createdBy: String!
276
+ ) {
277
+ addActionAttribute(
278
+ actionId: $actionId
279
+ attributeName: $attributeName
280
+ attributeValue: $attributeValue
281
+ createdBy: $createdBy
282
+ )
283
+ }
284
+ `;
@@ -3,3 +3,4 @@ export declare const GET_SERVICE_BY_TYPE: import("graphql").DocumentNode;
3
3
  export declare const GET_SERVICE_BY_OWNER_ID: import("graphql").DocumentNode;
4
4
  export declare const GET_SERVICE_ACTION: import("graphql").DocumentNode;
5
5
  export declare const GET_SERVICE_TICKETS: import("graphql").DocumentNode;
6
+ export declare const GET_ACTION_ATTRIBUTE: import("graphql").DocumentNode;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GET_SERVICE_TICKETS = exports.GET_SERVICE_ACTION = exports.GET_SERVICE_BY_OWNER_ID = exports.GET_SERVICE_BY_TYPE = exports.GET_SERVICE_BY_ID = void 0;
3
+ exports.GET_ACTION_ATTRIBUTE = exports.GET_SERVICE_TICKETS = exports.GET_SERVICE_ACTION = exports.GET_SERVICE_BY_OWNER_ID = exports.GET_SERVICE_BY_TYPE = exports.GET_SERVICE_BY_ID = void 0;
4
4
  const graphql_tag_1 = require("graphql-tag");
5
5
  exports.GET_SERVICE_BY_ID = (0, graphql_tag_1.gql) `
6
6
  query GetServiceById($partnerId: String!, $serviceId: String!) {
@@ -167,3 +167,8 @@ exports.GET_SERVICE_TICKETS = (0, graphql_tag_1.gql) `
167
167
  }
168
168
  }
169
169
  `;
170
+ exports.GET_ACTION_ATTRIBUTE = (0, graphql_tag_1.gql) `
171
+ query GetActionAttribute($actionId: String!, $attributeName: String!) {
172
+ getActionAttribute(actionId: $actionId, attributeName: $attributeName)
173
+ }
174
+ `;
@@ -1,3 +1,13 @@
1
1
  export declare const GET_PERSON_BY_IDS_QUERY: import("graphql").DocumentNode;
2
- export declare const GET_CUSTOMER_BY_ID: import("graphql").DocumentNode;
3
2
  export declare const SEARCH_COMPANY: import("graphql").DocumentNode;
3
+ export declare const GET_CUSTOMER_BY_ID: import("graphql").DocumentNode;
4
+ export declare const SEARCH_CUSTOMER: import("graphql").DocumentNode;
5
+ export declare const SEARCH_EMPLOYEES: import("graphql").DocumentNode;
6
+ export declare const GET_POSTIONS_BY_EMPLOYEES_ID: import("graphql").DocumentNode;
7
+ export declare const GET_STORE_CHANEL_IDS_BY_EMPLOYESS_ID: import("graphql").DocumentNode;
8
+ export declare const GET_EMPLOYEES_BY_STORE_CHANEL_ID: import("graphql").DocumentNode;
9
+ export declare const GET_COMPANY_BY_CONTACT_INFO_ID: import("graphql").DocumentNode;
10
+ export declare const GET_CONTACT_INFOS_BY_COMPANY_ID: import("graphql").DocumentNode;
11
+ export declare const GET_PROVINCES: import("graphql").DocumentNode;
12
+ export declare const GET_DISTRICTS: import("graphql").DocumentNode;
13
+ export declare const GET_WARDS: import("graphql").DocumentNode;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SEARCH_COMPANY = exports.GET_CUSTOMER_BY_ID = exports.GET_PERSON_BY_IDS_QUERY = void 0;
3
+ exports.GET_WARDS = exports.GET_DISTRICTS = exports.GET_PROVINCES = exports.GET_CONTACT_INFOS_BY_COMPANY_ID = exports.GET_COMPANY_BY_CONTACT_INFO_ID = exports.GET_EMPLOYEES_BY_STORE_CHANEL_ID = exports.GET_STORE_CHANEL_IDS_BY_EMPLOYESS_ID = exports.GET_POSTIONS_BY_EMPLOYEES_ID = exports.SEARCH_EMPLOYEES = exports.SEARCH_CUSTOMER = exports.GET_CUSTOMER_BY_ID = exports.SEARCH_COMPANY = exports.GET_PERSON_BY_IDS_QUERY = void 0;
4
4
  const graphql_tag_1 = require("graphql-tag");
5
5
  exports.GET_PERSON_BY_IDS_QUERY = (0, graphql_tag_1.gql) `
6
6
  query GetPersonByIds($partyIds: [String!]!) {
@@ -31,37 +31,222 @@ exports.GET_PERSON_BY_IDS_QUERY = (0, graphql_tag_1.gql) `
31
31
  }
32
32
  }
33
33
  `;
34
+ exports.SEARCH_COMPANY = (0, graphql_tag_1.gql) `
35
+ query SearchCompany($keyword: String, $orgId: String!, $limit: Int) {
36
+ searchCompany(keyword: $keyword, orgId: $orgId, limit: $limit) {
37
+ id
38
+ name
39
+ address
40
+ gender
41
+ identityNumber
42
+ birthDate
43
+ email
44
+ phone
45
+ createdStamp
46
+ createdBy
47
+ memberLevel
48
+ }
49
+ }
50
+ `;
34
51
  exports.GET_CUSTOMER_BY_ID = (0, graphql_tag_1.gql) `
35
- query GetCustomerById($id: String!){
36
- getCustomerById(id: $id) {
37
- id
38
- name
39
- address
40
- gender
41
- identityNumber
42
- birthDate
43
- email
44
- phone
45
- createdStamp
46
- createdBy
47
- memberLevel
52
+ query GetCustomerById($id: String!) {
53
+ getCustomerById(id: $id) {
54
+ id
55
+ name
56
+ address
57
+ gender
58
+ identityNumber
59
+ birthDate
60
+ email
61
+ phone
62
+ createdStamp
63
+ createdBy
64
+ memberLevel
65
+ }
48
66
  }
49
- }
50
67
  `;
51
- exports.SEARCH_COMPANY = (0, graphql_tag_1.gql) `
52
- query SearchCompany($keyword: String, $orgId: String!, $limit: Int){
53
- searchCompany(keyword: $keyword, orgId: $orgId, limit: $limit) {
54
- id
55
- name
56
- address
57
- gender
58
- identityNumber
59
- birthDate
60
- email
61
- phone
62
- createdStamp
63
- createdBy
64
- memberLevel
68
+ exports.SEARCH_CUSTOMER = (0, graphql_tag_1.gql) `
69
+ query SearchCustomers(
70
+ $keyword: String
71
+ $type: String
72
+ $startCreatedDate: DateCustom
73
+ $endCreatedDate: DateCustom
74
+ $memberLevel: String
75
+ $partnerId: String!
76
+ $currentPage: Int!
77
+ $pageSize: Int!
78
+ ) {
79
+ searchCustomers(
80
+ keyword: $keyword
81
+ type: $type
82
+ startCreatedDate: $startCreatedDate
83
+ endCreatedDate: $endCreatedDate
84
+ memberLevel: $memberLevel
85
+ partnerId: $partnerId
86
+ currentPage: $currentPage
87
+ pageSize: $pageSize
88
+ ) {
89
+ totalPages
90
+ totalElements
91
+ currentPage
92
+ content {
93
+ id
94
+ name
95
+ address
96
+ gender
97
+ identityNumber
98
+ birthDate
99
+ email
100
+ phone
101
+ createdStamp
102
+ createdBy
103
+ memberLevel
104
+ }
105
+ }
106
+ }
107
+ `;
108
+ exports.SEARCH_EMPLOYEES = (0, graphql_tag_1.gql) `
109
+ query SearchEmployees($keyword: String, $positionShortName: String, $partnerId: String) {
110
+ searchEmployees(
111
+ keyword: $keyword
112
+ positionShortName: $positionShortName
113
+ partnerId: $partnerId
114
+ ) {
115
+ id
116
+ name
117
+ address
118
+ gender
119
+ identityNumber
120
+ birthDate
121
+ email
122
+ phone
123
+ createdStamp
124
+ createdBy
125
+ memberLevel
126
+ }
127
+ }
128
+ `;
129
+ exports.GET_POSTIONS_BY_EMPLOYEES_ID = (0, graphql_tag_1.gql) `
130
+ query GetPositionsByEmployeeId($employeeId: String!, $partnerId: String!) {
131
+ getPositionsByEmployeeId(employeeId: $employeeId, partnerId: $partnerId)
132
+ }
133
+ `;
134
+ exports.GET_STORE_CHANEL_IDS_BY_EMPLOYESS_ID = (0, graphql_tag_1.gql) `
135
+ query GetStoreChannelIdsByEmployeeId($employeeId: String!, $partnerId: String!) {
136
+ getStoreChannelIdsByEmployeeId(employeeId: $employeeId, partnerId: $partnerId)
137
+ }
138
+ `;
139
+ exports.GET_EMPLOYEES_BY_STORE_CHANEL_ID = (0, graphql_tag_1.gql) `
140
+ query GetEmployeesByStoreChannelId($storeChannelId: String!, $partnerId: String!) {
141
+ getEmployeesByStoreChannelId(storeChannelId: $storeChannelId, partnerId: $partnerId) {
142
+ id
143
+ name
144
+ address
145
+ gender
146
+ identityNumber
147
+ birthDate
148
+ email
149
+ phone
150
+ createdStamp
151
+ createdBy
152
+ memberLevel
153
+ }
154
+ }
155
+ `;
156
+ exports.GET_COMPANY_BY_CONTACT_INFO_ID = (0, graphql_tag_1.gql) `
157
+ query GetCompanyByContactInfoId($contactId: String!, $partnerId: String!) {
158
+ getCompanyByContactInfoId(contactId: $contactId, partnerId: $partnerId) {
159
+ id
160
+ name
161
+ address
162
+ gender
163
+ identityNumber
164
+ birthDate
165
+ email
166
+ phone
167
+ createdStamp
168
+ createdBy
169
+ memberLevel
170
+ }
171
+ }
172
+ `;
173
+ exports.GET_CONTACT_INFOS_BY_COMPANY_ID = (0, graphql_tag_1.gql) `
174
+ query GetContactInfosByCompanyId($companyId: String!, $partnerId: String!) {
175
+ getContactInfosByCompanyId(companyId: $companyId, partnerId: $partnerId) {
176
+ id
177
+ name
178
+ address
179
+ gender
180
+ identityNumber
181
+ birthDate
182
+ email
183
+ phone
184
+ createdStamp
185
+ createdBy
186
+ memberLevel
187
+ }
188
+ }
189
+ `;
190
+ exports.GET_PROVINCES = (0, graphql_tag_1.gql) `
191
+ query GetProvinces {
192
+ getProvinces {
193
+ geoId
194
+ geoTypeId
195
+ geoName
196
+ geoNameLocal
197
+ geoCode
198
+ geoSecCode
199
+ abbreviation
200
+ vnPostId
201
+ jtExpressId
202
+ vnPostRegion
203
+ inetId
204
+ lastUpdatedStamp
205
+ lastUpdatedTxStamp
206
+ createdStamp
207
+ createdTxStamp
208
+ }
209
+ }
210
+ `;
211
+ exports.GET_DISTRICTS = (0, graphql_tag_1.gql) `
212
+ query GetDistricts($provinceId: String!) {
213
+ getDistricts(provinceId: $provinceId) {
214
+ geoId
215
+ geoTypeId
216
+ geoName
217
+ geoNameLocal
218
+ geoCode
219
+ geoSecCode
220
+ abbreviation
221
+ vnPostId
222
+ jtExpressId
223
+ vnPostRegion
224
+ inetId
225
+ lastUpdatedStamp
226
+ lastUpdatedTxStamp
227
+ createdStamp
228
+ createdTxStamp
229
+ }
230
+ }
231
+ `;
232
+ exports.GET_WARDS = (0, graphql_tag_1.gql) `
233
+ query GetWards($districtId: String!) {
234
+ getWards(districtId: $districtId) {
235
+ geoId
236
+ geoTypeId
237
+ geoName
238
+ geoNameLocal
239
+ geoCode
240
+ geoSecCode
241
+ abbreviation
242
+ vnPostId
243
+ jtExpressId
244
+ vnPostRegion
245
+ inetId
246
+ lastUpdatedStamp
247
+ lastUpdatedTxStamp
248
+ createdStamp
249
+ createdTxStamp
250
+ }
65
251
  }
66
- }
67
252
  `;
@@ -31,4 +31,5 @@ export declare class SDK {
31
31
  token: string | null;
32
32
  constructor(orgId: string, storeId: string, storefrontAccessToken: string);
33
33
  setToken(token: string): void;
34
+ setStoreId(storeId: string): void;
34
35
  }
@@ -43,5 +43,19 @@ class SDK {
43
43
  this.warehouse.setToken(token);
44
44
  // Set token for other services here
45
45
  }
46
+ // các module export từ serviceSDK.ts set storeId vào serviceSDK.ts
47
+ // src/service.ts
48
+ setStoreId(storeId) {
49
+ this.storeId = storeId;
50
+ this.product.setStoreId(storeId);
51
+ this.auth.setStoreId(storeId);
52
+ this.order.setStoreId(storeId);
53
+ this.user.setStoreId(storeId);
54
+ this.payment.setStoreId(storeId);
55
+ this.crm.setStoreId(storeId);
56
+ this.service.setStoreId(storeId);
57
+ this.warehouse.setStoreId(storeId);
58
+ // Set storeId for other services here
59
+ }
46
60
  }
47
61
  exports.SDK = SDK;
@@ -304,6 +304,7 @@ export declare class OrderService extends Service {
304
304
  * @throws If an error occurs while updating the customer and shipping address.
305
305
  */
306
306
  getListSellOrder(requestData: OrderQuery): Promise<any>;
307
+ getDiaries(requestData: OrderQuery): Promise<any>;
307
308
  /**
308
309
  * Get list sale order status
309
310
  * @returns A promise that resolves when the customer and shipping address are updated.
@@ -25,7 +25,6 @@ class OrderService extends serviceSDK_1.Service {
25
25
  super(endpoint, orgId, storeId);
26
26
  }
27
27
  setToken(token) {
28
- console.log("🚀 ~ OrderService ~ setToken ~ token:", token);
29
28
  this.token = token;
30
29
  }
31
30
  /**
@@ -784,6 +783,25 @@ class OrderService extends serviceSDK_1.Service {
784
783
  }
785
784
  });
786
785
  }
786
+ getDiaries(requestData) {
787
+ return __awaiter(this, void 0, void 0, function* () {
788
+ // Convert requestData to a format suitable for URLSearchParams
789
+ const params = new URLSearchParams(Object.entries(requestData).reduce((acc, [key, value]) => {
790
+ acc[key] = Array.isArray(value) ? value.join(",") : value.toString();
791
+ return acc;
792
+ }, {})).toString();
793
+ const endpoint = `/orders/${this.orgId}/${this.storeId}/diaries?${params}`;
794
+ const method = "GET";
795
+ try {
796
+ const response = yield this.restApiCallWithToken(endpoint, method);
797
+ return response;
798
+ }
799
+ catch (error) {
800
+ console.error(`Error in getListSellOrder: ${error}`);
801
+ throw error;
802
+ }
803
+ });
804
+ }
787
805
  /**
788
806
  * Get list sale order status
789
807
  * @returns A promise that resolves when the customer and shipping address are updated.
@@ -1163,20 +1181,3 @@ class OrderService extends serviceSDK_1.Service {
1163
1181
  }
1164
1182
  }
1165
1183
  exports.OrderService = OrderService;
1166
- const data = {
1167
- orderType: "POS_SALE",
1168
- customer_id: "20.51269",
1169
- line_items: [
1170
- {
1171
- id: "121122",
1172
- productName: "",
1173
- quantity: 1,
1174
- typeDiscount: "MONEY",
1175
- parent_id: "121121",
1176
- product_id: "121122",
1177
- supplier_id: "",
1178
- input_price: 220000,
1179
- discount_amount: 0,
1180
- },
1181
- ],
1182
- };
@@ -89,4 +89,6 @@ export declare class ServiceManagementService extends Service {
89
89
  createServiceTicket(serviceId: string, name: string, createdBy: string, description: string): Promise<any>;
90
90
  getServiceTicket(serviceId: string): Promise<any>;
91
91
  createServiceAction(serviceId: string, actionType: string, createdBy: string): Promise<any>;
92
+ addActionAttribute(actionId: string, attributeName: string, attributeValue: string, createdBy: string): Promise<any>;
93
+ getActionAttribute(actionId: string, attributeName: string): Promise<any>;
92
94
  }
@@ -310,5 +310,39 @@ class ServiceManagementService extends serviceSDK_1.Service {
310
310
  }
311
311
  });
312
312
  }
313
+ addActionAttribute(actionId, attributeName, attributeValue, createdBy) {
314
+ return __awaiter(this, void 0, void 0, function* () {
315
+ const mutation = mutations_1.ADD_ACTION_ATTRIBUTE;
316
+ const variables = {
317
+ actionId,
318
+ attributeName,
319
+ attributeValue,
320
+ createdBy,
321
+ };
322
+ try {
323
+ const response = yield this.graphqlMutation(mutation, variables);
324
+ return response.addActionAttribute;
325
+ }
326
+ catch (error) {
327
+ throw error;
328
+ }
329
+ });
330
+ }
331
+ getActionAttribute(actionId, attributeName) {
332
+ return __awaiter(this, void 0, void 0, function* () {
333
+ const query = queries_1.GET_ACTION_ATTRIBUTE;
334
+ const variables = {
335
+ actionId,
336
+ attributeName,
337
+ };
338
+ try {
339
+ const response = yield this.graphqlQuery(query, variables);
340
+ return response.getActionAttribute;
341
+ }
342
+ catch (error) {
343
+ throw error;
344
+ }
345
+ });
346
+ }
313
347
  }
314
348
  exports.ServiceManagementService = ServiceManagementService;
@@ -8,6 +8,7 @@ export declare class Service {
8
8
  protected endpoint: string;
9
9
  constructor(endpoint: string, orgId: string, storeId: string);
10
10
  setToken(token: string): void;
11
+ setStoreId(storeId: string): void;
11
12
  protected graphqlQuery(query: DocumentNode, variables: any): Promise<any>;
12
13
  protected graphqlMutation(mutation: DocumentNode, variables: any): Promise<any>;
13
14
  protected restApiCallWithToken(path: string, method: "GET" | "POST" | "PUT" | "DELETE", data?: any, headers?: any): Promise<any>;
@@ -16,11 +16,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.Service = void 0;
17
17
  const client_1 = require("@apollo/client");
18
18
  const axios_1 = __importDefault(require("axios"));
19
+ const cross_fetch_1 = __importDefault(require("cross-fetch"));
19
20
  class Service {
20
21
  constructor(endpoint, orgId, storeId) {
21
22
  this.token = null;
22
23
  this.client = new client_1.ApolloClient({
23
- uri: endpoint,
24
+ link: new client_1.HttpLink({ uri: endpoint, fetch: cross_fetch_1.default }),
25
+ // uri: endpoint,
24
26
  cache: new client_1.InMemoryCache(),
25
27
  defaultOptions: {
26
28
  query: {
@@ -35,6 +37,9 @@ class Service {
35
37
  setToken(token) {
36
38
  this.token = token;
37
39
  }
40
+ setStoreId(storeId) {
41
+ this.storeId = storeId;
42
+ }
38
43
  graphqlQuery(query, variables) {
39
44
  return __awaiter(this, void 0, void 0, function* () {
40
45
  try {
@@ -94,7 +99,8 @@ class Service {
94
99
  restApiCallWithNoToken(path, method, data, headers) {
95
100
  return __awaiter(this, void 0, void 0, function* () {
96
101
  try {
97
- const modifiedHeaders = Object.assign(Object.assign({}, headers), { PartnerId: this.orgId });
102
+ const modifiedHeaders = Object.assign(Object.assign({}, headers), { Partnerid: this.orgId });
103
+ console.log("🚀 ~ Service ~ modifiedHeaders:", modifiedHeaders);
98
104
  const response = yield (0, axios_1.default)({
99
105
  url: this.endpoint + path,
100
106
  method,
@@ -104,9 +110,6 @@ class Service {
104
110
  return response.data;
105
111
  }
106
112
  catch (error) {
107
- if (error.response.status === 401) {
108
- throw new Error("Không có quyền truy cập!");
109
- }
110
113
  console.log(`Error in restApiCallWithNoToken: ${error}`);
111
114
  throw error;
112
115
  }
@@ -1,5 +1,5 @@
1
1
  import { Service } from "../serviceSDK";
2
- import { createCompanyRequest, createCustomerRequest, dataCustomerRequest, updateCustomerRequest } from "../../types/user";
2
+ import { createCompanyRequest, createCustomerRequest, dataCustomerRequest, updateCustomerRequest, customerQuery, searchCustomersResponse, employeesQuery } from "../../types/user";
3
3
  export declare class UserService extends Service {
4
4
  constructor(endpoint: string, orgId: string, storeId: string);
5
5
  getPersonByPartyIds(partyIds: string[]): Promise<any>;
@@ -10,4 +10,14 @@ export declare class UserService extends Service {
10
10
  searchCompany(keyword: string, limit: number): Promise<any>;
11
11
  createCustomerV2(createCustomerRequest: createCustomerRequest, createdBy: string): Promise<any>;
12
12
  createCustomer(dataCustomerRequest: dataCustomerRequest, createdBy: string, type: string): Promise<any>;
13
+ searchCustomer(searchParams: customerQuery): Promise<searchCustomersResponse>;
14
+ searchEmployees(searchParams: employeesQuery): Promise<any>;
15
+ getPositionsByEmployeeId(employeeId: string): Promise<any>;
16
+ getStoreChannelIdsByEmployeeId(employeeId: string): Promise<any>;
17
+ getEmployeesByStoreChannelId(): Promise<any>;
18
+ getCompanyByContactInfoId(contactId: string): Promise<any>;
19
+ getContactInfosByCompanyId(companyId: string): Promise<any>;
20
+ getProvinces(): Promise<any>;
21
+ getDistricts(provinceId: string): Promise<any>;
22
+ getWards(districtId: string): Promise<any>;
13
23
  }
@@ -169,5 +169,177 @@ class UserService extends serviceSDK_1.Service {
169
169
  }
170
170
  });
171
171
  }
172
+ searchCustomer(searchParams) {
173
+ return __awaiter(this, void 0, void 0, function* () {
174
+ const query = queries_1.SEARCH_CUSTOMER;
175
+ const variables = {
176
+ keyword: searchParams.keyword,
177
+ type: searchParams.type,
178
+ startCreatedDate: searchParams.startCreatedDate,
179
+ endCreatedDate: searchParams.endCreatedDate,
180
+ memberLevel: searchParams.memberLevel,
181
+ partnerId: this.orgId,
182
+ currentPage: searchParams.currentPage,
183
+ pageSize: searchParams.pageSize,
184
+ };
185
+ try {
186
+ const response = yield this.graphqlQuery(query, variables);
187
+ return response.searchCustomers;
188
+ }
189
+ catch (error) {
190
+ console.log(`Error in searchCustomer: ${error}`);
191
+ throw error;
192
+ }
193
+ });
194
+ }
195
+ searchEmployees(searchParams) {
196
+ return __awaiter(this, void 0, void 0, function* () {
197
+ const query = queries_1.SEARCH_EMPLOYEES;
198
+ const variables = {
199
+ keyword: searchParams.keyword,
200
+ partnerId: this.orgId,
201
+ positionShortName: searchParams.positionShortName,
202
+ };
203
+ try {
204
+ const response = yield this.graphqlQuery(query, variables);
205
+ return response.searchEmployees;
206
+ }
207
+ catch (error) {
208
+ console.log(`Error inseachEmployess: ${error}`);
209
+ throw error;
210
+ }
211
+ });
212
+ }
213
+ getPositionsByEmployeeId(employeeId) {
214
+ return __awaiter(this, void 0, void 0, function* () {
215
+ const query = queries_1.GET_POSTIONS_BY_EMPLOYEES_ID;
216
+ const variables = {
217
+ employeeId,
218
+ partnerId: this.orgId,
219
+ };
220
+ try {
221
+ const response = yield this.graphqlQuery(query, variables);
222
+ return response.getPositionsByEmployeeId;
223
+ }
224
+ catch (error) {
225
+ console.log(`Error in getPositionsByEmployeeId: ${error}`);
226
+ throw error;
227
+ }
228
+ });
229
+ }
230
+ getStoreChannelIdsByEmployeeId(employeeId) {
231
+ return __awaiter(this, void 0, void 0, function* () {
232
+ const query = queries_1.GET_STORE_CHANEL_IDS_BY_EMPLOYESS_ID;
233
+ const variables = {
234
+ employeeId,
235
+ partnerId: this.orgId,
236
+ };
237
+ try {
238
+ const response = yield this.graphqlQuery(query, variables);
239
+ return response.getStoreChannelIdsByEmployeeId;
240
+ }
241
+ catch (error) {
242
+ console.log(`Error in getStoreChannelIdsByEmployeeId: ${error}`);
243
+ throw error;
244
+ }
245
+ });
246
+ }
247
+ getEmployeesByStoreChannelId() {
248
+ return __awaiter(this, void 0, void 0, function* () {
249
+ const query = queries_1.GET_EMPLOYEES_BY_STORE_CHANEL_ID;
250
+ const variables = {
251
+ storeChannelId: this.storeId,
252
+ partnerId: this.orgId,
253
+ };
254
+ try {
255
+ const response = yield this.graphqlQuery(query, variables);
256
+ return response.getEmployeesByStoreChannelId;
257
+ }
258
+ catch (error) {
259
+ console.log(`Error in getEmployeesByStoreChannelId: ${error}`);
260
+ throw error;
261
+ }
262
+ });
263
+ }
264
+ getCompanyByContactInfoId(contactId) {
265
+ return __awaiter(this, void 0, void 0, function* () {
266
+ const query = queries_1.GET_COMPANY_BY_CONTACT_INFO_ID;
267
+ const variables = {
268
+ contactId,
269
+ partnerId: this.orgId,
270
+ };
271
+ try {
272
+ const response = yield this.graphqlQuery(query, variables);
273
+ return response.getCompanyByContactInfoId;
274
+ }
275
+ catch (error) {
276
+ console.log(`Error in getCompanyByContactInfoId: ${error}`);
277
+ throw error;
278
+ }
279
+ });
280
+ }
281
+ getContactInfosByCompanyId(companyId) {
282
+ return __awaiter(this, void 0, void 0, function* () {
283
+ const query = queries_1.GET_CONTACT_INFOS_BY_COMPANY_ID;
284
+ const variables = {
285
+ companyId,
286
+ partnerId: this.orgId,
287
+ };
288
+ try {
289
+ const response = yield this.graphqlQuery(query, variables);
290
+ return response.getContactInfosByCompanyId;
291
+ }
292
+ catch (error) {
293
+ console.log(`Error in getContactInfosByCompanyId: ${error}`);
294
+ throw error;
295
+ }
296
+ });
297
+ }
298
+ getProvinces() {
299
+ return __awaiter(this, void 0, void 0, function* () {
300
+ const query = queries_1.GET_PROVINCES;
301
+ const variables = {};
302
+ try {
303
+ const response = yield this.graphqlQuery(query, variables);
304
+ return response.getProvinces;
305
+ }
306
+ catch (error) {
307
+ console.log(`Error in getProvinces: ${error}`);
308
+ throw error;
309
+ }
310
+ });
311
+ }
312
+ getDistricts(provinceId) {
313
+ return __awaiter(this, void 0, void 0, function* () {
314
+ const query = queries_1.GET_DISTRICTS;
315
+ const variables = {
316
+ provinceId,
317
+ };
318
+ try {
319
+ const response = yield this.graphqlQuery(query, variables);
320
+ return response.getDistricts;
321
+ }
322
+ catch (error) {
323
+ console.log(`Error in getDistricts: ${error}`);
324
+ throw error;
325
+ }
326
+ });
327
+ }
328
+ getWards(districtId) {
329
+ return __awaiter(this, void 0, void 0, function* () {
330
+ const query = queries_1.GET_WARDS;
331
+ const variables = {
332
+ districtId,
333
+ };
334
+ try {
335
+ const response = yield this.graphqlQuery(query, variables);
336
+ return response.getWards;
337
+ }
338
+ catch (error) {
339
+ console.log(`Error in getWards: ${error}`);
340
+ throw error;
341
+ }
342
+ });
343
+ }
172
344
  }
173
345
  exports.UserService = UserService;
@@ -1,9 +1,9 @@
1
1
  export interface LineItem {
2
2
  quantity: number;
3
- parent_id: string;
3
+ parent_id?: string;
4
4
  product_id: string;
5
- input_price: number;
6
- discount_amount: number;
5
+ input_price?: number;
6
+ discount_amount?: number;
7
7
  }
8
8
  export interface DiscountCampaign {
9
9
  type_discount: string;
@@ -31,23 +31,24 @@ export interface CampaignPromotion {
31
31
  campaign_action_type: string;
32
32
  }
33
33
  export interface OrderQuery {
34
- order_id: string;
35
- status: [number];
36
- status_ignore: [number];
37
- sub_status: string;
38
- ffm_status: string;
39
- sub_type: string;
40
- payment_method: string;
41
- keyword: string;
42
- customer_multi_value: string;
43
- product_multi_value: string;
44
- customer_id: string;
45
- created_by: string;
46
- date_create_from: number;
47
- date_create_to: number;
48
- date_update_from: number;
49
- date_update_to: number;
50
- employee_assign: string;
51
- currentPage: number;
52
- maxResult: number;
34
+ order_id?: string;
35
+ status?: [number];
36
+ status_ignore?: [number];
37
+ sub_status?: string;
38
+ ffm_status?: string;
39
+ sub_type?: string;
40
+ payment_method?: string;
41
+ keyword?: string;
42
+ customer_multi_value?: string;
43
+ product_multi_value?: string;
44
+ customer_id?: string;
45
+ created_by?: string;
46
+ date_create_from?: number;
47
+ date_create_to?: number;
48
+ date_update_from?: number;
49
+ date_update_to?: number;
50
+ employee_assign?: string;
51
+ currentPage?: number;
52
+ maxResult?: number;
53
+ source?: string;
53
54
  }
@@ -6,6 +6,8 @@ export interface Product {
6
6
  price: number;
7
7
  available: boolean;
8
8
  categories: Category[];
9
+ featuredImage: string;
10
+ subType: string;
9
11
  }
10
12
  export interface Category {
11
13
  id: string;
@@ -25,4 +25,5 @@ export interface ServiceRequest {
25
25
  urlPublic: String;
26
26
  serviceType: Number;
27
27
  actionResult: String;
28
+ attrs: {};
28
29
  }
@@ -64,3 +64,32 @@ export interface dataCustomerRequest {
64
64
  address: string;
65
65
  birthDate: Date;
66
66
  }
67
+ export interface customerQuery {
68
+ keyword: string;
69
+ type: string;
70
+ startCreatedDate?: number;
71
+ endCreatedDate?: number;
72
+ memberLevel?: string;
73
+ currentPage?: number | 1;
74
+ pageSize: number | 20;
75
+ }
76
+ export interface employeesQuery {
77
+ keyword: string;
78
+ positionShortName: string;
79
+ }
80
+ export interface customer {
81
+ id: string;
82
+ name: string;
83
+ address: string;
84
+ gender: string;
85
+ identityNumber: string;
86
+ birthDate: Date;
87
+ email: string;
88
+ phone: string;
89
+ createdStamp: Date;
90
+ createdBy: string;
91
+ memberLevel: string;
92
+ }
93
+ export interface searchCustomersResponse {
94
+ content: customer[];
95
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longvansoftware/storefront-js-client",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "files": [
@@ -22,6 +22,7 @@
22
22
  "@apollo/client": "3.9.11",
23
23
  "apollo-boost": "^0.4.9",
24
24
  "axios": "^1.6.8",
25
+ "cross-fetch": "^4.0.0",
25
26
  "crypto-js": "^4.2.0",
26
27
  "graphql": "^15.8.0",
27
28
  "graphql-request": "^6.1.0",