woodsportal-client-sdk 1.1.4-dev.30 → 1.1.4-dev.31

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/dist/index.js CHANGED
@@ -1,9 +1,7 @@
1
- import { actions, actions2, actions3 } from './chunk-3OQK7XCZ.js';
2
- import { ensureValidRefresh, HUBSPOT_DATA, PORTAL_ID, DEV_PORTAL_ID, HUB_ID, setRefreshCallback, getAccessToken, setRefreshToken, setAccessToken, isAuthenticateApp, isExpiresAccessToken, isCookieExpired, getRefreshToken, DEV_API_URL, setPortal, setSubscriptionType, setLoggedInDetails, clearAccessToken, removeAllCookie, getCookie } from './chunk-FLWPTIGZ.js';
3
- import { __export } from './chunk-PZ5AY32C.js';
1
+ import { getParamDetails, useUpdateLink, useTable, getRouteDetails, actions, actions2, actions3, getParam, decodeToBase64, generatePath, getPath, getRouteMenu, breadcrumbStage, isMessingParentLastItem, isMessingParent, generateUrl } from './chunk-RDCT25UV.js';
2
+ import { ensureValidRefresh, HUBSPOT_DATA, PORTAL_ID, DEV_PORTAL_ID, HUB_ID, setRefreshCallback, getAccessToken, setRefreshToken, setAccessToken, isAuthenticateApp, isExpiresAccessToken, getRefreshToken, DEV_API_URL, setPortal, setSubscriptionType, setLoggedInDetails, clearAccessToken } from './chunk-YLZA5S7A.js';
3
+ import { __export, isCookieExpired, removeAllCookie } from './chunk-NB7AINV4.js';
4
4
  import axios from 'axios';
5
- import pako from 'pako';
6
- import { Base64 } from 'js-base64';
7
5
 
8
6
  // src/client/index.ts
9
7
  var client_exports = {};
