randmarcomps 1.357.0 → 1.358.0

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.
@@ -62455,13 +62455,14 @@ function ManufacturerCategorySummary({
62455
62455
  productsNumber: n = 0,
62456
62456
  autoreorder: o = !1,
62457
62457
  starred: l = !1,
62458
- isLoading: d = !1
62458
+ isLoading: d = !1,
62459
+ children: f
62459
62460
  }) {
62460
- return d ? /* @__PURE__ */ jsxs(Card, { className: "w-full max-w-lg mx-auto", children: [
62461
+ return d ? /* @__PURE__ */ jsxs(Card, { children: [
62461
62462
  /* @__PURE__ */ jsx(CardHeader, { className: "pb-4", children: /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between", children: [
62462
62463
  /* @__PURE__ */ jsx("div", { className: "space-y-1 flex-1", children: /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
62463
- /* @__PURE__ */ jsx("div", { className: "h-3 w-20 bg-muted rounded-md animate-pulse" }),
62464
- /* @__PURE__ */ jsx("div", { className: "h-5 w-40 bg-muted rounded-md animate-pulse" })
62464
+ /* @__PURE__ */ jsx("div", { className: "h-3 w-28 bg-muted rounded-md animate-pulse" }),
62465
+ /* @__PURE__ */ jsx("div", { className: "h-5 w-48 bg-muted rounded-md animate-pulse" })
62465
62466
  ] }) }),
62466
62467
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-end gap-1", children: [
62467
62468
  /* @__PURE__ */ jsx("div", { className: "h-3 w-12 bg-muted rounded-md animate-pulse" }),
@@ -62490,54 +62491,53 @@ function ManufacturerCategorySummary({
62490
62491
  ] })
62491
62492
  ] })
62492
62493
  ] })
62493
- ] }) : /* @__PURE__ */ jsxs(Card, { className: "w-full max-w-lg mx-auto", children: [
62494
- /* @__PURE__ */ jsx(CardHeader, { className: "pb-4", children: /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between", children: [
62495
- /* @__PURE__ */ jsx("div", { className: "space-y-1 flex-1", children: /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
62494
+ ] }) : /* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsxs(CardContent, { className: "grid grid-cols-[1fr_auto] items-start gap-4 pt-6", children: [
62495
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-start gap-4", children: [
62496
+ /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
62496
62497
  /* @__PURE__ */ jsx("p", { className: "text-xs font-medium text-muted-foreground uppercase tracking-wide", children: "Category Name" }),
62497
62498
  /* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold leading-none tracking-tight", children: t })
62498
- ] }) }),
62499
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-end gap-1", children: [
62500
- /* @__PURE__ */ jsx("p", { className: "text-xs font-medium text-muted-foreground uppercase tracking-wide", children: "Starred" }),
62501
- l ? /* @__PURE__ */ jsx(Star, { className: "h-5 w-5 fill-yellow-400 text-yellow-400" }) : /* @__PURE__ */ jsx(Star, { className: "h-5 w-5 text-muted-foreground" })
62502
- ] })
62503
- ] }) }),
62504
- /* @__PURE__ */ jsxs(CardContent, { className: "space-y-4", children: [
62499
+ ] }),
62505
62500
  /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
62506
62501
  /* @__PURE__ */ jsx("p", { className: "text-xs font-medium text-muted-foreground uppercase tracking-wide", children: "Niche" }),
62507
62502
  /* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: e })
62508
62503
  ] }),
62509
- /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-4", children: [
62510
- /* @__PURE__ */ jsxs("div", { className: "space-y-1 flex-1", children: [
62511
- /* @__PURE__ */ jsx("p", { className: "text-xs font-medium text-muted-foreground uppercase tracking-wide", children: "Products" }),
62512
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
62513
- /* @__PURE__ */ jsx(Package, { className: "h-4 w-4 text-muted-foreground" }),
62514
- /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: n })
62515
- ] })
62516
- ] }),
62517
- /* @__PURE__ */ jsxs("div", { className: "space-y-1 flex-1 flex flex-col items-end ", children: [
62518
- /* @__PURE__ */ jsx("p", { className: "text-xs font-medium text-muted-foreground uppercase tracking-wide", children: "Auto-reorder" }),
62519
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
62520
- o ? /* @__PURE__ */ jsx(RefreshCw, { className: "size-4 text-green-600" }) : /* @__PURE__ */ jsx(RefreshCwOff, { className: "size-4 text-amber-600" }),
62521
- /* @__PURE__ */ jsx(
62522
- Badge,
62523
- {
62524
- variant: o ? "default" : "secondary",
62525
- className: cn("text-xs", o ? "text-green-600 bg-green-100 hover:bg-green-200" : "text-amber-600 bg-amber-100 hover:bg-amber-200"),
62526
- children: o ? "Enabled" : "Disabled"
62527
- }
62528
- )
62529
- ] })
62504
+ /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
62505
+ /* @__PURE__ */ jsx("p", { className: "text-xs font-medium text-muted-foreground uppercase tracking-wide", children: "Products" }),
62506
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
62507
+ /* @__PURE__ */ jsx(Package, { className: "h-4 w-4 text-muted-foreground" }),
62508
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: n })
62509
+ ] })
62510
+ ] })
62511
+ ] }),
62512
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-end justify-between gap-4 h-full", children: [
62513
+ f,
62514
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-end gap-1", children: [
62515
+ /* @__PURE__ */ jsx("p", { className: "text-xs font-medium text-muted-foreground uppercase tracking-wide", children: "Starred" }),
62516
+ l ? /* @__PURE__ */ jsx(Star, { className: "h-5 w-5 fill-yellow-400 text-yellow-400" }) : /* @__PURE__ */ jsx(Star, { className: "h-5 w-5 text-muted-foreground" })
62517
+ ] }),
62518
+ /* @__PURE__ */ jsxs("div", { className: "space-y-1 flex flex-col items-end", children: [
62519
+ /* @__PURE__ */ jsx("p", { className: "text-xs font-medium text-muted-foreground uppercase tracking-wide", children: "Auto-reorder" }),
62520
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
62521
+ o ? /* @__PURE__ */ jsx(RefreshCw, { className: "size-4 text-green-600" }) : /* @__PURE__ */ jsx(RefreshCwOff, { className: "size-4 text-amber-600" }),
62522
+ /* @__PURE__ */ jsx(
62523
+ Badge,
62524
+ {
62525
+ variant: o ? "default" : "secondary",
62526
+ className: cn("text-xs", o ? "text-green-600 bg-green-100 hover:bg-green-200" : "text-amber-600 bg-amber-100 hover:bg-amber-200"),
62527
+ children: o ? "Enabled" : "Disabled"
62528
+ }
62529
+ )
62530
62530
  ] })
62531
62531
  ] })
62532
62532
  ] })
62533
- ] });
62533
+ ] }) });
62534
62534
  }
