woodsportal-client-sdk 1.1.4-dev.4 → 1.1.4-dev.40
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/CHANGELOG.md +4 -0
- package/README.md +48 -2
- package/dist/adapters/angular/index.d.ts +29 -0
- package/dist/adapters/angular/index.js +34 -0
- package/dist/adapters/angular/index.js.map +1 -0
- package/dist/adapters/react/index.d.ts +29 -0
- package/dist/adapters/react/index.js +18 -0
- package/dist/adapters/react/index.js.map +1 -0
- package/dist/adapters/vue/index.d.ts +29 -0
- package/dist/adapters/vue/index.js +25 -0
- package/dist/adapters/vue/index.js.map +1 -0
- package/dist/auth-utils-A4WPJMPK.js +4 -0
- package/dist/auth-utils-A4WPJMPK.js.map +1 -0
- package/dist/chunk-HRLJLCAZ.js +1118 -0
- package/dist/chunk-HRLJLCAZ.js.map +1 -0
- package/dist/chunk-NB7AINV4.js +35 -0
- package/dist/chunk-NB7AINV4.js.map +1 -0
- package/dist/chunk-ULV2IIW6.js +15 -0
- package/dist/chunk-ULV2IIW6.js.map +1 -0
- package/dist/chunk-Y5MRAAGK.js +10 -0
- package/dist/chunk-Y5MRAAGK.js.map +1 -0
- package/dist/chunk-YLZA5S7A.js +102 -0
- package/dist/chunk-YLZA5S7A.js.map +1 -0
- package/dist/index.d.ts +106 -2
- package/dist/index.js +368 -851
- package/dist/index.js.map +1 -1
- package/dist/use-sync-LbURBOs_.d.ts +29 -0
- package/package.json +44 -8
|
@@ -0,0 +1,1118 @@
|
|
|
1
|
+
import { getCookie } from './chunk-NB7AINV4.js';
|
|
2
|
+
import pako from 'pako';
|
|
3
|
+
import { Base64 } from 'js-base64';
|
|
4
|
+
|
|
5
|
+
function convertToBase64(obj) {
|
|
6
|
+
try {
|
|
7
|
+
if (!obj) return "";
|
|
8
|
+
const json = JSON.stringify(obj);
|
|
9
|
+
const compressed = pako.deflate(json);
|
|
10
|
+
const base64 = Base64.fromUint8Array(compressed, true);
|
|
11
|
+
return base64;
|
|
12
|
+
} catch (error) {
|
|
13
|
+
console.error("Failed to encode object:", error);
|
|
14
|
+
return "";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function decodeToBase64(encoded) {
|
|
18
|
+
try {
|
|
19
|
+
if (!encoded) return null;
|
|
20
|
+
const uint8Array = Base64.toUint8Array(encoded);
|
|
21
|
+
const decompressed = pako.inflate(uint8Array, { to: "string" });
|
|
22
|
+
return JSON.parse(decompressed);
|
|
23
|
+
} catch (error) {
|
|
24
|
+
console.error("Failed to decode object:", error);
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// src/breadcrumb/url-utils.ts
|
|
30
|
+
function mapKeysDeep(obj, keyMap2) {
|
|
31
|
+
if (Array.isArray(obj)) {
|
|
32
|
+
return obj.map((item) => mapKeysDeep(item, keyMap2));
|
|
33
|
+
} else if (obj !== null && typeof obj === "object") {
|
|
34
|
+
return Object.entries(obj).reduce((acc, [key, value]) => {
|
|
35
|
+
const mappedKey = keyMap2[key] || key;
|
|
36
|
+
acc[mappedKey] = mapKeysDeep(value, keyMap2);
|
|
37
|
+
return acc;
|
|
38
|
+
}, {});
|
|
39
|
+
}
|
|
40
|
+
return obj;
|
|
41
|
+
}
|
|
42
|
+
function isMessingParent(breadcrumbs) {
|
|
43
|
+
let lastItem = breadcrumbs[breadcrumbs.length - 1];
|
|
44
|
+
let lastItem2 = breadcrumbs[breadcrumbs.length - 2];
|
|
45
|
+
let lastItem3 = breadcrumbs[breadcrumbs.length - 3];
|
|
46
|
+
return lastItem?.o_r_id && (!lastItem2?.o_r_id && lastItem2?.o_t_id) && lastItem3?.o_r_id ? true : false;
|
|
47
|
+
}
|
|
48
|
+
function isMessingParentLastItem(breadcrumbs) {
|
|
49
|
+
let lastItem = breadcrumbs[breadcrumbs.length - 1];
|
|
50
|
+
let lastItem2 = breadcrumbs[breadcrumbs.length - 2];
|
|
51
|
+
return !lastItem?.o_t_id && (lastItem2?.o_r_id && lastItem2?.o_t_id) ? false : true;
|
|
52
|
+
}
|
|
53
|
+
function breadcrumbStage(breadcrumbItems) {
|
|
54
|
+
let breadcrumbType = "child";
|
|
55
|
+
if (breadcrumbItems.length === 1) {
|
|
56
|
+
breadcrumbType = "root";
|
|
57
|
+
} else if (breadcrumbItems.length === 2) {
|
|
58
|
+
breadcrumbType = "root_details";
|
|
59
|
+
}
|
|
60
|
+
return breadcrumbType;
|
|
61
|
+
}
|
|
62
|
+
var generateUrl = (props, breadcrumbs) => {
|
|
63
|
+
const newBase64 = convertToBase64(breadcrumbs);
|
|
64
|
+
let url = "";
|
|
65
|
+
if (props?.objectTypeId && props?.recordId) {
|
|
66
|
+
url = `/${props?.recordId}/${props?.objectTypeId}/${props?.recordId}?b=${newBase64}`;
|
|
67
|
+
} else {
|
|
68
|
+
url = `/association/${props?.objectTypeId}?b=${newBase64}`;
|
|
69
|
+
}
|
|
70
|
+
return url;
|
|
71
|
+
};
|
|
72
|
+
function getTotalParentLength(data) {
|
|
73
|
+
return data.filter(
|
|
74
|
+
(item) => (item.pt || item.o_t_id) && !item.o_r_id
|
|
75
|
+
).length;
|
|
76
|
+
}
|
|
77
|
+
var generatePath = (breadcrumbs, breadcrumb, index) => {
|
|
78
|
+
const bc = convertToBase64(breadcrumbs.slice(0, index + 1));
|
|
79
|
+
if (index === 0) {
|
|
80
|
+
return {
|
|
81
|
+
name: breadcrumb?.n,
|
|
82
|
+
path: `/${breadcrumb?.pt || breadcrumb?.o_t_id}?b=${bc}`
|
|
83
|
+
};
|
|
84
|
+
} else if (index === 1) {
|
|
85
|
+
if (breadcrumb?.isHome) {
|
|
86
|
+
return {
|
|
87
|
+
name: breadcrumb?.n,
|
|
88
|
+
path: `/association/${breadcrumb?.o_t_id}?b=${bc}`
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
name: breadcrumb?.n,
|
|
93
|
+
path: `/${breadcrumb?.o_r_id}/${breadcrumb?.o_t_id}/${breadcrumb?.o_r_id}?b=${bc}`
|
|
94
|
+
};
|
|
95
|
+
} else {
|
|
96
|
+
if (breadcrumb?.o_t_id && breadcrumb?.o_r_id && !breadcrumb?.isHome) {
|
|
97
|
+
return {
|
|
98
|
+
name: breadcrumb?.n,
|
|
99
|
+
path: `/${breadcrumb?.o_r_id}/${breadcrumb?.o_t_id}/${breadcrumb?.o_r_id}?b=${bc}`
|
|
100
|
+
};
|
|
101
|
+
} else {
|
|
102
|
+
return {
|
|
103
|
+
name: breadcrumb?.n,
|
|
104
|
+
path: `/association/${breadcrumb?.o_t_id}?b=${bc}`
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
// src/breadcrumb/key-map.ts
|
|
111
|
+
var keyMap = {
|
|
112
|
+
dp: "defPermissions",
|
|
113
|
+
n: "name",
|
|
114
|
+
sort: "sort",
|
|
115
|
+
o_t_id: "objectTypeId",
|
|
116
|
+
s: "search",
|
|
117
|
+
fPn: "filterPropertyName",
|
|
118
|
+
fO: "filterOperator",
|
|
119
|
+
fV: "filterValue",
|
|
120
|
+
c: "cache",
|
|
121
|
+
isPC: "isPrimaryCompany",
|
|
122
|
+
v: "view",
|
|
123
|
+
l: "limit",
|
|
124
|
+
pt: "path",
|
|
125
|
+
p: "page",
|
|
126
|
+
a: "after",
|
|
127
|
+
aPip: "activePipeline",
|
|
128
|
+
aT: "activeTab",
|
|
129
|
+
cT: "create",
|
|
130
|
+
dP: "display",
|
|
131
|
+
dL: "display_label",
|
|
132
|
+
pId: "pipeline_id"
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
// src/utils/param.ts
|
|
136
|
+
function getParam(paramName) {
|
|
137
|
+
if (typeof globalThis === "undefined" || !globalThis.location) return null;
|
|
138
|
+
const hash = globalThis.location.hash || "";
|
|
139
|
+
if (!hash.startsWith("#/")) return null;
|
|
140
|
+
const hashWithoutHash = hash.startsWith("#") ? hash.substring(1) : hash;
|
|
141
|
+
const queryString = hashWithoutHash.split("?")[1];
|
|
142
|
+
if (!queryString) return null;
|
|
143
|
+
const params = new URLSearchParams(queryString);
|
|
144
|
+
return params.get(paramName);
|
|
145
|
+
}
|
|
146
|
+
function getPath() {
|
|
147
|
+
if (typeof globalThis === "undefined" || !globalThis.location) return null;
|
|
148
|
+
const hash = globalThis.location.hash || "";
|
|
149
|
+
if (!hash.startsWith("#/")) return null;
|
|
150
|
+
return hash.slice(1).split("?")[0];
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// src/breadcrumb/param.ts
|
|
154
|
+
var getRouteMenu = (path) => {
|
|
155
|
+
const apiRoutes = globalThis?.apiRoutes || [];
|
|
156
|
+
return apiRoutes.find((menu) => menu?.path === path);
|
|
157
|
+
};
|
|
158
|
+
var getRouteDetails = () => {
|
|
159
|
+
const search = getParam("b");
|
|
160
|
+
const breadcrumbs = decodeToBase64(search) || [];
|
|
161
|
+
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
|
162
|
+
const mapped = lastItem ? mapKeysDeep(lastItem, keyMap) : null;
|
|
163
|
+
return { routeDetails: mapped };
|
|
164
|
+
};
|
|
165
|
+
var getParamDetails = (props, isDetailsPage = false) => {
|
|
166
|
+
const search = getParam("b");
|
|
167
|
+
let breadcrumbs = decodeToBase64(search) || [];
|
|
168
|
+
if (breadcrumbs.length > 0 && breadcrumbs?.[0]?.isHome) {
|
|
169
|
+
breadcrumbs = breadcrumbs.slice(1);
|
|
170
|
+
}
|
|
171
|
+
let mediatorObjectTypeId = "";
|
|
172
|
+
let mediatorObjectRecordId = "";
|
|
173
|
+
let parentObjectTypeId = "";
|
|
174
|
+
let parentObjectRecordId = "";
|
|
175
|
+
let lastItem = breadcrumbs[breadcrumbs.length - 1];
|
|
176
|
+
const lastItem2 = breadcrumbs[breadcrumbs.length - 2];
|
|
177
|
+
const lastItem3 = breadcrumbs[breadcrumbs.length - 3];
|
|
178
|
+
if (isDetailsPage === true && lastItem && "prm" in lastItem) {
|
|
179
|
+
delete lastItem.prm;
|
|
180
|
+
}
|
|
181
|
+
if (breadcrumbs.length > 1) {
|
|
182
|
+
if (props?.type === "ticket" || props?.type === "association") {
|
|
183
|
+
mediatorObjectTypeId = breadcrumbs[1]?.o_t_id || "";
|
|
184
|
+
mediatorObjectRecordId = breadcrumbs[1]?.o_r_id || "";
|
|
185
|
+
parentObjectTypeId = lastItem?.o_t_id || "";
|
|
186
|
+
parentObjectRecordId = lastItem?.o_r_id || "";
|
|
187
|
+
} else {
|
|
188
|
+
if (breadcrumbs.length > 2) {
|
|
189
|
+
mediatorObjectTypeId = breadcrumbs[1]?.o_t_id || "";
|
|
190
|
+
mediatorObjectRecordId = breadcrumbs[1]?.o_r_id || "";
|
|
191
|
+
}
|
|
192
|
+
if (!lastItem?.o_r_id && breadcrumbs.length > 2) {
|
|
193
|
+
parentObjectTypeId = lastItem2?.o_t_id || "";
|
|
194
|
+
parentObjectRecordId = lastItem2?.o_r_id || "";
|
|
195
|
+
}
|
|
196
|
+
if (lastItem?.o_r_id && breadcrumbs.length > 2) {
|
|
197
|
+
parentObjectTypeId = lastItem3?.o_t_id || "";
|
|
198
|
+
parentObjectRecordId = lastItem3?.o_r_id || "";
|
|
199
|
+
}
|
|
200
|
+
if (lastItem2?.o_t_id === "0-5" && !parentObjectTypeId && !parentObjectRecordId) {
|
|
201
|
+
parentObjectTypeId = lastItem2?.o_t_id || "";
|
|
202
|
+
parentObjectRecordId = lastItem2?.o_r_id || "";
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
let paramsObject = {};
|
|
207
|
+
if (breadcrumbs[0]?.prm?.isPC || breadcrumbs[1]?.prm?.isPC || lastItem?.prm?.isPC) {
|
|
208
|
+
paramsObject["isPrimaryCompany"] = true;
|
|
209
|
+
}
|
|
210
|
+
if (parentObjectTypeId && parentObjectRecordId) {
|
|
211
|
+
paramsObject["parentObjectTypeId"] = parentObjectTypeId;
|
|
212
|
+
paramsObject["parentObjectRecordId"] = parentObjectRecordId;
|
|
213
|
+
}
|
|
214
|
+
if (mediatorObjectTypeId && mediatorObjectRecordId) {
|
|
215
|
+
paramsObject["mediatorObjectTypeId"] = mediatorObjectTypeId;
|
|
216
|
+
paramsObject["mediatorObjectRecordId"] = mediatorObjectRecordId;
|
|
217
|
+
}
|
|
218
|
+
const mappedLastItemParam = Object.fromEntries(
|
|
219
|
+
Object.entries(lastItem?.prm || {}).map(([key, value]) => [
|
|
220
|
+
keyMap[key] || key,
|
|
221
|
+
// use mapped name if exists, else keep original
|
|
222
|
+
value
|
|
223
|
+
])
|
|
224
|
+
);
|
|
225
|
+
let queryString = null;
|
|
226
|
+
if (props?.type === "association") {
|
|
227
|
+
queryString = new URLSearchParams({ ...paramsObject, ...{ cache: false } }).toString();
|
|
228
|
+
} else {
|
|
229
|
+
queryString = new URLSearchParams({ ...paramsObject, ...mappedLastItemParam }).toString();
|
|
230
|
+
}
|
|
231
|
+
let params = queryString ? `?${queryString}` : "";
|
|
232
|
+
const totalParentLength = getTotalParentLength(breadcrumbs);
|
|
233
|
+
let parentAccessLabel = false;
|
|
234
|
+
if (breadcrumbs[0]?.prm?.isPC && totalParentLength > 2 || // company object
|
|
235
|
+
!breadcrumbs[0]?.prm?.isPC && totalParentLength > 3 || // normal object
|
|
236
|
+
breadcrumbs[0]?.prm?.isPC && totalParentLength > 1 && props?.type === "ticket" || // company ticket
|
|
237
|
+
!breadcrumbs[0]?.prm?.isPC && totalParentLength > 2 && props?.type === "ticket") {
|
|
238
|
+
parentAccessLabel = true;
|
|
239
|
+
}
|
|
240
|
+
return {
|
|
241
|
+
breadcrumbs,
|
|
242
|
+
// paramsObject: Object.keys(mParamsObject).length === 0 ? null : mParamsObject,
|
|
243
|
+
paramsObject,
|
|
244
|
+
params,
|
|
245
|
+
parentAccessLabel
|
|
246
|
+
};
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
// src/breadcrumb/url.ts
|
|
250
|
+
var useUpdateLink = () => {
|
|
251
|
+
const updateLink = async (props, displayName = "prm") => {
|
|
252
|
+
const search = getParam("b");
|
|
253
|
+
const pathname = getPath();
|
|
254
|
+
let breadcrumbs = decodeToBase64(search) || [];
|
|
255
|
+
if (breadcrumbs.length < 1) {
|
|
256
|
+
const routeMenu = getRouteMenu(pathname);
|
|
257
|
+
breadcrumbs = [
|
|
258
|
+
{
|
|
259
|
+
n: routeMenu?.title,
|
|
260
|
+
pt: routeMenu?.path
|
|
261
|
+
}
|
|
262
|
+
];
|
|
263
|
+
}
|
|
264
|
+
const lastBreadcrumb = breadcrumbs[breadcrumbs.length - 1];
|
|
265
|
+
if (displayName) {
|
|
266
|
+
const ex = await getDeep(lastBreadcrumb, displayName) || {};
|
|
267
|
+
await setDeep(lastBreadcrumb, displayName, {
|
|
268
|
+
...ex,
|
|
269
|
+
...props
|
|
270
|
+
});
|
|
271
|
+
} else {
|
|
272
|
+
await Object.assign(lastBreadcrumb, props);
|
|
273
|
+
}
|
|
274
|
+
const newBase64 = convertToBase64(breadcrumbs);
|
|
275
|
+
updateBParam(newBase64);
|
|
276
|
+
};
|
|
277
|
+
function setDeep(obj, path, value) {
|
|
278
|
+
const keys = path.split(".");
|
|
279
|
+
let curr = obj;
|
|
280
|
+
for (let i = 0; i < keys.length - 1; i++) {
|
|
281
|
+
if (!curr[keys[i]] || typeof curr[keys[i]] !== "object") {
|
|
282
|
+
curr[keys[i]] = {};
|
|
283
|
+
}
|
|
284
|
+
curr = curr[keys[i]];
|
|
285
|
+
}
|
|
286
|
+
curr[keys[keys.length - 1]] = value;
|
|
287
|
+
return curr;
|
|
288
|
+
}
|
|
289
|
+
function getDeep(obj, path) {
|
|
290
|
+
return path.split(".").reduce((acc, key) => acc?.[key], obj);
|
|
291
|
+
}
|
|
292
|
+
const getLinkParams = (displayName = "prm") => {
|
|
293
|
+
const search = getParam("b");
|
|
294
|
+
let breadcrumbs = decodeToBase64(search) || [];
|
|
295
|
+
if (breadcrumbs.length < 1) return null;
|
|
296
|
+
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
|
297
|
+
const getDeep2 = (obj, path) => {
|
|
298
|
+
return path.split(".").reduce((acc, key) => acc?.[key], obj);
|
|
299
|
+
};
|
|
300
|
+
const expandKeys = (obj) => {
|
|
301
|
+
return Object.fromEntries(
|
|
302
|
+
Object.entries(obj).map(([key, value]) => [
|
|
303
|
+
keyMap[key] || key,
|
|
304
|
+
// map if exists, else keep original
|
|
305
|
+
value
|
|
306
|
+
])
|
|
307
|
+
);
|
|
308
|
+
};
|
|
309
|
+
const nestedValue = displayName ? getDeep2(lastItem, displayName) : null;
|
|
310
|
+
const output = nestedValue ? expandKeys(nestedValue) : null;
|
|
311
|
+
return output;
|
|
312
|
+
};
|
|
313
|
+
const filterParams = (displayName = "prm") => {
|
|
314
|
+
const search = getParam("b");
|
|
315
|
+
let breadcrumbs = decodeToBase64(search) || [];
|
|
316
|
+
if (breadcrumbs.length < 1) return null;
|
|
317
|
+
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
|
318
|
+
const getDeep2 = (obj, path) => {
|
|
319
|
+
return path.split(".").reduce((acc, key) => acc?.[key], obj);
|
|
320
|
+
};
|
|
321
|
+
const expandKeys = (obj) => {
|
|
322
|
+
return Object.fromEntries(
|
|
323
|
+
Object.entries(obj).map(([key, value]) => [
|
|
324
|
+
keyMap[key] || key,
|
|
325
|
+
// map if exists, else keep original
|
|
326
|
+
value
|
|
327
|
+
])
|
|
328
|
+
);
|
|
329
|
+
};
|
|
330
|
+
const nestedValue = displayName ? getDeep2(lastItem, displayName) : null;
|
|
331
|
+
const output = nestedValue ? expandKeys(nestedValue) : expandKeys(lastItem);
|
|
332
|
+
return output;
|
|
333
|
+
};
|
|
334
|
+
return { updateLink, getLinkParams, filterParams };
|
|
335
|
+
};
|
|
336
|
+
var updateBParam = (newValue) => {
|
|
337
|
+
if (typeof globalThis === "undefined" || !globalThis.location) return;
|
|
338
|
+
const hash = globalThis.location.hash || "";
|
|
339
|
+
if (!hash.startsWith("#/")) return;
|
|
340
|
+
const withoutHash = hash.slice(2);
|
|
341
|
+
const [path, queryString] = withoutHash.split("?");
|
|
342
|
+
const params = new URLSearchParams(queryString || "");
|
|
343
|
+
params.set("b", newValue);
|
|
344
|
+
const newHash = `#/${path}?${params.toString()}`;
|
|
345
|
+
if (typeof globalThis !== "undefined" && globalThis.history && globalThis.history.replaceState) {
|
|
346
|
+
globalThis.history.replaceState(null, "", newHash);
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
// src/store/index.ts
|
|
351
|
+
function createStore(initializer) {
|
|
352
|
+
let state;
|
|
353
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
354
|
+
const get = () => state;
|
|
355
|
+
const set = (partial) => {
|
|
356
|
+
const prevState = state;
|
|
357
|
+
const partialState = typeof partial === "function" ? partial(state) : partial;
|
|
358
|
+
state = {
|
|
359
|
+
...state,
|
|
360
|
+
...partialState
|
|
361
|
+
};
|
|
362
|
+
listeners.forEach(
|
|
363
|
+
(listener) => listener(state, prevState)
|
|
364
|
+
);
|
|
365
|
+
};
|
|
366
|
+
const subscribe = (listener) => {
|
|
367
|
+
listeners.add(listener);
|
|
368
|
+
return () => listeners.delete(listener);
|
|
369
|
+
};
|
|
370
|
+
state = initializer(set, get);
|
|
371
|
+
return {
|
|
372
|
+
getState: get,
|
|
373
|
+
setState: set,
|
|
374
|
+
subscribe
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// src/utils/getCookieData.ts
|
|
379
|
+
var getAuthSubscriptionType = () => {
|
|
380
|
+
return getCookie("subscriptionType");
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
// src/store/use-table.ts
|
|
384
|
+
var pageLimit = 10;
|
|
385
|
+
var tableStore = createStore((set, get) => ({
|
|
386
|
+
// ==============================
|
|
387
|
+
// STATE
|
|
388
|
+
// ==============================
|
|
389
|
+
tableUniqueId: null,
|
|
390
|
+
gridData: [],
|
|
391
|
+
sort: "-hs_createdate",
|
|
392
|
+
limit: 10,
|
|
393
|
+
after: "",
|
|
394
|
+
page: 1,
|
|
395
|
+
nextPage: 1,
|
|
396
|
+
stageId: "",
|
|
397
|
+
totalItems: 1,
|
|
398
|
+
numOfPages: 1,
|
|
399
|
+
currentPage: 1,
|
|
400
|
+
search: "",
|
|
401
|
+
filterPropertyName: "hs_pipeline",
|
|
402
|
+
filterOperator: "eq",
|
|
403
|
+
filterValue: "",
|
|
404
|
+
isPrimaryCompany: null,
|
|
405
|
+
view: null,
|
|
406
|
+
selectedPipeline: "",
|
|
407
|
+
tableParam: {},
|
|
408
|
+
tableDefPermissions: {},
|
|
409
|
+
tableData: [],
|
|
410
|
+
tablePrependData: [],
|
|
411
|
+
// ==============================
|
|
412
|
+
// BASIC SETTERS
|
|
413
|
+
// ==============================
|
|
414
|
+
setTableUniqueId: (v) => set({ tableUniqueId: v }),
|
|
415
|
+
setSort: (v) => set({ sort: v }),
|
|
416
|
+
setLimit: (v) => set({ limit: v }),
|
|
417
|
+
setAfter: (v) => set({ after: v }),
|
|
418
|
+
setPage: (v) => set({ page: v }),
|
|
419
|
+
setNextPage: (v) => set({ nextPage: v }),
|
|
420
|
+
setStageId: (v) => set({ stageId: v }),
|
|
421
|
+
setTotalItems: (v) => set({ totalItems: v }),
|
|
422
|
+
setNumOfPages: (v) => set({ numOfPages: v }),
|
|
423
|
+
setCurrentPage: (v) => set({ currentPage: v }),
|
|
424
|
+
setSearch: (v) => set({ search: v }),
|
|
425
|
+
setFilterPropertyName: (v) => set({ filterPropertyName: v }),
|
|
426
|
+
setFilterOperator: (v) => set({ filterOperator: v }),
|
|
427
|
+
setFilterValue: (v) => set({ filterValue: v }),
|
|
428
|
+
setIsPrimaryCompany: (v) => set({ isPrimaryCompany: v }),
|
|
429
|
+
// ==============================
|
|
430
|
+
// VIEW
|
|
431
|
+
// ==============================
|
|
432
|
+
setView: (mView) => {
|
|
433
|
+
set({
|
|
434
|
+
page: getAuthSubscriptionType() === "FREE" ? "" : 1,
|
|
435
|
+
view: mView
|
|
436
|
+
});
|
|
437
|
+
},
|
|
438
|
+
// ==============================
|
|
439
|
+
// PIPELINE
|
|
440
|
+
// ==============================
|
|
441
|
+
changePipeline: (mView) => {
|
|
442
|
+
set({
|
|
443
|
+
page: getAuthSubscriptionType() === "FREE" ? "" : 1,
|
|
444
|
+
selectedPipeline: mView || ""
|
|
445
|
+
});
|
|
446
|
+
},
|
|
447
|
+
setSelectedPipeline: (pipelines, pipeLineId) => {
|
|
448
|
+
let filterValue = "";
|
|
449
|
+
if (pipeLineId) {
|
|
450
|
+
const pipelineSingle = pipelines.find(
|
|
451
|
+
(pipeline) => pipeline.pipelineId === pipeLineId
|
|
452
|
+
);
|
|
453
|
+
filterValue = pipelineSingle?.pipelineId || "";
|
|
454
|
+
}
|
|
455
|
+
set({
|
|
456
|
+
filterPropertyName: "hs_pipeline",
|
|
457
|
+
filterOperator: "eq",
|
|
458
|
+
filterValue,
|
|
459
|
+
selectedPipeline: filterValue
|
|
460
|
+
});
|
|
461
|
+
},
|
|
462
|
+
// ==============================
|
|
463
|
+
// RESET
|
|
464
|
+
// ==============================
|
|
465
|
+
resetTableParam: () => {
|
|
466
|
+
set({
|
|
467
|
+
sort: "-hs_createdate",
|
|
468
|
+
limit: pageLimit,
|
|
469
|
+
after: "",
|
|
470
|
+
page: getAuthSubscriptionType() === "FREE" ? "" : 1,
|
|
471
|
+
totalItems: 1,
|
|
472
|
+
numOfPages: 1,
|
|
473
|
+
currentPage: 1,
|
|
474
|
+
search: "",
|
|
475
|
+
filterPropertyName: "hs_pipeline",
|
|
476
|
+
filterOperator: "eq",
|
|
477
|
+
filterValue: "",
|
|
478
|
+
isPrimaryCompany: null,
|
|
479
|
+
selectedPipeline: ""
|
|
480
|
+
});
|
|
481
|
+
},
|
|
482
|
+
// ==============================
|
|
483
|
+
// PARAM BUILDER
|
|
484
|
+
// ==============================
|
|
485
|
+
getTableParam: (companyAsMediator, currentPageOverride) => {
|
|
486
|
+
const state = get();
|
|
487
|
+
const baseParams = {
|
|
488
|
+
sort: state.sort,
|
|
489
|
+
search: state.search,
|
|
490
|
+
filterPropertyName: state.filterPropertyName,
|
|
491
|
+
filterOperator: state.filterOperator,
|
|
492
|
+
filterValue: state.selectedPipeline,
|
|
493
|
+
cache: true,
|
|
494
|
+
isPrimaryCompany: companyAsMediator || false,
|
|
495
|
+
view: state.view
|
|
496
|
+
};
|
|
497
|
+
if (getAuthSubscriptionType() === "FREE") {
|
|
498
|
+
return {
|
|
499
|
+
...baseParams,
|
|
500
|
+
after: state.page
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
return {
|
|
504
|
+
...baseParams,
|
|
505
|
+
limit: state.limit,
|
|
506
|
+
page: currentPageOverride || state.page,
|
|
507
|
+
...state.after && {
|
|
508
|
+
after: state.after
|
|
509
|
+
}
|
|
510
|
+
};
|
|
511
|
+
},
|
|
512
|
+
// ==============================
|
|
513
|
+
// GRID DATA
|
|
514
|
+
// ==============================
|
|
515
|
+
setGridData: async (type, deals) => {
|
|
516
|
+
if (type === "reset") {
|
|
517
|
+
await set({ gridData: [] });
|
|
518
|
+
return [];
|
|
519
|
+
}
|
|
520
|
+
if (type === "directly") {
|
|
521
|
+
await set({ gridData: deals });
|
|
522
|
+
return deals;
|
|
523
|
+
}
|
|
524
|
+
const finalData = await deals.map(
|
|
525
|
+
(deal) => {
|
|
526
|
+
const cards = deal?.data?.results?.rows?.map(
|
|
527
|
+
(row) => ({
|
|
528
|
+
id: row?.hs_object_id,
|
|
529
|
+
...row,
|
|
530
|
+
hubspotObjectTypeId: type === "deals" ? "0-3" : "0-5"
|
|
531
|
+
})
|
|
532
|
+
) || [];
|
|
533
|
+
return {
|
|
534
|
+
id: deal.id,
|
|
535
|
+
name: deal.label,
|
|
536
|
+
count: deal?.data?.total,
|
|
537
|
+
...deal,
|
|
538
|
+
cards
|
|
539
|
+
};
|
|
540
|
+
}
|
|
541
|
+
);
|
|
542
|
+
await set({ gridData: finalData });
|
|
543
|
+
return finalData;
|
|
544
|
+
},
|
|
545
|
+
// ==============================
|
|
546
|
+
// DEFAULT PIPELINE
|
|
547
|
+
// ==============================
|
|
548
|
+
setDefaultPipeline(data, hubspotObjectTypeId) {
|
|
549
|
+
if (!data) {
|
|
550
|
+
set({ selectedPipeline: "" });
|
|
551
|
+
return "";
|
|
552
|
+
}
|
|
553
|
+
const { updateLink, filterParams } = useUpdateLink();
|
|
554
|
+
const params = filterParams();
|
|
555
|
+
const excludedIds = ["0-1", "0-2", "0-3", "0-4", "0-5"];
|
|
556
|
+
const state = get();
|
|
557
|
+
const view = state.view;
|
|
558
|
+
const selectedPipeline = state.selectedPipeline;
|
|
559
|
+
let defaultPipelineId = "";
|
|
560
|
+
let mFilterValue = "";
|
|
561
|
+
const defaultPipeline = data?.data?.[0];
|
|
562
|
+
if (excludedIds.includes(hubspotObjectTypeId)) {
|
|
563
|
+
defaultPipelineId = defaultPipeline?.pipelineId || "";
|
|
564
|
+
}
|
|
565
|
+
if (params && params?.filterPropertyName === "hs_pipeline" && params?.filterValue) {
|
|
566
|
+
mFilterValue = params.filterValue;
|
|
567
|
+
} else {
|
|
568
|
+
if (view === "BOARD" && !selectedPipeline) {
|
|
569
|
+
mFilterValue = defaultPipelineId;
|
|
570
|
+
updateLink({
|
|
571
|
+
fV: defaultPipelineId
|
|
572
|
+
});
|
|
573
|
+
} else if (!excludedIds.includes(hubspotObjectTypeId)) {
|
|
574
|
+
mFilterValue = selectedPipeline || null;
|
|
575
|
+
} else {
|
|
576
|
+
mFilterValue = data.data.length === 1 ? defaultPipelineId : selectedPipeline;
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
set({ selectedPipeline: mFilterValue });
|
|
580
|
+
return mFilterValue;
|
|
581
|
+
},
|
|
582
|
+
setTableData: (response) => {
|
|
583
|
+
set({
|
|
584
|
+
tableData: response
|
|
585
|
+
});
|
|
586
|
+
},
|
|
587
|
+
setTablePrependData: async (response) => {
|
|
588
|
+
const state = get();
|
|
589
|
+
let rows = [];
|
|
590
|
+
if (response === "loading") {
|
|
591
|
+
const row = await state.tableData?.data?.results?.columns.reduce((acc, item) => {
|
|
592
|
+
if (!item.hidden) {
|
|
593
|
+
acc[item.key] = "loading";
|
|
594
|
+
}
|
|
595
|
+
return acc;
|
|
596
|
+
}, {});
|
|
597
|
+
rows = [row, ...state.tablePrependData];
|
|
598
|
+
} else {
|
|
599
|
+
const data = response?.data;
|
|
600
|
+
if (!data) {
|
|
601
|
+
set({
|
|
602
|
+
tablePrependData: []
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
const row = await Object.fromEntries(
|
|
606
|
+
Object.entries(data).map(([key, value]) => [
|
|
607
|
+
key,
|
|
608
|
+
value?.value ?? value
|
|
609
|
+
])
|
|
610
|
+
);
|
|
611
|
+
rows = [...state.tablePrependData];
|
|
612
|
+
if (rows.length > 0) {
|
|
613
|
+
rows[0] = row;
|
|
614
|
+
} else {
|
|
615
|
+
rows.push(row);
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
set({
|
|
619
|
+
tablePrependData: rows
|
|
620
|
+
});
|
|
621
|
+
return rows;
|
|
622
|
+
}
|
|
623
|
+
}));
|
|
624
|
+
function useTable() {
|
|
625
|
+
const tableState = tableStore.getState();
|
|
626
|
+
return {
|
|
627
|
+
...tableState,
|
|
628
|
+
...{ listeners: { subscribe: tableStore.subscribe } }
|
|
629
|
+
};
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
// src/store2/store.ts
|
|
633
|
+
function createStore2(initialState) {
|
|
634
|
+
let state = initialState;
|
|
635
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
636
|
+
return {
|
|
637
|
+
getState() {
|
|
638
|
+
return state;
|
|
639
|
+
},
|
|
640
|
+
setState(partial) {
|
|
641
|
+
state = {
|
|
642
|
+
...state,
|
|
643
|
+
...partial
|
|
644
|
+
};
|
|
645
|
+
listeners.forEach(
|
|
646
|
+
(listener) => listener(state)
|
|
647
|
+
);
|
|
648
|
+
},
|
|
649
|
+
subscribe(listener) {
|
|
650
|
+
listeners.add(listener);
|
|
651
|
+
return () => listeners.delete(listener);
|
|
652
|
+
}
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
// src/store2/use-table.ts
|
|
657
|
+
var tableStore2 = createStore2({
|
|
658
|
+
objectsData: null,
|
|
659
|
+
tableData: [],
|
|
660
|
+
tablePrependData: [],
|
|
661
|
+
hubspotObjectTypeId: "",
|
|
662
|
+
selectedPipeline: "",
|
|
663
|
+
viewType: ""
|
|
664
|
+
});
|
|
665
|
+
var actions = {
|
|
666
|
+
async setObjectsData(response) {
|
|
667
|
+
const state = tableStore2.getState();
|
|
668
|
+
if (response?.info?.viewType == "LIST") {
|
|
669
|
+
tableStore2.setState({
|
|
670
|
+
objectsData: response
|
|
671
|
+
});
|
|
672
|
+
}
|
|
673
|
+
if (response?.info?.viewType == "BOARD") {
|
|
674
|
+
const {
|
|
675
|
+
stageId
|
|
676
|
+
} = useTable();
|
|
677
|
+
if (stageId) {
|
|
678
|
+
const boardData = { ...state.objectsData };
|
|
679
|
+
const updatedBoardData = await {
|
|
680
|
+
...boardData,
|
|
681
|
+
data: {
|
|
682
|
+
...boardData.data,
|
|
683
|
+
results: boardData.data.results.map(
|
|
684
|
+
(item) => String(item.id) === String(stageId) ? {
|
|
685
|
+
...item,
|
|
686
|
+
data: {
|
|
687
|
+
...item.data,
|
|
688
|
+
results: {
|
|
689
|
+
...item.data.results,
|
|
690
|
+
rows: [
|
|
691
|
+
...item?.data?.results?.rows ?? [],
|
|
692
|
+
// keep existing rows
|
|
693
|
+
...response?.data?.results?.rows ?? []
|
|
694
|
+
// prepend new rows
|
|
695
|
+
]
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
} : item
|
|
699
|
+
)
|
|
700
|
+
}
|
|
701
|
+
};
|
|
702
|
+
tableStore2.setState({
|
|
703
|
+
objectsData: updatedBoardData
|
|
704
|
+
});
|
|
705
|
+
} else {
|
|
706
|
+
tableStore2.setState({
|
|
707
|
+
objectsData: response
|
|
708
|
+
});
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
},
|
|
712
|
+
setTableData(response, payload) {
|
|
713
|
+
const state = tableStore2.getState();
|
|
714
|
+
const rows = response?.data?.results?.rows ?? [];
|
|
715
|
+
const rowIds = new Set(
|
|
716
|
+
rows.map((row) => row.id ?? row.hs_object_id).filter((id) => id != null && id !== "").map((id) => String(id))
|
|
717
|
+
);
|
|
718
|
+
let newTablePrependData = state.tablePrependData.filter((item) => {
|
|
719
|
+
const itemId = item.id ?? item.hs_object_id;
|
|
720
|
+
if (itemId == null || itemId === "") return true;
|
|
721
|
+
return !rowIds.has(String(itemId));
|
|
722
|
+
});
|
|
723
|
+
const hubspotObjectTypeId = payload?.hubspotObjectTypeId;
|
|
724
|
+
const selectedPipeline = payload?.selectedPipeline;
|
|
725
|
+
const viewType = response?.info?.viewType;
|
|
726
|
+
if (response?.data?.total < 1 || payload?.componentName) {
|
|
727
|
+
newTablePrependData = [];
|
|
728
|
+
}
|
|
729
|
+
if (state.viewType && state.viewType != viewType) {
|
|
730
|
+
newTablePrependData = [];
|
|
731
|
+
}
|
|
732
|
+
if (state.hubspotObjectTypeId && state.hubspotObjectTypeId != hubspotObjectTypeId) {
|
|
733
|
+
newTablePrependData = [];
|
|
734
|
+
}
|
|
735
|
+
if (state.selectedPipeline && state.selectedPipeline != selectedPipeline) {
|
|
736
|
+
newTablePrependData = [];
|
|
737
|
+
}
|
|
738
|
+
tableStore2.setState({
|
|
739
|
+
tableData: response,
|
|
740
|
+
tablePrependData: newTablePrependData,
|
|
741
|
+
hubspotObjectTypeId,
|
|
742
|
+
viewType
|
|
743
|
+
});
|
|
744
|
+
},
|
|
745
|
+
modifiedObjectsData(results) {
|
|
746
|
+
const state = tableStore2.getState();
|
|
747
|
+
const tablePrependData = state.tablePrependData;
|
|
748
|
+
const modifiedData = results.map((result) => {
|
|
749
|
+
const matchedPrepend = tablePrependData.find(
|
|
750
|
+
(item) => String(item?.id) === String(result?.id)
|
|
751
|
+
);
|
|
752
|
+
if (!matchedPrepend) {
|
|
753
|
+
return result;
|
|
754
|
+
}
|
|
755
|
+
const prependRows = matchedPrepend?.data?.results?.rows ?? [];
|
|
756
|
+
const prependCards = prependRows.map((row) => ({
|
|
757
|
+
id: row.hs_object_id,
|
|
758
|
+
...row
|
|
759
|
+
}));
|
|
760
|
+
return {
|
|
761
|
+
...result,
|
|
762
|
+
// prepend in results.rows
|
|
763
|
+
data: {
|
|
764
|
+
...result.data,
|
|
765
|
+
results: {
|
|
766
|
+
...result.data.results,
|
|
767
|
+
rows: [
|
|
768
|
+
...prependRows,
|
|
769
|
+
...result?.data?.results?.rows ?? []
|
|
770
|
+
]
|
|
771
|
+
}
|
|
772
|
+
},
|
|
773
|
+
// prepend in cards
|
|
774
|
+
cards: [
|
|
775
|
+
...prependCards,
|
|
776
|
+
...result?.cards ?? []
|
|
777
|
+
]
|
|
778
|
+
};
|
|
779
|
+
});
|
|
780
|
+
tableStore2.setState({
|
|
781
|
+
objectsData: modifiedData
|
|
782
|
+
});
|
|
783
|
+
},
|
|
784
|
+
clearTablePrependData() {
|
|
785
|
+
tableStore2.setState({
|
|
786
|
+
tablePrependData: []
|
|
787
|
+
});
|
|
788
|
+
},
|
|
789
|
+
async setTablePrependData(response, props) {
|
|
790
|
+
const state = tableStore2.getState();
|
|
791
|
+
let rows = [];
|
|
792
|
+
if (state.tableData?.info?.viewType == "BOARD") {
|
|
793
|
+
if (response === "loading") {
|
|
794
|
+
const responseData = state.tableData?.data?.results ?? [];
|
|
795
|
+
const pipelineStage = props?.payload?.propertyPayload?.hs_pipeline_stage || props?.payload?.propertyPayload?.dealstage;
|
|
796
|
+
rows = responseData.map(
|
|
797
|
+
({ id, data }) => {
|
|
798
|
+
const matchedPrepend = state.tablePrependData.find(
|
|
799
|
+
(item) => String(item.id) === String(id)
|
|
800
|
+
);
|
|
801
|
+
const prependRows = matchedPrepend?.data?.results?.rows ?? [];
|
|
802
|
+
const newRow = String(id) === String(pipelineStage) ? [
|
|
803
|
+
(data?.results?.columns ?? []).reduce(
|
|
804
|
+
(obj, column) => {
|
|
805
|
+
obj[column.key] = "loading";
|
|
806
|
+
return obj;
|
|
807
|
+
},
|
|
808
|
+
{}
|
|
809
|
+
)
|
|
810
|
+
] : [];
|
|
811
|
+
return {
|
|
812
|
+
id,
|
|
813
|
+
data: {
|
|
814
|
+
results: {
|
|
815
|
+
columns: data?.results?.columns ?? [],
|
|
816
|
+
// prepend loading row + prepend rows
|
|
817
|
+
rows: [
|
|
818
|
+
...newRow,
|
|
819
|
+
...prependRows
|
|
820
|
+
]
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
};
|
|
824
|
+
}
|
|
825
|
+
);
|
|
826
|
+
} else {
|
|
827
|
+
const data = response?.data;
|
|
828
|
+
const hs_pipeline_stage = data?.hs_pipeline_stage?.value?.value || data?.dealstage?.value?.value;
|
|
829
|
+
if (!data) {
|
|
830
|
+
tableStore2.setState({
|
|
831
|
+
tablePrependData: []
|
|
832
|
+
});
|
|
833
|
+
}
|
|
834
|
+
rows = state?.tablePrependData.map((row) => {
|
|
835
|
+
const matchedPrepend = state.tablePrependData.find(
|
|
836
|
+
(item) => String(item.id) === String(row.id)
|
|
837
|
+
);
|
|
838
|
+
const prependRows = matchedPrepend?.data?.results?.rows ?? [];
|
|
839
|
+
if (String(row.id) === String(hs_pipeline_stage)) {
|
|
840
|
+
const updatedRow = (row?.data?.results?.columns ?? []).reduce(
|
|
841
|
+
(obj, column) => {
|
|
842
|
+
const key = column.key;
|
|
843
|
+
obj[key] = data?.[key]?.value ?? data?.[key] ?? "";
|
|
844
|
+
return obj;
|
|
845
|
+
},
|
|
846
|
+
{}
|
|
847
|
+
);
|
|
848
|
+
prependRows[0] = updatedRow;
|
|
849
|
+
return {
|
|
850
|
+
...row,
|
|
851
|
+
data: {
|
|
852
|
+
...row.data,
|
|
853
|
+
results: {
|
|
854
|
+
...row.data.results,
|
|
855
|
+
rows: prependRows
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
};
|
|
859
|
+
}
|
|
860
|
+
return row;
|
|
861
|
+
});
|
|
862
|
+
}
|
|
863
|
+
} else {
|
|
864
|
+
if (response === "loading") {
|
|
865
|
+
const row = await state.tableData?.data?.results?.columns.reduce((acc, item) => {
|
|
866
|
+
if (!item.hidden) {
|
|
867
|
+
acc[item.key] = "loading";
|
|
868
|
+
}
|
|
869
|
+
return acc;
|
|
870
|
+
}, {});
|
|
871
|
+
rows = [row, ...state.tablePrependData];
|
|
872
|
+
} else if (response?.data) {
|
|
873
|
+
const data = response?.data;
|
|
874
|
+
if (!data) {
|
|
875
|
+
tableStore2.setState({
|
|
876
|
+
tablePrependData: []
|
|
877
|
+
});
|
|
878
|
+
}
|
|
879
|
+
const row = await Object.fromEntries(
|
|
880
|
+
Object.entries(data).map(([key, value]) => [
|
|
881
|
+
key,
|
|
882
|
+
value?.value ?? value
|
|
883
|
+
])
|
|
884
|
+
);
|
|
885
|
+
rows = [...state.tablePrependData];
|
|
886
|
+
if (rows.length > 0) {
|
|
887
|
+
rows[0] = row;
|
|
888
|
+
} else {
|
|
889
|
+
rows.push(row);
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
tableStore2.setState({
|
|
894
|
+
tablePrependData: rows
|
|
895
|
+
});
|
|
896
|
+
}
|
|
897
|
+
};
|
|
898
|
+
|
|
899
|
+
// src/store2/use-note.ts
|
|
900
|
+
var noteStore = createStore2({
|
|
901
|
+
notes: [],
|
|
902
|
+
prependNotes: [],
|
|
903
|
+
id: ""
|
|
904
|
+
});
|
|
905
|
+
var actions2 = {
|
|
906
|
+
setNotes(response, payload) {
|
|
907
|
+
const state = noteStore.getState();
|
|
908
|
+
const rows = response?.data?.results?.rows ?? [];
|
|
909
|
+
const rowIds = new Set(
|
|
910
|
+
rows.map((row) => row.id ?? row.hs_object_id).filter((id2) => id2 != null && id2 !== "").map((id2) => String(id2))
|
|
911
|
+
);
|
|
912
|
+
let newPrependNotes = state.prependNotes.filter((item) => {
|
|
913
|
+
const itemId = item.id ?? item.hs_object_id;
|
|
914
|
+
if (itemId == null || itemId === "") return true;
|
|
915
|
+
return !rowIds.has(String(itemId));
|
|
916
|
+
});
|
|
917
|
+
const id = payload?.params?.id;
|
|
918
|
+
if (state.id && state.id != id) {
|
|
919
|
+
newPrependNotes = [];
|
|
920
|
+
}
|
|
921
|
+
noteStore.setState({
|
|
922
|
+
notes: response,
|
|
923
|
+
prependNotes: newPrependNotes,
|
|
924
|
+
id
|
|
925
|
+
});
|
|
926
|
+
},
|
|
927
|
+
async setPrependNote(response) {
|
|
928
|
+
const state = noteStore.getState();
|
|
929
|
+
let rows = [];
|
|
930
|
+
if (response === "loading") {
|
|
931
|
+
const row = await state.notes?.data?.results?.columns.reduce((acc, item) => {
|
|
932
|
+
if (!item.hidden) {
|
|
933
|
+
acc[item.key] = "loading";
|
|
934
|
+
}
|
|
935
|
+
return acc;
|
|
936
|
+
}, {});
|
|
937
|
+
rows = [row, ...state.prependNotes];
|
|
938
|
+
} else if (response?.data) {
|
|
939
|
+
const data = response?.data;
|
|
940
|
+
if (!data) {
|
|
941
|
+
noteStore.setState({
|
|
942
|
+
prependNotes: []
|
|
943
|
+
});
|
|
944
|
+
}
|
|
945
|
+
const row = await Object.fromEntries(
|
|
946
|
+
Object.entries(data).map(([key, value]) => [
|
|
947
|
+
key,
|
|
948
|
+
value?.value ?? value
|
|
949
|
+
])
|
|
950
|
+
);
|
|
951
|
+
rows = [...state.prependNotes];
|
|
952
|
+
if (rows.length > 0) {
|
|
953
|
+
rows[0] = row;
|
|
954
|
+
} else {
|
|
955
|
+
rows.push(row);
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
noteStore.setState({
|
|
959
|
+
prependNotes: rows
|
|
960
|
+
});
|
|
961
|
+
},
|
|
962
|
+
clearPrependNotes() {
|
|
963
|
+
noteStore.setState({
|
|
964
|
+
prependNotes: []
|
|
965
|
+
});
|
|
966
|
+
},
|
|
967
|
+
async updatePrependNote(response) {
|
|
968
|
+
const state = noteStore.getState();
|
|
969
|
+
const prependNotes = state.prependNotes || [];
|
|
970
|
+
const note = response.data || null;
|
|
971
|
+
const notes = prependNotes.map(
|
|
972
|
+
(item) => item?.hs_object_id === note?.hs_object_id?.value ? {
|
|
973
|
+
...item,
|
|
974
|
+
...Object.fromEntries(
|
|
975
|
+
Object.entries(note).map(([key, value]) => [
|
|
976
|
+
key,
|
|
977
|
+
value?.value ?? value
|
|
978
|
+
])
|
|
979
|
+
)
|
|
980
|
+
} : item
|
|
981
|
+
);
|
|
982
|
+
noteStore.setState({
|
|
983
|
+
prependNotes: notes
|
|
984
|
+
});
|
|
985
|
+
}
|
|
986
|
+
};
|
|
987
|
+
|
|
988
|
+
// src/store2/use-email.ts
|
|
989
|
+
var emailStore = createStore2({
|
|
990
|
+
emails: [],
|
|
991
|
+
prependEmails: [],
|
|
992
|
+
id: ""
|
|
993
|
+
});
|
|
994
|
+
var actions3 = {
|
|
995
|
+
setEmails(response, payload) {
|
|
996
|
+
const state = emailStore.getState();
|
|
997
|
+
const rows = response?.data?.results?.rows ?? [];
|
|
998
|
+
const rowIds = new Set(
|
|
999
|
+
rows.map((row) => row.id ?? row.hs_object_id).filter((id2) => id2 != null && id2 !== "").map((id2) => String(id2))
|
|
1000
|
+
);
|
|
1001
|
+
let newPrependEmails = state.prependEmails.filter((item) => {
|
|
1002
|
+
const itemId = item.id ?? item.hs_object_id;
|
|
1003
|
+
if (itemId == null || itemId === "") return true;
|
|
1004
|
+
return !rowIds.has(String(itemId));
|
|
1005
|
+
});
|
|
1006
|
+
const id = payload?.params?.id;
|
|
1007
|
+
if (state.id && state.id != id) {
|
|
1008
|
+
newPrependEmails = [];
|
|
1009
|
+
}
|
|
1010
|
+
emailStore.setState({
|
|
1011
|
+
emails: response,
|
|
1012
|
+
prependEmails: newPrependEmails,
|
|
1013
|
+
id
|
|
1014
|
+
});
|
|
1015
|
+
},
|
|
1016
|
+
async setPrependEmail(response) {
|
|
1017
|
+
const state = emailStore.getState();
|
|
1018
|
+
let rows = [];
|
|
1019
|
+
if (response === "loading") {
|
|
1020
|
+
const row = await state.emails?.data?.results?.columns.reduce((acc, item) => {
|
|
1021
|
+
if (!item.hidden) {
|
|
1022
|
+
acc[item.key] = "loading";
|
|
1023
|
+
}
|
|
1024
|
+
return acc;
|
|
1025
|
+
}, {});
|
|
1026
|
+
rows = [row, ...state.prependEmails];
|
|
1027
|
+
} else if (response?.data) {
|
|
1028
|
+
const data = response?.data;
|
|
1029
|
+
if (!data) {
|
|
1030
|
+
emailStore.setState({
|
|
1031
|
+
prependEmails: []
|
|
1032
|
+
});
|
|
1033
|
+
}
|
|
1034
|
+
const row = await Object.fromEntries(
|
|
1035
|
+
Object.entries(data).map(([key, value]) => [
|
|
1036
|
+
key,
|
|
1037
|
+
value?.value ?? value
|
|
1038
|
+
])
|
|
1039
|
+
);
|
|
1040
|
+
rows = [...state.prependEmails];
|
|
1041
|
+
if (rows.length > 0) {
|
|
1042
|
+
rows[0] = row;
|
|
1043
|
+
} else {
|
|
1044
|
+
rows.push(row);
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
emailStore.setState({
|
|
1048
|
+
prependEmails: rows
|
|
1049
|
+
});
|
|
1050
|
+
},
|
|
1051
|
+
clearPrependEmails() {
|
|
1052
|
+
emailStore.setState({
|
|
1053
|
+
prependEmails: []
|
|
1054
|
+
});
|
|
1055
|
+
},
|
|
1056
|
+
async updatePrependEmail(response) {
|
|
1057
|
+
const state = emailStore.getState();
|
|
1058
|
+
const prependEmails = state.prependEmails || [];
|
|
1059
|
+
const email = response.data || null;
|
|
1060
|
+
const emails = prependEmails.map(
|
|
1061
|
+
(item) => item?.hs_object_id === email?.hs_object_id?.value ? {
|
|
1062
|
+
...item,
|
|
1063
|
+
...Object.fromEntries(
|
|
1064
|
+
Object.entries(email).map(([key, value]) => [
|
|
1065
|
+
key,
|
|
1066
|
+
value?.value ?? value
|
|
1067
|
+
])
|
|
1068
|
+
)
|
|
1069
|
+
} : item
|
|
1070
|
+
);
|
|
1071
|
+
emailStore.setState({
|
|
1072
|
+
prependEmails: emails
|
|
1073
|
+
});
|
|
1074
|
+
}
|
|
1075
|
+
};
|
|
1076
|
+
|
|
1077
|
+
// src/store2/use-sync.ts
|
|
1078
|
+
var syncStore = createStore2({
|
|
1079
|
+
apiSync: false,
|
|
1080
|
+
sync: false,
|
|
1081
|
+
isSyncLoading: false,
|
|
1082
|
+
isSyncDisable: false
|
|
1083
|
+
});
|
|
1084
|
+
var actions4 = {
|
|
1085
|
+
setIsSyncLoading(status) {
|
|
1086
|
+
syncStore.setState({
|
|
1087
|
+
isSyncLoading: status,
|
|
1088
|
+
sync: status
|
|
1089
|
+
});
|
|
1090
|
+
},
|
|
1091
|
+
setSync(status) {
|
|
1092
|
+
resetAllStore();
|
|
1093
|
+
syncStore.setState({
|
|
1094
|
+
isSyncLoading: status,
|
|
1095
|
+
sync: status
|
|
1096
|
+
});
|
|
1097
|
+
},
|
|
1098
|
+
setApiSync(status) {
|
|
1099
|
+
syncStore.setState({
|
|
1100
|
+
isSyncLoading: status,
|
|
1101
|
+
apiSync: status
|
|
1102
|
+
});
|
|
1103
|
+
},
|
|
1104
|
+
setSyncDisable(status) {
|
|
1105
|
+
syncStore.setState({
|
|
1106
|
+
isSyncDisable: status
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
1109
|
+
};
|
|
1110
|
+
var resetAllStore = () => {
|
|
1111
|
+
actions.clearTablePrependData();
|
|
1112
|
+
actions2.clearPrependNotes();
|
|
1113
|
+
actions3.clearPrependEmails();
|
|
1114
|
+
};
|
|
1115
|
+
|
|
1116
|
+
export { actions, actions2, actions3, actions4, breadcrumbStage, decodeToBase64, emailStore, generatePath, generateUrl, getParam, getParamDetails, getPath, getRouteDetails, getRouteMenu, isMessingParent, isMessingParentLastItem, noteStore, resetAllStore, syncStore, tableStore2 as tableStore, useTable, useUpdateLink };
|
|
1117
|
+
//# sourceMappingURL=chunk-HRLJLCAZ.js.map
|
|
1118
|
+
//# sourceMappingURL=chunk-HRLJLCAZ.js.map
|