@@ -336,350 +334,6 @@ var setProfileData = (data) => {
336
334
  var getProfileData = () => {
337
335
  return PROFILE;
338
336
  };
339
- function convertToBase64(obj) {
340
- try {
341
- if (!obj) return "";
342
- const json = JSON.stringify(obj);
343
- const compressed = pako.deflate(json);
344
- const base64 = Base64.fromUint8Array(compressed, true);
345
- return base64;
346
- } catch (error) {
347
- console.error("Failed to encode object:", error);
348
- return "";
349
- }
350
- }
351
- function decodeToBase64(encoded) {
352
- try {
353
- if (!encoded) return null;
354
- const uint8Array = Base64.toUint8Array(encoded);
355
- const decompressed = pako.inflate(uint8Array, { to: "string" });
356
- return JSON.parse(decompressed);
357
- } catch (error) {
358
- console.error("Failed to decode object:", error);
359
- return null;
360
- }
361
- }
362
-
363
- // src/breadcrumb/url-utils.ts
364
- function mapKeysDeep(obj, keyMap2) {
365
- if (Array.isArray(obj)) {
366
- return obj.map((item) => mapKeysDeep(item, keyMap2));
367
- } else if (obj !== null && typeof obj === "object") {
368
- return Object.entries(obj).reduce((acc, [key, value]) => {
369
- const mappedKey = keyMap2[key] || key;
370
- acc[mappedKey] = mapKeysDeep(value, keyMap2);
371
- return acc;
372
- }, {});
373
- }
374
- return obj;
375
- }
376
- function isMessingParent(breadcrumbs) {
377
- let lastItem = breadcrumbs[breadcrumbs.length - 1];
378
- let lastItem2 = breadcrumbs[breadcrumbs.length - 2];
379
- let lastItem3 = breadcrumbs[breadcrumbs.length - 3];
380
- return lastItem?.o_r_id && (!lastItem2?.o_r_id && lastItem2?.o_t_id) && lastItem3?.o_r_id ? true : false;
381
- }
382
- function isMessingParentLastItem(breadcrumbs) {
383
- let lastItem = breadcrumbs[breadcrumbs.length - 1];
384
- let lastItem2 = breadcrumbs[breadcrumbs.length - 2];
385
- return !lastItem?.o_t_id && (lastItem2?.o_r_id && lastItem2?.o_t_id) ? false : true;
386
- }
387
- function breadcrumbStage(breadcrumbItems) {
388
- let breadcrumbType = "child";
389
- if (breadcrumbItems.length === 1) {
390
- breadcrumbType = "root";
391
- } else if (breadcrumbItems.length === 2) {
392
- breadcrumbType = "root_details";
393
- }
394
- return breadcrumbType;
395
- }
396
- var generateUrl = (props, breadcrumbs) => {
397
- const newBase64 = convertToBase64(breadcrumbs);
398
- let url2 = "";
399
- if (props?.objectTypeId && props?.recordId) {
400
- url2 = `/${props?.recordId}/${props?.objectTypeId}/${props?.recordId}?b=${newBase64}`;
401
- } else {
402
- url2 = `/association/${props?.objectTypeId}?b=${newBase64}`;
403
- }
404
- return url2;
405
- };
406
- function getTotalParentLength(data) {
407
- return data.filter(
408
- (item) => (item.pt || item.o_t_id) && !item.o_r_id
409
- ).length;
410
- }
411
- var generatePath = (breadcrumbs, breadcrumb, index) => {
412
- const bc = convertToBase64(breadcrumbs.slice(0, index + 1));
413
- if (index === 0) {
414
- return {
415
- name: breadcrumb?.n,
416
- path: `/${breadcrumb?.pt || breadcrumb?.o_t_id}?b=${bc}`
417
- };
418
- } else if (index === 1) {
419
- if (breadcrumb?.isHome) {
420
- return {
421
- name: breadcrumb?.n,
422
- path: `/association/${breadcrumb?.o_t_id}?b=${bc}`
423
- };
424
- }
425
- return {
426
- name: breadcrumb?.n,
427
- path: `/${breadcrumb?.o_r_id}/${breadcrumb?.o_t_id}/${breadcrumb?.o_r_id}?b=${bc}`
428
- };
429
- } else {
430
- if (breadcrumb?.o_t_id && breadcrumb?.o_r_id && !breadcrumb?.isHome) {
431
- return {
432
- name: breadcrumb?.n,
433
- path: `/${breadcrumb?.o_r_id}/${breadcrumb?.o_t_id}/${breadcrumb?.o_r_id}?b=${bc}`
434
- };
435
- } else {
436
- return {
437
- name: breadcrumb?.n,
438
- path: `/association/${breadcrumb?.o_t_id}?b=${bc}`
439
- };
440
- }
441
- }
442
- };
443
-
444
- // src/breadcrumb/key-map.ts
445
- var keyMap = {
446
- dp: "defPermissions",
447
- n: "name",
448
- sort: "sort",
449
- o_t_id: "objectTypeId",
450
- s: "search",
451
- fPn: "filterPropertyName",
452
- fO: "filterOperator",
453
- fV: "filterValue",
454
- c: "cache",
455
- isPC: "isPrimaryCompany",
456
- v: "view",
457
- l: "limit",
458
- pt: "path",
459
- p: "page",
460
- a: "after",
461
- aPip: "activePipeline",
462
- aT: "activeTab",
463
- cT: "create",
464
- dP: "display",
465
- dL: "display_label",
466
- pId: "pipeline_id"
467
- };
468
-
469
- // src/utils/param.ts
470
- function getParam(paramName) {
471
- if (typeof globalThis === "undefined" || !globalThis.location) return null;
472
- const hash = globalThis.location.hash || "";
473
- if (!hash.startsWith("#/")) return null;
474
- const hashWithoutHash = hash.startsWith("#") ? hash.substring(1) : hash;
475
- const queryString = hashWithoutHash.split("?")[1];
476
- if (!queryString) return null;
477
- const params = new URLSearchParams(queryString);
478
- return params.get(paramName);
479
- }
480
- function getPath() {
481
- if (typeof globalThis === "undefined" || !globalThis.location) return null;
482
- const hash = globalThis.location.hash || "";
483
- if (!hash.startsWith("#/")) return null;
484
- return hash.slice(1).split("?")[0];
485
- }
486
-
487
- // src/breadcrumb/param.ts
488
- var getRouteMenu = (path) => {
489
- const apiRoutes = globalThis?.apiRoutes || [];
490
- return apiRoutes.find((menu) => menu?.path === path);
491
- };
492
- var getRouteDetails = () => {
493
- const search = getParam("b");
494
- const breadcrumbs = decodeToBase64(search) || [];
495
- const lastItem = breadcrumbs[breadcrumbs.length - 1];
496
- const mapped = lastItem ? mapKeysDeep(lastItem, keyMap) : null;
497
- return { routeDetails: mapped };
498
- };
499
- var getParamDetails = (props, isDetailsPage = false) => {
500
- const search = getParam("b");
501
- let breadcrumbs = decodeToBase64(search) || [];
502
- if (breadcrumbs.length > 0 && breadcrumbs?.[0]?.isHome) {
503
- breadcrumbs = breadcrumbs.slice(1);
504
- }
505
- let mediatorObjectTypeId = "";
506
- let mediatorObjectRecordId = "";
507
- let parentObjectTypeId = "";
508
- let parentObjectRecordId = "";
509
- let lastItem = breadcrumbs[breadcrumbs.length - 1];
510
- const lastItem2 = breadcrumbs[breadcrumbs.length - 2];
511
- const lastItem3 = breadcrumbs[breadcrumbs.length - 3];
512
- if (isDetailsPage === true && lastItem && "prm" in lastItem) {
513
- delete lastItem.prm;
514
- }
515
- if (breadcrumbs.length > 1) {
516
- if (props?.type === "ticket" || props?.type === "association") {
517
- mediatorObjectTypeId = breadcrumbs[1]?.o_t_id || "";
518
- mediatorObjectRecordId = breadcrumbs[1]?.o_r_id || "";
519
- parentObjectTypeId = lastItem?.o_t_id || "";
520
- parentObjectRecordId = lastItem?.o_r_id || "";
521
- } else {
522
- if (breadcrumbs.length > 2) {
523
- mediatorObjectTypeId = breadcrumbs[1]?.o_t_id || "";
524
- mediatorObjectRecordId = breadcrumbs[1]?.o_r_id || "";
525
- }
526
- if (!lastItem?.o_r_id && breadcrumbs.length > 2) {
527
- parentObjectTypeId = lastItem2?.o_t_id || "";
528
- parentObjectRecordId = lastItem2?.o_r_id || "";
529
- }
530
- if (lastItem?.o_r_id && breadcrumbs.length > 2) {
531
- parentObjectTypeId = lastItem3?.o_t_id || "";
532
- parentObjectRecordId = lastItem3?.o_r_id || "";
533
- }
534
- if (lastItem2?.o_t_id === "0-5" && !parentObjectTypeId && !parentObjectRecordId) {
535
- parentObjectTypeId = lastItem2?.o_t_id || "";
536
- parentObjectRecordId = lastItem2?.o_r_id || "";
537
- }
538
- }
539
- }
540
- let paramsObject = {};
541
- if (breadcrumbs[0]?.prm?.isPC || breadcrumbs[1]?.prm?.isPC || lastItem?.prm?.isPC) {
542
- paramsObject["isPrimaryCompany"] = true;
543
- }
544
- if (parentObjectTypeId && parentObjectRecordId) {
545
- paramsObject["parentObjectTypeId"] = parentObjectTypeId;
546
- paramsObject["parentObjectRecordId"] = parentObjectRecordId;
547
- }
548
- if (mediatorObjectTypeId && mediatorObjectRecordId) {
549
- paramsObject["mediatorObjectTypeId"] = mediatorObjectTypeId;
550
- paramsObject["mediatorObjectRecordId"] = mediatorObjectRecordId;
551
- }
552
- const mappedLastItemParam = Object.fromEntries(
553
- Object.entries(lastItem?.prm || {}).map(([key, value]) => [
554
- keyMap[key] || key,
555
- // use mapped name if exists, else keep original
556
- value
557
- ])
558
- );
559
- let queryString = null;
560
- if (props?.type === "association") {
561
- queryString = new URLSearchParams({ ...paramsObject, ...{ cache: false } }).toString();
562
- } else {
563
- queryString = new URLSearchParams({ ...paramsObject, ...mappedLastItemParam }).toString();
564
- }
565
- let params = queryString ? `?${queryString}` : "";
566
- const totalParentLength = getTotalParentLength(breadcrumbs);
567
- let parentAccessLabel = false;
568
- if (breadcrumbs[0]?.prm?.isPC && totalParentLength > 2 || // company object
569
- !breadcrumbs[0]?.prm?.isPC && totalParentLength > 3 || // normal object
570
- breadcrumbs[0]?.prm?.isPC && totalParentLength > 1 && props?.type === "ticket" || // company ticket
571
- !breadcrumbs[0]?.prm?.isPC && totalParentLength > 2 && props?.type === "ticket") {
572
- parentAccessLabel = true;
573
- }
574
- return {
575
- breadcrumbs,
576
- // paramsObject: Object.keys(mParamsObject).length === 0 ? null : mParamsObject,
577
- paramsObject,
578
- params,
579
- parentAccessLabel
580
- };
581
- };
582
-
583
- // src/breadcrumb/url.ts
584
- var useUpdateLink = () => {
585
- const updateLink = async (props, displayName = "prm") => {
586
- const search = getParam("b");
587
- const pathname = getPath();
588
- let breadcrumbs = decodeToBase64(search) || [];
589
- if (breadcrumbs.length < 1) {
590
- const routeMenu = getRouteMenu(pathname);
591
- breadcrumbs = [
592
- {
593
- n: routeMenu?.title,
594
- pt: routeMenu?.path
595
- }
596
- ];
597
- }
598
- const lastBreadcrumb = breadcrumbs[breadcrumbs.length - 1];
599
- if (displayName) {
600
- const ex = await getDeep(lastBreadcrumb, displayName) || {};
601
- await setDeep(lastBreadcrumb, displayName, {
602
- ...ex,
603
- ...props
604
- });
605
- } else {
606
- await Object.assign(lastBreadcrumb, props);
607
- }
608
- const newBase64 = convertToBase64(breadcrumbs);
609
- updateBParam(newBase64);
610
- };
611
- function setDeep(obj, path, value) {
612
- const keys = path.split(".");
613
- let curr = obj;
614
- for (let i = 0; i < keys.length - 1; i++) {
615
- if (!curr[keys[i]] || typeof curr[keys[i]] !== "object") {
616
- curr[keys[i]] = {};
617
- }
618
- curr = curr[keys[i]];
619
- }
620
- curr[keys[keys.length - 1]] = value;
621
- return curr;
622
- }
623
- function getDeep(obj, path) {
624
- return path.split(".").reduce((acc, key) => acc?.[key], obj);
625
- }
626
- const getLinkParams = (displayName = "prm") => {
627
- const search = getParam("b");
628
- let breadcrumbs = decodeToBase64(search) || [];
629
- if (breadcrumbs.length < 1) return null;
630
- const lastItem = breadcrumbs[breadcrumbs.length - 1];
631
- const getDeep2 = (obj, path) => {
632
- return path.split(".").reduce((acc, key) => acc?.[key], obj);
633
- };
634
- const expandKeys = (obj) => {
635
- return Object.fromEntries(
636
- Object.entries(obj).map(([key, value]) => [
637
- keyMap[key] || key,
638
- // map if exists, else keep original
639
- value
640
- ])
641
- );
642
- };
643
- const nestedValue = displayName ? getDeep2(lastItem, displayName) : null;
644
- const output = nestedValue ? expandKeys(nestedValue) : null;
645
- return output;
646
- };
647
- const filterParams = (displayName = "prm") => {
648
- const search = getParam("b");
649
- let breadcrumbs = decodeToBase64(search) || [];
650
- if (breadcrumbs.length < 1) return null;
651
- const lastItem = breadcrumbs[breadcrumbs.length - 1];
652
- const getDeep2 = (obj, path) => {
653
- return path.split(".").reduce((acc, key) => acc?.[key], obj);
654
- };
655
- const expandKeys = (obj) => {
656
- return Object.fromEntries(
657
- Object.entries(obj).map(([key, value]) => [
658
- keyMap[key] || key,
659
- // map if exists, else keep original
660
- value
661
- ])
662
- );
663
- };
664
- const nestedValue = displayName ? getDeep2(lastItem, displayName) : null;
665
- const output = nestedValue ? expandKeys(nestedValue) : expandKeys(lastItem);
666
- return output;
667
- };
668
- return { updateLink, getLinkParams, filterParams };
669
- };
670
- var updateBParam = (newValue) => {
671
- if (typeof globalThis === "undefined" || !globalThis.location) return;
672
- const hash = globalThis.location.hash || "";
673
- if (!hash.startsWith("#/")) return;
674
- const withoutHash = hash.slice(2);
675
- const [path, queryString] = withoutHash.split("?");
676
- const params = new URLSearchParams(queryString || "");
677
- params.set("b", newValue);
678
- const newHash = `#/${path}?${params.toString()}`;
679
- if (typeof globalThis !== "undefined" && globalThis.history && globalThis.history.replaceState) {
680
- globalThis.history.replaceState(null, "", newHash);
681
- }
682
- };
683
337
 
684
338
  // src/client/index.ts
685
339
  var recordWriteContext = (paramsObject) => {
@@ -835,6 +489,16 @@ var Client = {
835
489
  param.parentObjectTypeId = parentObjectTypeId;
836
490
  }
837
491
  param.parentAccessLabel = parentAccessLabel;
492
+ const {
493
+ stageId,
494
+ nextPage
495
+ } = useTable();
496
+ if (stageId) {
497
+ param.stageId = stageId;
498
+ }
499
+ if (param?.view === "BOARD") {
500
+ param.page = nextPage;
501
+ }
838
502
  const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS, params, queryParams: param });