62535
62535
  function ManufacturerProducts({
62536
62536
  applicationId: t,
62537
62537
  manufacturer: e,
62538
62538
  shopifyHostName: n
62539
62539
  }) {
62540
- var I, V, q, z, Q, F, j, te, ne;
62540
+ var I, V, q, z, Q, F, j;
62541
62541
  const [o] = usePostV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeShopifyMutation(), [l, d] = useState(((V = (I = e.Categories) == null ? void 0 : I[0]) == null ? void 0 : V.CategoryCode) || ""), [f, g] = useState(!1), [b, S] = useState(!1), { toast: _ } = useToast(), {
62542
62542
  data: C,
62543
62543
  isLoading: E,
@@ -62563,8 +62563,8 @@ function ManufacturerProducts({
62563
62563
  description: "Category synced to Shopify successfully",
62564
62564
  variant: "success"
62565
62565
  });
62566
- } catch (oe) {
62567
- console.error("Error syncing to Shopify:", oe), _({
62566
+ } catch (te) {
62567
+ console.error("Error syncing to Shopify:", te), _({
62568
62568
  title: "Error",
62569
62569
  description: "Error syncing category to Shopify.",
62570
62570
  variant: "destructive"
@@ -62573,8 +62573,8 @@ function ManufacturerProducts({
62573
62573
  g(!1);
62574
62574
  }
62575
62575
  }, M = () => {
62576
- var oe, ge;
62577
- return ((ge = (oe = e.Categories) == null ? void 0 : oe.find((se) => se.CategoryCode === l)) == null ? void 0 : ge.CategoryName) || l;
62576
+ var te, ne;
62577
+ return ((ne = (te = e.Categories) == null ? void 0 : te.find((oe) => oe.CategoryCode === l)) == null ? void 0 : ne.CategoryName) || l;
62578
62578
  };
62579
62579
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [
62580
62580
  /* @__PURE__ */ jsxs("div", { className: "mb-4", children: [
@@ -62586,56 +62586,37 @@ function ManufacturerProducts({
62586
62586
  onSelectCategory: d
62587
62587
  }
62588
62588
  ),
62589
- n && ((q = e.Categories) == null ? void 0 : q.findIndex((oe) => oe.AvailableToBuy)) !== -1 && /* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsxs(Dialog, { open: b, onOpenChange: S, children: [
62590
- /* @__PURE__ */ jsx(DialogTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(Button, { className: "bg-green-600 hover:bg-green-700 mb-4", disabled: f, children: f ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
62591
- /* @__PURE__ */ jsx(LoaderCircle, { className: "mr-2 h-4 w-4 animate-spin" }),
62592
- "Syncing..."
62593
- ] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
62594
- /* @__PURE__ */ jsx(ShoppingCart, { className: "mr-2 h-4 w-4" }),
62595
- "Sync Category to Shopify"
62596
- ] }) }) }),
62597
- /* @__PURE__ */ jsxs(DialogContent, { children: [
62598
- /* @__PURE__ */ jsxs(DialogHeader, { children: [
62599
- /* @__PURE__ */ jsx(DialogTitle, { children: "Confirm Sync to Shopify" }),
62600
- /* @__PURE__ */ jsxs(DialogDescription, { children: [
62601
- 'Are you sure you want to sync the category "',
62602
- M(),
62603
- '" to Shopify? This will add all products in this category to your Shopify store.'
62604
- ] })
62605
- ] }),
62606
- /* @__PURE__ */ jsxs(DialogFooter, { children: [
62607
- /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => S(!1), children: "Cancel" }),
62608
- /* @__PURE__ */ jsx(
62609
- Button,
62610
- {
62611
- className: "bg-green-600 hover:bg-green-700",
62612
- onClick: A,
62613
- disabled: f,
62614
- children: f ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
62615
- /* @__PURE__ */ jsx(LoaderCircle, { className: "mr-2 h-4 w-4 animate-spin" }),
62616
- "Syncing..."
62617
- ] }) : "Confirm Sync"
62618
- }
62619
- )
62620
- ] })
62621
- ] })
62622
- ] }) }),
62623
- /* @__PURE__ */ jsx("div", { className: "mb-4", children: /* @__PURE__ */ jsx(
62589
+ /* @__PURE__ */ jsx("div", { className: "mb-4 w-full", children: /* @__PURE__ */ jsx(
62624
62590
  ManufacturerCategorySummary,
62625
62591
  {
62626
62592
  name: M(),
62627
- niche: ((Q = (z = e.Categories) == null ? void 0 : z.find((oe) => oe.CategoryCode === l)) == null ? void 0 : Q.CategoryName) || l,
62628
- productsNumber: ((F = C == null ? void 0 : C.Products) == null ? void 0 : F.length) || 0,
62593
+ niche: (C == null ? void 0 : C.Niche) || "",
62594
+ productsNumber: ((q = C == null ? void 0 : C.Products) == null ? void 0 : q.length) || 0,
62629
62595
  autoreorder: (C == null ? void 0 : C.AutoReorder) || !1,
62630
62596
  starred: (C == null ? void 0 : C.Starred) || !1,
62631
- isLoading: E
62597
+ isLoading: E || R,
62598
+ children: n && ((z = e.Categories) == null ? void 0 : z.findIndex((te) => te.AvailableToBuy)) !== -1 && /* @__PURE__ */ jsx(
62599
+ Button,
62600
+ {
62601
+ className: "bg-green-600 hover:bg-green-700",
62602
+ disabled: f,
62603
+ onClick: () => S(!0),
62604
+ children: f ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
62605
+ /* @__PURE__ */ jsx(LoaderCircle, { className: "mr-2 h-4 w-4 animate-spin" }),
62606
+ "Syncing..."
62607
+ ] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
62608
+ /* @__PURE__ */ jsx(ShoppingCart, { className: "mr-2 h-4 w-4" }),
62609
+ "Sync Category to Shopify"
62610
+ ] })
62611
+ }
62612
+ )
62632
62613
  }
62633
62614
  ) }),
62634
62615
  /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 @md:grid-cols-2 gap-4", children: [
