braid-ui 1.0.35 → 1.0.36

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.cjs CHANGED
@@ -10663,11 +10663,121 @@ var mockCounterpartiesList = [
10663
10663
  modified: "2023-12-28"
10664
10664
  }
10665
10665
  ];
10666
+ var CounterpartiesView = ({
10667
+ table,
10668
+ filters,
10669
+ onFilterChange,
10670
+ onResetFilters,
10671
+ onApplyFilters,
10672
+ onCreateCounterparty
10673
+ }) => {
10674
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col h-screen bg-gradient-subtle", children: [
10675
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-none border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "container mx-auto px-4 py-6 max-w-none", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
10676
+ /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-3xl font-bold text-foreground mb-2", children: "Counterparties" }) }),
10677
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
10678
+ /* @__PURE__ */ jsxRuntime.jsxs(Sheet, { children: [
10679
+ /* @__PURE__ */ jsxRuntime.jsx(SheetTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(Button, { variant: "outline", className: "gap-2", children: [
10680
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Filter, { className: "h-4 w-4" }),
10681
+ "Filters"
10682
+ ] }) }),
10683
+ /* @__PURE__ */ jsxRuntime.jsxs(SheetContent, { side: "right", className: "w-full sm:max-w-xl overflow-y-auto", children: [
10684
+ /* @__PURE__ */ jsxRuntime.jsx(SheetHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(SheetTitle, { children: "Counterparty Filters" }) }),
10685
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6 py-6", children: [
10686
+ /* @__PURE__ */ jsxRuntime.jsx(
10687
+ EnhancedInput,
10688
+ {
10689
+ label: "Name",
10690
+ value: filters.name,
10691
+ onChange: (e) => onFilterChange("name", e.target.value),
10692
+ placeholder: "Enter counterparty name"
10693
+ }
10694
+ ),
10695
+ /* @__PURE__ */ jsxRuntime.jsx(
10696
+ EnhancedSelect,
10697
+ {
10698
+ label: "Type",
10699
+ value: filters.type,
10700
+ onValueChange: (value) => onFilterChange("type", value),
10701
+ placeholder: "Select type",
10702
+ options: [
10703
+ { value: "BUSINESS", label: "Business" },
10704
+ { value: "INDIVIDUAL", label: "Individual" }
10705
+ ]
10706
+ }
10707
+ ),
10708
+ /* @__PURE__ */ jsxRuntime.jsx(
10709
+ EnhancedSelect,
10710
+ {
10711
+ label: "Status",
10712
+ value: filters.status,
10713
+ onValueChange: (value) => onFilterChange("status", value),
10714
+ placeholder: "Select status",
10715
+ options: [
10716
+ { value: "ACTIVE", label: "Active" },
10717
+ { value: "INACTIVE", label: "Inactive" },
10718
+ { value: "PENDING", label: "Pending" },
10719
+ { value: "SUSPENDED", label: "Suspended" }
10720
+ ]
10721
+ }
10722
+ ),
10723
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
10724
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
10725
+ /* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-sm font-medium", children: "Created Date Start" }),
10726
+ /* @__PURE__ */ jsxRuntime.jsx(
10727
+ DatePicker,
10728
+ {
10729
+ date: filters.createdDateStart,
10730
+ onDateChange: (date) => onFilterChange("createdDateStart", date),
10731
+ placeholder: "MM/DD/YYYY",
10732
+ buttonClassName: "w-full",
10733
+ className: "bg-background z-50"
10734
+ }
10735
+ )
10736
+ ] }),
10737
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
10738
+ /* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-sm font-medium", children: "Created Date End" }),
10739
+ /* @__PURE__ */ jsxRuntime.jsx(
10740
+ DatePicker,
10741
+ {
10742
+ date: filters.createdDateEnd,
10743
+ onDateChange: (date) => onFilterChange("createdDateEnd", date),
10744
+ placeholder: "MM/DD/YYYY",
10745
+ buttonClassName: "w-full",
10746
+ className: "bg-background z-50"
10747
+ }
10748
+ )
10749
+ ] })
10750
+ ] })
10751
+ ] }),
10752
+ /* @__PURE__ */ jsxRuntime.jsxs(SheetFooter, { className: "gap-2", children: [
10753
+ /* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "outline", onClick: onResetFilters, children: "Reset Filters" }),
10754
+ /* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: onApplyFilters, children: "Apply Filters" })
10755
+ ] })
10756
+ ] })
10757
+ ] }),
10758
+ /* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: onCreateCounterparty, children: "Create Counterparty" })
10759
+ ] })
10760
+ ] }) }) }),
10761
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "container mx-auto px-4 h-full max-w-none flex flex-col", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 mt-4 overflow-auto", children: table }) }) })
10762
+ ] });
10763
+ };
10764
+ var mockProducts3 = {
10765
+ "prod-001": "Business Banking Pro",
10766
+ "prod-002": "Premium Banking",
10767
+ "prod-003": "Business Banking Plus"
10768
+ };
10769
+ var mockBusinesses2 = {
10770
+ "bus-001": "Tech Solutions LLC",
10771
+ "bus-002": "Digital Ventures"
10772
+ };
10773
+ var mockIndividuals2 = {
10774
+ "ind-001": "Cloud Services Corp",
10775
+ "ind-002": "Wealth Management"
10776
+ };
10666
10777
  var Counterparties = () => {
10667
10778
  const navigate = reactRouterDom.useNavigate();
10668
10779
  const [searchParams] = reactRouterDom.useSearchParams();
10669
- const { counterparties: enrichedCounterparties, loading: loadingEntities } = useCounterpartyEntity(mockCounterpartiesList);
10670
- const [filteredCounterparties, setFilteredCounterparties] = React15.useState([]);
10780
+ const [counterparties, setCounterparties] = React15.useState([]);
10671
10781
  const [sortBy, setSortBy] = React15.useState("created");
10672
10782
  const [sortDirection, setSortDirection] = React15.useState("desc");
10673
10783
  const [filters, setFilters] = React15.useState({
@@ -10677,43 +10787,78 @@ var Counterparties = () => {
10677
10787
  createdDateStart: void 0,
10678
10788
  createdDateEnd: void 0
10679
10789
  });
10680
- const handleFilterChange = (field, value) => {
10681
- setFilters((prev) => ({ ...prev, [field]: value }));
10682
- };
10683
- const applyFilters = () => {
10684
- let filtered = enrichedCounterparties;
10790
+ React15.useEffect(() => {
10791
+ const enrichCounterparties = async () => {
10792
+ const enriched = await Promise.all(
10793
+ mockCounterpartiesList.map(async (counterparty) => {
10794
+ let associatedEntity = "";
10795
+ let entityType = null;
10796
+ if (counterparty.productId) {
10797
+ associatedEntity = mockProducts3[counterparty.productId] || counterparty.productId;
10798
+ entityType = "product";
10799
+ } else if (counterparty.businessId) {
10800
+ associatedEntity = mockBusinesses2[counterparty.businessId] || counterparty.businessId;
10801
+ entityType = "business";
10802
+ } else if (counterparty.individualId) {
10803
+ associatedEntity = mockIndividuals2[counterparty.individualId] || counterparty.individualId;
10804
+ entityType = "individual";
10805
+ } else if (counterparty.accountNumber) {
10806
+ associatedEntity = counterparty.accountNumber;
10807
+ entityType = "account";
10808
+ }
10809
+ return {
10810
+ ...counterparty,
10811
+ associatedEntity,
10812
+ entityType
10813
+ };
10814
+ })
10815
+ );
10816
+ setCounterparties(enriched);
10817
+ };
10818
+ enrichCounterparties();
10819
+ }, []);
10820
+ const filteredCounterparties = React15.useMemo(() => {
10821
+ const customerId = searchParams.get("customerId");
10822
+ let filtered = counterparties;
10823
+ if (customerId) {
10824
+ filtered = filtered.filter((cp) => cp.customerId === customerId);
10825
+ }
10685
10826
  if (filters.name) {
10686
10827
  filtered = filtered.filter(
10687
- (counterparty) => counterparty.name.toLowerCase().includes(filters.name.toLowerCase())
10828
+ (cp) => cp.name.toLowerCase().includes(filters.name.toLowerCase())
10688
10829
  );
10689
10830
  }
10690
10831
  if (filters.type) {
10691
- filtered = filtered.filter((counterparty) => counterparty.type === filters.type);
10832
+ filtered = filtered.filter((cp) => cp.type === filters.type);
10692
10833
  }
10693
10834
  if (filters.status) {
10694
- filtered = filtered.filter((counterparty) => counterparty.status === filters.status);
10835
+ filtered = filtered.filter((cp) => cp.status === filters.status);
10695
10836
  }
10696
10837
  if (filters.createdDateStart) {
10697
10838
  filtered = filtered.filter(
10698
- (counterparty) => new Date(counterparty.created) >= filters.createdDateStart
10839
+ (cp) => new Date(cp.created) >= filters.createdDateStart
10699
10840
  );
10700
10841
  }
10701
10842
  if (filters.createdDateEnd) {
10702
10843
  filtered = filtered.filter(
10703
- (counterparty) => new Date(counterparty.created) <= filters.createdDateEnd
10844
+ (cp) => new Date(cp.created) <= filters.createdDateEnd
10704
10845
  );
10705
10846
  }
10706
- setFilteredCounterparties(filtered);
10707
- };
10708
- React15.useEffect(() => {
10709
- const customerId = searchParams.get("customerId");
10710
- let filtered = enrichedCounterparties;
10711
- if (customerId) {
10712
- filtered = filtered.filter((cp) => cp.customerId === customerId);
10713
- }
10714
- setFilteredCounterparties(filtered);
10715
- }, [enrichedCounterparties, searchParams]);
10716
- const resetFilters = () => {
10847
+ return filtered;
10848
+ }, [counterparties, filters, searchParams]);
10849
+ const sortedCounterparties = React15.useMemo(() => {
10850
+ return [...filteredCounterparties].sort((a, b) => {
10851
+ const aValue = a[sortBy];
10852
+ const bValue = b[sortBy];
10853
+ if (aValue < bValue) return sortDirection === "asc" ? -1 : 1;
10854
+ if (aValue > bValue) return sortDirection === "asc" ? 1 : -1;
10855
+ return 0;
10856
+ });
10857
+ }, [filteredCounterparties, sortBy, sortDirection]);
10858
+ const handleFilterChange = React15.useCallback((field, value) => {
10859
+ setFilters((prev) => ({ ...prev, [field]: value }));
10860
+ }, []);
10861
+ const handleResetFilters = React15.useCallback(() => {
10717
10862
  setFilters({
10718
10863
  name: "",
10719
10864
  type: "",
@@ -10721,19 +10866,23 @@ var Counterparties = () => {
10721
10866
  createdDateStart: void 0,
10722
10867
  createdDateEnd: void 0
10723
10868
  });
10724
- setFilteredCounterparties(enrichedCounterparties);
10725
- };
10726
- const handleSort = (key) => {
10869
+ }, []);
10870
+ const handleApplyFilters = React15.useCallback(() => {
10871
+ }, []);
10872
+ const handleSort = React15.useCallback((key) => {
10727
10873
  if (sortBy === key) {
10728
- setSortDirection(sortDirection === "asc" ? "desc" : "asc");
10874
+ setSortDirection((prev) => prev === "asc" ? "desc" : "asc");
10729
10875
  } else {
10730
10876
  setSortBy(key);
10731
10877
  setSortDirection("asc");
10732
10878
  }
10733
- };
10734
- const handleRowClick = (counterparty) => {
10879
+ }, [sortBy]);
10880
+ const handleRowClick = React15.useCallback((counterparty) => {
10735
10881
  navigate(`/counterparty/${counterparty.id}`);
10736
- };
10882
+ }, [navigate]);
10883
+ const handleCreateCounterparty = React15.useCallback(() => {
10884
+ navigate("/counterparty/create");
10885
+ }, [navigate]);
10737
10886
  const columns3 = [
10738
10887
  {
10739
10888
  key: "name",
@@ -10786,112 +10935,28 @@ var Counterparties = () => {
10786
10935
  sortable: true
10787
10936
  }
10788
10937
  ];
10789
- const sortedCounterparties = [...filteredCounterparties].sort((a, b) => {
10790
- const aValue = a[sortBy];
10791
- const bValue = b[sortBy];
10792
- if (aValue < bValue) return sortDirection === "asc" ? -1 : 1;
10793
- if (aValue > bValue) return sortDirection === "asc" ? 1 : -1;
10794
- return 0;
10795
- });
10796
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col h-screen bg-gradient-subtle", children: [
10797
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-none border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "container mx-auto px-4 py-6 max-w-none", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
10798
- /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-3xl font-bold text-foreground mb-2", children: "Counterparties" }) }),
10799
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
10800
- /* @__PURE__ */ jsxRuntime.jsxs(Sheet, { children: [
10801
- /* @__PURE__ */ jsxRuntime.jsx(SheetTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(Button, { variant: "outline", className: "gap-2", children: [
10802
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Filter, { className: "h-4 w-4" }),
10803
- "Filters"
10804
- ] }) }),
10805
- /* @__PURE__ */ jsxRuntime.jsxs(SheetContent, { side: "right", className: "w-full sm:max-w-xl overflow-y-auto", children: [
10806
- /* @__PURE__ */ jsxRuntime.jsx(SheetHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(SheetTitle, { children: "Counterparty Filters" }) }),
10807
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6 py-6", children: [
10808
- /* @__PURE__ */ jsxRuntime.jsx(
10809
- EnhancedInput,
10810
- {
10811
- label: "Name",
10812
- value: filters.name,
10813
- onChange: (e) => handleFilterChange("name", e.target.value),
10814
- placeholder: "Enter counterparty name"
10815
- }
10816
- ),
10817
- /* @__PURE__ */ jsxRuntime.jsx(
10818
- EnhancedSelect,
10819
- {
10820
- label: "Type",
10821
- value: filters.type,
10822
- onValueChange: (value) => handleFilterChange("type", value),
10823
- placeholder: "Select type",
10824
- options: [
10825
- { value: "BUSINESS", label: "Business" },
10826
- { value: "INDIVIDUAL", label: "Individual" }
10827
- ]
10828
- }
10829
- ),
10830
- /* @__PURE__ */ jsxRuntime.jsx(
10831
- EnhancedSelect,
10832
- {
10833
- label: "Status",
10834
- value: filters.status,
10835
- onValueChange: (value) => handleFilterChange("status", value),
10836
- placeholder: "Select status",
10837
- options: [
10838
- { value: "ACTIVE", label: "Active" },
10839
- { value: "INACTIVE", label: "Inactive" },
10840
- { value: "PENDING", label: "Pending" },
10841
- { value: "SUSPENDED", label: "Suspended" }
10842
- ]
10843
- }
10844
- ),
10845
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
10846
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
10847
- /* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-sm font-medium", children: "Created Date Start" }),
10848
- /* @__PURE__ */ jsxRuntime.jsx(
10849
- DatePicker,
10850
- {
10851
- date: filters.createdDateStart,
10852
- onDateChange: (date) => handleFilterChange("createdDateStart", date),
10853
- placeholder: "MM/DD/YYYY",
10854
- buttonClassName: "w-full",
10855
- className: "bg-background z-50"
10856
- }
10857
- )
10858
- ] }),
10859
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
10860
- /* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-sm font-medium", children: "Created Date End" }),
10861
- /* @__PURE__ */ jsxRuntime.jsx(
10862
- DatePicker,
10863
- {
10864
- date: filters.createdDateEnd,
10865
- onDateChange: (date) => handleFilterChange("createdDateEnd", date),
10866
- placeholder: "MM/DD/YYYY",
10867
- buttonClassName: "w-full",
10868
- className: "bg-background z-50"
10869
- }
10870
- )
10871
- ] })
10872
- ] })
10873
- ] }),
10874
- /* @__PURE__ */ jsxRuntime.jsxs(SheetFooter, { className: "gap-2", children: [
10875
- /* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "outline", onClick: resetFilters, children: "Reset Filters" }),
10876
- /* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: applyFilters, children: "Apply Filters" })
10877
- ] })
10878
- ] })
10879
- ] }),
10880
- /* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: () => navigate("/counterparty/create"), children: "Create Counterparty" })
10881
- ] })
10882
- ] }) }) }),
10883
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "container mx-auto px-4 h-full max-w-none flex flex-col", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 mt-4 overflow-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
10884
- DataTable,
10885
- {
10886
- columns: columns3,
10887
- data: sortedCounterparties,
10888
- sortBy,
10889
- sortDirection,
10890
- onSort: handleSort,
10891
- onRowClick: handleRowClick
10892
- }
10893
- ) }) }) })
10894
- ] });
10938
+ const table = React15.useMemo(() => /* @__PURE__ */ jsxRuntime.jsx(
10939
+ DataTable,
10940
+ {
10941
+ columns: columns3,
10942
+ data: sortedCounterparties,
10943
+ sortBy,
10944
+ sortDirection,
10945
+ onSort: handleSort,
10946
+ onRowClick: handleRowClick
10947
+ }
10948
+ ), [columns3, sortedCounterparties, sortBy, sortDirection, handleSort, handleRowClick]);
10949
+ return /* @__PURE__ */ jsxRuntime.jsx(
10950
+ CounterpartiesView,
10951
+ {
10952
+ table,
10953
+ filters,
10954
+ onFilterChange: handleFilterChange,
10955
+ onResetFilters: handleResetFilters,
10956
+ onApplyFilters: handleApplyFilters,
10957
+ onCreateCounterparty: handleCreateCounterparty
10958
+ }
10959
+ );
10895
10960
  };
10896
10961
  var Counterparties_default = Counterparties;
10897
10962
  var mockCounterpartyTimeline = [