839
503
  return HttpClient.get(apiUrl);
840
504
  },
@@ -1389,284 +1053,6 @@ function changePassword(options) {
1389
1053
  };
1390
1054
  }
1391
1055
 
1392
- // src/store/index.ts
1393
- function createStore(initializer) {
1394
- let state;
1395
- const listeners = /* @__PURE__ */ new Set();
1396
- const get = () => state;
1397
- const set = (partial) => {
1398
- const prevState = state;
1399
- const partialState = typeof partial === "function" ? partial(state) : partial;
1400
- state = {
1401
- ...state,
1402
- ...partialState
1403
- };
1404
- listeners.forEach(
1405
- (listener) => listener(state, prevState)
1406
- );
1407
- };
1408
- const subscribe = (listener) => {
1409
- listeners.add(listener);
1410
- return () => listeners.delete(listener);
1411
- };
1412
- state = initializer(set, get);
1413
- return {
1414
- getState: get,
1415
- setState: set,
1416
- subscribe
1417
- };
1418
- }
1419
-
1420
- // src/utils/getCookieData.ts
1421
- var getAuthSubscriptionType = () => {
1422
- return getCookie("subscriptionType");
1423
- };
1424
-
1425
- // src/store/use-table.ts
1426
- var pageLimit = 10;
1427
- var tableStore = createStore((set, get) => ({
1428
- // ==============================
1429
- // STATE
1430
- // ==============================
1431
- tableUniqueId: null,
1432
- gridData: [],
1433
- sort: "-hs_createdate",
1434
- limit: 10,
1435
- after: "",
1436
- page: 1,
1437
- totalItems: 1,
1438
- numOfPages: 1,
1439
- currentPage: 1,
1440
- search: "",
1441
- filterPropertyName: "hs_pipeline",
1442
- filterOperator: "eq",
1443
- filterValue: "",
1444
- isPrimaryCompany: null,
1445
- view: null,
1446
- selectedPipeline: "",
1447
- tableParam: {},
1448
- tableDefPermissions: {},
1449
- tableData: [],
1450
- tablePrependData: [],
1451
- // ==============================
1452
- // BASIC SETTERS
1453
- // ==============================
1454
- setTableUniqueId: (v) => set({ tableUniqueId: v }),
1455
- setSort: (v) => set({ sort: v }),
1456
- setLimit: (v) => set({ limit: v }),
1457
- setAfter: (v) => set({ after: v }),
1458
- setPage: (v) => set({ page: v }),
1459
- setTotalItems: (v) => set({ totalItems: v }),
1460
- setNumOfPages: (v) => set({ numOfPages: v }),
1461
- setCurrentPage: (v) => set({ currentPage: v }),
1462
- setSearch: (v) => set({ search: v }),
1463
- setFilterPropertyName: (v) => set({ filterPropertyName: v }),
1464
- setFilterOperator: (v) => set({ filterOperator: v }),
1465
- setFilterValue: (v) => set({ filterValue: v }),
1466
- setIsPrimaryCompany: (v) => set({ isPrimaryCompany: v }),
1467
- // ==============================
1468
- // VIEW
1469
- // ==============================
1470
- setView: (mView) => {
1471
- set({
1472
- page: getAuthSubscriptionType() === "FREE" ? "" : 1,
1473
- view: mView
1474
- });
1475
- },
1476
- // ==============================
1477
- // PIPELINE
1478
- // ==============================
1479
- changePipeline: (mView) => {
1480
- set({
1481
- page: getAuthSubscriptionType() === "FREE" ? "" : 1,
1482
- selectedPipeline: mView || ""
1483
- });
1484
- },
1485
- setSelectedPipeline: (pipelines, pipeLineId) => {
1486
- let filterValue = "";
1487
- if (pipeLineId) {
1488
- const pipelineSingle = pipelines.find(
1489
- (pipeline) => pipeline.pipelineId === pipeLineId
1490
- );
1491
- filterValue = pipelineSingle?.pipelineId || "";
1492
- }
1493
- set({
1494
- filterPropertyName: "hs_pipeline",
1495
- filterOperator: "eq",
1496
- filterValue,
1497
- selectedPipeline: filterValue
1498
- });
1499
- },
1500
- // ==============================
1501
- // RESET
1502
- // ==============================
1503
- resetTableParam: () => {
1504
- set({
1505
- sort: "-hs_createdate",
1506
- limit: pageLimit,
1507
- after: "",
1508
- page: getAuthSubscriptionType() === "FREE" ? "" : 1,
1509
- totalItems: 1,
1510
- numOfPages: 1,
1511
- currentPage: 1,
1512
- search: "",
1513
- filterPropertyName: "hs_pipeline",
1514
- filterOperator: "eq",
1515
- filterValue: "",
1516
- isPrimaryCompany: null,
1517
- selectedPipeline: ""
1518
- });
1519
- },
1520
- // ==============================
1521
- // PARAM BUILDER
1522
- // ==============================
1523
- getTableParam: (companyAsMediator, currentPageOverride) => {
1524
- const state = get();
1525
- const baseParams = {
1526
- sort: state.sort,
1527
- search: state.search,
1528
- filterPropertyName: state.filterPropertyName,
1529
- filterOperator: state.filterOperator,
1530
- filterValue: state.selectedPipeline,
1531
- cache: true,
1532
- isPrimaryCompany: companyAsMediator || false,
1533
- view: state.view
1534
- };
1535
- if (getAuthSubscriptionType() === "FREE") {
1536
- return {
1537
- ...baseParams,
1538
- after: state.page
1539
- };
1540
- }
1541
- return {
1542
- ...baseParams,
1543
- limit: state.limit,
1544
- page: currentPageOverride || state.page,
1545
- ...state.after && {
1546
- after: state.after
1547
- }
1548
- };
1549
- },
1550
- // ==============================
1551
- // GRID DATA
1552
- // ==============================
1553
- setGridData: async (type, deals) => {
1554
- if (type === "reset") {
1555
- await set({ gridData: [] });
1556
- return [];
1557
- }
1558
- if (type === "directly") {
1559
- await set({ gridData: deals });
1560
- return deals;
1561
- }
1562
- const finalData = await deals.map(
1563
- (deal) => {
1564
- const cards = deal?.data?.results?.rows?.map(
1565
- (row) => ({
1566
- id: row?.hs_object_id,
1567
- ...row,
1568
- hubspotObjectTypeId: type === "deals" ? "0-3" : "0-5"
1569
- })
1570
- ) || [];
1571
- return {
1572
- id: deal.id,
1573
- name: deal.label,
1574
- count: deal?.data?.total,
1575
- ...deal,
1576
- cards
1577
- };
1578
- }
1579
- );
1580
- await set({ gridData: finalData });
1581
- return finalData;
1582
- },
1583
- // ==============================
1584
- // DEFAULT PIPELINE
1585
- // ==============================
1586
- setDefaultPipeline(data, hubspotObjectTypeId) {
1587
- if (!data) {
1588
- set({ selectedPipeline: "" });
1589
- return "";
1590
- }
1591
- const { updateLink, filterParams } = useUpdateLink();
1592
- const params = filterParams();
1593
- const excludedIds = ["0-1", "0-2", "0-3", "0-4", "0-5"];
1594
- const state = get();
1595
- const view = state.view;
1596
- const selectedPipeline = state.selectedPipeline;
1597
- let defaultPipelineId = "";
1598
- let mFilterValue = "";
1599
- const defaultPipeline = data?.data?.[0];
1600
- if (excludedIds.includes(hubspotObjectTypeId)) {
1601
- defaultPipelineId = defaultPipeline?.pipelineId || "";
1602
- }
1603
- if (params && params?.filterPropertyName === "hs_pipeline" && params?.filterValue) {
1604
- mFilterValue = params.filterValue;
1605
- } else {
1606
- if (view === "BOARD" && !selectedPipeline) {
1607
- mFilterValue = defaultPipelineId;
1608
- updateLink({
1609
- fV: defaultPipelineId
1610
- });
1611
- } else if (!excludedIds.includes(hubspotObjectTypeId)) {
1612
- mFilterValue = selectedPipeline || null;
1613
- } else {
1614
- mFilterValue = data.data.length === 1 ? defaultPipelineId : selectedPipeline;
1615
- }
1616
- }
1617
- set({ selectedPipeline: mFilterValue });
1618
- return mFilterValue;
1619
- },
1620
- setTableData: (response) => {
1621
- set({
1622
- tableData: response
1623
- });
1624
- },
1625
- setTablePrependData: async (response) => {
1626
- const state = get();
1627
- let rows = [];
1628
- if (response === "loading") {
1629
- const row = await state.tableData?.data?.results?.columns.reduce((acc, item) => {
1630
- if (!item.hidden) {
1631
- acc[item.key] = "loading";
1632
- }
1633
- return acc;
1634
- }, {});
1635
- rows = [row, ...state.tablePrependData];
1636
- } else {
1637
- const data = response?.data;
1638
- if (!data) {
1639
- set({
1640
- tablePrependData: []
1641
- });
1642
- }
1643
- const row = await Object.fromEntries(
1644
- Object.entries(data).map(([key, value]) => [
1645
- key,
1646
- value?.value ?? value
1647
- ])
1648
- );
1649
- rows = [...state.tablePrependData];
1650
- if (rows.length > 0) {
1651
- rows[0] = row;
1652
- } else {
1653
- rows.push(row);
1654
- }
1655
- }
1656
- set({
1657
- tablePrependData: rows
1658
- });
1659
- return rows;
1660
- }
1661
- }));
1662
- function useTable() {
1663
- const tableState = tableStore.getState();
1664
- return {
1665
- ...tableState,
1666
- ...{ listeners: { subscribe: tableStore.subscribe } }
1667
- };
1668
- }
1669
-
1670
1056
  // src/apis/pipeline.ts
