woodsportal-client-sdk 1.1.4-dev.52 → 1.1.4-dev.54

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