62635
62616
  /* @__PURE__ */ jsx(
62636
62617
  ManufacturerCategoriesStats,
62637
62618
  {
62638
- categories: [(j = e.Categories) == null ? void 0 : j.find((oe) => oe.CategoryCode === l)].filter(Boolean),
62619
+ categories: [(Q = e.Categories) == null ? void 0 : Q.find((te) => te.CategoryCode === l)].filter(Boolean),
62639
62620
  manufID: e.ManufacturerId,
62640
62621
  appID: t
62641
62622
  }
@@ -62643,9 +62624,9 @@ function ManufacturerProducts({
62643
62624
  /* @__PURE__ */ jsx(
62644
62625
  ActiveOrdersCard,
62645
62626
  {
62646
- orders: (te = C == null ? void 0 : C.Products) == null ? void 0 : te.flatMap(
62647
- (oe) => (oe.ActiveOrderDetails || []).filter(
62648
- (ge) => ge.Category === l
62627
+ orders: (F = C == null ? void 0 : C.Products) == null ? void 0 : F.flatMap(
62628
+ (te) => (te.ActiveOrderDetails || []).filter(
62629
+ (ne) => ne.Category === l
62649
62630
  )
62650
62631
  ),
62651
62632
  loading: E || R
@@ -62653,22 +62634,47 @@ function ManufacturerProducts({
62653
62634
  )
62654
62635
  ] })
62655
62636
  ] }),
62656
- /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 @md:grid-cols-2 gap-4 mb-4", children: E || R ? Array.from({ length: 4 }).map((oe, ge) => /* @__PURE__ */ jsx(ProductCard, {}, ge)) : C != null && C.Products && (C == null ? void 0 : C.Products.length) > 0 ? (ne = [...C.Products].sort((oe, ge) => {
62657
- const se = oe.OverallPercentileRank ?? 0;
62658
- return (ge.OverallPercentileRank ?? 0) - se;
62659
- })) == null ? void 0 : ne.map((oe) => /* @__PURE__ */ jsx(
62637
+ /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 @md:grid-cols-2 gap-4 mb-4", children: E || R ? Array.from({ length: 4 }).map((te, ne) => /* @__PURE__ */ jsx(ProductCard, {}, ne)) : C != null && C.Products && (C == null ? void 0 : C.Products.length) > 0 ? (j = [...C.Products].sort((te, ne) => {
62638
+ const oe = te.OverallPercentileRank ?? 0;
62639
+ return (ne.OverallPercentileRank ?? 0) - oe;
62640
+ })) == null ? void 0 : j.map((te) => /* @__PURE__ */ jsx(
62660
62641
  ProductCard,
62661
62642
  {
62662
62643
  applicationId: t,
62663
- product: oe,
62664
- viewProductLink: `/${t}/Product/${oe.RandmarSKU}`,
62644
+ product: te,
62645
+ viewProductLink: `/${t}/Product/${te.RandmarSKU}`,
62665
62646
  shopifyHostname: n
62666
62647
  },
62667
- oe.RandmarSKU
62648
+ te.RandmarSKU
62668
62649
  )) : /* @__PURE__ */ jsxs(Alert, { variant: "warning", className: "col-span-1 @md:col-span-2", children: [
62669
62650
  /* @__PURE__ */ jsx(CircleAlert, { className: "h-4 w-4" }),
62670
62651
  /* @__PURE__ */ jsx(AlertTitle, { children: "Warning" }),
62671
62652
  /* @__PURE__ */ jsx(AlertDescription, { children: "No products found for this manufacturer category." })
62653
+ ] }) }),
62654
+ /* @__PURE__ */ jsx(Dialog, { open: b, onOpenChange: S, children: /* @__PURE__ */ jsxs(DialogContent, { children: [
62655
+ /* @__PURE__ */ jsxs(DialogHeader, { children: [
62656
+ /* @__PURE__ */ jsx(DialogTitle, { children: "Confirm Sync to Shopify" }),
62657
+ /* @__PURE__ */ jsxs(DialogDescription, { children: [
62658
+ 'Are you sure you want to sync the category "',
62659
+ M(),
62660
+ '" to Shopify? This will add all products in this category to your Shopify store.'
62661
+ ] })
62662
+ ] }),
62663
+ /* @__PURE__ */ jsxs(DialogFooter, { children: [
62664
+ /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => S(!1), children: "Cancel" }),
62665
+ /* @__PURE__ */ jsx(
62666
+ Button,
62667
+ {
62668
+ className: "bg-green-600 hover:bg-green-700",
62669
+ onClick: A,
62670
+ disabled: f,
62671
+ children: f ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
62672
+ /* @__PURE__ */ jsx(LoaderCircle, { className: "mr-2 h-4 w-4 animate-spin" }),
62673
+ "Syncing..."
62674
+ ] }) : "Confirm Sync"
62675
+ }
62676
+ )
62677
+ ] })
62672
62678
  ] }) })
62673
62679
  ] });
62674
62680
  }
