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.js CHANGED
@@ -10631,11 +10631,121 @@ var mockCounterpartiesList = [
10631
10631
  modified: "2023-12-28"
10632
10632
  }
10633
10633
  ];
10634
+ var CounterpartiesView = ({
10635
+ table,
10636
+ filters,
10637
+ onFilterChange,
10638
+ onResetFilters,
10639
+ onApplyFilters,
10640
+ onCreateCounterparty
10641
+ }) => {
10642
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col h-screen bg-gradient-subtle", children: [
10643
+ /* @__PURE__ */ jsx("div", { className: "flex-none border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60", children: /* @__PURE__ */ jsx("div", { className: "container mx-auto px-4 py-6 max-w-none", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
10644
+ /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("h1", { className: "text-3xl font-bold text-foreground mb-2", children: "Counterparties" }) }),
10645
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
10646
+ /* @__PURE__ */ jsxs(Sheet, { children: [
10647
+ /* @__PURE__ */ jsx(SheetTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(Button, { variant: "outline", className: "gap-2", children: [
10648
+ /* @__PURE__ */ jsx(Filter, { className: "h-4 w-4" }),
10649
+ "Filters"
10650
+ ] }) }),
10651
+ /* @__PURE__ */ jsxs(SheetContent, { side: "right", className: "w-full sm:max-w-xl overflow-y-auto", children: [
10652
+ /* @__PURE__ */ jsx(SheetHeader, { children: /* @__PURE__ */ jsx(SheetTitle, { children: "Counterparty Filters" }) }),
10653
+ /* @__PURE__ */ jsxs("div", { className: "space-y-6 py-6", children: [
10654
+ /* @__PURE__ */ jsx(
10655
+ EnhancedInput,
10656
+ {
10657
+ label: "Name",
10658
+ value: filters.name,
10659
+ onChange: (e) => onFilterChange("name", e.target.value),
10660
+ placeholder: "Enter counterparty name"
10661
+ }
10662
+ ),
10663
+ /* @__PURE__ */ jsx(
10664
+ EnhancedSelect,
10665
+ {
10666
+ label: "Type",
10667
+ value: filters.type,
10668
+ onValueChange: (value) => onFilterChange("type", value),
10669
+ placeholder: "Select type",
10670
+ options: [
10671
+ { value: "BUSINESS", label: "Business" },
10672
+ { value: "INDIVIDUAL", label: "Individual" }
10673
+ ]
10674
+ }
10675
+ ),
10676
+ /* @__PURE__ */ jsx(
10677
+ EnhancedSelect,
10678
+ {
10679
+ label: "Status",
10680
+ value: filters.status,
10681
+ onValueChange: (value) => onFilterChange("status", value),
10682
+ placeholder: "Select status",
10683
+ options: [
10684
+ { value: "ACTIVE", label: "Active" },
10685
+ { value: "INACTIVE", label: "Inactive" },
10686
+ { value: "PENDING", label: "Pending" },
10687
+ { value: "SUSPENDED", label: "Suspended" }
10688
+ ]
10689
+ }
10690
+ ),
10691
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
10692
+ /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
10693
+ /* @__PURE__ */ jsx("label", { className: "text-sm font-medium", children: "Created Date Start" }),
10694
+ /* @__PURE__ */ jsx(
10695
+ DatePicker,
10696
+ {
10697
+ date: filters.createdDateStart,
10698
+ onDateChange: (date) => onFilterChange("createdDateStart", date),
10699
+ placeholder: "MM/DD/YYYY",
10700
+ buttonClassName: "w-full",
10701
+ className: "bg-background z-50"
10702
+ }
10703
+ )
10704
+ ] }),
10705
+ /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
10706
+ /* @__PURE__ */ jsx("label", { className: "text-sm font-medium", children: "Created Date End" }),
10707
+ /* @__PURE__ */ jsx(
10708
+ DatePicker,
10709
+ {
10710
+ date: filters.createdDateEnd,
10711
+ onDateChange: (date) => onFilterChange("createdDateEnd", date),
10712
+ placeholder: "MM/DD/YYYY",
10713
+ buttonClassName: "w-full",
10714
+ className: "bg-background z-50"
10715
+ }
10716
+ )
10717
+ ] })
10718
+ ] })
10719
+ ] }),
10720
+ /* @__PURE__ */ jsxs(SheetFooter, { className: "gap-2", children: [
10721
+ /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: onResetFilters, children: "Reset Filters" }),
10722
+ /* @__PURE__ */ jsx(Button, { onClick: onApplyFilters, children: "Apply Filters" })
10723
+ ] })
10724
+ ] })
10725
+ ] }),
10726
+ /* @__PURE__ */ jsx(Button, { onClick: onCreateCounterparty, children: "Create Counterparty" })
10727
+ ] })
10728
+ ] }) }) }),
10729
+ /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "container mx-auto px-4 h-full max-w-none flex flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex-1 mt-4 overflow-auto", children: table }) }) })
10730
+ ] });
10731
+ };
10732
+ var mockProducts3 = {
10733
+ "prod-001": "Business Banking Pro",
10734
+ "prod-002": "Premium Banking",
10735
+ "prod-003": "Business Banking Plus"
10736
+ };
10737
+ var mockBusinesses2 = {
10738
+ "bus-001": "Tech Solutions LLC",
10739
+ "bus-002": "Digital Ventures"
10740
+ };
10741
+ var mockIndividuals2 = {
10742
+ "ind-001": "Cloud Services Corp",
10743
+ "ind-002": "Wealth Management"
10744
+ };
10634
10745
  var Counterparties = () => {
10635
10746
  const navigate = useNavigate();
10636
10747
  const [searchParams] = useSearchParams();
10637
- const { counterparties: enrichedCounterparties, loading: loadingEntities } = useCounterpartyEntity(mockCounterpartiesList);
10638
- const [filteredCounterparties, setFilteredCounterparties] = useState([]);
10748
+ const [counterparties, setCounterparties] = useState([]);
10639
10749
  const [sortBy, setSortBy] = useState("created");
10640
10750
  const [sortDirection, setSortDirection] = useState("desc");
10641
10751
  const [filters, setFilters] = useState({
@@ -10645,43 +10755,78 @@ var Counterparties = () => {
10645
10755
  createdDateStart: void 0,
10646
10756
  createdDateEnd: void 0
10647
10757
  });
10648
- const handleFilterChange = (field, value) => {
10649
- setFilters((prev) => ({ ...prev, [field]: value }));
10650
- };
10651
- const applyFilters = () => {
10652
- let filtered = enrichedCounterparties;
10758
+ useEffect(() => {
10759
+ const enrichCounterparties = async () => {
10760
+ const enriched = await Promise.all(
10761
+ mockCounterpartiesList.map(async (counterparty) => {
10762
+ let associatedEntity = "";
10763
+ let entityType = null;
10764
+ if (counterparty.productId) {
10765
+ associatedEntity = mockProducts3[counterparty.productId] || counterparty.productId;
10766
+ entityType = "product";
10767
+ } else if (counterparty.businessId) {
10768
+ associatedEntity = mockBusinesses2[counterparty.businessId] || counterparty.businessId;
10769
+ entityType = "business";
10770
+ } else if (counterparty.individualId) {
10771
+ associatedEntity = mockIndividuals2[counterparty.individualId] || counterparty.individualId;
10772
+ entityType = "individual";
10773
+ } else if (counterparty.accountNumber) {
10774
+ associatedEntity = counterparty.accountNumber;
10775
+ entityType = "account";
10776
+ }
10777
+ return {
10778
+ ...counterparty,
10779
+ associatedEntity,
10780
+ entityType
10781
+ };
10782
+ })
10783
+ );
10784
+ setCounterparties(enriched);
10785
+ };
10786
+ enrichCounterparties();
10787
+ }, []);
10788
+ const filteredCounterparties = useMemo(() => {
10789
+ const customerId = searchParams.get("customerId");
10790
+ let filtered = counterparties;
10791
+ if (customerId) {
10792
+ filtered = filtered.filter((cp) => cp.customerId === customerId);
10793
+ }
10653
10794
  if (filters.name) {
10654
10795
  filtered = filtered.filter(
10655
- (counterparty) => counterparty.name.toLowerCase().includes(filters.name.toLowerCase())
10796
+ (cp) => cp.name.toLowerCase().includes(filters.name.toLowerCase())
10656
10797
  );
10657
10798
  }
10658
10799
  if (filters.type) {
10659
- filtered = filtered.filter((counterparty) => counterparty.type === filters.type);
10800
+ filtered = filtered.filter((cp) => cp.type === filters.type);
10660
10801
  }
10661
10802
  if (filters.status) {
10662
- filtered = filtered.filter((counterparty) => counterparty.status === filters.status);
10803
+ filtered = filtered.filter((cp) => cp.status === filters.status);
10663
10804
  }
10664
10805
  if (filters.createdDateStart) {
10665
10806
  filtered = filtered.filter(
10666
- (counterparty) => new Date(counterparty.created) >= filters.createdDateStart
10807
+ (cp) => new Date(cp.created) >= filters.createdDateStart
10667
10808
  );
10668
10809
  }
10669
10810
  if (filters.createdDateEnd) {
10670
10811
  filtered = filtered.filter(
10671
- (counterparty) => new Date(counterparty.created) <= filters.createdDateEnd
10812
+ (cp) => new Date(cp.created) <= filters.createdDateEnd
10672
10813
  );
10673
10814
  }
10674
- setFilteredCounterparties(filtered);
10675
- };
10676
- useEffect(() => {
10677
- const customerId = searchParams.get("customerId");
10678
- let filtered = enrichedCounterparties;
10679
- if (customerId) {
10680
- filtered = filtered.filter((cp) => cp.customerId === customerId);
10681
- }
10682
- setFilteredCounterparties(filtered);
10683
- }, [enrichedCounterparties, searchParams]);
10684
- const resetFilters = () => {
10815
+ return filtered;
10816
+ }, [counterparties, filters, searchParams]);
10817
+ const sortedCounterparties = useMemo(() => {
10818
+ return [...filteredCounterparties].sort((a, b) => {
10819
+ const aValue = a[sortBy];
10820
+ const bValue = b[sortBy];
10821
+ if (aValue < bValue) return sortDirection === "asc" ? -1 : 1;
10822
+ if (aValue > bValue) return sortDirection === "asc" ? 1 : -1;
10823
+ return 0;
10824
+ });
10825
+ }, [filteredCounterparties, sortBy, sortDirection]);
10826
+ const handleFilterChange = useCallback((field, value) => {
10827
+ setFilters((prev) => ({ ...prev, [field]: value }));
10828
+ }, []);
10829
+ const handleResetFilters = useCallback(() => {
10685
10830
  setFilters({
10686
10831
  name: "",
10687
10832
  type: "",
@@ -10689,19 +10834,23 @@ var Counterparties = () => {
10689
10834
  createdDateStart: void 0,
10690
10835
  createdDateEnd: void 0
10691
10836
  });
10692
- setFilteredCounterparties(enrichedCounterparties);
10693
- };
10694
- const handleSort = (key) => {
10837
+ }, []);
10838
+ const handleApplyFilters = useCallback(() => {
10839
+ }, []);
10840
+ const handleSort = useCallback((key) => {
10695
10841
  if (sortBy === key) {
10696
- setSortDirection(sortDirection === "asc" ? "desc" : "asc");
10842
+ setSortDirection((prev) => prev === "asc" ? "desc" : "asc");
10697
10843
  } else {
10698
10844
  setSortBy(key);
10699
10845
  setSortDirection("asc");
10700
10846
  }
10701
- };
10702
- const handleRowClick = (counterparty) => {
10847
+ }, [sortBy]);
10848
+ const handleRowClick = useCallback((counterparty) => {
10703
10849
  navigate(`/counterparty/${counterparty.id}`);
10704
- };
10850
+ }, [navigate]);
10851
+ const handleCreateCounterparty = useCallback(() => {
10852
+ navigate("/counterparty/create");
10853
+ }, [navigate]);
10705
10854
  const columns3 = [
10706
10855
  {
10707
10856
  key: "name",
@@ -10754,112 +10903,28 @@ var Counterparties = () => {
10754
10903
  sortable: true
10755
10904
  }
10756
10905
  ];
10757
- const sortedCounterparties = [...filteredCounterparties].sort((a, b) => {
10758
- const aValue = a[sortBy];
10759
- const bValue = b[sortBy];
10760
- if (aValue < bValue) return sortDirection === "asc" ? -1 : 1;
10761
- if (aValue > bValue) return sortDirection === "asc" ? 1 : -1;
10762
- return 0;
10763
- });
10764
- return /* @__PURE__ */ jsxs("div", { className: "flex flex-col h-screen bg-gradient-subtle", children: [
10765
- /* @__PURE__ */ jsx("div", { className: "flex-none border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60", children: /* @__PURE__ */ jsx("div", { className: "container mx-auto px-4 py-6 max-w-none", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
10766
- /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("h1", { className: "text-3xl font-bold text-foreground mb-2", children: "Counterparties" }) }),
10767
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
10768
- /* @__PURE__ */ jsxs(Sheet, { children: [
10769
- /* @__PURE__ */ jsx(SheetTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(Button, { variant: "outline", className: "gap-2", children: [
10770
- /* @__PURE__ */ jsx(Filter, { className: "h-4 w-4" }),
10771
- "Filters"
10772
- ] }) }),
10773
- /* @__PURE__ */ jsxs(SheetContent, { side: "right", className: "w-full sm:max-w-xl overflow-y-auto", children: [
10774
- /* @__PURE__ */ jsx(SheetHeader, { children: /* @__PURE__ */ jsx(SheetTitle, { children: "Counterparty Filters" }) }),
10775
- /* @__PURE__ */ jsxs("div", { className: "space-y-6 py-6", children: [
10776
- /* @__PURE__ */ jsx(
10777
- EnhancedInput,
10778
- {
10779
- label: "Name",
10780
- value: filters.name,
10781
- onChange: (e) => handleFilterChange("name", e.target.value),
10782
- placeholder: "Enter counterparty name"
10783
- }
10784
- ),
10785
- /* @__PURE__ */ jsx(
10786
- EnhancedSelect,
10787
- {
10788
- label: "Type",
10789
- value: filters.type,
10790
- onValueChange: (value) => handleFilterChange("type", value),
10791
- placeholder: "Select type",
10792
- options: [
10793
- { value: "BUSINESS", label: "Business" },
10794
- { value: "INDIVIDUAL", label: "Individual" }
10795
- ]
10796
- }
10797
- ),
10798
- /* @__PURE__ */ jsx(
10799
- EnhancedSelect,
10800
- {
10801
- label: "Status",
10802
- value: filters.status,
10803
- onValueChange: (value) => handleFilterChange("status", value),
10804
- placeholder: "Select status",
10805
- options: [
10806
- { value: "ACTIVE", label: "Active" },
10807
- { value: "INACTIVE", label: "Inactive" },
10808
- { value: "PENDING", label: "Pending" },
10809
- { value: "SUSPENDED", label: "Suspended" }
10810
- ]
10811
- }
10812
- ),
10813
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
10814
- /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
10815
- /* @__PURE__ */ jsx("label", { className: "text-sm font-medium", children: "Created Date Start" }),
10816
- /* @__PURE__ */ jsx(
10817
- DatePicker,
10818
- {
10819
- date: filters.createdDateStart,
10820
- onDateChange: (date) => handleFilterChange("createdDateStart", date),
10821
- placeholder: "MM/DD/YYYY",
10822
- buttonClassName: "w-full",
10823
- className: "bg-background z-50"
10824
- }
10825
- )
10826
- ] }),
10827
- /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
10828
- /* @__PURE__ */ jsx("label", { className: "text-sm font-medium", children: "Created Date End" }),
10829
- /* @__PURE__ */ jsx(
10830
- DatePicker,
10831
- {
10832
- date: filters.createdDateEnd,
10833
- onDateChange: (date) => handleFilterChange("createdDateEnd", date),
10834
- placeholder: "MM/DD/YYYY",
10835
- buttonClassName: "w-full",
10836
- className: "bg-background z-50"
10837
- }
10838
- )
10839
- ] })
10840
- ] })
10841
- ] }),
10842
- /* @__PURE__ */ jsxs(SheetFooter, { className: "gap-2", children: [
10843
- /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: resetFilters, children: "Reset Filters" }),
10844
- /* @__PURE__ */ jsx(Button, { onClick: applyFilters, children: "Apply Filters" })
10845
- ] })
10846
- ] })
10847
- ] }),
10848
- /* @__PURE__ */ jsx(Button, { onClick: () => navigate("/counterparty/create"), children: "Create Counterparty" })
10849
- ] })
10850
- ] }) }) }),
10851
- /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "container mx-auto px-4 h-full max-w-none flex flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex-1 mt-4 overflow-auto", children: /* @__PURE__ */ jsx(
10852
- DataTable,
10853
- {
10854
- columns: columns3,
10855
- data: sortedCounterparties,
10856
- sortBy,
10857
- sortDirection,
10858
- onSort: handleSort,
10859
- onRowClick: handleRowClick
10860
- }
10861
- ) }) }) })
10862
- ] });
10906
+ const table = useMemo(() => /* @__PURE__ */ jsx(
10907
+ DataTable,
10908
+ {
10909
+ columns: columns3,
10910
+ data: sortedCounterparties,
10911
+ sortBy,
10912
+ sortDirection,
10913
+ onSort: handleSort,
10914
+ onRowClick: handleRowClick
10915
+ }
10916
+ ), [columns3, sortedCounterparties, sortBy, sortDirection, handleSort, handleRowClick]);
10917
+ return /* @__PURE__ */ jsx(
10918
+ CounterpartiesView,
10919
+ {
10920
+ table,
10921
+ filters,
10922
+ onFilterChange: handleFilterChange,
10923
+ onResetFilters: handleResetFilters,
10924
+ onApplyFilters: handleApplyFilters,
10925
+ onCreateCounterparty: handleCreateCounterparty
10926
+ }
10927
+ );
10863
10928
  };
10864
10929
  var Counterparties_default = Counterparties;
10865
10930
  var mockCounterpartyTimeline = [