1671
1057
  function list(options) {
1672
1058
  const {
@@ -1705,15 +1091,14 @@ function list2(options) {
1705
1091
 
1706
1092
  // src/apis/object.ts
1707
1093
  function list3(options) {
1708
- const {
1709
- getTableParam
1710
- } = useTable();
1711
- const { setTableData } = actions;
1094
+ const { getTableParam } = useTable();
1095
+ const { setObjectsData, setTableData } = actions;
1712
1096
  const { mutate, isLoading } = createMutation(
1713
1097
  async (payload) => {
1714
1098
  const param = await getTableParam(payload?.companyAsMediator);
1715
1099
  const response = await Client.object.list(payload, param);
1716
- setTableData(response, payload);
1100
+ await setObjectsData(response);
1101
+ await setTableData(response, payload);
1717
1102
  return response;
1718
1103
  },
1719
1104
  options
@@ -1770,9 +1155,13 @@ function create(options) {
1770
1155
  const { setTablePrependData } = actions;
1771
1156
  const { mutate, isLoading } = createMutation(
1772
1157
  async (props) => {
1773
- if (props?.componentName != "association") await setTablePrependData("loading", props?.payload?.propertyPayload?.hs_pipeline_stage);
1158
+ if (props?.componentName != "association") await setTablePrependData("loading", props);
1774
1159
  const response = await Client.object.create(props);
1775
- if (props?.componentName != "association") await setTablePrependData(response, props?.payload?.propertyPayload?.hs_pipeline_stage);
1160
+ console.log(
1161
+ "props",
1162
+ props
1163
+ );
1164
+ if (props?.componentName != "association") await setTablePrependData(response, props);
1776
1165
  return response;
1777
1166
  },
1778
1167
  options