@@ -1130,7 +1130,7 @@ Please report this to https://github.com/markedjs/marked.`,t){const o="<p>An err
1130
1130
  - less than the value passed to \`max\` (or ${DEFAULT_MAX} if no \`max\` prop is set)
1131
1131
  - \`null\` or \`undefined\` if the progress is indeterminate.
1132
1132
 
1133
- Defaulting to \`null\`.`}var Root=Progress$1,Indicator=ProgressIndicator;const Progress=React__namespace.forwardRef(({className:t,value:e,...n},o)=>jsxRuntime.jsx(Root,{ref:o,className:cn("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",t),...n,children:jsxRuntime.jsx(Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(e||0)}%)`}})}));Progress.displayName=Root.displayName;function ManufacturerInventoryFinanceCard({manufacturer:t,isLoading:e}){const{data:n,isLoading:o,isFetching:l}=useGetV4ManufacturerByRouteManufacturerIdInventoryValueQuery({routeManufacturerId:(t==null?void 0:t.ManufacturerId)??""},{skip:!(t!=null&&t.ManufacturerId)}),d=(t==null?void 0:t.DefaultMaxInventoryValue)??0,f=(n||[]).reduce((S,_)=>S+(_.InventoryValue||0),0),g=d-f,b=Math.round(f/d*100);return e||o||l?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsx(Skeleton,{className:"h-7 w-3/4"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/2 mt-2"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16"})]}),jsxRuntime.jsx(Skeleton,{className:"h-2 w-full"})]})]})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsxs(CardTitle,{className:"flex items-center gap-2",children:[jsxRuntime.jsx(DollarSign,{className:"h-5 w-5 text-muted-foreground"}),"Inventory Finance"]}),jsxRuntime.jsx(CardDescription,{children:"Current inventory financial status"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[d!==0&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Max Allowance"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(d)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Current value"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(f)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Available"}),jsxRuntime.jsx("span",{className:`font-bold ${g>=0?"text-emerald-600 dark:text-emerald-500":"text-red-600 dark:text-red-500"}`,children:formatMoney(g)})]})]}),d!==0&&jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Budget Usage"}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsxs("span",{className:"text-sm font-medium",children:[b,"%"]}),b>80&&jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4 text-amber-500"})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:b>80?"High usage alert":"Budget usage"})})]})})]}),jsxRuntime.jsx(Progress,{value:b,className:"h-2"})]})]})]})}function ManufacturerCreditFinanceCard({manufacturer:t,isLoading:e}){const n=(t==null?void 0:t.CreditLimit)??0,o=(t==null?void 0:t.OutstandingBalance)??0,l=n-o,d=Math.round(o/n*100);return e?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsx(Skeleton,{className:"h-7 w-3/4"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/2 mt-2"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16"})]}),jsxRuntime.jsx(Skeleton,{className:"h-2 w-full"})]})]})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsxs(CardTitle,{className:"flex items-center gap-2",children:[jsxRuntime.jsx(CreditCard,{className:"h-5 w-5 text-muted-foreground"}),"Credit Finance"]}),jsxRuntime.jsx(CardDescription,{children:"Current credit financial status"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Credit Limit"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(n)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Outstanding Balance"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(o)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Available Credit"}),jsxRuntime.jsx("span",{className:`font-bold ${l>=0?"text-emerald-600 dark:text-emerald-500":"text-red-600 dark:text-red-500"}`,children:formatMoney(l)})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Credit Usage"}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsxs("span",{className:"text-sm font-medium",children:[d,"%"]}),d>80&&jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4 text-amber-500"})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:d>80?"High credit usage alert":"Credit usage"})})]})})]}),jsxRuntime.jsx(Progress,{value:d,className:"h-2"})]})]})]})}function SalesChartCard({statistics:t,loading:e=!1,mode:n="month",chartHeight:o=300,className:l,size:d="default"}){return e?jsxRuntime.jsxs(Card,{className:cn("w-full",l),children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(Skeleton,{className:"h-7 w-48 rounded-md"})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsx("div",{style:{height:o},children:jsxRuntime.jsx(Skeleton,{className:"h-full w-full rounded-md"})}),d==="default"&&n==="month"&&jsxRuntime.jsxs("div",{className:"mt-4 flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-10 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-40 rounded-md"})]})]})]}):jsxRuntime.jsxs(Card,{className:cn("w-full",l),children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:n==="week"?"Weekly Sales Performance":"Monthly Sales Performance"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(SalesChart,{statistics:t,mode:n,chartHeight:o,size:d})})]})}function ManufacturerOverviewPage({applicationId:t,readonly:e,withReports:n,manufacturer:o,userEmail:l}){const{data:d,isLoading:f,isError:g}=useGetV4PartnerByApplicationIdAccountManufacturerQuery({applicationId:t,withSpecification:!0},{skip:!!o}),[b,S]=React.useState({publicInfo:{hasUnsavedChanges:!1},qualifications:{hasUnsavedChanges:!1},billingInfo:{hasUnsavedChanges:!1}}),_=React.useCallback(()=>e?!1:b.publicInfo.hasUnsavedChanges||b.qualifications.hasUnsavedChanges||b.billingInfo.hasUnsavedChanges,[e,b]),R=React.useCallback((A,M)=>{S(I=>{var j;return((j=I[A])==null?void 0:j.hasUnsavedChanges)!==M.hasUnsavedChanges?(console.log(`Updating form state for ${A}:`,M.hasUnsavedChanges),{...I,[A]:M}):I})},[]),{NavigationGuardDialog:C}=useRouterNavigationGuard(_),E=o??d;return jsxRuntime.jsxs("div",{className:"@container",children:[g?jsxRuntime.jsx(Card,{className:"p-6",children:jsxRuntime.jsxs(Alert,{variant:"destructive",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Error"}),jsxRuntime.jsx(AlertDescription,{children:"There was an error loading your manufacturer information. Please try again later."})]})}):jsxRuntime.jsxs("div",{className:"space-y-6 mb-6",children:[jsxRuntime.jsx(SalesSummary,{fiscalYearMonthStart:E==null?void 0:E.FiscalYearMonthStart,salesData:E==null?void 0:E.SalesData,isLoading:f}),jsxRuntime.jsxs("div",{className:"grid @2xl:grid-cols-2 gap-6",children:[jsxRuntime.jsx(SalesChartCard,{statistics:(E==null?void 0:E.SalesStatistics)??[],loading:f}),jsxRuntime.jsx(ManufacturerResellerOrdersSection,{manufacturerId:(E==null?void 0:E.ManufacturerId)??"",activeOrders:(E==null?void 0:E.ActiveOrderDetails)??void 0,isLoading:f}),n&&jsxRuntime.jsx(ManufacturerInventoryFinanceCard,{manufacturer:E,isLoading:f}),n&&jsxRuntime.jsx(ManufacturerCreditFinanceCard,{manufacturer:E,isLoading:f}),n&&jsxRuntime.jsx(ManufacturerReorderingCard,{manufacturer:E??{},onSave:()=>{},loading:f,readonly:e}),n&&jsxRuntime.jsx(ManufacturerPublicInfoSection,{manufacturer:E,readonly:e,isLoading:f,onUnsavedChanges:A=>R("publicInfo",{hasUnsavedChanges:A})}),n&&jsxRuntime.jsx(OpenToWorkSection,{manufacturer:E,readonly:e,isLoading:f}),n&&jsxRuntime.jsx(ManufacturerBillingInfoSection,{manufacturer:E,readonly:e,isLoading:f,onUnsavedChanges:A=>R("billingInfo",{hasUnsavedChanges:A})}),n&&jsxRuntime.jsx(ManufacturerQualificationsSection,{manufacturer:E,readonly:e,isLoading:f,onUnsavedChanges:A=>R("qualifications",{hasUnsavedChanges:A})})]}),n&&jsxRuntime.jsx(ManufacturerReportsSection,{manufacturerId:(E==null?void 0:E.ManufacturerId)??"",userEmail:l,isLoading:f})]}),jsxRuntime.jsx(C,{})]})}function ManufacturerCategories({categories:t,activeCategory:e,onSelectCategory:n}){return jsxRuntime.jsx("div",{className:"grid",children:jsxRuntime.jsx("div",{className:"flex overflow-x-auto small-scrollbar pb-4",children:jsxRuntime.jsx("div",{className:"flex gap-2",children:t.map(o=>jsxRuntime.jsxs(Button,{onClick:()=>n(o.CategoryCode??""),variant:e===o.CategoryCode?"default":"outline",size:"sm",className:"px-3 py-1.5 text-xs whitespace-nowrap rounded-full",children:[o.CategoryName??"Undefined",o.QualificationRequired&&jsxRuntime.jsx(ShieldCheck,{className:`ml-1 w-5 h-5 ${e!==o.CategoryCode?"text-red-500":""}`})]},o.CategoryCode))})})})}function CategoryStats(t){const{data:e,isLoading:n,isFetching:o}=useGetV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeQuery({routeResellerId:t.appID,manufacturerId:t.manufID,categoryCode:t.categoryCode});return jsxRuntime.jsx(Card,{className:"w-full",children:jsxRuntime.jsx(CardContent,{className:"p-4 space-y-1",children:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground mb-2",children:t.categoryName}),jsxRuntime.jsx(SalesChart,{statistics:(e==null?void 0:e.SalesStatistics)??[],loading:n||o,chartHeight:300})]})})})}function ManufacturerCategoriesStats(t){return(t.categories??[]).filter(n=>n.CategoryName).map(n=>jsxRuntime.jsx(CategoryStats,{appID:t.appID,manufID:t.manufID,categoryCode:n.CategoryCode,categoryName:n.CategoryName},`${t.manufID}-${n.CategoryCode}`))}const badgeVariants=cva("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground border border-input hover:bg-accent hover:text-accent-foreground",success:"bg-green-600 text-white hover:bg-green-700",warning:"bg-yellow-500 text-white hover:bg-yellow-600",info:"bg-blue-500 text-white hover:bg-blue-600",ghost:"bg-background hover:bg-accent hover:text-accent-foreground",randmarRed:"bg-randmar-red text-white hover:bg-randmar-red/80",randmarBlue:"bg-randmar-blue text-white hover:bg-randmar-blue/80",randmarPurple:"bg-randmar-purple text-white hover:bg-randmar-purple/80",randmarGreen:"bg-randmar-green text-black hover:bg-randmar-green/80",randmarBlack:"bg-randmar-black text-white hover:bg-randmar-black/80",randmarYellow:"bg-randmar-yellow text-black hover:bg-randmar-yellow/80"},size:{default:"h-6",sm:"h-5 text-[10px]",lg:"h-7 px-3"}},defaultVariants:{variant:"default",size:"default"}}),Badge=React__namespace.forwardRef(({className:t,variant:e,size:n,icon:o,children:l,...d},f)=>jsxRuntime.jsxs("div",{ref:f,className:cn(badgeVariants({variant:e,size:n}),t),...d,children:[o&&jsxRuntime.jsx("span",{className:"mr-1",children:o}),l]}));Badge.displayName="Badge";function ManufacturerCategorySummary({name:t="N/A",niche:e="N/A",productsNumber:n=0,autoreorder:o=!1,starred:l=!1,isLoading:d=!1}){return d?jsxRuntime.jsxs(Card,{className:"w-full max-w-lg mx-auto",children:[jsxRuntime.jsx(CardHeader,{className:"pb-4",children:jsxRuntime.jsxs("div",{className:"flex items-start justify-between",children:[jsxRuntime.jsx("div",{className:"space-y-1 flex-1",children:jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("div",{className:"h-3 w-20 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-5 w-40 bg-muted rounded-md animate-pulse"})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end gap-1",children:[jsxRuntime.jsx("div",{className:"h-3 w-12 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-5 w-5 bg-muted rounded-md animate-pulse"})]})]})}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("div",{className:"h-3 w-8 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-4 w-32 bg-muted rounded-md animate-pulse"})]}),jsxRuntime.jsxs("div",{className:"flex items-start justify-between gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-1 flex-1",children:[jsxRuntime.jsx("div",{className:"h-3 w-16 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"h-4 w-4 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-4 w-6 bg-muted rounded-md animate-pulse"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-1 flex-1 flex flex-col items-end",children:[jsxRuntime.jsx("div",{className:"h-3 w-20 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"h-4 w-4 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-6 w-16 bg-muted rounded-md animate-pulse"})]})]})]})]})]}):jsxRuntime.jsxs(Card,{className:"w-full max-w-lg mx-auto",children:[jsxRuntime.jsx(CardHeader,{className:"pb-4",children:jsxRuntime.jsxs("div",{className:"flex items-start justify-between",children:[jsxRuntime.jsx("div",{className:"space-y-1 flex-1",children:jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Category Name"}),jsxRuntime.jsx("h3",{className:"text-lg font-semibold leading-none tracking-tight",children:t})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end gap-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Starred"}),l?jsxRuntime.jsx(Star,{className:"h-5 w-5 fill-yellow-400 text-yellow-400"}):jsxRuntime.jsx(Star,{className:"h-5 w-5 text-muted-foreground"})]})]})}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Niche"}),jsxRuntime.jsx("p",{className:"text-sm font-medium",children:e})]}),jsxRuntime.jsxs("div",{className:"flex items-start justify-between gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-1 flex-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Products"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Package,{className:"h-4 w-4 text-muted-foreground"}),jsxRuntime.jsx("span",{className:"text-sm font-medium",children:n})]})]}),jsxRuntime.jsxs("div",{className:"space-y-1 flex-1 flex flex-col items-end ",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Auto-reorder"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[o?jsxRuntime.jsx(RefreshCw,{className:"size-4 text-green-600"}):jsxRuntime.jsx(RefreshCwOff,{className:"size-4 text-amber-600"}),jsxRuntime.jsx(Badge,{variant:o?"default":"secondary",className:cn("text-xs",o?"text-green-600 bg-green-100 hover:bg-green-200":"text-amber-600 bg-amber-100 hover:bg-amber-200"),children:o?"Enabled":"Disabled"})]})]})]})]})]})}function ManufacturerProducts({applicationId:t,manufacturer:e,shopifyHostName:n}){var I,j,q,z,Q,O,F,te,ne;const[o]=usePostV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeShopifyMutation(),[l,d]=React.useState(((j=(I=e.Categories)==null?void 0:I[0])==null?void 0:j.CategoryCode)||""),[f,g]=React.useState(!1),[b,S]=React.useState(!1),{toast:_}=useToast(),{data:R,isLoading:C,isFetching:E}=useGetV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeQuery({routeResellerId:t,manufacturerId:e.ManufacturerId,categoryCode:l??""},{skip:!e.ManufacturerId||!l}),A=async()=>{try{g(!0),S(!1),await o({routeResellerId:t,manufacturerId:e.ManufacturerId??"",categoryCode:l,shopifyHostName:n}).unwrap()&&_({title:"Success",description:"Category synced to Shopify successfully",variant:"success"})}catch(se){console.error("Error syncing to Shopify:",se),_({title:"Error",description:"Error syncing category to Shopify.",variant:"destructive"})}finally{g(!1)}},M=()=>{var se,ge;return((ge=(se=e.Categories)==null?void 0:se.find(oe=>oe.CategoryCode===l))==null?void 0:ge.CategoryName)||l};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"mb-4",children:[jsxRuntime.jsx(ManufacturerCategories,{categories:e.Categories||[],activeCategory:l,onSelectCategory:d}),n&&((q=e.Categories)==null?void 0:q.findIndex(se=>se.AvailableToBuy))!==-1&&jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsxs(Dialog,{open:b,onOpenChange:S,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{className:"bg-green-600 hover:bg-green-700 mb-4",disabled:f,children:f?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2 h-4 w-4"}),"Sync Category to Shopify"]})})}),jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Confirm Sync to Shopify"}),jsxRuntime.jsxs(DialogDescription,{children:['Are you sure you want to sync the category "',M(),'" to Shopify? This will add all products in this category to your Shopify store.']})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button,{variant:"outline",onClick:()=>S(!1),children:"Cancel"}),jsxRuntime.jsx(Button,{className:"bg-green-600 hover:bg-green-700",onClick:A,disabled:f,children:f?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):"Confirm Sync"})]})]})]})}),jsxRuntime.jsx("div",{className:"mb-4",children:jsxRuntime.jsx(ManufacturerCategorySummary,{name:M(),niche:((Q=(z=e.Categories)==null?void 0:z.find(se=>se.CategoryCode===l))==null?void 0:Q.CategoryName)||l,productsNumber:((O=R==null?void 0:R.Products)==null?void 0:O.length)||0,autoreorder:(R==null?void 0:R.AutoReorder)||!1,starred:(R==null?void 0:R.Starred)||!1,isLoading:C})}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4",children:[jsxRuntime.jsx(ManufacturerCategoriesStats,{categories:[(F=e.Categories)==null?void 0:F.find(se=>se.CategoryCode===l)].filter(Boolean),manufID:e.ManufacturerId,appID:t}),jsxRuntime.jsx(ActiveOrdersCard,{orders:(te=R==null?void 0:R.Products)==null?void 0:te.flatMap(se=>(se.ActiveOrderDetails||[]).filter(ge=>ge.Category===l)),loading:C||E})]})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4 mb-4",children:C||E?Array.from({length:4}).map((se,ge)=>jsxRuntime.jsx(ProductCard,{},ge)):R!=null&&R.Products&&(R==null?void 0:R.Products.length)>0?(ne=[...R.Products].sort((se,ge)=>{const oe=se.OverallPercentileRank??0;return(ge.OverallPercentileRank??0)-oe}))==null?void 0:ne.map(se=>jsxRuntime.jsx(ProductCard,{applicationId:t,product:se,viewProductLink:`/${t}/Product/${se.RandmarSKU}`,shopifyHostname:n},se.RandmarSKU)):jsxRuntime.jsxs(Alert,{variant:"warning",className:"col-span-1 @md:col-span-2",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Warning"}),jsxRuntime.jsx(AlertDescription,{children:"No products found for this manufacturer category."})]})})]})}function PartnerRelationshipPage({applicationId:t,partnerId:e,userEmail:n,shopifyHostName:o,isSuperAdmin:l}){var q,z,Q;const{data:d}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:t}),{data:f,isLoading:g,isFetching:b}=useGetV4PartnerByRouteApplicationIdPartnerAndPartnerIdQuery({routeApplicationId:t,partnerId:e,withSpecification:!0}),{toast:S}=useToast(),[_]=usePostV4ResellerByRouteResellerIdManufacturerAndManufacturerIdShopifyMutation(),[R,C]=React.useState(!1),[E,A]=React.useState(!1),M=async()=>{try{C(!0),A(!1),await _({routeResellerId:t??"",manufacturerId:e??"",shopifyHostName:o}).unwrap()&&S({title:"Success",description:"Manufacturer synced to Shopify successfully",variant:"success"})}catch(O){console.error("Error syncing to Shopify:",O),S({title:"Error",description:"Error syncing manufacturer to Shopify.",variant:"destructive"})}finally{C(!1)}},I=()=>f!=null&&f.Reseller?"reseller-overview":f!=null&&f.Manufacturer?"manufacturer-overview":"",j=React.useMemo(()=>!d||!f?"":`
1133
+ Defaulting to \`null\`.`}var Root=Progress$1,Indicator=ProgressIndicator;const Progress=React__namespace.forwardRef(({className:t,value:e,...n},o)=>jsxRuntime.jsx(Root,{ref:o,className:cn("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",t),...n,children:jsxRuntime.jsx(Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(e||0)}%)`}})}));Progress.displayName=Root.displayName;function ManufacturerInventoryFinanceCard({manufacturer:t,isLoading:e}){const{data:n,isLoading:o,isFetching:l}=useGetV4ManufacturerByRouteManufacturerIdInventoryValueQuery({routeManufacturerId:(t==null?void 0:t.ManufacturerId)??""},{skip:!(t!=null&&t.ManufacturerId)}),d=(t==null?void 0:t.DefaultMaxInventoryValue)??0,f=(n||[]).reduce((S,_)=>S+(_.InventoryValue||0),0),g=d-f,b=Math.round(f/d*100);return e||o||l?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsx(Skeleton,{className:"h-7 w-3/4"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/2 mt-2"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16"})]}),jsxRuntime.jsx(Skeleton,{className:"h-2 w-full"})]})]})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsxs(CardTitle,{className:"flex items-center gap-2",children:[jsxRuntime.jsx(DollarSign,{className:"h-5 w-5 text-muted-foreground"}),"Inventory Finance"]}),jsxRuntime.jsx(CardDescription,{children:"Current inventory financial status"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[d!==0&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Max Allowance"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(d)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Current value"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(f)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Available"}),jsxRuntime.jsx("span",{className:`font-bold ${g>=0?"text-emerald-600 dark:text-emerald-500":"text-red-600 dark:text-red-500"}`,children:formatMoney(g)})]})]}),d!==0&&jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Budget Usage"}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsxs("span",{className:"text-sm font-medium",children:[b,"%"]}),b>80&&jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4 text-amber-500"})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:b>80?"High usage alert":"Budget usage"})})]})})]}),jsxRuntime.jsx(Progress,{value:b,className:"h-2"})]})]})]})}function ManufacturerCreditFinanceCard({manufacturer:t,isLoading:e}){const n=(t==null?void 0:t.CreditLimit)??0,o=(t==null?void 0:t.OutstandingBalance)??0,l=n-o,d=Math.round(o/n*100);return e?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsx(Skeleton,{className:"h-7 w-3/4"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/2 mt-2"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16"})]}),jsxRuntime.jsx(Skeleton,{className:"h-2 w-full"})]})]})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsxs(CardTitle,{className:"flex items-center gap-2",children:[jsxRuntime.jsx(CreditCard,{className:"h-5 w-5 text-muted-foreground"}),"Credit Finance"]}),jsxRuntime.jsx(CardDescription,{children:"Current credit financial status"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Credit Limit"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(n)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Outstanding Balance"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(o)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Available Credit"}),jsxRuntime.jsx("span",{className:`font-bold ${l>=0?"text-emerald-600 dark:text-emerald-500":"text-red-600 dark:text-red-500"}`,children:formatMoney(l)})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Credit Usage"}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsxs("span",{className:"text-sm font-medium",children:[d,"%"]}),d>80&&jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4 text-amber-500"})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:d>80?"High credit usage alert":"Credit usage"})})]})})]}),jsxRuntime.jsx(Progress,{value:d,className:"h-2"})]})]})]})}function SalesChartCard({statistics:t,loading:e=!1,mode:n="month",chartHeight:o=300,className:l,size:d="default"}){return e?jsxRuntime.jsxs(Card,{className:cn("w-full",l),children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(Skeleton,{className:"h-7 w-48 rounded-md"})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsx("div",{style:{height:o},children:jsxRuntime.jsx(Skeleton,{className:"h-full w-full rounded-md"})}),d==="default"&&n==="month"&&jsxRuntime.jsxs("div",{className:"mt-4 flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-10 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-40 rounded-md"})]})]})]}):jsxRuntime.jsxs(Card,{className:cn("w-full",l),children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:n==="week"?"Weekly Sales Performance":"Monthly Sales Performance"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(SalesChart,{statistics:t,mode:n,chartHeight:o,size:d})})]})}function ManufacturerOverviewPage({applicationId:t,readonly:e,withReports:n,manufacturer:o,userEmail:l}){const{data:d,isLoading:f,isError:g}=useGetV4PartnerByApplicationIdAccountManufacturerQuery({applicationId:t,withSpecification:!0},{skip:!!o}),[b,S]=React.useState({publicInfo:{hasUnsavedChanges:!1},qualifications:{hasUnsavedChanges:!1},billingInfo:{hasUnsavedChanges:!1}}),_=React.useCallback(()=>e?!1:b.publicInfo.hasUnsavedChanges||b.qualifications.hasUnsavedChanges||b.billingInfo.hasUnsavedChanges,[e,b]),R=React.useCallback((A,M)=>{S(I=>{var j;return((j=I[A])==null?void 0:j.hasUnsavedChanges)!==M.hasUnsavedChanges?(console.log(`Updating form state for ${A}:`,M.hasUnsavedChanges),{...I,[A]:M}):I})},[]),{NavigationGuardDialog:C}=useRouterNavigationGuard(_),E=o??d;return jsxRuntime.jsxs("div",{className:"@container",children:[g?jsxRuntime.jsx(Card,{className:"p-6",children:jsxRuntime.jsxs(Alert,{variant:"destructive",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Error"}),jsxRuntime.jsx(AlertDescription,{children:"There was an error loading your manufacturer information. Please try again later."})]})}):jsxRuntime.jsxs("div",{className:"space-y-6 mb-6",children:[jsxRuntime.jsx(SalesSummary,{fiscalYearMonthStart:E==null?void 0:E.FiscalYearMonthStart,salesData:E==null?void 0:E.SalesData,isLoading:f}),jsxRuntime.jsxs("div",{className:"grid @2xl:grid-cols-2 gap-6",children:[jsxRuntime.jsx(SalesChartCard,{statistics:(E==null?void 0:E.SalesStatistics)??[],loading:f}),jsxRuntime.jsx(ManufacturerResellerOrdersSection,{manufacturerId:(E==null?void 0:E.ManufacturerId)??"",activeOrders:(E==null?void 0:E.ActiveOrderDetails)??void 0,isLoading:f}),n&&jsxRuntime.jsx(ManufacturerInventoryFinanceCard,{manufacturer:E,isLoading:f}),n&&jsxRuntime.jsx(ManufacturerCreditFinanceCard,{manufacturer:E,isLoading:f}),n&&jsxRuntime.jsx(ManufacturerReorderingCard,{manufacturer:E??{},onSave:()=>{},loading:f,readonly:e}),n&&jsxRuntime.jsx(ManufacturerPublicInfoSection,{manufacturer:E,readonly:e,isLoading:f,onUnsavedChanges:A=>R("publicInfo",{hasUnsavedChanges:A})}),n&&jsxRuntime.jsx(OpenToWorkSection,{manufacturer:E,readonly:e,isLoading:f}),n&&jsxRuntime.jsx(ManufacturerBillingInfoSection,{manufacturer:E,readonly:e,isLoading:f,onUnsavedChanges:A=>R("billingInfo",{hasUnsavedChanges:A})}),n&&jsxRuntime.jsx(ManufacturerQualificationsSection,{manufacturer:E,readonly:e,isLoading:f,onUnsavedChanges:A=>R("qualifications",{hasUnsavedChanges:A})})]}),n&&jsxRuntime.jsx(ManufacturerReportsSection,{manufacturerId:(E==null?void 0:E.ManufacturerId)??"",userEmail:l,isLoading:f})]}),jsxRuntime.jsx(C,{})]})}function ManufacturerCategories({categories:t,activeCategory:e,onSelectCategory:n}){return jsxRuntime.jsx("div",{className:"grid",children:jsxRuntime.jsx("div",{className:"flex overflow-x-auto small-scrollbar pb-4",children:jsxRuntime.jsx("div",{className:"flex gap-2",children:t.map(o=>jsxRuntime.jsxs(Button,{onClick:()=>n(o.CategoryCode??""),variant:e===o.CategoryCode?"default":"outline",size:"sm",className:"px-3 py-1.5 text-xs whitespace-nowrap rounded-full",children:[o.CategoryName??"Undefined",o.QualificationRequired&&jsxRuntime.jsx(ShieldCheck,{className:`ml-1 w-5 h-5 ${e!==o.CategoryCode?"text-red-500":""}`})]},o.CategoryCode))})})})}function CategoryStats(t){const{data:e,isLoading:n,isFetching:o}=useGetV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeQuery({routeResellerId:t.appID,manufacturerId:t.manufID,categoryCode:t.categoryCode});return jsxRuntime.jsx(Card,{className:"w-full",children:jsxRuntime.jsx(CardContent,{className:"p-4 space-y-1",children:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground mb-2",children:t.categoryName}),jsxRuntime.jsx(SalesChart,{statistics:(e==null?void 0:e.SalesStatistics)??[],loading:n||o,chartHeight:300})]})})})}function ManufacturerCategoriesStats(t){return(t.categories??[]).filter(n=>n.CategoryName).map(n=>jsxRuntime.jsx(CategoryStats,{appID:t.appID,manufID:t.manufID,categoryCode:n.CategoryCode,categoryName:n.CategoryName},`${t.manufID}-${n.CategoryCode}`))}const badgeVariants=cva("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground border border-input hover:bg-accent hover:text-accent-foreground",success:"bg-green-600 text-white hover:bg-green-700",warning:"bg-yellow-500 text-white hover:bg-yellow-600",info:"bg-blue-500 text-white hover:bg-blue-600",ghost:"bg-background hover:bg-accent hover:text-accent-foreground",randmarRed:"bg-randmar-red text-white hover:bg-randmar-red/80",randmarBlue:"bg-randmar-blue text-white hover:bg-randmar-blue/80",randmarPurple:"bg-randmar-purple text-white hover:bg-randmar-purple/80",randmarGreen:"bg-randmar-green text-black hover:bg-randmar-green/80",randmarBlack:"bg-randmar-black text-white hover:bg-randmar-black/80",randmarYellow:"bg-randmar-yellow text-black hover:bg-randmar-yellow/80"},size:{default:"h-6",sm:"h-5 text-[10px]",lg:"h-7 px-3"}},defaultVariants:{variant:"default",size:"default"}}),Badge=React__namespace.forwardRef(({className:t,variant:e,size:n,icon:o,children:l,...d},f)=>jsxRuntime.jsxs("div",{ref:f,className:cn(badgeVariants({variant:e,size:n}),t),...d,children:[o&&jsxRuntime.jsx("span",{className:"mr-1",children:o}),l]}));Badge.displayName="Badge";function ManufacturerCategorySummary({name:t="N/A",niche:e="N/A",productsNumber:n=0,autoreorder:o=!1,starred:l=!1,isLoading:d=!1,children:f}){return d?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{className:"pb-4",children:jsxRuntime.jsxs("div",{className:"flex items-start justify-between",children:[jsxRuntime.jsx("div",{className:"space-y-1 flex-1",children:jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("div",{className:"h-3 w-28 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-5 w-48 bg-muted rounded-md animate-pulse"})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end gap-1",children:[jsxRuntime.jsx("div",{className:"h-3 w-12 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-5 w-5 bg-muted rounded-md animate-pulse"})]})]})}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("div",{className:"h-3 w-8 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-4 w-32 bg-muted rounded-md animate-pulse"})]}),jsxRuntime.jsxs("div",{className:"flex items-start justify-between gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-1 flex-1",children:[jsxRuntime.jsx("div",{className:"h-3 w-16 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"h-4 w-4 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-4 w-6 bg-muted rounded-md animate-pulse"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-1 flex-1 flex flex-col items-end",children:[jsxRuntime.jsx("div",{className:"h-3 w-20 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"h-4 w-4 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-6 w-16 bg-muted rounded-md animate-pulse"})]})]})]})]})]}):jsxRuntime.jsx(Card,{children:jsxRuntime.jsxs(CardContent,{className:"grid grid-cols-[1fr_auto] items-start gap-4 pt-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-col items-start gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Category Name"}),jsxRuntime.jsx("h3",{className:"text-lg font-semibold leading-none tracking-tight",children:t})]}),jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Niche"}),jsxRuntime.jsx("p",{className:"text-sm font-medium",children:e})]}),jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Products"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Package,{className:"h-4 w-4 text-muted-foreground"}),jsxRuntime.jsx("span",{className:"text-sm font-medium",children:n})]})]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end justify-between gap-4 h-full",children:[f,jsxRuntime.jsxs("div",{className:"flex flex-col items-end gap-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Starred"}),l?jsxRuntime.jsx(Star,{className:"h-5 w-5 fill-yellow-400 text-yellow-400"}):jsxRuntime.jsx(Star,{className:"h-5 w-5 text-muted-foreground"})]}),jsxRuntime.jsxs("div",{className:"space-y-1 flex flex-col items-end",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Auto-reorder"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[o?jsxRuntime.jsx(RefreshCw,{className:"size-4 text-green-600"}):jsxRuntime.jsx(RefreshCwOff,{className:"size-4 text-amber-600"}),jsxRuntime.jsx(Badge,{variant:o?"default":"secondary",className:cn("text-xs",o?"text-green-600 bg-green-100 hover:bg-green-200":"text-amber-600 bg-amber-100 hover:bg-amber-200"),children:o?"Enabled":"Disabled"})]})]})]})]})})}function ManufacturerProducts({applicationId:t,manufacturer:e,shopifyHostName:n}){var I,j,q,z,Q,O,F;const[o]=usePostV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeShopifyMutation(),[l,d]=React.useState(((j=(I=e.Categories)==null?void 0:I[0])==null?void 0:j.CategoryCode)||""),[f,g]=React.useState(!1),[b,S]=React.useState(!1),{toast:_}=useToast(),{data:R,isLoading:C,isFetching:E}=useGetV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeQuery({routeResellerId:t,manufacturerId:e.ManufacturerId,categoryCode:l??""},{skip:!e.ManufacturerId||!l}),A=async()=>{try{g(!0),S(!1),await o({routeResellerId:t,manufacturerId:e.ManufacturerId??"",categoryCode:l,shopifyHostName:n}).unwrap()&&_({title:"Success",description:"Category synced to Shopify successfully",variant:"success"})}catch(te){console.error("Error syncing to Shopify:",te),_({title:"Error",description:"Error syncing category to Shopify.",variant:"destructive"})}finally{g(!1)}},M=()=>{var te,ne;return((ne=(te=e.Categories)==null?void 0:te.find(se=>se.CategoryCode===l))==null?void 0:ne.CategoryName)||l};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"mb-4",children:[jsxRuntime.jsx(ManufacturerCategories,{categories:e.Categories||[],activeCategory:l,onSelectCategory:d}),jsxRuntime.jsx("div",{className:"mb-4 w-full",children:jsxRuntime.jsx(ManufacturerCategorySummary,{name:M(),niche:(R==null?void 0:R.Niche)||"",productsNumber:((q=R==null?void 0:R.Products)==null?void 0:q.length)||0,autoreorder:(R==null?void 0:R.AutoReorder)||!1,starred:(R==null?void 0:R.Starred)||!1,isLoading:C||E,children:n&&((z=e.Categories)==null?void 0:z.findIndex(te=>te.AvailableToBuy))!==-1&&jsxRuntime.jsx(Button,{className:"bg-green-600 hover:bg-green-700",disabled:f,onClick:()=>S(!0),children:f?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2 h-4 w-4"}),"Sync Category to Shopify"]})})})}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4",children:[jsxRuntime.jsx(ManufacturerCategoriesStats,{categories:[(Q=e.Categories)==null?void 0:Q.find(te=>te.CategoryCode===l)].filter(Boolean),manufID:e.ManufacturerId,appID:t}),jsxRuntime.jsx(ActiveOrdersCard,{orders:(O=R==null?void 0:R.Products)==null?void 0:O.flatMap(te=>(te.ActiveOrderDetails||[]).filter(ne=>ne.Category===l)),loading:C||E})]})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4 mb-4",children:C||E?Array.from({length:4}).map((te,ne)=>jsxRuntime.jsx(ProductCard,{},ne)):R!=null&&R.Products&&(R==null?void 0:R.Products.length)>0?(F=[...R.Products].sort((te,ne)=>{const se=te.OverallPercentileRank??0;return(ne.OverallPercentileRank??0)-se}))==null?void 0:F.map(te=>jsxRuntime.jsx(ProductCard,{applicationId:t,product:te,viewProductLink:`/${t}/Product/${te.RandmarSKU}`,shopifyHostname:n},te.RandmarSKU)):jsxRuntime.jsxs(Alert,{variant:"warning",className:"col-span-1 @md:col-span-2",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Warning"}),jsxRuntime.jsx(AlertDescription,{children:"No products found for this manufacturer category."})]})}),jsxRuntime.jsx(Dialog,{open:b,onOpenChange:S,children:jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Confirm Sync to Shopify"}),jsxRuntime.jsxs(DialogDescription,{children:['Are you sure you want to sync the category "',M(),'" to Shopify? This will add all products in this category to your Shopify store.']})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button,{variant:"outline",onClick:()=>S(!1),children:"Cancel"}),jsxRuntime.jsx(Button,{className:"bg-green-600 hover:bg-green-700",onClick:A,disabled:f,children:f?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):"Confirm Sync"})]})]})})]})}function PartnerRelationshipPage({applicationId:t,partnerId:e,userEmail:n,shopifyHostName:o,isSuperAdmin:l}){var q,z,Q;const{data:d}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:t}),{data:f,isLoading:g,isFetching:b}=useGetV4PartnerByRouteApplicationIdPartnerAndPartnerIdQuery({routeApplicationId:t,partnerId:e,withSpecification:!0}),{toast:S}=useToast(),[_]=usePostV4ResellerByRouteResellerIdManufacturerAndManufacturerIdShopifyMutation(),[R,C]=React.useState(!1),[E,A]=React.useState(!1),M=async()=>{try{C(!0),A(!1),await _({routeResellerId:t??"",manufacturerId:e??"",shopifyHostName:o}).unwrap()&&S({title:"Success",description:"Manufacturer synced to Shopify successfully",variant:"success"})}catch(O){console.error("Error syncing to Shopify:",O),S({title:"Error",description:"Error syncing manufacturer to Shopify.",variant:"destructive"})}finally{C(!1)}},I=()=>f!=null&&f.Reseller?"reseller-overview":f!=null&&f.Manufacturer?"manufacturer-overview":"",j=React.useMemo(()=>!d||!f?"":`
1134
1134
  Act as a business analyst. Your task is to provide a short, high-level summary
1135
1135
  of the relationship between the two companies described in the JSON data below.
1136
1136
  Suggest how these two entities can best work together.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "randmarcomps",
3
3
  "private": false,
4
- "version": "1.357.0",
4
+ "version": "1.358.0",
5
5
  "description": "The UI library enabling speed and consistency in Randmar frontends.",
6
6
  "type": "module",
7
7
  "files": [