woodsportal-client-sdk 1.1.4-dev.51 → 1.1.4-dev.53

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.
@@ -1,1404 +0,0 @@
1
- import { getCookie } from './chunk-T4ORQSB3.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", "home"];
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 viewType = response?.info?.viewType;
715
- let newTablePrependData;
716
- if (viewType === "BOARD") {
717
- const stages = response?.data?.results ?? [];
718
- newTablePrependData = state.tablePrependData.map((prependStage) => {
719
- const matchingStage = stages.find(
720
- (stage) => String(stage.id) === String(prependStage.id)
721
- );
722
- const rows = matchingStage?.data?.results?.rows ?? [];
723
- const rowIds = new Set(
724
- rows.map((row) => row.id ?? row.hs_object_id).filter((id) => id != null && id !== "").map((id) => String(id))
725
- );
726
- const filteredRows = (prependStage?.data?.results?.rows ?? []).filter((item) => {
727
- const itemId = item.id ?? item.hs_object_id;
728
- if (itemId == null || itemId === "") return true;
729
- return !rowIds.has(String(itemId));
730
- });
731
- return {
732
- ...prependStage,
733
- data: {
734
- ...prependStage.data,
735
- results: {
736
- ...prependStage.data?.results,
737
- rows: filteredRows
738
- }
739
- }
740
- };
741
- });
742
- } else {
743
- const rows = response?.data?.results?.rows ?? [];
744
- const rowIds = new Set(
745
- rows.map((row) => row.id ?? row.hs_object_id).filter((id) => id != null && id !== "").map((id) => String(id))
746
- );
747
- newTablePrependData = state.tablePrependData.filter((item) => {
748
- const itemId = item.id ?? item.hs_object_id;
749
- if (itemId == null || itemId === "") return true;
750
- return !rowIds.has(String(itemId));
751
- });
752
- }
753
- const hubspotObjectTypeId = payload?.hubspotObjectTypeId;
754
- const selectedPipeline = payload?.selectedPipeline;
755
- if (response?.data?.total < 1 || payload?.componentName) {
756
- newTablePrependData = [];
757
- }
758
- if (state.viewType && state.viewType != viewType) {
759
- newTablePrependData = [];
760
- }
761
- if (state.hubspotObjectTypeId && state.hubspotObjectTypeId != hubspotObjectTypeId) {
762
- newTablePrependData = [];
763
- }
764
- if (state.selectedPipeline && state.selectedPipeline != selectedPipeline) {
765
- newTablePrependData = [];
766
- }
767
- if (payload.isFristTimeLoadData) {
768
- newTablePrependData = [];
769
- }
770
- tableStore2.setState({
771
- tableData: response,
772
- tablePrependData: newTablePrependData || [],
773
- hubspotObjectTypeId,
774
- viewType
775
- });
776
- },
777
- modifiedObjectsData(results) {
778
- const state = tableStore2.getState();
779
- const tablePrependData = state.tablePrependData;
780
- const modifiedData = results.map((result) => {
781
- const matchedPrepend = tablePrependData.find(
782
- (item) => String(item?.id) === String(result?.id)
783
- );
784
- if (!matchedPrepend) {
785
- return result;
786
- }
787
- const prependRows = matchedPrepend?.data?.results?.rows ?? [];
788
- const prependCards = prependRows.map((row) => ({
789
- id: row.hs_object_id,
790
- ...row
791
- }));
792
- return {
793
- ...result,
794
- // prepend in results.rows
795
- data: {
796
- ...result.data,
797
- results: {
798
- ...result.data.results,
799
- rows: [
800
- ...prependRows,
801
- ...result?.data?.results?.rows ?? []
802
- ]
803
- }
804
- },
805
- // prepend in cards
806
- cards: [
807
- ...prependCards,
808
- ...result?.cards ?? []
809
- ]
810
- };
811
- });
812
- tableStore2.setState({
813
- objectsData: modifiedData
814
- });
815
- },
816
- clearTablePrependData() {
817
- tableStore2.setState({
818
- tablePrependData: []
819
- });
820
- },
821
- async setTablePrependData(response, props) {
822
- const state = tableStore2.getState();
823
- let rows = [];
824
- if (state.tableData?.info?.viewType == "BOARD") {
825
- if (response === "loading") {
826
- const responseData = state.tableData?.data?.results ?? [];
827
- const pipelineStage = props?.payload?.propertyPayload?.hs_pipeline_stage || props?.payload?.propertyPayload?.dealstage;
828
- rows = responseData.map(
829
- ({ id, data }) => {
830
- const matchedPrepend = state.tablePrependData.find(
831
- (item) => String(item.id) === String(id)
832
- );
833
- const prependRows = matchedPrepend?.data?.results?.rows ?? [];
834
- const newRow = String(id) === String(pipelineStage) ? [
835
- (data?.results?.columns ?? []).reduce(
836
- (obj, column) => {
837
- obj[column.key] = "loading";
838
- return obj;
839
- },
840
- {}
841
- )
842
- ] : [];
843
- return {
844
- id,
845
- data: {
846
- results: {
847
- columns: data?.results?.columns ?? [],
848
- // prepend loading row + prepend rows
849
- rows: [
850
- ...newRow,
851
- ...prependRows
852
- ]
853
- }
854
- }
855
- };
856
- }
857
- );
858
- } else {
859
- const data = response?.data;
860
- const hs_pipeline_stage = data?.hs_pipeline_stage?.value?.value || data?.dealstage?.value?.value;
861
- if (!data) {
862
- tableStore2.setState({
863
- tablePrependData: []
864
- });
865
- }
866
- rows = state?.tablePrependData.map((row) => {
867
- const matchedPrepend = state.tablePrependData.find(
868
- (item) => String(item.id) === String(row.id)
869
- );
870
- const prependRows = matchedPrepend?.data?.results?.rows ?? [];
871
- if (String(row.id) === String(hs_pipeline_stage)) {
872
- const updatedRow = (row?.data?.results?.columns ?? []).reduce(
873
- (obj, column) => {
874
- const key = column.key;
875
- obj[key] = data?.[key]?.value ?? data?.[key] ?? "";
876
- return obj;
877
- },
878
- {}
879
- );
880
- prependRows[0] = updatedRow;
881
- return {
882
- ...row,
883
- data: {
884
- ...row.data,
885
- results: {
886
- ...row.data.results,
887
- rows: prependRows
888
- }
889
- }
890
- };
891
- }
892
- return row;
893
- });
894
- }
895
- } else if (state.tableData?.info?.viewType == "LIST") {
896
- if (response === "loading") {
897
- const row = await state.tableData?.data?.results?.columns.reduce((acc, item) => {
898
- if (!item.hidden) {
899
- acc[item.key] = "loading";
900
- }
901
- return acc;
902
- }, {});
903
- rows = [row, ...state.tablePrependData];
904
- } else if (response?.data) {
905
- const data = response?.data;
906
- if (!data) {
907
- tableStore2.setState({
908
- tablePrependData: []
909
- });
910
- }
911
- const row = await Object.fromEntries(
912
- Object.entries(data).map(([key, value]) => [
913
- key,
914
- value?.value ?? value
915
- ])
916
- );
917
- rows = [...state.tablePrependData];
918
- if (rows.length > 0) {
919
- rows[0] = row;
920
- } else {
921
- rows.push(row);
922
- }
923
- }
924
- }
925
- tableStore2.setState({
926
- tablePrependData: rows
927
- });
928
- }
929
- };
930
-
931
- // src/store2/use-uploader.ts
932
- var uploaderStore = createStore2({
933
- attachments: []
934
- });
935
- function toAttachmentSummary(attachment) {
936
- return {
937
- createdAt: attachment.createdAt,
938
- id: attachment.id,
939
- name: attachment.name,
940
- size: attachment.size,
941
- type: attachment.type,
942
- updatedAt: attachment.updatedAt
943
- };
944
- }
945
- function resolveAttachmentsFromIds(attachmentIds, storedAttachments) {
946
- const raw = typeof attachmentIds === "object" && attachmentIds !== null && "value" in attachmentIds ? attachmentIds.value : attachmentIds;
947
- const ids = String(raw ?? "").split(";").map((id) => id.trim()).filter(Boolean);
948
- return ids.map((id) => storedAttachments.find((a) => String(a.id) === id)).filter((a) => a != null).map(toAttachmentSummary);
949
- }
950
- var actions2 = {
951
- setAttachment(response) {
952
- const data = response?.data;
953
- if (!data?.id) return;
954
- const state = uploaderStore.getState();
955
- const id = String(data.id);
956
- const existing = state.attachments;
957
- const index = existing.findIndex((item) => String(item.id) === id);
958
- const attachments = index >= 0 ? existing.map((item, i) => i === index ? data : item) : [...existing, data];
959
- uploaderStore.setState({ attachments });
960
- },
961
- clearAttachments() {
962
- uploaderStore.setState({ attachments: [] });
963
- }
964
- };
965
-
966
- // src/store2/use-note.ts
967
- var noteStore = createStore2({
968
- notes: [],
969
- prependNotes: [],
970
- id: ""
971
- });
972
- var actions3 = {
973
- setNotes(response, payload) {
974
- const state = noteStore.getState();
975
- const rows = response?.data?.results?.rows ?? [];
976
- const rowIds = new Set(
977
- rows.map((row) => row.id ?? row.hs_object_id).filter((id2) => id2 != null && id2 !== "").map((id2) => String(id2))
978
- );
979
- let newPrependNotes = state.prependNotes.filter((item) => {
980
- const itemId = item.id ?? item.hs_object_id;
981
- if (itemId == null || itemId === "") return true;
982
- return !rowIds.has(String(itemId));
983
- });
984
- const id = payload?.params?.id;
985
- if (state.id && state.id != id) {
986
- newPrependNotes = [];
987
- }
988
- noteStore.setState({
989
- notes: response,
990
- prependNotes: newPrependNotes,
991
- id
992
- });
993
- },
994
- async setPrependNote(response) {
995
- const state = noteStore.getState();
996
- let rows = [];
997
- if (response === "loading") {
998
- const row = await state.notes?.data?.results?.columns.reduce((acc, item) => {
999
- if (!item.hidden) {
1000
- acc[item.key] = "loading";
1001
- }
1002
- return acc;
1003
- }, {});
1004
- rows = [row, ...state.prependNotes];
1005
- } else if (response?.data) {
1006
- const data = response?.data;
1007
- if (!data) {
1008
- noteStore.setState({
1009
- prependNotes: []
1010
- });
1011
- }
1012
- const storedAttachments = uploaderStore.getState().attachments;
1013
- const row = Object.fromEntries(
1014
- Object.entries(data).map(([key, value]) => {
1015
- if (key === "hs_attachment_ids") {
1016
- return [
1017
- key,
1018
- resolveAttachmentsFromIds(value, storedAttachments)
1019
- ];
1020
- }
1021
- return [key, value?.value ?? value];
1022
- })
1023
- );
1024
- rows = [...state.prependNotes];
1025
- if (rows.length > 0) {
1026
- rows[0] = row;
1027
- } else {
1028
- rows.push(row);
1029
- }
1030
- }
1031
- noteStore.setState({
1032
- prependNotes: rows
1033
- });
1034
- },
1035
- clearPrependNotes() {
1036
- noteStore.setState({
1037
- prependNotes: []
1038
- });
1039
- actions2.clearAttachments();
1040
- },
1041
- async updatePrependNote(response) {
1042
- const responseData = { ...response };
1043
- const state = noteStore.getState();
1044
- const prependNotes = state.prependNotes || [];
1045
- const note = response.data || null;
1046
- const storedAttachments = uploaderStore.getState().attachments;
1047
- const notes = prependNotes.map(
1048
- (item) => item?.hs_object_id === note?.hs_object_id?.value ? {
1049
- ...item,
1050
- ...Object.fromEntries(
1051
- Object.entries(note).map(([key, value]) => {
1052
- if (key === "hs_attachment_ids") {
1053
- return [
1054
- key,
1055
- resolveAttachmentsFromIds(value, storedAttachments)
1056
- ];
1057
- }
1058
- return [key, value?.value ?? value];
1059
- })
1060
- )
1061
- } : item
1062
- );
1063
- noteStore.setState({
1064
- prependNotes: notes
1065
- });
1066
- if (responseData?.data?.hs_attachment_ids != null) {
1067
- const noteObjectId = note?.hs_object_id?.value;
1068
- const rows = state.notes?.data?.results?.rows ?? [];
1069
- const matchingRow = rows.find(
1070
- (row) => String(row.hs_object_id) === String(noteObjectId)
1071
- );
1072
- const originalPrependItem = prependNotes.find(
1073
- (item) => String(item?.hs_object_id) === String(noteObjectId)
1074
- );
1075
- const existingAttachments = matchingRow?.hs_attachment_ids ?? originalPrependItem?.hs_attachment_ids ?? [];
1076
- const newAttachments = resolveAttachmentsFromIds(
1077
- responseData.data.hs_attachment_ids,
1078
- storedAttachments
1079
- );
1080
- const mergedAttachments = [
1081
- ...existingAttachments,
1082
- ...newAttachments.filter(
1083
- (attachment) => !existingAttachments.some(
1084
- (existing) => String(existing.id) === String(attachment.id)
1085
- )
1086
- )
1087
- ];
1088
- const stateUpdates = {};
1089
- if (matchingRow && state.notes?.data?.results) {
1090
- stateUpdates.notes = {
1091
- ...state.notes,
1092
- data: {
1093
- ...state.notes.data,
1094
- results: {
1095
- ...state.notes.data.results,
1096
- rows: rows.map(
1097
- (row) => String(row.hs_object_id) === String(noteObjectId) ? { ...row, hs_attachment_ids: mergedAttachments } : row
1098
- )
1099
- }
1100
- }
1101
- };
1102
- }
1103
- if (originalPrependItem) {
1104
- stateUpdates.prependNotes = prependNotes.map(
1105
- (item) => String(item?.hs_object_id) === String(noteObjectId) ? { ...item, hs_attachment_ids: mergedAttachments } : item
1106
- );
1107
- }
1108
- if (Object.keys(stateUpdates).length > 0) {
1109
- noteStore.setState(stateUpdates);
1110
- }
1111
- responseData.data.hs_attachment_ids = mergedAttachments;
1112
- }
1113
- return responseData;
1114
- }
1115
- };
1116
-
1117
- // src/store2/use-email.ts
1118
- var emailStore = createStore2({
1119
- emails: [],
1120
- prependEmails: [],
1121
- id: ""
1122
- });
1123
- var actions4 = {
1124
- setEmails(response, payload) {
1125
- const state = emailStore.getState();
1126
- const rows = response?.data?.results?.rows ?? [];
1127
- const rowIds = new Set(
1128
- rows.map((row) => row.id ?? row.hs_object_id).filter((id2) => id2 != null && id2 !== "").map((id2) => String(id2))
1129
- );
1130
- let newPrependEmails = state.prependEmails.filter((item) => {
1131
- const itemId = item.id ?? item.hs_object_id;
1132
- if (itemId == null || itemId === "") return true;
1133
- return !rowIds.has(String(itemId));
1134
- });
1135
- const id = payload?.params?.id;
1136
- if (state.id && state.id != id) {
1137
- newPrependEmails = [];
1138
- }
1139
- emailStore.setState({
1140
- emails: response,
1141
- prependEmails: newPrependEmails,
1142
- id
1143
- });
1144
- },
1145
- async setPrependEmail(response) {
1146
- const state = emailStore.getState();
1147
- let rows = [];
1148
- if (response === "loading") {
1149
- const row = await state.emails?.data?.results?.columns.reduce((acc, item) => {
1150
- if (!item.hidden) {
1151
- acc[item.key] = "loading";
1152
- }
1153
- return acc;
1154
- }, {});
1155
- rows = [row, ...state.prependEmails];
1156
- } else if (response?.data) {
1157
- const data = response?.data;
1158
- if (!data) {
1159
- emailStore.setState({
1160
- prependEmails: []
1161
- });
1162
- }
1163
- const storedAttachments = uploaderStore.getState().attachments;
1164
- const row = Object.fromEntries(
1165
- Object.entries(data).map(([key, value]) => {
1166
- if (key === "hs_attachment_ids") {
1167
- return [
1168
- key,
1169
- resolveAttachmentsFromIds(value, storedAttachments)
1170
- ];
1171
- }
1172
- return [key, value?.value ?? value];
1173
- })
1174
- );
1175
- rows = [...state.prependEmails];
1176
- if (rows.length > 0) {
1177
- rows[0] = row;
1178
- } else {
1179
- rows.push(row);
1180
- }
1181
- }
1182
- emailStore.setState({
1183
- prependEmails: rows
1184
- });
1185
- },
1186
- clearPrependEmails() {
1187
- emailStore.setState({
1188
- prependEmails: []
1189
- });
1190
- actions2.clearAttachments();
1191
- },
1192
- async updatePrependEmail(response) {
1193
- const responseData = { ...response };
1194
- const state = emailStore.getState();
1195
- const prependEmails = state.prependEmails || [];
1196
- const email = response.data || null;
1197
- const storedAttachments = uploaderStore.getState().attachments;
1198
- const emails = prependEmails.map(
1199
- (item) => item?.hs_object_id === email?.hs_object_id?.value ? {
1200
- ...item,
1201
- ...Object.fromEntries(
1202
- Object.entries(email).map(([key, value]) => {
1203
- if (key === "hs_attachment_ids") {
1204
- return [
1205
- key,
1206
- resolveAttachmentsFromIds(value, storedAttachments)
1207
- ];
1208
- }
1209
- return [key, value?.value ?? value];
1210
- })
1211
- )
1212
- } : item
1213
- );
1214
- emailStore.setState({
1215
- prependEmails: emails
1216
- });
1217
- if (responseData?.data?.hs_attachment_ids != null) {
1218
- const emailObjectId = email?.hs_object_id?.value;
1219
- const rows = state.emails?.data?.results?.rows ?? [];
1220
- const matchingRow = rows.find(
1221
- (row) => String(row.hs_object_id) === String(emailObjectId)
1222
- );
1223
- const originalPrependItem = prependEmails.find(
1224
- (item) => String(item?.hs_object_id) === String(emailObjectId)
1225
- );
1226
- const existingAttachments = matchingRow?.hs_attachment_ids ?? originalPrependItem?.hs_attachment_ids ?? [];
1227
- const newAttachments = resolveAttachmentsFromIds(
1228
- responseData.data.hs_attachment_ids,
1229
- storedAttachments
1230
- );
1231
- const mergedAttachments = [
1232
- ...existingAttachments,
1233
- ...newAttachments.filter(
1234
- (attachment) => !existingAttachments.some(
1235
- (existing) => String(existing.id) === String(attachment.id)
1236
- )
1237
- )
1238
- ];
1239
- const stateUpdates = {};
1240
- if (matchingRow && state.emails?.data?.results) {
1241
- stateUpdates.emails = {
1242
- ...state.emails,
1243
- data: {
1244
- ...state.emails.data,
1245
- results: {
1246
- ...state.emails.data.results,
1247
- rows: rows.map(
1248
- (row) => String(row.hs_object_id) === String(emailObjectId) ? { ...row, hs_attachment_ids: mergedAttachments } : row
1249
- )
1250
- }
1251
- }
1252
- };
1253
- }
1254
- if (originalPrependItem) {
1255
- stateUpdates.prependEmails = prependEmails.map(
1256
- (item) => String(item?.hs_object_id) === String(emailObjectId) ? { ...item, hs_attachment_ids: mergedAttachments } : item
1257
- );
1258
- }
1259
- if (Object.keys(stateUpdates).length > 0) {
1260
- emailStore.setState(stateUpdates);
1261
- }
1262
- responseData.data.hs_attachment_ids = mergedAttachments;
1263
- }
1264
- return responseData;
1265
- }
1266
- };
1267
-
1268
- // src/store2/use-sync.ts
1269
- var syncStore = createStore2({
1270
- apiSync: false,
1271
- sync: false,
1272
- isSyncLoading: false,
1273
- isSyncDisable: false
1274
- });
1275
- var actions5 = {
1276
- setIsSyncLoading(status) {
1277
- syncStore.setState({
1278
- isSyncLoading: status,
1279
- sync: status
1280
- });
1281
- },
1282
- setSync(status) {
1283
- resetAllStore();
1284
- syncStore.setState({
1285
- isSyncLoading: status,
1286
- sync: status
1287
- });
1288
- },
1289
- setApiSync(status) {
1290
- syncStore.setState({
1291
- isSyncLoading: status,
1292
- apiSync: status
1293
- });
1294
- },
1295
- setSyncDisable(status) {
1296
- syncStore.setState({
1297
- isSyncDisable: status
1298
- });
1299
- }
1300
- };
1301
- var resetAllStore = () => {
1302
- actions.clearTablePrependData();
1303
- actions3.clearPrependNotes();
1304
- actions4.clearPrependEmails();
1305
- };
1306
-
1307
- // src/store2/use-multi-object.ts
1308
- var multiObjectStore = createStore2({
1309
- objects: {},
1310
- objectsPrependData: {},
1311
- meta: {}
1312
- });
1313
- function getObjectKey(payload) {
1314
- return String(payload?.hubspotObjectTypeId ?? "");
1315
- }
1316
- var actions6 = {
1317
- setMultiObjectData(response, payload) {
1318
- const key = getObjectKey(payload);
1319
- const state = multiObjectStore.getState();
1320
- const rows = response?.data?.results?.rows ?? [];
1321
- const rowIds = new Set(
1322
- rows.map((row) => row.id ?? row.hs_object_id).filter((id) => id != null && id !== "").map((id) => String(id))
1323
- );
1324
- let newPrependForKey = (state.objectsPrependData[key] ?? []).filter((item) => {
1325
- const itemId = item.id ?? item.hs_object_id;
1326
- if (itemId == null || itemId === "") return true;
1327
- return !rowIds.has(String(itemId));
1328
- });
1329
- const selectedPipeline = payload?.selectedPipeline ?? "";
1330
- const viewType = response?.info?.viewType ?? "";
1331
- const prevMeta = state.meta[key];
1332
- if (response?.data?.total < 1 || payload?.componentName) {
1333
- newPrependForKey = [];
1334
- }
1335
- if (prevMeta?.viewType && prevMeta.viewType !== viewType) {
1336
- newPrependForKey = [];
1337
- }
1338
- if (prevMeta?.selectedPipeline && prevMeta.selectedPipeline !== selectedPipeline) {
1339
- newPrependForKey = [];
1340
- }
1341
- multiObjectStore.setState({
1342
- objects: { ...state.objects, [key]: response },
1343
- objectsPrependData: { ...state.objectsPrependData, [key]: newPrependForKey },
1344
- meta: {
1345
- ...state.meta,
1346
- [key]: { selectedPipeline, viewType }
1347
- }
1348
- });
1349
- },
1350
- clearMultiObjectPrependData(hubspotObjectTypeId) {
1351
- const state = multiObjectStore.getState();
1352
- if (!hubspotObjectTypeId) {
1353
- multiObjectStore.setState({ objectsPrependData: {} });
1354
- return;
1355
- }
1356
- const key = String(hubspotObjectTypeId);
1357
- const { [key]: _, ...rest } = state.objectsPrependData;
1358
- multiObjectStore.setState({ objectsPrependData: rest });
1359
- },
1360
- async setMultiObjectPrependData(response, props) {
1361
- const key = getObjectKey(props);
1362
- const state = multiObjectStore.getState();
1363
- const tableResponse = state.objects[key];
1364
- let rows = state.objectsPrependData[key] ?? [];
1365
- if (tableResponse?.data?.total > 1) {
1366
- if (response === "loading") {
1367
- const row = tableResponse?.data?.results?.columns.reduce(
1368
- (acc, item) => {
1369
- if (!item.hidden) {
1370
- acc[item.key] = "loading";
1371
- }
1372
- return acc;
1373
- },
1374
- {}
1375
- );
1376
- rows = [row, ...rows];
1377
- } else if (response?.data) {
1378
- const data = response?.data;
1379
- if (!data) {
1380
- multiObjectStore.setState({
1381
- objectsPrependData: { ...state.objectsPrependData, [key]: [] }
1382
- });
1383
- return;
1384
- }
1385
- const row = Object.fromEntries(
1386
- Object.entries(data).map(([k, value]) => [k, value?.value ?? value])
1387
- );
1388
- rows = [...rows];
1389
- if (rows.length > 0) {
1390
- rows[0] = row;
1391
- } else {
1392
- rows.push(row);
1393
- }
1394
- }
1395
- }
1396
- multiObjectStore.setState({
1397
- objectsPrependData: { ...state.objectsPrependData, [key]: rows }
1398
- });
1399
- }
1400
- };
1401
-
1402
- export { actions, actions2, actions3, actions4, actions5, actions6, breadcrumbStage, decodeToBase64, emailStore, generatePath, generateUrl, getParam, getParamDetails, getPath, getRouteDetails, getRouteMenu, isMessingParent, isMessingParentLastItem, multiObjectStore, noteStore, resetAllStore, syncStore, tableStore2 as tableStore, uploaderStore, useTable, useUpdateLink };
1403
- //# sourceMappingURL=chunk-B4J3MT7F.js.map
1404
- //# sourceMappingURL=chunk-B4J3MT7F.js.map