randmarcomps 1.246.0 → 1.248.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.
- package/dist/randmarcomps.d.ts +1 -2
- package/dist/randmarcomps.js +72 -74
- package/dist/randmarcomps.umd.cjs +3 -3
- package/package.json +2 -2
package/dist/randmarcomps.d.ts
CHANGED
|
@@ -412,7 +412,6 @@ declare interface IProps {
|
|
|
412
412
|
declare interface IProps_2 {
|
|
413
413
|
applicationId: string;
|
|
414
414
|
sku: string;
|
|
415
|
-
readonly?: boolean;
|
|
416
415
|
productDefaultOpportunityNumber?: string;
|
|
417
416
|
productOnAddToCart?: (state: {
|
|
418
417
|
quantity: number;
|
|
@@ -590,7 +589,7 @@ declare interface ProductInventoryGridProps {
|
|
|
590
589
|
showBinLocation?: boolean;
|
|
591
590
|
}
|
|
592
591
|
|
|
593
|
-
export declare function ProductOverviewPage({ applicationId, sku,
|
|
592
|
+
export declare function ProductOverviewPage({ applicationId, sku, productDefaultOpportunityNumber, productOnAddToCart, productAddingToCart, productShopifyHostname, productCustomAction }: IProps_2): JSX.Element;
|
|
594
593
|
|
|
595
594
|
export declare const Progress: React_2.ForwardRefExoticComponent<Omit<ProgressPrimitive.ProgressProps & React_2.RefAttributes<HTMLDivElement>, "ref"> & React_2.RefAttributes<HTMLDivElement>>;
|
|
596
595
|
|
package/dist/randmarcomps.js
CHANGED
|
@@ -68796,65 +68796,63 @@ function ManufacturerReportsSection({ manufacturerId: t, userEmail: e, isLoading
|
|
|
68796
68796
|
] }) })
|
|
68797
68797
|
] });
|
|
68798
68798
|
}
|
|
68799
|
-
function ManufacturerResellerOrdersSection({
|
|
68800
|
-
manufacturerId: t
|
|
68801
|
-
}) {
|
|
68799
|
+
function ManufacturerResellerOrdersSection(t) {
|
|
68802
68800
|
const {
|
|
68803
68801
|
data: e,
|
|
68804
68802
|
isLoading: n,
|
|
68805
68803
|
isError: o
|
|
68806
68804
|
} = useGetV4ManufacturerByRouteManufacturerIdDocumentsActiveOrderDetailsQuery({
|
|
68807
|
-
routeManufacturerId: t
|
|
68808
|
-
}),
|
|
68809
|
-
if (!
|
|
68805
|
+
routeManufacturerId: t.manufacturerId
|
|
68806
|
+
}, { skip: !!t.activeOrders }), l = t.activeOrders ?? e, f = (() => {
|
|
68807
|
+
if (!l)
|
|
68810
68808
|
return {
|
|
68811
68809
|
all: { orders: 0, amount: 0 },
|
|
68812
68810
|
processing: { orders: 0, amount: 0 },
|
|
68813
68811
|
shipped: { orders: 0, amount: 0 },
|
|
68814
68812
|
delayed: { orders: 0, amount: 0 }
|
|
68815
68813
|
};
|
|
68816
|
-
const
|
|
68814
|
+
const b = l.filter((Q) => Q.DocumentType === "Order"), S = l.filter((Q) => Q.DocumentType === "Shipment"), _ = b.filter((Q) => Q.WarehouseCode !== "3PLE"), C = _.reduce((Q, F) => Q + (F.Quantity || 0), 0), E = _.reduce((Q, F) => Q + (F.ExtendedPrice || 0), 0), R = b.filter((Q) => Q.WarehouseCode === "3PLE"), A = R.reduce((Q, F) => Q + (F.Quantity || 0), 0), I = R.reduce((Q, F) => Q + (F.ExtendedPrice || 0), 0), M = S.length, O = S.reduce((Q, F) => Q + (F.ExtendedPrice || 0), 0), q = C + A + M, z = E + I + O;
|
|
68817
68815
|
return {
|
|
68818
|
-
all: { orders:
|
|
68819
|
-
processing: { orders:
|
|
68820
|
-
shipped: { orders:
|
|
68821
|
-
delayed: { orders:
|
|
68816
|
+
all: { orders: q, amount: z },
|
|
68817
|
+
processing: { orders: C, amount: E },
|
|
68818
|
+
shipped: { orders: M, amount: O },
|
|
68819
|
+
delayed: { orders: A, amount: I }
|
|
68822
68820
|
};
|
|
68823
|
-
})(),
|
|
68821
|
+
})(), g = [
|
|
68824
68822
|
{
|
|
68825
68823
|
name: "All",
|
|
68826
68824
|
icon: Package,
|
|
68827
68825
|
color: "bg-blue-500",
|
|
68828
|
-
orders:
|
|
68829
|
-
amount:
|
|
68826
|
+
orders: f.all.orders,
|
|
68827
|
+
amount: f.all.amount
|
|
68830
68828
|
},
|
|
68831
68829
|
{
|
|
68832
68830
|
name: "Processing",
|
|
68833
68831
|
icon: RefreshCcw,
|
|
68834
68832
|
color: "bg-yellow-500",
|
|
68835
|
-
orders:
|
|
68836
|
-
amount:
|
|
68833
|
+
orders: f.processing.orders,
|
|
68834
|
+
amount: f.processing.amount
|
|
68837
68835
|
},
|
|
68838
68836
|
{
|
|
68839
68837
|
name: "Shipped",
|
|
68840
68838
|
icon: Truck,
|
|
68841
68839
|
color: "bg-green-500",
|
|
68842
|
-
orders:
|
|
68843
|
-
amount:
|
|
68840
|
+
orders: f.shipped.orders,
|
|
68841
|
+
amount: f.shipped.amount
|
|
68844
68842
|
},
|
|
68845
68843
|
{
|
|
68846
68844
|
name: "Delayed",
|
|
68847
68845
|
icon: CircleAlert,
|
|
68848
68846
|
color: "bg-red-500",
|
|
68849
|
-
orders:
|
|
68850
|
-
amount:
|
|
68847
|
+
orders: f.delayed.orders,
|
|
68848
|
+
amount: f.delayed.amount
|
|
68851
68849
|
}
|
|
68852
68850
|
];
|
|
68853
68851
|
return n ? /* @__PURE__ */ jsxs(Card, { className: "w-full md:col-span-2 xl:col-span-1", children: [
|
|
68854
68852
|
/* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { className: "text-1xl font-bold", children: "Reseller Orders" }) }),
|
|
68855
68853
|
/* @__PURE__ */ jsxs(CardContent, { children: [
|
|
68856
68854
|
/* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-40 mb-4" }),
|
|
68857
|
-
/* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3.5", children: [1, 2, 3, 4].map((
|
|
68855
|
+
/* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3.5", children: [1, 2, 3, 4].map((b) => /* @__PURE__ */ jsx(Skeleton, { className: "h-32 w-full" }, b)) })
|
|
68858
68856
|
] })
|
|
68859
68857
|
] }) : o ? /* @__PURE__ */ jsxs(Card, { className: "w-full md:col-span-2 xl:col-span-1", children: [
|
|
68860
68858
|
/* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { className: "text-1xl font-bold", children: "Reseller Orders" }) }),
|
|
@@ -68868,26 +68866,26 @@ function ManufacturerResellerOrdersSection({
|
|
|
68868
68866
|
/* @__PURE__ */ jsxs(CardContent, { children: [
|
|
68869
68867
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center mb-4", children: [
|
|
68870
68868
|
/* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: "Active Orders:" }),
|
|
68871
|
-
/* @__PURE__ */ jsx("span", { className: "ml-2 font-bold", children:
|
|
68869
|
+
/* @__PURE__ */ jsx("span", { className: "ml-2 font-bold", children: f.all.orders })
|
|
68872
68870
|
] }),
|
|
68873
|
-
/* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3.5", children:
|
|
68874
|
-
/* @__PURE__ */ jsx("div", { className: `${
|
|
68871
|
+
/* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3.5", children: g.map((b) => /* @__PURE__ */ jsx(Card, { className: "overflow-hidden rounded-md rounded-b-lg border-0 shadow-md", children: /* @__PURE__ */ jsxs(CardContent, { className: "p-0", children: [
|
|
68872
|
+
/* @__PURE__ */ jsx("div", { className: `${b.color} bg-opacity-60 h-[3px]` }),
|
|
68875
68873
|
/* @__PURE__ */ jsxs("div", { className: "p-6 border border-t-0", children: [
|
|
68876
68874
|
/* @__PURE__ */ jsxs("div", { className: "flex justify-between items-center mb-4", children: [
|
|
68877
|
-
/* @__PURE__ */ jsx("h3", { className: "font-semibold text-base", children:
|
|
68878
|
-
/* @__PURE__ */ jsx("div", { className: `${
|
|
68875
|
+
/* @__PURE__ */ jsx("h3", { className: "font-semibold text-base", children: b.name }),
|
|
68876
|
+
/* @__PURE__ */ jsx("div", { className: `${b.color} bg-opacity-90 p-2 rounded-full`, children: /* @__PURE__ */ jsx(b.icon, { className: "size-4 shrink-0 text-white" }) })
|
|
68879
68877
|
] }),
|
|
68880
68878
|
/* @__PURE__ */ jsxs("div", { className: "flex justify-between items-start", children: [
|
|
68881
68879
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
68882
68880
|
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Total Orders" }),
|
|
68883
|
-
/* @__PURE__ */ jsx("p", { className: "text-xl font-bold", children:
|
|
68881
|
+
/* @__PURE__ */ jsx("p", { className: "text-xl font-bold", children: b.orders })
|
|
68884
68882
|
] }),
|
|
68885
68883
|
/* @__PURE__ */ jsxs("div", { className: "text-end", children: [
|
|
68886
68884
|
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Total Amount" }),
|
|
68887
68885
|
/* @__PURE__ */ jsx("p", { className: "text-base font-semibold", children: /* @__PURE__ */ jsx(
|
|
68888
68886
|
FormattedNumber,
|
|
68889
68887
|
{
|
|
68890
|
-
value:
|
|
68888
|
+
value: b.amount,
|
|
68891
68889
|
style: "currency",
|
|
68892
68890
|
currency: "CAD",
|
|
68893
68891
|
currencyDisplay: "symbol"
|
|
@@ -68896,7 +68894,7 @@ function ManufacturerResellerOrdersSection({
|
|
|
68896
68894
|
] })
|
|
68897
68895
|
] })
|
|
68898
68896
|
] })
|
|
68899
|
-
] }) },
|
|
68897
|
+
] }) }, b.name)) })
|
|
68900
68898
|
] })
|
|
68901
68899
|
] });
|
|
68902
68900
|
}
|
|
@@ -69230,7 +69228,8 @@ function ManufacturerOverviewPage({
|
|
|
69230
69228
|
/* @__PURE__ */ jsx(
|
|
69231
69229
|
ManufacturerResellerOrdersSection,
|
|
69232
69230
|
{
|
|
69233
|
-
manufacturerId: t
|
|
69231
|
+
manufacturerId: t,
|
|
69232
|
+
activeOrders: (R == null ? void 0 : R.ActiveOrderDetails) ?? void 0
|
|
69234
69233
|
}
|
|
69235
69234
|
),
|
|
69236
69235
|
n && /* @__PURE__ */ jsx(
|
|
@@ -84115,7 +84114,7 @@ function ResellerOpportunitiesTable({
|
|
|
84115
84114
|
return /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: "Actions unavailable" });
|
|
84116
84115
|
const se = ae.BidNumber, ge = ($e = l[se]) == null ? void 0 : $e.isSettingDefault, oe = (_ == null ? void 0 : _.BidNumber) === se && ((Oe = l[se]) == null ? void 0 : Oe.isSendingReport), Ae = ge || oe, Ne = ae.CanBeSetAsDefault === !0;
|
|
84117
84116
|
return /* @__PURE__ */ jsxs("div", { className: "flex space-x-2", children: [
|
|
84118
|
-
/* @__PURE__ */ jsx("a", { href:
|
|
84117
|
+
/* @__PURE__ */ jsx("a", { href: `/${t}/Opportunity/${ae.ManufacturerId}/${ae.BidNumber}`, children: /* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", className: "flex items-center", children: [
|
|
84119
84118
|
/* @__PURE__ */ jsx(Star, { className: "mr-2 h-4 w-4" }),
|
|
84120
84119
|
" View"
|
|
84121
84120
|
] }) }),
|
|
@@ -84420,23 +84419,22 @@ function ReceiptsTable({
|
|
|
84420
84419
|
function ProductOverviewPage({
|
|
84421
84420
|
applicationId: t,
|
|
84422
84421
|
sku: e,
|
|
84423
|
-
readonly
|
|
84424
|
-
productDefaultOpportunityNumber:
|
|
84425
|
-
productOnAddToCart:
|
|
84426
|
-
productAddingToCart:
|
|
84427
|
-
productShopifyHostname:
|
|
84428
|
-
productCustomAction:
|
|
84422
|
+
//readonly = false,
|
|
84423
|
+
productDefaultOpportunityNumber: n = "",
|
|
84424
|
+
productOnAddToCart: o,
|
|
84425
|
+
productAddingToCart: l = !1,
|
|
84426
|
+
productShopifyHostname: d,
|
|
84427
|
+
productCustomAction: f = /* @__PURE__ */ jsx(Fragment$1, {})
|
|
84429
84428
|
}) {
|
|
84430
|
-
console.log("ProductOverviewPage", "readonly", n);
|
|
84431
84429
|
const {
|
|
84432
|
-
data:
|
|
84430
|
+
data: g
|
|
84433
84431
|
} = useGetV4PartnerByApplicationIdAccountQuery({
|
|
84434
84432
|
applicationId: t
|
|
84435
84433
|
}, {
|
|
84436
84434
|
skip: !t || !e
|
|
84437
84435
|
}), {
|
|
84438
|
-
data:
|
|
84439
|
-
isLoading:
|
|
84436
|
+
data: b,
|
|
84437
|
+
isLoading: S
|
|
84440
84438
|
} = useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({
|
|
84441
84439
|
routeApplicationId: t,
|
|
84442
84440
|
randmarSku: e,
|
|
@@ -84444,27 +84442,27 @@ function ProductOverviewPage({
|
|
|
84444
84442
|
}, {
|
|
84445
84443
|
skip: !t || !e
|
|
84446
84444
|
}), {
|
|
84447
|
-
data:
|
|
84448
|
-
isLoading:
|
|
84445
|
+
data: _,
|
|
84446
|
+
isLoading: C
|
|
84449
84447
|
} = useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({
|
|
84450
84448
|
routeApplicationId: t,
|
|
84451
84449
|
randmarSku: e,
|
|
84452
84450
|
withSpecification: !0
|
|
84453
84451
|
}, {
|
|
84454
|
-
skip: !
|
|
84455
|
-
});
|
|
84456
|
-
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
84452
|
+
skip: !b
|
|
84453
|
+
}), E = (b == null ? void 0 : b.ManufacturerId) !== t;
|
|
84454
|
+
return console.log("readonly", E), /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
84457
84455
|
/* @__PURE__ */ jsxs("div", { className: "grid gap-4 grid-cols-1 md:grid-cols-2 lg:grid-cols-3", children: [
|
|
84458
84456
|
/* @__PURE__ */ jsx("div", { className: "lg:col-span-2", children: /* @__PURE__ */ jsx(
|
|
84459
84457
|
ProductCard,
|
|
84460
84458
|
{
|
|
84461
84459
|
applicationId: t,
|
|
84462
|
-
product:
|
|
84463
|
-
defaultOpportunityNumber:
|
|
84464
|
-
onAddToCart:
|
|
84465
|
-
addingToCart:
|
|
84466
|
-
shopifyHostname:
|
|
84467
|
-
customAction:
|
|
84460
|
+
product: _ || b,
|
|
84461
|
+
defaultOpportunityNumber: n,
|
|
84462
|
+
onAddToCart: o,
|
|
84463
|
+
addingToCart: l,
|
|
84464
|
+
shopifyHostname: d,
|
|
84465
|
+
customAction: f
|
|
84468
84466
|
}
|
|
84469
84467
|
) }),
|
|
84470
84468
|
/* @__PURE__ */ jsxs(Card, { children: [
|
|
@@ -84472,7 +84470,7 @@ function ProductOverviewPage({
|
|
|
84472
84470
|
/* @__PURE__ */ jsx(Info, { className: "h-5 w-5 inline mr-2" }),
|
|
84473
84471
|
" Additionnal information"
|
|
84474
84472
|
] }) }),
|
|
84475
|
-
/* @__PURE__ */ jsx(CardContent, { children:
|
|
84473
|
+
/* @__PURE__ */ jsx(CardContent, { children: S ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
84476
84474
|
/* @__PURE__ */ jsxs("div", { className: "flex justify-between", children: [
|
|
84477
84475
|
/* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-32" }),
|
|
84478
84476
|
/* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-24" })
|
|
@@ -84496,30 +84494,30 @@ function ProductOverviewPage({
|
|
|
84496
84494
|
] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
84497
84495
|
/* @__PURE__ */ jsxs("div", { className: "flex justify-between", children: [
|
|
84498
84496
|
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "Cateory Name" }),
|
|
84499
|
-
/* @__PURE__ */ jsx("span", { className: "font-medium", children: (
|
|
84497
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium", children: (b == null ? void 0 : b.ProductType) || "N/A" })
|
|
84500
84498
|
] }),
|
|
84501
84499
|
/* @__PURE__ */ jsxs("div", { className: "flex justify-between mt-2", children: [
|
|
84502
84500
|
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "Master Carton" }),
|
|
84503
|
-
/* @__PURE__ */ jsx("span", { className: "font-medium", children: (
|
|
84501
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium", children: (b == null ? void 0 : b.MasterCarton) || "N/A" })
|
|
84504
84502
|
] }),
|
|
84505
84503
|
/* @__PURE__ */ jsxs("div", { className: "flex justify-between mt-2", children: [
|
|
84506
84504
|
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "Skid Quantity" }),
|
|
84507
|
-
/* @__PURE__ */ jsx("span", { className: "font-medium", children: (
|
|
84505
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium", children: (b == null ? void 0 : b.SkidQuantity) || "N/A" })
|
|
84508
84506
|
] }),
|
|
84509
84507
|
/* @__PURE__ */ jsxs("div", { className: "flex justify-between mt-2", children: [
|
|
84510
84508
|
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "Automatic Reorder" }),
|
|
84511
|
-
/* @__PURE__ */ jsx("span", { className: "font-medium", children:
|
|
84509
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium", children: b != null && b.AutoUpdate ? "Yes" : "No" })
|
|
84512
84510
|
] }),
|
|
84513
|
-
((
|
|
84511
|
+
((b == null ? void 0 : b.VoiceoverCaption) || (b == null ? void 0 : b.BodyHTML)) && /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
84514
84512
|
/* @__PURE__ */ jsx("hr", { className: "my-6" }),
|
|
84515
84513
|
/* @__PURE__ */ jsx("div", { className: "text-muted-foreground mb-2", children: "Description" }),
|
|
84516
84514
|
/* @__PURE__ */ jsxs("div", { className: "max-h-44 overflow-scroll", children: [
|
|
84517
|
-
(
|
|
84518
|
-
(
|
|
84515
|
+
(b == null ? void 0 : b.VoiceoverCaption) && /* @__PURE__ */ jsx("div", { children: b == null ? void 0 : b.VoiceoverCaption }),
|
|
84516
|
+
(b == null ? void 0 : b.BodyHTML) && /* @__PURE__ */ jsx(
|
|
84519
84517
|
"div",
|
|
84520
84518
|
{
|
|
84521
84519
|
className: "prose prose-sm max-w-none",
|
|
84522
|
-
dangerouslySetInnerHTML: { __html: (
|
|
84520
|
+
dangerouslySetInnerHTML: { __html: (b == null ? void 0 : b.BodyHTML) ?? "" }
|
|
84523
84521
|
}
|
|
84524
84522
|
)
|
|
84525
84523
|
] })
|
|
@@ -84527,7 +84525,7 @@ function ProductOverviewPage({
|
|
|
84527
84525
|
] }) })
|
|
84528
84526
|
] })
|
|
84529
84527
|
] }),
|
|
84530
|
-
/* @__PURE__ */ jsx("div", { className: "my-4", children:
|
|
84528
|
+
/* @__PURE__ */ jsx("div", { className: "my-4", children: S ? /* @__PURE__ */ jsx("div", { className: "mx-auto flex justify-center items-center h-32", children: /* @__PURE__ */ jsx(LoaderCircle, { className: "h-8 w-8 animate-spin text-primary" }) }) : /* @__PURE__ */ jsxs(Tabs, { defaultValue: "stats", children: [
|
|
84531
84529
|
/* @__PURE__ */ jsxs(TabsList, { className: "inline-flex h-auto items-center justify-center rounded-none border-b bg-transparent p-0", children: [
|
|
84532
84530
|
/* @__PURE__ */ jsx(
|
|
84533
84531
|
TabsTrigger,
|
|
@@ -84537,7 +84535,7 @@ function ProductOverviewPage({
|
|
|
84537
84535
|
children: "Statistics"
|
|
84538
84536
|
}
|
|
84539
84537
|
),
|
|
84540
|
-
(
|
|
84538
|
+
(g == null ? void 0 : g.IsReseller) && /* @__PURE__ */ jsx(
|
|
84541
84539
|
TabsTrigger,
|
|
84542
84540
|
{
|
|
84543
84541
|
value: "opportunities",
|
|
@@ -84565,16 +84563,16 @@ function ProductOverviewPage({
|
|
|
84565
84563
|
/* @__PURE__ */ jsx(TabsContent, { value: "stats", children: /* @__PURE__ */ jsx("div", { className: "mt-4", children: /* @__PURE__ */ jsx(
|
|
84566
84564
|
SalesChart,
|
|
84567
84565
|
{
|
|
84568
|
-
salesData: (
|
|
84569
|
-
isLoading:
|
|
84566
|
+
salesData: (_ == null ? void 0 : _.SalesStatistics) ?? [],
|
|
84567
|
+
isLoading: C
|
|
84570
84568
|
}
|
|
84571
84569
|
) }) }),
|
|
84572
|
-
(
|
|
84570
|
+
(g == null ? void 0 : g.IsReseller) && /* @__PURE__ */ jsx(TabsContent, { value: "opportunities", children: /* @__PURE__ */ jsx("div", { className: "mt-4", children: /* @__PURE__ */ jsx(
|
|
84573
84571
|
ResellerOpportunitiesTable,
|
|
84574
84572
|
{
|
|
84575
84573
|
applicationId: t,
|
|
84576
|
-
opportunities:
|
|
84577
|
-
loading:
|
|
84574
|
+
opportunities: b == null ? void 0 : b.Opportunities,
|
|
84575
|
+
loading: S
|
|
84578
84576
|
}
|
|
84579
84577
|
) }) }),
|
|
84580
84578
|
/* @__PURE__ */ jsxs(TabsContent, { value: "orders", children: [
|
|
@@ -84582,24 +84580,24 @@ function ProductOverviewPage({
|
|
|
84582
84580
|
OrdersTable,
|
|
84583
84581
|
{
|
|
84584
84582
|
title: "Open Orders",
|
|
84585
|
-
orders:
|
|
84586
|
-
loading:
|
|
84583
|
+
orders: _ == null ? void 0 : _.ActiveOrderDetails,
|
|
84584
|
+
loading: C
|
|
84587
84585
|
}
|
|
84588
84586
|
) }),
|
|
84589
84587
|
/* @__PURE__ */ jsx("div", { className: "mt-4", children: /* @__PURE__ */ jsx(
|
|
84590
84588
|
OrdersTable,
|
|
84591
84589
|
{
|
|
84592
84590
|
title: "Completed Orders",
|
|
84593
|
-
orders:
|
|
84594
|
-
loading:
|
|
84591
|
+
orders: _ == null ? void 0 : _.CompletedOrderDetails,
|
|
84592
|
+
loading: C
|
|
84595
84593
|
}
|
|
84596
84594
|
) })
|
|
84597
84595
|
] }),
|
|
84598
84596
|
/* @__PURE__ */ jsx(TabsContent, { value: "warehouse", children: /* @__PURE__ */ jsx("div", { className: "mt-4", children: /* @__PURE__ */ jsx(
|
|
84599
84597
|
ReceiptsTable,
|
|
84600
84598
|
{
|
|
84601
|
-
receipts:
|
|
84602
|
-
loading:
|
|
84599
|
+
receipts: _ == null ? void 0 : _.Receipts,
|
|
84600
|
+
loading: C
|
|
84603
84601
|
}
|
|
84604
84602
|
) }) })
|
|
84605
84603
|
] }) })
|
|
@@ -1082,12 +1082,12 @@ $10 with opportunities under $1,000`:t==="D"?"$15 under $1,500":t==="E"?"Full sh
|
|
|
1082
1082
|
* LICENSE.md file in the root directory of this source tree.
|
|
1083
1083
|
*
|
|
1084
1084
|
* @license MIT
|
|
1085
|
-
*/function flexRender(t,e){return t?isReactComponent(t)?React__namespace.createElement(t,e):t:null}function isReactComponent(t){return isClassComponent(t)||typeof t=="function"||isExoticComponent(t)}function isClassComponent(t){return typeof t=="function"&&(()=>{const e=Object.getPrototypeOf(t);return e.prototype&&e.prototype.isReactComponent})()}function isExoticComponent(t){return typeof t=="object"&&typeof t.$$typeof=="symbol"&&["react.memo","react.forward_ref"].includes(t.$$typeof.description)}function useReactTable(t){const e={state:{},onStateChange:()=>{},renderFallbackValue:null,...t},[n]=React__namespace.useState(()=>({current:createTable(e)})),[o,l]=React__namespace.useState(()=>n.current.initialState);return n.current.setOptions(d=>({...d,...t,state:{...o,...t.state},onStateChange:f=>{l(f),t.onStateChange==null||t.onStateChange(f)}})),n.current}function DataTable({columns:t,data:e,uniqueValues:n}){var E;const[o,l]=React.useState([]),[d,f]=React.useState([]),[g,b]=React.useState({pageIndex:0,pageSize:10}),[_,S]=React.useState(null),R=useReactTable({data:e,columns:t,getCoreRowModel:getCoreRowModel(),onSortingChange:l,getSortedRowModel:getSortedRowModel(),onColumnFiltersChange:f,getFilteredRowModel:getFilteredRowModel(),getPaginationRowModel:getPaginationRowModel(),onPaginationChange:b,state:{sorting:o,columnFilters:d,pagination:g}}),C=(A,I)=>{A.toggleSorting(I),S(null)};return jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs(ScrollArea,{className:"rounded-md border",children:[jsxRuntime.jsxs(Table,{children:[jsxRuntime.jsx(TableHeader,{children:R.getHeaderGroups().map(A=>jsxRuntime.jsx(TableRow,{children:A.headers.map(I=>{var M;return jsxRuntime.jsx(TableHead,{children:I.isPlaceholder?null:I.column.getCanSort()||I.column.getCanFilter()?jsxRuntime.jsxs(Popover,{open:_===I.id,onOpenChange:j=>S(j?I.id:null),children:[jsxRuntime.jsx(PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button,{variant:"ghost",className:"pl-0",children:[flexRender(I.column.columnDef.header,I.getContext()),I.column.getIsFiltered()?jsxRuntime.jsx(Filter,{className:"ml-2 h-4 w-4"}):I.column.getIsSorted()==="asc"?jsxRuntime.jsx(ArrowUp,{className:"ml-2 h-4 w-4"}):I.column.getIsSorted()==="desc"?jsxRuntime.jsx(ArrowDown,{className:"ml-2 h-4 w-4"}):jsxRuntime.jsx(ArrowUpDown,{className:"ml-2 h-4 w-4"})]})}),jsxRuntime.jsx(PopoverContent,{className:"w-56",children:jsxRuntime.jsxs("div",{className:"space-y-2",children:[I.column.getCanSort()&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Button,{variant:"ghost",className:"w-full justify-start",onClick:()=>C(I.column,!1),children:[jsxRuntime.jsx(ArrowUp,{className:"mr-2 h-4 w-4"}),"Sort Ascending"]}),jsxRuntime.jsxs(Button,{variant:"ghost",className:"w-full justify-start",onClick:()=>C(I.column,!0),children:[jsxRuntime.jsx(ArrowDown,{className:"mr-2 h-4 w-4"}),"Sort Descending"]})]}),I.column.getCanFilter()&&jsxRuntime.jsx("div",{className:"px-2 py-1",children:n[I.column.id]?jsxRuntime.jsxs(Select,{onValueChange:j=>I.column.setFilterValue(j==="all"?void 0:[j]),children:[jsxRuntime.jsx(SelectTrigger,{children:jsxRuntime.jsx(SelectValue,{placeholder:`Filter ${I.column.columnDef.header}...`})}),jsxRuntime.jsxs(SelectContent,{children:[jsxRuntime.jsx(SelectItem,{value:"all",children:"All"}),(M=n[I.column.id])==null?void 0:M.map(j=>jsxRuntime.jsx(SelectItem,{value:j||"empty",children:j||"(Empty)"},j))]})]}):jsxRuntime.jsx(Input,{placeholder:`Filter ${I.column.columnDef.header}...`,value:I.column.getFilterValue()??"",onChange:j=>I.column.setFilterValue(j.target.value),className:"w-full"})})]})})]}):jsxRuntime.jsx("div",{className:"py-2 px-4",children:flexRender(I.column.columnDef.header,I.getContext())})},I.id)})},A.id))}),jsxRuntime.jsx(TableBody,{children:(E=R.getRowModel().rows)!=null&&E.length?R.getRowModel().rows.map(A=>jsxRuntime.jsx(TableRow,{"data-state":A.getIsSelected()&&"selected",children:A.getVisibleCells().map(I=>jsxRuntime.jsx(TableCell,{children:flexRender(I.column.columnDef.cell,I.getContext())},I.id))},A.id)):jsxRuntime.jsx(TableRow,{children:jsxRuntime.jsx(TableCell,{colSpan:t.length,className:"h-24 text-center",children:"No results."})})})]}),jsxRuntime.jsx(ScrollBar,{orientation:"horizontal"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx("p",{className:"text-sm font-medium",children:"Rows per page"}),jsxRuntime.jsxs(Select,{value:`${R.getState().pagination.pageSize}`,onValueChange:A=>{R.setPageSize(Number(A))},children:[jsxRuntime.jsx(SelectTrigger,{className:"h-8 w-[70px]",children:jsxRuntime.jsx(SelectValue,{placeholder:R.getState().pagination.pageSize})}),jsxRuntime.jsx(SelectContent,{side:"top",children:[10,20,30,40,50].map(A=>jsxRuntime.jsx(SelectItem,{value:`${A}`,children:A},A))})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsxs(Button,{variant:"outline",className:"hidden h-8 w-8 p-0 lg:flex",onClick:()=>R.setPageIndex(0),disabled:!R.getCanPreviousPage(),children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Go to first page"}),jsxRuntime.jsx(ChevronsLeft,{className:"h-4 w-4"})]}),jsxRuntime.jsxs(Button,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>R.previousPage(),disabled:!R.getCanPreviousPage(),children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Go to previous page"}),jsxRuntime.jsx(ChevronLeft,{className:"h-4 w-4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("p",{className:"text-sm font-medium",children:"Page"}),jsxRuntime.jsx("span",{className:"text-sm font-medium",children:R.getState().pagination.pageIndex+1}),jsxRuntime.jsx("p",{className:"text-sm font-medium",children:"of"}),jsxRuntime.jsx("span",{className:"text-sm font-medium",children:R.getPageCount()})]}),jsxRuntime.jsxs(Button,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>R.nextPage(),disabled:!R.getCanNextPage(),children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Go to next page"}),jsxRuntime.jsx(ChevronRight,{className:"h-4 w-4"})]}),jsxRuntime.jsxs(Button,{variant:"outline",className:"hidden h-8 w-8 p-0 lg:flex",onClick:()=>R.setPageIndex(R.getPageCount()-1),disabled:!R.getCanNextPage(),children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Go to last page"}),jsxRuntime.jsx(ChevronsRight,{className:"h-4 w-4"})]})]})]})]})}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.jsx(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},o.CategoryCode))})})})}function ManufacturerProducts({applicationId:t,manufacturer:e,shopifyHostName:n}){var M,j,q,z;const[o]=usePostV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeShopifyMutation(),[l,d]=React.useState(((j=(M=e.Categories)==null?void 0:M[0])==null?void 0:j.CategoryCode)||""),[f,g]=React.useState(!1),[b,_]=React.useState(!1),{toast:S}=useToast(),{data:R,isLoading:C,isFetching:E}=useGetV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeQuery({routeResellerId:t,manufacturerId:e.ManufacturerId,categoryCode:l??""},{skip:!e.ManufacturerId||!l}),A=async()=>{try{g(!0),_(!1),await o({routeResellerId:t,manufacturerId:e.ManufacturerId??"",categoryCode:l,shopifyHostName:n}).unwrap()&&S({title:"Success",description:"Category synced to Shopify successfully",variant:"success"})}catch(Q){console.error("Error syncing to Shopify:",Q),S({title:"Error",description:"Error syncing category to Shopify.",variant:"destructive"})}finally{g(!1)}},I=()=>{var Q,F;return((F=(Q=e.Categories)==null?void 0:Q.find(V=>V.CategoryCode===l))==null?void 0:F.CategoryName)||l};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(ManufacturerCategories,{categories:e.Categories||[],activeCategory:l,onSelectCategory:d}),n&&((q=e.Categories)==null?void 0:q.findIndex(Q=>Q.AvailableToBuy))!==-1&&jsxRuntime.jsxs(Dialog,{open:b,onOpenChange:_,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 "',I(),'" to Shopify? This will add all products in this category to your Shopify store.']})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button,{variant:"outline",onClick:()=>_(!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:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-2 gap-4 mb-4",children:C||E?Array.from({length:4}).map((Q,F)=>jsxRuntime.jsx(ProductCard,{},F)):R!=null&&R.Products&&(R==null?void 0:R.Products.length)>0?(z=R==null?void 0:R.Products)==null?void 0:z.map(Q=>jsxRuntime.jsx(ProductCard,{applicationId:t,product:Q,viewProductLink:`/${t}/Product/${Q.RandmarSKU}`,shopifyHostname:n},Q.RandmarSKU)):jsxRuntime.jsxs(Alert,{variant:"warning",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 I,M,j;const{data:d,isLoading:f}=useGetV4PartnerByRouteApplicationIdPartnerAndPartnerIdQuery({routeApplicationId:t,partnerId:e,withSpecification:!0}),{toast:g}=useToast(),[b]=usePostV4ResellerByRouteResellerIdManufacturerAndManufacturerIdShopifyMutation(),[_,S]=React.useState(!1),[R,C]=React.useState(!1),E=async()=>{try{S(!0),C(!1),await b({routeResellerId:t??"",manufacturerId:e??"",shopifyHostName:o}).unwrap()&&g({title:"Success",description:"Manufacturer synced to Shopify successfully",variant:"success"})}catch(q){console.error("Error syncing to Shopify:",q),g({title:"Error",description:"Error syncing manufacturer to Shopify.",variant:"destructive"})}finally{S(!1)}},A=()=>d!=null&&d.Reseller?"reseller-overview":d!=null&&d.Manufacturer?"manufacturer-overview":"";return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"grid gap-4 grid-cols-1 md:grid-cols-2",children:[jsxRuntime.jsx(PartnerCard,{account:d,loading:f,withAbout:!0,withVoice:!1,action:" "}),jsxRuntime.jsxs("div",{className:"grid gap-4",children:[((d==null?void 0:d.Manufacturer)||f)&&jsxRuntime.jsx(ManufacturerCard,{manufacturer:d==null?void 0:d.Manufacturer,loading:f,mainAction:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[(d==null?void 0:d.Manufacturer)&&jsxRuntime.jsx(ManufacturerGetStartedButton,{applicationId:t,manufacturer:d==null?void 0:d.Manufacturer}),o&&((M=(I=d==null?void 0:d.Manufacturer)==null?void 0:I.Categories)==null?void 0:M.findIndex(q=>q.AvailableToBuy))!==-1&&jsxRuntime.jsxs(Dialog,{open:R,onOpenChange:C,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{className:"bg-green-600 hover:bg-green-700 ml-2",disabled:_,children:_?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 Manufacturer 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 manufacturer "',(j=d==null?void 0:d.Manufacturer)==null?void 0:j.PublicName,'" to Shopify? This will add all products from this manufacturer to your Shopify store.']})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button,{variant:"outline",onClick:()=>C(!1),children:"Cancel"}),jsxRuntime.jsx(Button,{className:"bg-green-600 hover:bg-green-700",onClick:E,disabled:_,children:_?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):"Confirm Sync"})]})]})]})]})}),(d==null?void 0:d.Reseller)&&jsxRuntime.jsx(ResellerCard,{reseller:d==null?void 0:d.Reseller,loading:f})]})]}),((d==null?void 0:d.Reseller)||(d==null?void 0:d.Manufacturer))&&!f&&jsxRuntime.jsx("div",{className:"max-w-6xl mx-auto p-4",children:jsxRuntime.jsxs(Tabs,{defaultValue:A(),className:"w-full",children:[jsxRuntime.jsxs(TabsList,{className:"inline-flex h-auto items-center justify-center rounded-none border-b bg-transparent p-0",children:[(d==null?void 0:d.Reseller)&&jsxRuntime.jsx(TabsTrigger,{value:"reseller-overview",className:"reseller-theme relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Reseller Overview"}),(d==null?void 0:d.Manufacturer)&&jsxRuntime.jsx(TabsTrigger,{value:"manufacturer-overview",className:"manufacturer-theme relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Manufacturer Overview"}),(d==null?void 0:d.Manufacturer)&&jsxRuntime.jsx(TabsTrigger,{value:"products",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Products"})]}),(d==null?void 0:d.Reseller)&&jsxRuntime.jsx(TabsContent,{value:"reseller-overview",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ResellerOverview,{readonly:!0,appID:d.ApplicationId||"",reseller:d==null?void 0:d.Reseller,userEmail:n,isSuperAdmin:l,withoutReports:!0})})}),(d==null?void 0:d.Manufacturer)&&jsxRuntime.jsx(TabsContent,{value:"manufacturer-overview",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ManufacturerOverviewPage,{readonly:!0,manufacturer:d==null?void 0:d.Manufacturer,applicationId:d.ApplicationId||"",userEmail:n})})}),(d==null?void 0:d.Manufacturer)&&jsxRuntime.jsx(TabsContent,{value:"products",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ManufacturerProducts,{applicationId:t,manufacturer:d.Manufacturer,shopifyHostName:o})})})]})}),f&&jsxRuntime.jsx("div",{className:"max-w-6xl mx-auto p-4 mt-4 flex justify-center items-center h-32",children:jsxRuntime.jsx(LoaderCircle,{className:"h-8 w-8 animate-spin text-primary"})})]})}function ManufacturerBillingInfoSection({manufacturer:t,readonly:e=!1,isLoading:n,onUnsavedChanges:o}){const{toast:l}=useToast(),[d]=usePostV4PartnerByApplicationIdAccountManufacturerAndFieldNameMutation(),[f,g]=React.useState({}),b=React.useMemo(()=>({accountsPayableRep:(t==null?void 0:t.ContactName)??"",representativeEmail:(t==null?void 0:t.RepresentativeEmail)??"",phone:(t==null?void 0:t.Phone)??"",creditLimit:(t==null?void 0:t.CreditLimit)??0,terms:(t==null?void 0:t.Terms)??""}),[t]),{register:_,handleSubmit:S,reset:R,watch:C,formState:{errors:E,isSubmitting:A}}=useForm({defaultValues:b}),I=C(),M=React.useCallback(()=>e||!f?!1:JSON.stringify(I)!==JSON.stringify(f),[e,I,f]);React.useEffect(()=>{o&&o(M())},[M,o]),React.useEffect(()=>{t&&(R(b),g(b))},[t,R,b]);const j=async q=>{if(e)return;let z=!0,Q=!1;const F=[{key:"accountsPayableRep",apiKey:"ContactName",value:q.accountsPayableRep},{key:"representativeEmail",apiKey:"RepresentativeEmail",value:q.representativeEmail},{key:"phone",apiKey:"Phone",value:q.phone},{key:"terms",apiKey:"Terms",value:q.terms}];for(const V of F){const te=V.value,ae=t==null?void 0:t[V.apiKey];if(te!==ae&&te!==void 0){Q=!0;try{await d({applicationId:(t==null?void 0:t.ManufacturerId)??"",fieldName:V.apiKey,newValue:String(te)}).unwrap()||(z=!1,console.error(`Failed to update ${V.apiKey}`))}catch(se){console.error(`Error updating ${V.apiKey}:`,se),z=!1}}}z&&Q?(l({title:"Billing info",description:"Information updated successfully",variant:"success"}),g({...q}),o&&o(!1)):z?Q||l({title:"No changes",description:"No changes were made to the information.",variant:"info"}):l({title:"Update error",description:"Failed to update. Please try again.",variant:"destructive"})};return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Billing, Credit, & Rebates"})}),jsxRuntime.jsx(CardContent,{children:n?jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-48"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-36"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-16"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-16"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-20"})]}):jsxRuntime.jsxs("form",{onSubmit:S(j),className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{className:"text-sm font-medium leading-none",htmlFor:"accountsPayableRep",children:"Accounts Payable Representative"}),jsxRuntime.jsx(Input,{id:"accountsPayableRep",placeholder:"John Doe",..._("accountsPayableRep"),readOnly:e})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{className:"text-sm font-medium leading-none",htmlFor:"representativeEmail",children:"Representative Email"}),jsxRuntime.jsx(Input,{id:"representativeEmail",placeholder:"john.doe@company.com",..._("representativeEmail",{pattern:{value:/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,message:"Invalid email address"}}),readOnly:e}),E.representativeEmail&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:E.representativeEmail.message})]})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{className:"text-sm font-medium leading-none",htmlFor:"phone",children:"Phone"}),jsxRuntime.jsx(Input,{id:"phone",placeholder:"(555) 123-4567",..._("phone"),readOnly:e})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{className:"text-sm font-medium leading-none",htmlFor:"creditLimit",children:"Credit Limit"}),jsxRuntime.jsx("div",{className:"p-2 border rounded-md bg-gray-100",children:jsxRuntime.jsx(FormattedNumber,{value:(t==null?void 0:t.CreditLimit)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"})})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{className:"text-sm font-medium leading-none",htmlFor:"terms",children:"Terms"}),jsxRuntime.jsx(Input,{id:"terms",placeholder:"NET 30 DAYS",..._("terms"),readOnly:!0})]}),!e&&jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx(Button,{type:"submit",disabled:A,className:"w-full sm:w-auto",children:A?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save"})})]})})]})}function OpenToWorkSection({manufacturer:t,readonly:e=!1,isLoading:n}){const{toast:o}=useToast(),[l]=usePostV4PartnerByApplicationIdAccountManufacturerAndFieldNameMutation(),d=React.useMemo(()=>({openToWork:(t==null?void 0:t.OpenToWork)??!1}),[t]),{reset:f,watch:g}=useForm({defaultValues:d});React.useEffect(()=>{t&&f(d)},[t,f,d]);const b=async _=>{if(!e)try{await l({applicationId:(t==null?void 0:t.ManufacturerId)??"",fieldName:"OpenToWork",newValue:_?"true":"false"}).unwrap()&&o({title:"Open to work info",description:"Information updated successfully",variant:"success"})}catch(S){console.error("Error updating",S)}};return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Open to Work with Resellers"})}),jsxRuntime.jsx(CardContent,{children:n?jsxRuntime.jsx("div",{className:"space-y-4",children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-20"})}):jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"Resellers will be introducing their business, and communicating opportunities for your Brand through Randmar."}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"You'll engage directly with resellers, allow them to learn about your product lines, and grow your business faster."}),jsxRuntime.jsx("br",{}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Switch,{id:"openToWork",checked:g("openToWork"),onCheckedChange:_=>b(_),disabled:e}),jsxRuntime.jsx(Label$2,{htmlFor:"openToWork",children:"Open to work with Resellers"})]})]})})]})}const tagSuggestions=["Arts and Crafts","Cleaning Solutions","Clothing","Electronics","Generic Compatible Toner","Ink","Luggage and Bags","Miscellaneous","Networking Devices","Paper Products","Printers","Printing Supplies","Toner"];function ManufacturerPublicInfoSection({manufacturer:t,readonly:e=!1,isLoading:n,onUnsavedChanges:o}){const{toast:l}=useToast(),[d]=usePostV4PartnerByApplicationIdAccountManufacturerAndFieldNameMutation(),[f,g]=React.useState([]),[b,_]=React.useState({}),S=React.useMemo(()=>({publicName:(t==null?void 0:t.PublicName)??"",website:(t==null?void 0:t.Website)??"",customerServiceEmail:(t==null?void 0:t.PublicEmail)??"",publicResources:(t==null?void 0:t.PublicResourcesLink)??""}),[t]),{register:R,handleSubmit:C,reset:E,watch:A,formState:{errors:I,isSubmitting:M}}=useForm({defaultValues:S}),j=A(),q=React.useCallback(()=>e||!b?!1:JSON.stringify(j)!==JSON.stringify(b),[e,j,b]);React.useEffect(()=>{o&&o(q())},[q,o]),React.useEffect(()=>{t&&(E(S),g(t.Tags?t.Tags.split(",").map(V=>V.trim()):[]),_(S))},[t,E,S]);const z=async V=>{if(e)return;let te=!0,ae=!1;const se=[{key:"publicName",apiKey:"PublicName",value:V.publicName},{key:"website",apiKey:"Website",value:V.website},{key:"manufacturerCategories",apiKey:"Tags",value:f.join(", ")},{key:"customerServiceEmail",apiKey:"PublicEmail",value:V.customerServiceEmail},{key:"publicResources",apiKey:"PublicResourcesLink",value:V.publicResources}];for(const ge of se){const oe=ge.value,Ae=t==null?void 0:t[ge.apiKey],Ne=typeof Ae=="boolean"?String(Ae):Ae;if(oe!==Ne&&oe!==void 0){ae=!0;try{await d({applicationId:(t==null?void 0:t.ManufacturerId)??"",fieldName:ge.apiKey,newValue:String(oe)}).unwrap()||(te=!1)}catch(je){console.error(`Error updating ${ge.apiKey}:`,je),te=!1}}}te&&ae?(l({title:"Public info",description:"Information updated successfully",variant:"success"}),_({...V}),o&&o(!1)):te||l({title:"Update error",description:"Failed to update",variant:"destructive"})},Q=V=>!V||V.trim()==="",F=V=>{g(V)};return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Public Information"})}),jsxRuntime.jsx(CardContent,{children:n?jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-40"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-10"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-48"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-40"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-40"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-20"})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[(Q(A("publicName"))||Q(A("website"))||Q(A("customerServiceEmail")))&&jsxRuntime.jsxs(Alert,{variant:"destructive",className:"mb-6",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Missing information"}),jsxRuntime.jsx(AlertDescription,{children:"All fields are required to get started at working with Resellers."})]}),jsxRuntime.jsxs("form",{onSubmit:C(z),className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{className:"text-sm font-medium leading-none",htmlFor:"publicName",children:"Public Manufacturer Name *"}),jsxRuntime.jsx(Input,{id:"publicName",placeholder:"Company Name",...R("publicName",{}),className:Q(A("publicName"))?"input-error-indicator":"",readOnly:e}),I.publicName&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:I.publicName.message})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{className:"text-sm font-medium leading-none",htmlFor:"website",children:"Website *"}),jsxRuntime.jsx(Input,{id:"website",placeholder:"https://company.com",...R("website",{pattern:{value:/^.{7,}$/,message:"Must be at least 7 characters"}}),className:Q(A("website"))?"input-error-indicator":"",readOnly:e}),I.website&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:I.website.message})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{className:"text-sm font-medium leading-none",htmlFor:"manufacturerCategories",children:"Manufacturer Categories"}),jsxRuntime.jsx(MultiSelect,{options:tagSuggestions,selected:f,onChange:F,placeholder:"Select or type categories...",disabled:e})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{className:"text-sm font-medium leading-none",htmlFor:"customerServiceEmail",children:"Customer Service Email *"}),jsxRuntime.jsx(Input,{id:"customerServiceEmail",placeholder:"support@company.com",...R("customerServiceEmail",{pattern:{value:/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,message:"Invalid email address"}}),className:Q(A("customerServiceEmail"))?"input-error-indicator":"",readOnly:e}),I.customerServiceEmail&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:I.customerServiceEmail.message})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{className:"text-sm font-medium leading-none",htmlFor:"publicResources",children:"Public Resources"}),jsxRuntime.jsx(Input,{id:"publicResources",placeholder:"https://resources.company.com",...R("publicResources"),readOnly:e})]}),!e&&jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx(Button,{type:"submit",disabled:M,className:"w-full sm:w-auto",children:M?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save"})})]})]})})]})}function ManufacturerQualificationsSection({manufacturer:t,readonly:e=!1,isLoading:n,onUnsavedChanges:o}){const{toast:l}=useToast(),[d]=usePostV4PartnerByApplicationIdAccountManufacturerAndFieldNameMutation(),[f,g]=React.useState({}),b=React.useMemo(()=>({partnerPortal:(t==null?void 0:t.PartnerPortal)??"",partnerRegistrationLink:(t==null?void 0:t.PartnerRegistrationLink)??""}),[t]),{register:_,handleSubmit:S,reset:R,watch:C,formState:{errors:E,isSubmitting:A}}=useForm({defaultValues:b}),I=C(),M=React.useCallback(()=>e||!f?!1:JSON.stringify(I)!==JSON.stringify(f),[e,I,f]);React.useEffect(()=>{o&&o(M())},[M,o]),React.useEffect(()=>{t&&(R(b),g(b))},[t,R,b]);const j=async z=>{if(e)return!1;let Q=!0,F=!1;const V=[{key:"partnerPortal",apiKey:"PartnerPortal",value:z.partnerPortal},{key:"partnerRegistrationLink",apiKey:"PartnerRegistrationLink",value:z.partnerRegistrationLink}];for(const te of V){const ae=te.value,se=t==null?void 0:t[te.apiKey];if(ae!==se&&ae!==void 0){F=!0;try{await d({applicationId:(t==null?void 0:t.ManufacturerId)??"",fieldName:te.apiKey,newValue:String(ae)}).unwrap()||(Q=!1,console.error(`Failed to update ${te.apiKey}`))}catch(ge){console.error(`Error updating ${te.apiKey}:`,ge),Q=!1}}}Q&&F?(l({title:"Qualifications info",description:"Information updated successfully",variant:"success"}),g({...z}),o&&o(!1)):Q?F||l({title:"No changes",description:"No changes were made to the information.",variant:"info"}):l({title:"Update error",description:"Failed to update. Please try again.",variant:"destructive"})},q=/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?(\?[^\s#]*)??(#[^\s]*)?$/i;return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Qualifications"})}),jsxRuntime.jsx(CardContent,{children:n?jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-48"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-20"})]}):jsxRuntime.jsxs("form",{onSubmit:S(j),className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{className:"text-sm font-medium leading-none",htmlFor:"partnerPortal",children:"Partner Portal"}),jsxRuntime.jsx(Input,{id:"partnerPortal",placeholder:"https://partner.example.com",..._("partnerPortal",{pattern:{value:q,message:"Invalid URL format"}}),readOnly:e}),E.partnerPortal&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:E.partnerPortal.message})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{className:"text-sm font-medium leading-none",htmlFor:"partnerRegistrationLink",children:"Partner Registration Link"}),jsxRuntime.jsx(Input,{id:"partnerRegistrationLink",placeholder:"https://register.example.com",..._("partnerRegistrationLink",{pattern:{value:q,message:"Invalid URL format"}}),readOnly:e}),E.partnerRegistrationLink&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:E.partnerRegistrationLink.message})]}),!e&&jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx(Button,{type:"submit",disabled:A,className:"w-full sm:w-auto",children:A?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save"})})]})})]})}function ManufacturerReportsSection({manufacturerId:t,userEmail:e,isLoading:n}){const{toast:o}=useToast(),[l,{isLoading:d}]=usePostV4ManufacturerByRouteManufacturerIdDocumentAndDocumentNumberEmailMutation(),[f,g]=React.useState(null),[b,_]=React.useState(e),[S,R]=React.useState(!1),C=[{name:"Orders & Sales",reports:[{id:"OpenOrders",title:"Open Orders Report",description:"The Open Orders Report provides a snapshot of active orders, aiding your business in efficiently tracking and fulfilling customer demands.",icon:FileText},{id:"Sales",title:"Sales Report",description:"Summary of your company's sales activity over a certain period, detailing total sales and helping identifying trends, successes, and areas needing improvement.",icon:ChartNoAxesColumnIncreasing}]},{name:"Purchase Orders",reports:[{id:"PurchasedOrders",title:"Open Purchase Orders Report",description:"The Open Purchase Orders Report provides a snapshot of Randmar's active orders, aiding your business in efficiently tracking and fulfilling Randmar's inventory demands.",icon:ShoppingCart},{id:"Reorder",title:"Reordering Report",description:"The Reordering Report provides a snapshot of all part numbers auto-reordering statuses. Aiding your understanding of what will be automatically reordered by our system or not once the inventory reaches low numbers.",icon:ClipboardList}]},{name:"Inventory",reports:[{id:"Inventory",title:"Inventory Report",description:"Detailed document outlining the quantity, type, and value of products Randmar has on hand. It aids in managing stock levels, identifying shortages or surpluses, and informing purchasing decisions.",icon:Package},{id:"Products",title:"Products Report",description:"Detailed document outlining all your products properties. It provides a comprehensive overview of essential information and insights that help you make informed decisions.",icon:ClipboardList}]}],E=async I=>{g(I),R(!0)},A=async()=>{if(!(!f||!t))try{await l({routeManufacturerId:t,documentNumber:f.id,emailAddress:b}).unwrap(),o({title:"Report requested",description:`The ${f.title} will be sent to ${b} shortly.`,variant:"success"}),R(!1),_("")}catch(I){console.error("Error requesting report:",I),o({title:"Error",description:"Failed to request report. Please try again.",variant:"destructive"})}};return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Reports"}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"Download essential business reports, from your Open Orders & Sales Report, to your Inventory Reports."})]}),jsxRuntime.jsx(CardContent,{className:"space-y-6",children:n?jsxRuntime.jsx(jsxRuntime.Fragment,{children:[1,2,3].map(I=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-48"}),[1,2].map(M=>jsxRuntime.jsxs("div",{className:"flex items-start gap-4 p-4 border rounded-lg",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-9 rounded-full"}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full"})]}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"})]},M))]},I))}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:C.map(I=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx("h3",{className:"text-sm font-semibold",children:I.name}),I.reports.map(M=>jsxRuntime.jsxs("div",{className:"flex items-start gap-4 p-4 border rounded-lg hover:bg-gray-100 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-2 rounded-full",children:jsxRuntime.jsx(M.icon,{className:"h-5 w-5 text-primary"})}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx("h4",{className:"font-semibold text-sm",children:M.title}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:M.description})]}),jsxRuntime.jsxs(Button,{variant:"outline",size:"sm",className:"flex items-center gap-1",onClick:()=>E(M),children:[jsxRuntime.jsx(Download,{className:"h-4 w-4"}),"Request"]})]},M.id))]},I.name))})}),jsxRuntime.jsx(Dialog,{open:S,onOpenChange:R,children:jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsxs(DialogTitle,{children:["Request ",f==null?void 0:f.title]}),jsxRuntime.jsx(DialogDescription,{children:"Enter the email address where you would like to receive the report."})]}),jsxRuntime.jsxs("div",{className:"py-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"email",children:"Email"}),jsxRuntime.jsx(Input,{id:"email",value:b,onChange:I=>_(I.target.value),placeholder:"your@email.com",className:"mt-2"})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button,{variant:"outline",onClick:()=>R(!1),children:"Cancel"}),jsxRuntime.jsx(Button,{onClick:A,disabled:!b||d,children:d?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):"Send Report"})]})]})})]})}function ManufacturerResellerOrdersSection({manufacturerId:t}){const{data:e,isLoading:n,isError:o}=useGetV4ManufacturerByRouteManufacturerIdDocumentsActiveOrderDetailsQuery({routeManufacturerId:t}),d=(()=>{if(!e)return{all:{orders:0,amount:0},processing:{orders:0,amount:0},shipped:{orders:0,amount:0},delayed:{orders:0,amount:0}};const g=e.filter(z=>z.DocumentType==="Order"),b=e.filter(z=>z.DocumentType==="Shipment"),_=g.filter(z=>z.WarehouseCode!=="3PLE"),S=_.reduce((z,Q)=>z+(Q.Quantity||0),0),R=_.reduce((z,Q)=>z+(Q.ExtendedPrice||0),0),C=g.filter(z=>z.WarehouseCode==="3PLE"),E=C.reduce((z,Q)=>z+(Q.Quantity||0),0),A=C.reduce((z,Q)=>z+(Q.ExtendedPrice||0),0),I=b.length,M=b.reduce((z,Q)=>z+(Q.ExtendedPrice||0),0),j=S+E+I,q=R+A+M;return{all:{orders:j,amount:q},processing:{orders:S,amount:R},shipped:{orders:I,amount:M},delayed:{orders:E,amount:A}}})(),f=[{name:"All",icon:Package,color:"bg-blue-500",orders:d.all.orders,amount:d.all.amount},{name:"Processing",icon:RefreshCcw,color:"bg-yellow-500",orders:d.processing.orders,amount:d.processing.amount},{name:"Shipped",icon:Truck,color:"bg-green-500",orders:d.shipped.orders,amount:d.shipped.amount},{name:"Delayed",icon:CircleAlert,color:"bg-red-500",orders:d.delayed.orders,amount:d.delayed.amount}];return n?jsxRuntime.jsxs(Card,{className:"w-full md:col-span-2 xl:col-span-1",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Reseller Orders"})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-40 mb-4"}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3.5",children:[1,2,3,4].map(g=>jsxRuntime.jsx(Skeleton,{className:"h-32 w-full"},g))})]})]}):o?jsxRuntime.jsxs(Card,{className:"w-full md:col-span-2 xl:col-span-1",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Reseller Orders"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsxs(Alert,{variant:"destructive",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Error"}),jsxRuntime.jsx(AlertDescription,{children:"Failed to load reseller orders. Please try again later."})]})})]}):jsxRuntime.jsxs(Card,{className:"w-full md:col-span-2 xl:col-span-1",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Reseller Orders"})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsxs("div",{className:"flex items-center mb-4",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Active Orders:"}),jsxRuntime.jsx("span",{className:"ml-2 font-bold",children:d.all.orders})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3.5",children:f.map(g=>jsxRuntime.jsx(Card,{className:"overflow-hidden rounded-md rounded-b-lg border-0 shadow-md",children:jsxRuntime.jsxs(CardContent,{className:"p-0",children:[jsxRuntime.jsx("div",{className:`${g.color} bg-opacity-60 h-[3px]`}),jsxRuntime.jsxs("div",{className:"p-6 border border-t-0",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-base",children:g.name}),jsxRuntime.jsx("div",{className:`${g.color} bg-opacity-90 p-2 rounded-full`,children:jsxRuntime.jsx(g.icon,{className:"size-4 shrink-0 text-white"})})]}),jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Orders"}),jsxRuntime.jsx("p",{className:"text-xl font-bold",children:g.orders})]}),jsxRuntime.jsxs("div",{className:"text-end",children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Amount"}),jsxRuntime.jsx("p",{className:"text-base font-semibold",children:jsxRuntime.jsx(FormattedNumber,{value:g.amount,style:"currency",currency:"CAD",currencyDisplay:"symbol"})})]})]})]})]})},g.name))})]})]})}var PROGRESS_NAME="Progress",DEFAULT_MAX=100,[createProgressContext,createProgressScope]=createContextScope(PROGRESS_NAME),[ProgressProvider,useProgressContext]=createProgressContext(PROGRESS_NAME),Progress$1=React__namespace.forwardRef((t,e)=>{const{__scopeProgress:n,value:o=null,max:l,getValueLabel:d=defaultGetValueLabel,...f}=t;(l||l===0)&&!isValidMaxNumber(l)&&console.error(getInvalidMaxError(`${l}`,"Progress"));const g=isValidMaxNumber(l)?l:DEFAULT_MAX;o!==null&&!isValidValueNumber(o,g)&&console.error(getInvalidValueError(`${o}`,"Progress"));const b=isValidValueNumber(o,g)?o:null,_=isNumber$1(b)?d(b,g):void 0;return jsxRuntime.jsx(ProgressProvider,{scope:n,value:b,max:g,children:jsxRuntime.jsx(Primitive.div,{"aria-valuemax":g,"aria-valuemin":0,"aria-valuenow":isNumber$1(b)?b:void 0,"aria-valuetext":_,role:"progressbar","data-state":getProgressState(b,g),"data-value":b??void 0,"data-max":g,...f,ref:e})})});Progress$1.displayName=PROGRESS_NAME;var INDICATOR_NAME="ProgressIndicator",ProgressIndicator=React__namespace.forwardRef((t,e)=>{const{__scopeProgress:n,...o}=t,l=useProgressContext(INDICATOR_NAME,n);return jsxRuntime.jsx(Primitive.div,{"data-state":getProgressState(l.value,l.max),"data-value":l.value??void 0,"data-max":l.max,...o,ref:e})});ProgressIndicator.displayName=INDICATOR_NAME;function defaultGetValueLabel(t,e){return`${Math.round(t/e*100)}%`}function getProgressState(t,e){return t==null?"indeterminate":t===e?"complete":"loading"}function isNumber$1(t){return typeof t=="number"}function isValidMaxNumber(t){return isNumber$1(t)&&!isNaN(t)&&t>0}function isValidValueNumber(t,e){return isNumber$1(t)&&!isNaN(t)&&t<=e&&t>=0}function getInvalidMaxError(t,e){return`Invalid prop \`max\` of value \`${t}\` supplied to \`${e}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${DEFAULT_MAX}\`.`}function getInvalidValueError(t,e){return`Invalid prop \`value\` of value \`${t}\` supplied to \`${e}\`. The \`value\` prop must be:
|
|
1085
|
+
*/function flexRender(t,e){return t?isReactComponent(t)?React__namespace.createElement(t,e):t:null}function isReactComponent(t){return isClassComponent(t)||typeof t=="function"||isExoticComponent(t)}function isClassComponent(t){return typeof t=="function"&&(()=>{const e=Object.getPrototypeOf(t);return e.prototype&&e.prototype.isReactComponent})()}function isExoticComponent(t){return typeof t=="object"&&typeof t.$$typeof=="symbol"&&["react.memo","react.forward_ref"].includes(t.$$typeof.description)}function useReactTable(t){const e={state:{},onStateChange:()=>{},renderFallbackValue:null,...t},[n]=React__namespace.useState(()=>({current:createTable(e)})),[o,l]=React__namespace.useState(()=>n.current.initialState);return n.current.setOptions(d=>({...d,...t,state:{...o,...t.state},onStateChange:f=>{l(f),t.onStateChange==null||t.onStateChange(f)}})),n.current}function DataTable({columns:t,data:e,uniqueValues:n}){var E;const[o,l]=React.useState([]),[d,f]=React.useState([]),[g,b]=React.useState({pageIndex:0,pageSize:10}),[_,S]=React.useState(null),R=useReactTable({data:e,columns:t,getCoreRowModel:getCoreRowModel(),onSortingChange:l,getSortedRowModel:getSortedRowModel(),onColumnFiltersChange:f,getFilteredRowModel:getFilteredRowModel(),getPaginationRowModel:getPaginationRowModel(),onPaginationChange:b,state:{sorting:o,columnFilters:d,pagination:g}}),C=(A,I)=>{A.toggleSorting(I),S(null)};return jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs(ScrollArea,{className:"rounded-md border",children:[jsxRuntime.jsxs(Table,{children:[jsxRuntime.jsx(TableHeader,{children:R.getHeaderGroups().map(A=>jsxRuntime.jsx(TableRow,{children:A.headers.map(I=>{var M;return jsxRuntime.jsx(TableHead,{children:I.isPlaceholder?null:I.column.getCanSort()||I.column.getCanFilter()?jsxRuntime.jsxs(Popover,{open:_===I.id,onOpenChange:j=>S(j?I.id:null),children:[jsxRuntime.jsx(PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button,{variant:"ghost",className:"pl-0",children:[flexRender(I.column.columnDef.header,I.getContext()),I.column.getIsFiltered()?jsxRuntime.jsx(Filter,{className:"ml-2 h-4 w-4"}):I.column.getIsSorted()==="asc"?jsxRuntime.jsx(ArrowUp,{className:"ml-2 h-4 w-4"}):I.column.getIsSorted()==="desc"?jsxRuntime.jsx(ArrowDown,{className:"ml-2 h-4 w-4"}):jsxRuntime.jsx(ArrowUpDown,{className:"ml-2 h-4 w-4"})]})}),jsxRuntime.jsx(PopoverContent,{className:"w-56",children:jsxRuntime.jsxs("div",{className:"space-y-2",children:[I.column.getCanSort()&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Button,{variant:"ghost",className:"w-full justify-start",onClick:()=>C(I.column,!1),children:[jsxRuntime.jsx(ArrowUp,{className:"mr-2 h-4 w-4"}),"Sort Ascending"]}),jsxRuntime.jsxs(Button,{variant:"ghost",className:"w-full justify-start",onClick:()=>C(I.column,!0),children:[jsxRuntime.jsx(ArrowDown,{className:"mr-2 h-4 w-4"}),"Sort Descending"]})]}),I.column.getCanFilter()&&jsxRuntime.jsx("div",{className:"px-2 py-1",children:n[I.column.id]?jsxRuntime.jsxs(Select,{onValueChange:j=>I.column.setFilterValue(j==="all"?void 0:[j]),children:[jsxRuntime.jsx(SelectTrigger,{children:jsxRuntime.jsx(SelectValue,{placeholder:`Filter ${I.column.columnDef.header}...`})}),jsxRuntime.jsxs(SelectContent,{children:[jsxRuntime.jsx(SelectItem,{value:"all",children:"All"}),(M=n[I.column.id])==null?void 0:M.map(j=>jsxRuntime.jsx(SelectItem,{value:j||"empty",children:j||"(Empty)"},j))]})]}):jsxRuntime.jsx(Input,{placeholder:`Filter ${I.column.columnDef.header}...`,value:I.column.getFilterValue()??"",onChange:j=>I.column.setFilterValue(j.target.value),className:"w-full"})})]})})]}):jsxRuntime.jsx("div",{className:"py-2 px-4",children:flexRender(I.column.columnDef.header,I.getContext())})},I.id)})},A.id))}),jsxRuntime.jsx(TableBody,{children:(E=R.getRowModel().rows)!=null&&E.length?R.getRowModel().rows.map(A=>jsxRuntime.jsx(TableRow,{"data-state":A.getIsSelected()&&"selected",children:A.getVisibleCells().map(I=>jsxRuntime.jsx(TableCell,{children:flexRender(I.column.columnDef.cell,I.getContext())},I.id))},A.id)):jsxRuntime.jsx(TableRow,{children:jsxRuntime.jsx(TableCell,{colSpan:t.length,className:"h-24 text-center",children:"No results."})})})]}),jsxRuntime.jsx(ScrollBar,{orientation:"horizontal"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx("p",{className:"text-sm font-medium",children:"Rows per page"}),jsxRuntime.jsxs(Select,{value:`${R.getState().pagination.pageSize}`,onValueChange:A=>{R.setPageSize(Number(A))},children:[jsxRuntime.jsx(SelectTrigger,{className:"h-8 w-[70px]",children:jsxRuntime.jsx(SelectValue,{placeholder:R.getState().pagination.pageSize})}),jsxRuntime.jsx(SelectContent,{side:"top",children:[10,20,30,40,50].map(A=>jsxRuntime.jsx(SelectItem,{value:`${A}`,children:A},A))})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsxs(Button,{variant:"outline",className:"hidden h-8 w-8 p-0 lg:flex",onClick:()=>R.setPageIndex(0),disabled:!R.getCanPreviousPage(),children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Go to first page"}),jsxRuntime.jsx(ChevronsLeft,{className:"h-4 w-4"})]}),jsxRuntime.jsxs(Button,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>R.previousPage(),disabled:!R.getCanPreviousPage(),children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Go to previous page"}),jsxRuntime.jsx(ChevronLeft,{className:"h-4 w-4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("p",{className:"text-sm font-medium",children:"Page"}),jsxRuntime.jsx("span",{className:"text-sm font-medium",children:R.getState().pagination.pageIndex+1}),jsxRuntime.jsx("p",{className:"text-sm font-medium",children:"of"}),jsxRuntime.jsx("span",{className:"text-sm font-medium",children:R.getPageCount()})]}),jsxRuntime.jsxs(Button,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>R.nextPage(),disabled:!R.getCanNextPage(),children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Go to next page"}),jsxRuntime.jsx(ChevronRight,{className:"h-4 w-4"})]}),jsxRuntime.jsxs(Button,{variant:"outline",className:"hidden h-8 w-8 p-0 lg:flex",onClick:()=>R.setPageIndex(R.getPageCount()-1),disabled:!R.getCanNextPage(),children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Go to last page"}),jsxRuntime.jsx(ChevronsRight,{className:"h-4 w-4"})]})]})]})]})}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.jsx(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},o.CategoryCode))})})})}function ManufacturerProducts({applicationId:t,manufacturer:e,shopifyHostName:n}){var M,j,q,z;const[o]=usePostV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeShopifyMutation(),[l,d]=React.useState(((j=(M=e.Categories)==null?void 0:M[0])==null?void 0:j.CategoryCode)||""),[f,g]=React.useState(!1),[b,_]=React.useState(!1),{toast:S}=useToast(),{data:R,isLoading:C,isFetching:E}=useGetV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeQuery({routeResellerId:t,manufacturerId:e.ManufacturerId,categoryCode:l??""},{skip:!e.ManufacturerId||!l}),A=async()=>{try{g(!0),_(!1),await o({routeResellerId:t,manufacturerId:e.ManufacturerId??"",categoryCode:l,shopifyHostName:n}).unwrap()&&S({title:"Success",description:"Category synced to Shopify successfully",variant:"success"})}catch(Q){console.error("Error syncing to Shopify:",Q),S({title:"Error",description:"Error syncing category to Shopify.",variant:"destructive"})}finally{g(!1)}},I=()=>{var Q,F;return((F=(Q=e.Categories)==null?void 0:Q.find(V=>V.CategoryCode===l))==null?void 0:F.CategoryName)||l};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(ManufacturerCategories,{categories:e.Categories||[],activeCategory:l,onSelectCategory:d}),n&&((q=e.Categories)==null?void 0:q.findIndex(Q=>Q.AvailableToBuy))!==-1&&jsxRuntime.jsxs(Dialog,{open:b,onOpenChange:_,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 "',I(),'" to Shopify? This will add all products in this category to your Shopify store.']})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button,{variant:"outline",onClick:()=>_(!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:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-2 gap-4 mb-4",children:C||E?Array.from({length:4}).map((Q,F)=>jsxRuntime.jsx(ProductCard,{},F)):R!=null&&R.Products&&(R==null?void 0:R.Products.length)>0?(z=R==null?void 0:R.Products)==null?void 0:z.map(Q=>jsxRuntime.jsx(ProductCard,{applicationId:t,product:Q,viewProductLink:`/${t}/Product/${Q.RandmarSKU}`,shopifyHostname:n},Q.RandmarSKU)):jsxRuntime.jsxs(Alert,{variant:"warning",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 I,M,j;const{data:d,isLoading:f}=useGetV4PartnerByRouteApplicationIdPartnerAndPartnerIdQuery({routeApplicationId:t,partnerId:e,withSpecification:!0}),{toast:g}=useToast(),[b]=usePostV4ResellerByRouteResellerIdManufacturerAndManufacturerIdShopifyMutation(),[_,S]=React.useState(!1),[R,C]=React.useState(!1),E=async()=>{try{S(!0),C(!1),await b({routeResellerId:t??"",manufacturerId:e??"",shopifyHostName:o}).unwrap()&&g({title:"Success",description:"Manufacturer synced to Shopify successfully",variant:"success"})}catch(q){console.error("Error syncing to Shopify:",q),g({title:"Error",description:"Error syncing manufacturer to Shopify.",variant:"destructive"})}finally{S(!1)}},A=()=>d!=null&&d.Reseller?"reseller-overview":d!=null&&d.Manufacturer?"manufacturer-overview":"";return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"grid gap-4 grid-cols-1 md:grid-cols-2",children:[jsxRuntime.jsx(PartnerCard,{account:d,loading:f,withAbout:!0,withVoice:!1,action:" "}),jsxRuntime.jsxs("div",{className:"grid gap-4",children:[((d==null?void 0:d.Manufacturer)||f)&&jsxRuntime.jsx(ManufacturerCard,{manufacturer:d==null?void 0:d.Manufacturer,loading:f,mainAction:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[(d==null?void 0:d.Manufacturer)&&jsxRuntime.jsx(ManufacturerGetStartedButton,{applicationId:t,manufacturer:d==null?void 0:d.Manufacturer}),o&&((M=(I=d==null?void 0:d.Manufacturer)==null?void 0:I.Categories)==null?void 0:M.findIndex(q=>q.AvailableToBuy))!==-1&&jsxRuntime.jsxs(Dialog,{open:R,onOpenChange:C,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{className:"bg-green-600 hover:bg-green-700 ml-2",disabled:_,children:_?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 Manufacturer 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 manufacturer "',(j=d==null?void 0:d.Manufacturer)==null?void 0:j.PublicName,'" to Shopify? This will add all products from this manufacturer to your Shopify store.']})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button,{variant:"outline",onClick:()=>C(!1),children:"Cancel"}),jsxRuntime.jsx(Button,{className:"bg-green-600 hover:bg-green-700",onClick:E,disabled:_,children:_?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):"Confirm Sync"})]})]})]})]})}),(d==null?void 0:d.Reseller)&&jsxRuntime.jsx(ResellerCard,{reseller:d==null?void 0:d.Reseller,loading:f})]})]}),((d==null?void 0:d.Reseller)||(d==null?void 0:d.Manufacturer))&&!f&&jsxRuntime.jsx("div",{className:"max-w-6xl mx-auto p-4",children:jsxRuntime.jsxs(Tabs,{defaultValue:A(),className:"w-full",children:[jsxRuntime.jsxs(TabsList,{className:"inline-flex h-auto items-center justify-center rounded-none border-b bg-transparent p-0",children:[(d==null?void 0:d.Reseller)&&jsxRuntime.jsx(TabsTrigger,{value:"reseller-overview",className:"reseller-theme relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Reseller Overview"}),(d==null?void 0:d.Manufacturer)&&jsxRuntime.jsx(TabsTrigger,{value:"manufacturer-overview",className:"manufacturer-theme relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Manufacturer Overview"}),(d==null?void 0:d.Manufacturer)&&jsxRuntime.jsx(TabsTrigger,{value:"products",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Products"})]}),(d==null?void 0:d.Reseller)&&jsxRuntime.jsx(TabsContent,{value:"reseller-overview",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ResellerOverview,{readonly:!0,appID:d.ApplicationId||"",reseller:d==null?void 0:d.Reseller,userEmail:n,isSuperAdmin:l,withoutReports:!0})})}),(d==null?void 0:d.Manufacturer)&&jsxRuntime.jsx(TabsContent,{value:"manufacturer-overview",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ManufacturerOverviewPage,{readonly:!0,manufacturer:d==null?void 0:d.Manufacturer,applicationId:d.ApplicationId||"",userEmail:n})})}),(d==null?void 0:d.Manufacturer)&&jsxRuntime.jsx(TabsContent,{value:"products",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ManufacturerProducts,{applicationId:t,manufacturer:d.Manufacturer,shopifyHostName:o})})})]})}),f&&jsxRuntime.jsx("div",{className:"max-w-6xl mx-auto p-4 mt-4 flex justify-center items-center h-32",children:jsxRuntime.jsx(LoaderCircle,{className:"h-8 w-8 animate-spin text-primary"})})]})}function ManufacturerBillingInfoSection({manufacturer:t,readonly:e=!1,isLoading:n,onUnsavedChanges:o}){const{toast:l}=useToast(),[d]=usePostV4PartnerByApplicationIdAccountManufacturerAndFieldNameMutation(),[f,g]=React.useState({}),b=React.useMemo(()=>({accountsPayableRep:(t==null?void 0:t.ContactName)??"",representativeEmail:(t==null?void 0:t.RepresentativeEmail)??"",phone:(t==null?void 0:t.Phone)??"",creditLimit:(t==null?void 0:t.CreditLimit)??0,terms:(t==null?void 0:t.Terms)??""}),[t]),{register:_,handleSubmit:S,reset:R,watch:C,formState:{errors:E,isSubmitting:A}}=useForm({defaultValues:b}),I=C(),M=React.useCallback(()=>e||!f?!1:JSON.stringify(I)!==JSON.stringify(f),[e,I,f]);React.useEffect(()=>{o&&o(M())},[M,o]),React.useEffect(()=>{t&&(R(b),g(b))},[t,R,b]);const j=async q=>{if(e)return;let z=!0,Q=!1;const F=[{key:"accountsPayableRep",apiKey:"ContactName",value:q.accountsPayableRep},{key:"representativeEmail",apiKey:"RepresentativeEmail",value:q.representativeEmail},{key:"phone",apiKey:"Phone",value:q.phone},{key:"terms",apiKey:"Terms",value:q.terms}];for(const V of F){const te=V.value,ae=t==null?void 0:t[V.apiKey];if(te!==ae&&te!==void 0){Q=!0;try{await d({applicationId:(t==null?void 0:t.ManufacturerId)??"",fieldName:V.apiKey,newValue:String(te)}).unwrap()||(z=!1,console.error(`Failed to update ${V.apiKey}`))}catch(se){console.error(`Error updating ${V.apiKey}:`,se),z=!1}}}z&&Q?(l({title:"Billing info",description:"Information updated successfully",variant:"success"}),g({...q}),o&&o(!1)):z?Q||l({title:"No changes",description:"No changes were made to the information.",variant:"info"}):l({title:"Update error",description:"Failed to update. Please try again.",variant:"destructive"})};return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Billing, Credit, & Rebates"})}),jsxRuntime.jsx(CardContent,{children:n?jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-48"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-36"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-16"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-16"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-20"})]}):jsxRuntime.jsxs("form",{onSubmit:S(j),className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{className:"text-sm font-medium leading-none",htmlFor:"accountsPayableRep",children:"Accounts Payable Representative"}),jsxRuntime.jsx(Input,{id:"accountsPayableRep",placeholder:"John Doe",..._("accountsPayableRep"),readOnly:e})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{className:"text-sm font-medium leading-none",htmlFor:"representativeEmail",children:"Representative Email"}),jsxRuntime.jsx(Input,{id:"representativeEmail",placeholder:"john.doe@company.com",..._("representativeEmail",{pattern:{value:/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,message:"Invalid email address"}}),readOnly:e}),E.representativeEmail&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:E.representativeEmail.message})]})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{className:"text-sm font-medium leading-none",htmlFor:"phone",children:"Phone"}),jsxRuntime.jsx(Input,{id:"phone",placeholder:"(555) 123-4567",..._("phone"),readOnly:e})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{className:"text-sm font-medium leading-none",htmlFor:"creditLimit",children:"Credit Limit"}),jsxRuntime.jsx("div",{className:"p-2 border rounded-md bg-gray-100",children:jsxRuntime.jsx(FormattedNumber,{value:(t==null?void 0:t.CreditLimit)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"})})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{className:"text-sm font-medium leading-none",htmlFor:"terms",children:"Terms"}),jsxRuntime.jsx(Input,{id:"terms",placeholder:"NET 30 DAYS",..._("terms"),readOnly:!0})]}),!e&&jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx(Button,{type:"submit",disabled:A,className:"w-full sm:w-auto",children:A?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save"})})]})})]})}function OpenToWorkSection({manufacturer:t,readonly:e=!1,isLoading:n}){const{toast:o}=useToast(),[l]=usePostV4PartnerByApplicationIdAccountManufacturerAndFieldNameMutation(),d=React.useMemo(()=>({openToWork:(t==null?void 0:t.OpenToWork)??!1}),[t]),{reset:f,watch:g}=useForm({defaultValues:d});React.useEffect(()=>{t&&f(d)},[t,f,d]);const b=async _=>{if(!e)try{await l({applicationId:(t==null?void 0:t.ManufacturerId)??"",fieldName:"OpenToWork",newValue:_?"true":"false"}).unwrap()&&o({title:"Open to work info",description:"Information updated successfully",variant:"success"})}catch(S){console.error("Error updating",S)}};return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Open to Work with Resellers"})}),jsxRuntime.jsx(CardContent,{children:n?jsxRuntime.jsx("div",{className:"space-y-4",children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-20"})}):jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"Resellers will be introducing their business, and communicating opportunities for your Brand through Randmar."}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"You'll engage directly with resellers, allow them to learn about your product lines, and grow your business faster."}),jsxRuntime.jsx("br",{}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Switch,{id:"openToWork",checked:g("openToWork"),onCheckedChange:_=>b(_),disabled:e}),jsxRuntime.jsx(Label$2,{htmlFor:"openToWork",children:"Open to work with Resellers"})]})]})})]})}const tagSuggestions=["Arts and Crafts","Cleaning Solutions","Clothing","Electronics","Generic Compatible Toner","Ink","Luggage and Bags","Miscellaneous","Networking Devices","Paper Products","Printers","Printing Supplies","Toner"];function ManufacturerPublicInfoSection({manufacturer:t,readonly:e=!1,isLoading:n,onUnsavedChanges:o}){const{toast:l}=useToast(),[d]=usePostV4PartnerByApplicationIdAccountManufacturerAndFieldNameMutation(),[f,g]=React.useState([]),[b,_]=React.useState({}),S=React.useMemo(()=>({publicName:(t==null?void 0:t.PublicName)??"",website:(t==null?void 0:t.Website)??"",customerServiceEmail:(t==null?void 0:t.PublicEmail)??"",publicResources:(t==null?void 0:t.PublicResourcesLink)??""}),[t]),{register:R,handleSubmit:C,reset:E,watch:A,formState:{errors:I,isSubmitting:M}}=useForm({defaultValues:S}),j=A(),q=React.useCallback(()=>e||!b?!1:JSON.stringify(j)!==JSON.stringify(b),[e,j,b]);React.useEffect(()=>{o&&o(q())},[q,o]),React.useEffect(()=>{t&&(E(S),g(t.Tags?t.Tags.split(",").map(V=>V.trim()):[]),_(S))},[t,E,S]);const z=async V=>{if(e)return;let te=!0,ae=!1;const se=[{key:"publicName",apiKey:"PublicName",value:V.publicName},{key:"website",apiKey:"Website",value:V.website},{key:"manufacturerCategories",apiKey:"Tags",value:f.join(", ")},{key:"customerServiceEmail",apiKey:"PublicEmail",value:V.customerServiceEmail},{key:"publicResources",apiKey:"PublicResourcesLink",value:V.publicResources}];for(const ge of se){const oe=ge.value,Ae=t==null?void 0:t[ge.apiKey],Ne=typeof Ae=="boolean"?String(Ae):Ae;if(oe!==Ne&&oe!==void 0){ae=!0;try{await d({applicationId:(t==null?void 0:t.ManufacturerId)??"",fieldName:ge.apiKey,newValue:String(oe)}).unwrap()||(te=!1)}catch(je){console.error(`Error updating ${ge.apiKey}:`,je),te=!1}}}te&&ae?(l({title:"Public info",description:"Information updated successfully",variant:"success"}),_({...V}),o&&o(!1)):te||l({title:"Update error",description:"Failed to update",variant:"destructive"})},Q=V=>!V||V.trim()==="",F=V=>{g(V)};return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Public Information"})}),jsxRuntime.jsx(CardContent,{children:n?jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-40"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-10"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-48"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-40"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-40"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-20"})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[(Q(A("publicName"))||Q(A("website"))||Q(A("customerServiceEmail")))&&jsxRuntime.jsxs(Alert,{variant:"destructive",className:"mb-6",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Missing information"}),jsxRuntime.jsx(AlertDescription,{children:"All fields are required to get started at working with Resellers."})]}),jsxRuntime.jsxs("form",{onSubmit:C(z),className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{className:"text-sm font-medium leading-none",htmlFor:"publicName",children:"Public Manufacturer Name *"}),jsxRuntime.jsx(Input,{id:"publicName",placeholder:"Company Name",...R("publicName",{}),className:Q(A("publicName"))?"input-error-indicator":"",readOnly:e}),I.publicName&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:I.publicName.message})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{className:"text-sm font-medium leading-none",htmlFor:"website",children:"Website *"}),jsxRuntime.jsx(Input,{id:"website",placeholder:"https://company.com",...R("website",{pattern:{value:/^.{7,}$/,message:"Must be at least 7 characters"}}),className:Q(A("website"))?"input-error-indicator":"",readOnly:e}),I.website&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:I.website.message})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{className:"text-sm font-medium leading-none",htmlFor:"manufacturerCategories",children:"Manufacturer Categories"}),jsxRuntime.jsx(MultiSelect,{options:tagSuggestions,selected:f,onChange:F,placeholder:"Select or type categories...",disabled:e})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{className:"text-sm font-medium leading-none",htmlFor:"customerServiceEmail",children:"Customer Service Email *"}),jsxRuntime.jsx(Input,{id:"customerServiceEmail",placeholder:"support@company.com",...R("customerServiceEmail",{pattern:{value:/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,message:"Invalid email address"}}),className:Q(A("customerServiceEmail"))?"input-error-indicator":"",readOnly:e}),I.customerServiceEmail&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:I.customerServiceEmail.message})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{className:"text-sm font-medium leading-none",htmlFor:"publicResources",children:"Public Resources"}),jsxRuntime.jsx(Input,{id:"publicResources",placeholder:"https://resources.company.com",...R("publicResources"),readOnly:e})]}),!e&&jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx(Button,{type:"submit",disabled:M,className:"w-full sm:w-auto",children:M?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save"})})]})]})})]})}function ManufacturerQualificationsSection({manufacturer:t,readonly:e=!1,isLoading:n,onUnsavedChanges:o}){const{toast:l}=useToast(),[d]=usePostV4PartnerByApplicationIdAccountManufacturerAndFieldNameMutation(),[f,g]=React.useState({}),b=React.useMemo(()=>({partnerPortal:(t==null?void 0:t.PartnerPortal)??"",partnerRegistrationLink:(t==null?void 0:t.PartnerRegistrationLink)??""}),[t]),{register:_,handleSubmit:S,reset:R,watch:C,formState:{errors:E,isSubmitting:A}}=useForm({defaultValues:b}),I=C(),M=React.useCallback(()=>e||!f?!1:JSON.stringify(I)!==JSON.stringify(f),[e,I,f]);React.useEffect(()=>{o&&o(M())},[M,o]),React.useEffect(()=>{t&&(R(b),g(b))},[t,R,b]);const j=async z=>{if(e)return!1;let Q=!0,F=!1;const V=[{key:"partnerPortal",apiKey:"PartnerPortal",value:z.partnerPortal},{key:"partnerRegistrationLink",apiKey:"PartnerRegistrationLink",value:z.partnerRegistrationLink}];for(const te of V){const ae=te.value,se=t==null?void 0:t[te.apiKey];if(ae!==se&&ae!==void 0){F=!0;try{await d({applicationId:(t==null?void 0:t.ManufacturerId)??"",fieldName:te.apiKey,newValue:String(ae)}).unwrap()||(Q=!1,console.error(`Failed to update ${te.apiKey}`))}catch(ge){console.error(`Error updating ${te.apiKey}:`,ge),Q=!1}}}Q&&F?(l({title:"Qualifications info",description:"Information updated successfully",variant:"success"}),g({...z}),o&&o(!1)):Q?F||l({title:"No changes",description:"No changes were made to the information.",variant:"info"}):l({title:"Update error",description:"Failed to update. Please try again.",variant:"destructive"})},q=/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?(\?[^\s#]*)??(#[^\s]*)?$/i;return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Qualifications"})}),jsxRuntime.jsx(CardContent,{children:n?jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-48"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-20"})]}):jsxRuntime.jsxs("form",{onSubmit:S(j),className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{className:"text-sm font-medium leading-none",htmlFor:"partnerPortal",children:"Partner Portal"}),jsxRuntime.jsx(Input,{id:"partnerPortal",placeholder:"https://partner.example.com",..._("partnerPortal",{pattern:{value:q,message:"Invalid URL format"}}),readOnly:e}),E.partnerPortal&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:E.partnerPortal.message})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{className:"text-sm font-medium leading-none",htmlFor:"partnerRegistrationLink",children:"Partner Registration Link"}),jsxRuntime.jsx(Input,{id:"partnerRegistrationLink",placeholder:"https://register.example.com",..._("partnerRegistrationLink",{pattern:{value:q,message:"Invalid URL format"}}),readOnly:e}),E.partnerRegistrationLink&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:E.partnerRegistrationLink.message})]}),!e&&jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx(Button,{type:"submit",disabled:A,className:"w-full sm:w-auto",children:A?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save"})})]})})]})}function ManufacturerReportsSection({manufacturerId:t,userEmail:e,isLoading:n}){const{toast:o}=useToast(),[l,{isLoading:d}]=usePostV4ManufacturerByRouteManufacturerIdDocumentAndDocumentNumberEmailMutation(),[f,g]=React.useState(null),[b,_]=React.useState(e),[S,R]=React.useState(!1),C=[{name:"Orders & Sales",reports:[{id:"OpenOrders",title:"Open Orders Report",description:"The Open Orders Report provides a snapshot of active orders, aiding your business in efficiently tracking and fulfilling customer demands.",icon:FileText},{id:"Sales",title:"Sales Report",description:"Summary of your company's sales activity over a certain period, detailing total sales and helping identifying trends, successes, and areas needing improvement.",icon:ChartNoAxesColumnIncreasing}]},{name:"Purchase Orders",reports:[{id:"PurchasedOrders",title:"Open Purchase Orders Report",description:"The Open Purchase Orders Report provides a snapshot of Randmar's active orders, aiding your business in efficiently tracking and fulfilling Randmar's inventory demands.",icon:ShoppingCart},{id:"Reorder",title:"Reordering Report",description:"The Reordering Report provides a snapshot of all part numbers auto-reordering statuses. Aiding your understanding of what will be automatically reordered by our system or not once the inventory reaches low numbers.",icon:ClipboardList}]},{name:"Inventory",reports:[{id:"Inventory",title:"Inventory Report",description:"Detailed document outlining the quantity, type, and value of products Randmar has on hand. It aids in managing stock levels, identifying shortages or surpluses, and informing purchasing decisions.",icon:Package},{id:"Products",title:"Products Report",description:"Detailed document outlining all your products properties. It provides a comprehensive overview of essential information and insights that help you make informed decisions.",icon:ClipboardList}]}],E=async I=>{g(I),R(!0)},A=async()=>{if(!(!f||!t))try{await l({routeManufacturerId:t,documentNumber:f.id,emailAddress:b}).unwrap(),o({title:"Report requested",description:`The ${f.title} will be sent to ${b} shortly.`,variant:"success"}),R(!1),_("")}catch(I){console.error("Error requesting report:",I),o({title:"Error",description:"Failed to request report. Please try again.",variant:"destructive"})}};return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Reports"}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"Download essential business reports, from your Open Orders & Sales Report, to your Inventory Reports."})]}),jsxRuntime.jsx(CardContent,{className:"space-y-6",children:n?jsxRuntime.jsx(jsxRuntime.Fragment,{children:[1,2,3].map(I=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-48"}),[1,2].map(M=>jsxRuntime.jsxs("div",{className:"flex items-start gap-4 p-4 border rounded-lg",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-9 rounded-full"}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full"})]}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"})]},M))]},I))}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:C.map(I=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx("h3",{className:"text-sm font-semibold",children:I.name}),I.reports.map(M=>jsxRuntime.jsxs("div",{className:"flex items-start gap-4 p-4 border rounded-lg hover:bg-gray-100 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-2 rounded-full",children:jsxRuntime.jsx(M.icon,{className:"h-5 w-5 text-primary"})}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx("h4",{className:"font-semibold text-sm",children:M.title}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:M.description})]}),jsxRuntime.jsxs(Button,{variant:"outline",size:"sm",className:"flex items-center gap-1",onClick:()=>E(M),children:[jsxRuntime.jsx(Download,{className:"h-4 w-4"}),"Request"]})]},M.id))]},I.name))})}),jsxRuntime.jsx(Dialog,{open:S,onOpenChange:R,children:jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsxs(DialogTitle,{children:["Request ",f==null?void 0:f.title]}),jsxRuntime.jsx(DialogDescription,{children:"Enter the email address where you would like to receive the report."})]}),jsxRuntime.jsxs("div",{className:"py-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"email",children:"Email"}),jsxRuntime.jsx(Input,{id:"email",value:b,onChange:I=>_(I.target.value),placeholder:"your@email.com",className:"mt-2"})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button,{variant:"outline",onClick:()=>R(!1),children:"Cancel"}),jsxRuntime.jsx(Button,{onClick:A,disabled:!b||d,children:d?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):"Send Report"})]})]})})]})}function ManufacturerResellerOrdersSection(t){const{data:e,isLoading:n,isError:o}=useGetV4ManufacturerByRouteManufacturerIdDocumentsActiveOrderDetailsQuery({routeManufacturerId:t.manufacturerId},{skip:!!t.activeOrders}),l=t.activeOrders??e,f=(()=>{if(!l)return{all:{orders:0,amount:0},processing:{orders:0,amount:0},shipped:{orders:0,amount:0},delayed:{orders:0,amount:0}};const b=l.filter(Q=>Q.DocumentType==="Order"),_=l.filter(Q=>Q.DocumentType==="Shipment"),S=b.filter(Q=>Q.WarehouseCode!=="3PLE"),R=S.reduce((Q,F)=>Q+(F.Quantity||0),0),C=S.reduce((Q,F)=>Q+(F.ExtendedPrice||0),0),E=b.filter(Q=>Q.WarehouseCode==="3PLE"),A=E.reduce((Q,F)=>Q+(F.Quantity||0),0),I=E.reduce((Q,F)=>Q+(F.ExtendedPrice||0),0),M=_.length,j=_.reduce((Q,F)=>Q+(F.ExtendedPrice||0),0),q=R+A+M,z=C+I+j;return{all:{orders:q,amount:z},processing:{orders:R,amount:C},shipped:{orders:M,amount:j},delayed:{orders:A,amount:I}}})(),g=[{name:"All",icon:Package,color:"bg-blue-500",orders:f.all.orders,amount:f.all.amount},{name:"Processing",icon:RefreshCcw,color:"bg-yellow-500",orders:f.processing.orders,amount:f.processing.amount},{name:"Shipped",icon:Truck,color:"bg-green-500",orders:f.shipped.orders,amount:f.shipped.amount},{name:"Delayed",icon:CircleAlert,color:"bg-red-500",orders:f.delayed.orders,amount:f.delayed.amount}];return n?jsxRuntime.jsxs(Card,{className:"w-full md:col-span-2 xl:col-span-1",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Reseller Orders"})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-40 mb-4"}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3.5",children:[1,2,3,4].map(b=>jsxRuntime.jsx(Skeleton,{className:"h-32 w-full"},b))})]})]}):o?jsxRuntime.jsxs(Card,{className:"w-full md:col-span-2 xl:col-span-1",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Reseller Orders"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsxs(Alert,{variant:"destructive",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Error"}),jsxRuntime.jsx(AlertDescription,{children:"Failed to load reseller orders. Please try again later."})]})})]}):jsxRuntime.jsxs(Card,{className:"w-full md:col-span-2 xl:col-span-1",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Reseller Orders"})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsxs("div",{className:"flex items-center mb-4",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Active Orders:"}),jsxRuntime.jsx("span",{className:"ml-2 font-bold",children:f.all.orders})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3.5",children:g.map(b=>jsxRuntime.jsx(Card,{className:"overflow-hidden rounded-md rounded-b-lg border-0 shadow-md",children:jsxRuntime.jsxs(CardContent,{className:"p-0",children:[jsxRuntime.jsx("div",{className:`${b.color} bg-opacity-60 h-[3px]`}),jsxRuntime.jsxs("div",{className:"p-6 border border-t-0",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-base",children:b.name}),jsxRuntime.jsx("div",{className:`${b.color} bg-opacity-90 p-2 rounded-full`,children:jsxRuntime.jsx(b.icon,{className:"size-4 shrink-0 text-white"})})]}),jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Orders"}),jsxRuntime.jsx("p",{className:"text-xl font-bold",children:b.orders})]}),jsxRuntime.jsxs("div",{className:"text-end",children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Amount"}),jsxRuntime.jsx("p",{className:"text-base font-semibold",children:jsxRuntime.jsx(FormattedNumber,{value:b.amount,style:"currency",currency:"CAD",currencyDisplay:"symbol"})})]})]})]})]})},b.name))})]})]})}var PROGRESS_NAME="Progress",DEFAULT_MAX=100,[createProgressContext,createProgressScope]=createContextScope(PROGRESS_NAME),[ProgressProvider,useProgressContext]=createProgressContext(PROGRESS_NAME),Progress$1=React__namespace.forwardRef((t,e)=>{const{__scopeProgress:n,value:o=null,max:l,getValueLabel:d=defaultGetValueLabel,...f}=t;(l||l===0)&&!isValidMaxNumber(l)&&console.error(getInvalidMaxError(`${l}`,"Progress"));const g=isValidMaxNumber(l)?l:DEFAULT_MAX;o!==null&&!isValidValueNumber(o,g)&&console.error(getInvalidValueError(`${o}`,"Progress"));const b=isValidValueNumber(o,g)?o:null,_=isNumber$1(b)?d(b,g):void 0;return jsxRuntime.jsx(ProgressProvider,{scope:n,value:b,max:g,children:jsxRuntime.jsx(Primitive.div,{"aria-valuemax":g,"aria-valuemin":0,"aria-valuenow":isNumber$1(b)?b:void 0,"aria-valuetext":_,role:"progressbar","data-state":getProgressState(b,g),"data-value":b??void 0,"data-max":g,...f,ref:e})})});Progress$1.displayName=PROGRESS_NAME;var INDICATOR_NAME="ProgressIndicator",ProgressIndicator=React__namespace.forwardRef((t,e)=>{const{__scopeProgress:n,...o}=t,l=useProgressContext(INDICATOR_NAME,n);return jsxRuntime.jsx(Primitive.div,{"data-state":getProgressState(l.value,l.max),"data-value":l.value??void 0,"data-max":l.max,...o,ref:e})});ProgressIndicator.displayName=INDICATOR_NAME;function defaultGetValueLabel(t,e){return`${Math.round(t/e*100)}%`}function getProgressState(t,e){return t==null?"indeterminate":t===e?"complete":"loading"}function isNumber$1(t){return typeof t=="number"}function isValidMaxNumber(t){return isNumber$1(t)&&!isNaN(t)&&t>0}function isValidValueNumber(t,e){return isNumber$1(t)&&!isNaN(t)&&t<=e&&t>=0}function getInvalidMaxError(t,e){return`Invalid prop \`max\` of value \`${t}\` supplied to \`${e}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${DEFAULT_MAX}\`.`}function getInvalidValueError(t,e){return`Invalid prop \`value\` of value \`${t}\` supplied to \`${e}\`. The \`value\` prop must be:
|
|
1086
1086
|
- a positive number
|
|
1087
1087
|
- less than the value passed to \`max\` (or ${DEFAULT_MAX} if no \`max\` prop is set)
|
|
1088
1088
|
- \`null\` or \`undefined\` if the progress is indeterminate.
|
|
1089
1089
|
|
|
1090
|
-
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,R)=>S+(R.InventoryValue||0),0),g=d-f,b=Math.round(f/d*100),_=S=>new Intl.NumberFormat("en-CA",{style:"currency",currency:"CAD",minimumFractionDigits:2}).format(S);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:[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:_(d)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Current Funds"}),jsxRuntime.jsx("span",{className:"font-bold",children:_(f)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Available Funds"}),jsxRuntime.jsx("span",{className:`font-bold ${g>=0?"text-emerald-600 dark:text-emerald-500":"text-red-600 dark:text-red-500"}`,children:_(g)})]})]}),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),f=g=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2}).format(g);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:f(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:f(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:f(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 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,_]=React.useState({publicInfo:{hasUnsavedChanges:!1},qualifications:{hasUnsavedChanges:!1},billingInfo:{hasUnsavedChanges:!1}}),S=React.useCallback(()=>e?!1:b.publicInfo.hasUnsavedChanges||b.qualifications.hasUnsavedChanges||b.billingInfo.hasUnsavedChanges,[e,b]),R=React.useCallback((A,I)=>{_(M=>{var j;return((j=M[A])==null?void 0:j.hasUnsavedChanges)!==I.hasUnsavedChanges?(console.log(`Updating form state for ${A}:`,I.hasUnsavedChanges),{...M,[A]:I}):M})},[]),{NavigationGuardDialog:C}=useRouterNavigationGuard(S),E=o??d;return jsxRuntime.jsxs(jsxRuntime.Fragment,{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 grid-cols-1 lg:grid-cols-2 gap-6",children:[jsxRuntime.jsx(SalesChart,{salesData:(E==null?void 0:E.SalesStatistics)??[],isLoading:f}),jsxRuntime.jsx(ManufacturerResellerOrdersSection,{manufacturerId:t}),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:!0}),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:t,userEmail:l,isLoading:f})]}),jsxRuntime.jsx(C,{})]})}var ROOT_NAME="AlertDialog",[createAlertDialogContext,createAlertDialogScope]=createContextScope(ROOT_NAME,[createDialogScope]),useDialogScope=createDialogScope(),AlertDialog$1=t=>{const{__scopeAlertDialog:e,...n}=t,o=useDialogScope(e);return jsxRuntime.jsx(Root$8,{...o,...n,modal:!0})};AlertDialog$1.displayName=ROOT_NAME;var TRIGGER_NAME="AlertDialogTrigger",AlertDialogTrigger$1=React__namespace.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,l=useDialogScope(n);return jsxRuntime.jsx(Trigger$5,{...l,...o,ref:e})});AlertDialogTrigger$1.displayName=TRIGGER_NAME;var PORTAL_NAME="AlertDialogPortal",AlertDialogPortal$1=t=>{const{__scopeAlertDialog:e,...n}=t,o=useDialogScope(e);return jsxRuntime.jsx(Portal$4,{...o,...n})};AlertDialogPortal$1.displayName=PORTAL_NAME;var OVERLAY_NAME="AlertDialogOverlay",AlertDialogOverlay$1=React__namespace.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,l=useDialogScope(n);return jsxRuntime.jsx(Overlay,{...l,...o,ref:e})});AlertDialogOverlay$1.displayName=OVERLAY_NAME;var CONTENT_NAME="AlertDialogContent",[AlertDialogContentProvider,useAlertDialogContentContext]=createAlertDialogContext(CONTENT_NAME),Slottable=createSlottable("AlertDialogContent"),AlertDialogContent$1=React__namespace.forwardRef((t,e)=>{const{__scopeAlertDialog:n,children:o,...l}=t,d=useDialogScope(n),f=React__namespace.useRef(null),g=useComposedRefs(e,f),b=React__namespace.useRef(null);return jsxRuntime.jsx(WarningProvider,{contentName:CONTENT_NAME,titleName:TITLE_NAME,docsSlug:"alert-dialog",children:jsxRuntime.jsx(AlertDialogContentProvider,{scope:n,cancelRef:b,children:jsxRuntime.jsxs(Content$2,{role:"alertdialog",...d,...l,ref:g,onOpenAutoFocus:composeEventHandlers(l.onOpenAutoFocus,_=>{var S;_.preventDefault(),(S=b.current)==null||S.focus({preventScroll:!0})}),onPointerDownOutside:_=>_.preventDefault(),onInteractOutside:_=>_.preventDefault(),children:[jsxRuntime.jsx(Slottable,{children:o}),jsxRuntime.jsx(DescriptionWarning,{contentRef:f})]})})})});AlertDialogContent$1.displayName=CONTENT_NAME;var TITLE_NAME="AlertDialogTitle",AlertDialogTitle$1=React__namespace.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,l=useDialogScope(n);return jsxRuntime.jsx(Title$1,{...l,...o,ref:e})});AlertDialogTitle$1.displayName=TITLE_NAME;var DESCRIPTION_NAME="AlertDialogDescription",AlertDialogDescription$1=React__namespace.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,l=useDialogScope(n);return jsxRuntime.jsx(Description$1,{...l,...o,ref:e})});AlertDialogDescription$1.displayName=DESCRIPTION_NAME;var ACTION_NAME="AlertDialogAction",AlertDialogAction$1=React__namespace.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,l=useDialogScope(n);return jsxRuntime.jsx(Close$1,{...l,...o,ref:e})});AlertDialogAction$1.displayName=ACTION_NAME;var CANCEL_NAME="AlertDialogCancel",AlertDialogCancel$1=React__namespace.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,{cancelRef:l}=useAlertDialogContentContext(CANCEL_NAME,n),d=useDialogScope(n),f=useComposedRefs(e,l);return jsxRuntime.jsx(Close$1,{...d,...o,ref:f})});AlertDialogCancel$1.displayName=CANCEL_NAME;var DescriptionWarning=({contentRef:t})=>{const e=`\`${CONTENT_NAME}\` requires a description for the component to be accessible for screen reader users.
|
|
1090
|
+
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,R)=>S+(R.InventoryValue||0),0),g=d-f,b=Math.round(f/d*100),_=S=>new Intl.NumberFormat("en-CA",{style:"currency",currency:"CAD",minimumFractionDigits:2}).format(S);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:[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:_(d)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Current Funds"}),jsxRuntime.jsx("span",{className:"font-bold",children:_(f)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Available Funds"}),jsxRuntime.jsx("span",{className:`font-bold ${g>=0?"text-emerald-600 dark:text-emerald-500":"text-red-600 dark:text-red-500"}`,children:_(g)})]})]}),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),f=g=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2}).format(g);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:f(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:f(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:f(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 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,_]=React.useState({publicInfo:{hasUnsavedChanges:!1},qualifications:{hasUnsavedChanges:!1},billingInfo:{hasUnsavedChanges:!1}}),S=React.useCallback(()=>e?!1:b.publicInfo.hasUnsavedChanges||b.qualifications.hasUnsavedChanges||b.billingInfo.hasUnsavedChanges,[e,b]),R=React.useCallback((A,I)=>{_(M=>{var j;return((j=M[A])==null?void 0:j.hasUnsavedChanges)!==I.hasUnsavedChanges?(console.log(`Updating form state for ${A}:`,I.hasUnsavedChanges),{...M,[A]:I}):M})},[]),{NavigationGuardDialog:C}=useRouterNavigationGuard(S),E=o??d;return jsxRuntime.jsxs(jsxRuntime.Fragment,{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 grid-cols-1 lg:grid-cols-2 gap-6",children:[jsxRuntime.jsx(SalesChart,{salesData:(E==null?void 0:E.SalesStatistics)??[],isLoading:f}),jsxRuntime.jsx(ManufacturerResellerOrdersSection,{manufacturerId:t,activeOrders:(E==null?void 0:E.ActiveOrderDetails)??void 0}),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:!0}),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:t,userEmail:l,isLoading:f})]}),jsxRuntime.jsx(C,{})]})}var ROOT_NAME="AlertDialog",[createAlertDialogContext,createAlertDialogScope]=createContextScope(ROOT_NAME,[createDialogScope]),useDialogScope=createDialogScope(),AlertDialog$1=t=>{const{__scopeAlertDialog:e,...n}=t,o=useDialogScope(e);return jsxRuntime.jsx(Root$8,{...o,...n,modal:!0})};AlertDialog$1.displayName=ROOT_NAME;var TRIGGER_NAME="AlertDialogTrigger",AlertDialogTrigger$1=React__namespace.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,l=useDialogScope(n);return jsxRuntime.jsx(Trigger$5,{...l,...o,ref:e})});AlertDialogTrigger$1.displayName=TRIGGER_NAME;var PORTAL_NAME="AlertDialogPortal",AlertDialogPortal$1=t=>{const{__scopeAlertDialog:e,...n}=t,o=useDialogScope(e);return jsxRuntime.jsx(Portal$4,{...o,...n})};AlertDialogPortal$1.displayName=PORTAL_NAME;var OVERLAY_NAME="AlertDialogOverlay",AlertDialogOverlay$1=React__namespace.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,l=useDialogScope(n);return jsxRuntime.jsx(Overlay,{...l,...o,ref:e})});AlertDialogOverlay$1.displayName=OVERLAY_NAME;var CONTENT_NAME="AlertDialogContent",[AlertDialogContentProvider,useAlertDialogContentContext]=createAlertDialogContext(CONTENT_NAME),Slottable=createSlottable("AlertDialogContent"),AlertDialogContent$1=React__namespace.forwardRef((t,e)=>{const{__scopeAlertDialog:n,children:o,...l}=t,d=useDialogScope(n),f=React__namespace.useRef(null),g=useComposedRefs(e,f),b=React__namespace.useRef(null);return jsxRuntime.jsx(WarningProvider,{contentName:CONTENT_NAME,titleName:TITLE_NAME,docsSlug:"alert-dialog",children:jsxRuntime.jsx(AlertDialogContentProvider,{scope:n,cancelRef:b,children:jsxRuntime.jsxs(Content$2,{role:"alertdialog",...d,...l,ref:g,onOpenAutoFocus:composeEventHandlers(l.onOpenAutoFocus,_=>{var S;_.preventDefault(),(S=b.current)==null||S.focus({preventScroll:!0})}),onPointerDownOutside:_=>_.preventDefault(),onInteractOutside:_=>_.preventDefault(),children:[jsxRuntime.jsx(Slottable,{children:o}),jsxRuntime.jsx(DescriptionWarning,{contentRef:f})]})})})});AlertDialogContent$1.displayName=CONTENT_NAME;var TITLE_NAME="AlertDialogTitle",AlertDialogTitle$1=React__namespace.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,l=useDialogScope(n);return jsxRuntime.jsx(Title$1,{...l,...o,ref:e})});AlertDialogTitle$1.displayName=TITLE_NAME;var DESCRIPTION_NAME="AlertDialogDescription",AlertDialogDescription$1=React__namespace.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,l=useDialogScope(n);return jsxRuntime.jsx(Description$1,{...l,...o,ref:e})});AlertDialogDescription$1.displayName=DESCRIPTION_NAME;var ACTION_NAME="AlertDialogAction",AlertDialogAction$1=React__namespace.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,l=useDialogScope(n);return jsxRuntime.jsx(Close$1,{...l,...o,ref:e})});AlertDialogAction$1.displayName=ACTION_NAME;var CANCEL_NAME="AlertDialogCancel",AlertDialogCancel$1=React__namespace.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,{cancelRef:l}=useAlertDialogContentContext(CANCEL_NAME,n),d=useDialogScope(n),f=useComposedRefs(e,l);return jsxRuntime.jsx(Close$1,{...d,...o,ref:f})});AlertDialogCancel$1.displayName=CANCEL_NAME;var DescriptionWarning=({contentRef:t})=>{const e=`\`${CONTENT_NAME}\` requires a description for the component to be accessible for screen reader users.
|
|
1091
1091
|
|
|
1092
1092
|
You can add a description to the \`${CONTENT_NAME}\` by passing a \`${DESCRIPTION_NAME}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
|
|
1093
1093
|
|
|
@@ -1271,4 +1271,4 @@ img.ProseMirror-separator {
|
|
|
1271
1271
|
.ProseMirror p {
|
|
1272
1272
|
margin-bottom: 0.5em;
|
|
1273
1273
|
}
|
|
1274
|
-
`;function RichTextEditor({id:t,name:e,value:n,onChange:o,placeholder:l,className:d,...f}){const[g,b]=React.useState(!1),_=React.useRef(null),S=React.useRef(null),R=useEditor({extensions:[StarterKit,Underline],content:n,editorProps:{attributes:{class:"prose prose-sm sm:prose dark:prose-invert focus:outline-none",id:t??"",name:e??""}},onUpdate:({editor:j})=>{const q=j.getHTML();o({target:{id:t,name:e,value:q}})}});React.useEffect(()=>{R&&n!==R.getHTML()&&R.commands.setContent(n)},[n,R]);const C=React.useCallback(j=>{if(R)if(R.chain().focus(),j==="paragraph")R.chain().setParagraph().run();else{const q=Number.parseInt(j.slice(1));R.chain().setHeading({level:q}).run()}},[R]),E=React.useCallback(j=>{if(R)switch(R.chain().focus(),j){case"bold":R.chain().toggleBold().run();break;case"italic":R.chain().toggleItalic().run();break;case"underline":R.chain().toggleUnderline().run();break;case"strike":R.chain().toggleStrike().run();break;case"bulletList":R.chain().toggleBulletList().run();break;case"orderedList":R.chain().toggleOrderedList().run();break}},[R]),A=React.useCallback(()=>{b(j=>!j)},[]),I=React.useCallback(j=>{const q=j.target.value;R&&R.commands.setContent(q),o({target:{id:t,name:e,value:q}})},[o,R,t,e]),M=React.useCallback(()=>{!g&&R&&R.commands.focus()},[g,R]);return R?jsxRuntime.jsxs("div",{ref:S,className:cn("border border-input rounded-md overflow-hidden focus-within:outline-hidden focus-within:ring-1 focus-within:ring-ring",d),onClick:M,...f,children:[jsxRuntime.jsx("style",{children:editorStyles}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center p-2 border-b border-input gap-2 bg-background",children:[jsxRuntime.jsxs(Select,{onValueChange:C,disabled:g,children:[jsxRuntime.jsx(SelectTrigger,{className:"w-[160px]",children:jsxRuntime.jsx(SelectValue,{placeholder:"Format"})}),jsxRuntime.jsx(SelectContent,{children:formatOptions.map(j=>jsxRuntime.jsx(SelectItem,{value:j.value,children:j.label},j.value))})]}),["bold","italic","underline","strike","bulletList","orderedList"].map(j=>jsxRuntime.jsxs(Button,{type:"button",variant:"ghost",size:"sm",onClick:()=>E(j),className:R.isActive(j)?"bg-muted":"",disabled:g,children:[j==="bold"&&jsxRuntime.jsx(Bold$1,{className:"h-4 w-4"}),j==="italic"&&jsxRuntime.jsx(Italic$1,{className:"h-4 w-4"}),j==="underline"&&jsxRuntime.jsx(Underline$1,{className:"h-4 w-4"}),j==="strike"&&jsxRuntime.jsx(Strikethrough,{className:"h-4 w-4"}),j==="bulletList"&&jsxRuntime.jsx(List$1,{className:"h-4 w-4"}),j==="orderedList"&&jsxRuntime.jsx(ListOrdered,{className:"h-4 w-4"})]},j)),jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"sm",onClick:A,className:g?"bg-muted":"",children:jsxRuntime.jsx(Code$1,{className:"h-4 w-4"})})]}),jsxRuntime.jsx("div",{className:"p-3",children:g?jsxRuntime.jsx(Textarea,{ref:_,id:t,name:e,value:R.getHTML(),onChange:I,className:cn("min-h-[150px] font-mono text-sm resize-none border-0 focus-visible:ring-0 focus-visible:ring-offset-0",d),placeholder:l}):jsxRuntime.jsx(EditorContent,{editor:R})})]}):null}function SalesChart({salesData:t,chartHeight:e=300,units:n="$",unitsPosition:o="left",className:l,isLoading:d=!1}){const[f,g]=React.useState([]),[b,_]=React.useState(!0),S=!d&&!!t&&t.length>0;return React.useEffect(()=>{if(d||!t||t.length===0){g([]);return}const R=t.reduce((Q,F)=>{const V=F.Day??0,te=Math.floor(V).toString();if(te.length!==8||isNaN(Number.parseInt(te)))return console.warn(`Skipping invalid Day format: ${F.Day}`),Q;const ae=te.substring(0,4),se=te.substring(4,6),ge=`${ae}-${se}`;return Q[ge]=(Q[ge]||0)+(F.ExtendedPrice??0),Q},{}),C=Object.keys(R).sort(),E=new Date,A=E.getFullYear(),I=E.getMonth(),M=E.getDate(),j=`${A}-${(I+1).toString().padStart(2,"0")}`,q={...R};if(b&&C.length>0&&C[C.length-1]===j){const Q=q[j],F=new Date(A,I+1,0).getDate();if(M<F&&M>0){const te=Q/M*F;q[j]=te}}const z=C.map(Q=>{const F=q[Q],[V,te]=Q.split("-").map(Number);return{month:new Date(V,te-1).toLocaleString("default",{month:"short",year:"numeric"}),sales:F}});g(z)},[t,b,d]),d?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(Skeleton,{className:"h-6 w-24"})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsx("div",{style:{height:e},children:jsxRuntime.jsx(Skeleton,{className:"h-full w-full rounded-md"})}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2 my-1 pt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-10"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-20"})]}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-3/4 mt-1"})]})]}):f.length===0?jsxRuntime.jsx("div",{style:{height:e},className:l||"p-4 text-center text-muted-foreground flex items-center justify-center",children:"No monthly sales data to display."}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Sales"})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsx(AreaChart,{data:f,units:n,unitsPosition:o,height:e,className:l}),S&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2 my-1 pt-2",children:[jsxRuntime.jsx(Switch,{checked:b,onCheckedChange:_,id:"extrapolate-switch","aria-label":"Toggle sales extrapolation"}),jsxRuntime.jsx(Label$2,{htmlFor:"extrapolate-switch",children:"Extrapolate"})]}),b&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"* Sales for the current month are projected, not actual."})]})]})]})}function getEndDateStatus(t){if(!t)return{text:"No End Date",variant:"neutral",daysRemaining:null};const e=new Date(t);if(isNaN(e.getTime()))return{text:"Invalid Date",variant:"neutral",daysRemaining:null};const n=new Date,o=new Date(e.getFullYear(),e.getMonth(),e.getDate()),l=new Date(n.getFullYear(),n.getMonth(),n.getDate()),d=o.getTime()-l.getTime(),f=Math.ceil(d/(1e3*60*60*24));return f<0?{text:`Ended ${Math.abs(f)}d ago`,variant:"destructive",daysRemaining:f}:f===0?{text:"Ends today",variant:"destructive",daysRemaining:f}:f<=7?{text:`Ends in ${f}d`,variant:"destructive",daysRemaining:f}:f<=30?{text:`Ends in ${f}d`,variant:"warning",daysRemaining:f}:{text:`Ends in ${f}d`,variant:"neutral",daysRemaining:f}}const formatDate=t=>{if(!t)return"N/A";try{const e=new Date(t);return isNaN(e.getTime())?"Invalid Date":e.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return"Invalid Date"}};function ResellerOpportunitiesTable({applicationId:t,opportunities:e=null,loading:n=!1}){var V;const{toast:o}=useToast(),[l,d]=React.useState({}),[f,g]=React.useState(!1),[b,_]=React.useState(""),[S,R]=React.useState(null),C=React.useCallback((te,ae,se)=>{d(ge=>({...ge,[te]:{...ge[te],[ae]:se}}))},[]),[E]=usePutV4ResellerByRouteResellerIdOpportunityAndManufacturerIdDefaultMutation(),A=React.useCallback(async te=>{if(!te.BidNumber){o({title:"Error",description:"Bid Number is missing, cannot set default.",variant:"destructive"});return}const ae=te.BidNumber;C(ae,"isSettingDefault",!0),E({routeResellerId:t,manufacturerId:te.ManufacturerId??"",opportunityNumber:ae}).unwrap().then(()=>{o({title:"Success",description:`Opportunity "${te.OpportunityName||te.Opportunity||ae}" was successfully set as default.`,variant:"success"})}).catch(se=>{var ge;console.error("Set as default error:",se),o({title:"Error",description:((ge=se.data)==null?void 0:ge.message)||se.message||"An error occurred while setting this opportunity as default.",variant:"destructive"})}).finally(()=>{C(ae,"isSettingDefault",!1)})},[t,E,o,C]),[I]=usePostV4ResellerByRouteResellerIdOpportunityAndManufacturerIdBidNumberEmailMutation(),M=React.useCallback(te=>{if(!te.BidNumber){o({title:"Error",description:"Bid Number is missing, cannot prepare report.",variant:"destructive"});return}R(te),_(""),g(!0)},[o]),j=React.useCallback(async()=>{if(!S||!S.BidNumber){o({title:"Error",description:"No opportunity selected or Bid Number is missing.",variant:"destructive"});return}if(!b.trim()||!/\S+@\S+\.\S+/.test(b)){o({title:"Validation Error",description:"Please enter a valid email address.",variant:"destructive"});return}const te=S.BidNumber;C(te,"isSendingReport",!0),I({routeResellerId:t,manufacturerId:S.ManufacturerId??"",bidNumber:te,emailAddress:b}).unwrap().then(()=>{o({title:"Success",description:`A report for "${S.OpportunityName||S.Opportunity||te}" was successfully sent to ${b}.`,variant:"success"}),g(!1)}).catch(ae=>{var se;console.error("Send report by email error:",ae),o({title:"Error",description:((se=ae.data)==null?void 0:se.message)||ae.message||"An error occurred while sending the report by email.",variant:"destructive"})}).finally(()=>{C(te,"isSendingReport",!1),f||(R(null),_(""))})},[S,b,t,I,o,C,g]),q=React.useMemo(()=>[{accessorKey:"ManufacturerId",header:"Manuf.",cell:({row:te})=>jsxRuntime.jsx("div",{className:"w-20 h-8",children:jsxRuntime.jsx(PartnerLogo,{id:te.original.ManufacturerId,width:80,height:32})}),enableSorting:!0,enableFiltering:!0},{id:"opportunityDisplay",accessorFn:te=>te.OpportunityName||te.Opportunity,header:"Opportunity",cell:({getValue:te})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:te()??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"BidNumber",header:"Bid Number",cell:({row:te})=>te.original.BidNumber??"N/A",enableSorting:!0,enableFiltering:!0},{id:"statusInfo",header:"Status",cell:({row:te})=>{const ae=te.original,se=ae.Active===!0,ge=getEndDateStatus(ae.EndDate);let oe="border-gray-400 bg-gray-100 text-gray-600 dark:border-gray-600 dark:bg-gray-800/50 dark:text-gray-400";return ge.variant==="destructive"?oe="border-red-500 bg-red-100 text-red-700 dark:border-red-600 dark:bg-red-900/50 dark:text-red-400":ge.variant==="warning"&&(oe="border-yellow-500 bg-yellow-100 text-yellow-700 dark:border-yellow-600 dark:bg-yellow-900/50 dark:text-yellow-400"),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2 min-w-[200px]",children:[jsxRuntime.jsx(Badge,{variant:"outline",className:se?"border-green-500 bg-green-100 text-green-700 dark:border-green-600 dark:bg-green-900/50 dark:text-green-400 font-medium":"border-gray-400 bg-gray-100 text-gray-600 dark:border-gray-600 dark:bg-gray-800/50 dark:text-gray-400 font-medium",children:se?"Active":"Inactive"}),ae.EndDate&&jsxRuntime.jsx(Badge,{variant:"outline",className:`${oe} font-medium`,children:ge.text}),jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"ghost",size:"icon",className:"h-6 w-6 p-0 data-[state=delayed-open]:bg-accent data-[state=instant-open]:bg-accent",children:jsxRuntime.jsx(Info,{className:"h-4 w-4 text-muted-foreground"})})}),jsxRuntime.jsx(TooltipContent,{side:"top",align:"center",className:"bg-popover text-popover-foreground p-2 rounded shadow-lg",children:jsxRuntime.jsxs("div",{className:"text-sm space-y-1",children:[jsxRuntime.jsxs("p",{children:[jsxRuntime.jsx("strong",{children:"Start:"})," ",formatDate(ae.StartDate)]}),jsxRuntime.jsxs("p",{children:[jsxRuntime.jsx("strong",{children:"End:"})," ",formatDate(ae.EndDate)]}),jsxRuntime.jsxs("p",{children:[jsxRuntime.jsx("strong",{children:"Updated:"})," ",formatDate(ae.LastUpdate)]})]})})]})})]})},enableFiltering:!1},{id:"actions",header:"Actions",cell:({row:te})=>{var je,$e;const ae=te.original;if(!ae.BidNumber)return jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"Actions unavailable"});const se=ae.BidNumber,ge=(je=l[se])==null?void 0:je.isSettingDefault,oe=(S==null?void 0:S.BidNumber)===se&&(($e=l[se])==null?void 0:$e.isSendingReport),Ae=ge||oe,Ne=ae.CanBeSetAsDefault===!0;return jsxRuntime.jsxs("div",{className:"flex space-x-2",children:[jsxRuntime.jsx("a",{href:`https://reseller.randmar.io/${t}/Opportunity/${ae.ManufacturerId}/${ae.BidNumber}`,target:"_blank",children:jsxRuntime.jsxs(Button,{variant:"outline",size:"sm",className:"flex items-center",children:[jsxRuntime.jsx(Star,{className:"mr-2 h-4 w-4"})," View"]})}),jsxRuntime.jsxs(Button,{variant:"outline",size:"sm",onClick:()=>A(ae),disabled:Ae||!Ne,title:Ne?"Set as default":"This opportunity cannot be set as default",className:"flex items-center",children:[ge?jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}):jsxRuntime.jsx(Star,{className:"mr-2 h-4 w-4"})," Set Default"]}),jsxRuntime.jsxs(Button,{variant:"outline",size:"sm",onClick:()=>M(ae),disabled:Ae,title:"Send report by email",className:"flex items-center",children:[oe?jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}):jsxRuntime.jsx(Send,{className:"mr-2 h-4 w-4"})," Send Report"]})]})}}],[l,A,M,S]),z=React.useMemo(()=>{const te={};if(e){const ae=Array.from(new Set(e.map(ge=>ge.ManufacturerId).filter(ge=>ge!=null)));te.ManufacturerId=ae;const se=Array.from(new Set(e.map(ge=>ge.OpportunityName||ge.Opportunity).filter(ge=>ge!=null)));te.opportunityDisplay=se}return te},[e]),Q=e||[],F=S!=null&&S.BidNumber?(V=l[S.BidNumber])==null?void 0:V.isSendingReport:!1;return n?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(Skeleton,{className:"h-7 w-48"})," "]}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-48 w-full rounded-md border"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-[130px]"}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-20"})," ",jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"})," ",jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})," ",jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})]})]})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Opportunities"})," "]}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:q,data:Q,uniqueValues:z})})]}),jsxRuntime.jsx(Dialog,{open:f,onOpenChange:te=>{g(te),te||(R(null),_(""))},children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[425px]",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Send Opportunity Report"}),jsxRuntime.jsxs(DialogDescription,{children:["Enter the email address to send the report for opportunity: ",jsxRuntime.jsx("br",{}),jsxRuntime.jsx("span",{className:"font-semibold",children:(S==null?void 0:S.OpportunityName)||(S==null?void 0:S.Opportunity)||"N/A"}),(S==null?void 0:S.BidNumber)&&jsxRuntime.jsxs("span",{className:"block text-sm text-muted-foreground",children:["Bid Number: ",S.BidNumber]})]})]}),jsxRuntime.jsx("div",{className:"grid gap-4 py-4",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"email",className:"text-right",children:"Email"}),jsxRuntime.jsx(Input,{id:"email",type:"email",value:b,onChange:te=>_(te.target.value),placeholder:"recipient@example.com",className:"col-span-3",disabled:F})]})}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button,{variant:"outline",onClick:()=>g(!1),disabled:F,children:"Cancel"}),jsxRuntime.jsxs(Button,{type:"submit",onClick:j,disabled:F,children:[F&&jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"})," Send Report"]})]})]})})]})}function formatYYYYMMDDIntToDateString$1(t){if(t===null||typeof t>"u")return"N/A";const e=t.toString();return e.length===8?`${e.substring(0,4)}-${e.substring(4,6)}-${e.substring(6,8)}`:e}function formatCurrency(t){return t===null||typeof t>"u"?"N/A":t.toLocaleString(void 0,{style:"currency",currency:"CAD"})}function OrdersTable({orders:t=null,loading:e=!1,title:n="Order Details"}){const o=React.useMemo(()=>[{accessorKey:"DocumentNumber",header:"Document Number",cell:({row:f})=>f.original.DocumentNumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"DocumentDate",header:"Document Date",cell:({row:f})=>formatYYYYMMDDIntToDateString$1(f.original.DocumentDate),enableSorting:!0,enableFiltering:!1},{accessorKey:"OrderNumber",header:"Order Number",cell:({row:f})=>f.original.OrderNumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"PONumber",header:"PO Number",cell:({row:f})=>f.original.PONumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"WarehouseCode",header:"Warehouse",cell:({row:f})=>f.original.WarehouseCode??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:f})=>f.original.Quantity??"N/A",enableSorting:!0,enableFiltering:!1},{accessorKey:"ShipToName",header:"Name",cell:({row:f})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:f.original.ShipToName??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"UnitPrice",header:"Unit Price",cell:({row:f})=>formatCurrency(f.original.UnitPrice),enableSorting:!0,enableFiltering:!1}],[]),l=React.useMemo(()=>{const f={};if(t){const g=Array.from(new Set(t.map(C=>C.WarehouseCode).filter(C=>C!=null)));f.WarehouseCode=g;const b=Array.from(new Set(t.map(C=>C.ShipToName).filter(C=>C!=null)));f.ShipToName=b;const _=Array.from(new Set(t.map(C=>C.DocumentNumber).filter(C=>C!=null)));f.DocumentNumber=_;const S=Array.from(new Set(t.map(C=>C.OrderNumber).filter(C=>C!=null)));f.OrderNumber=S;const R=Array.from(new Set(t.map(C=>C.PONumber).filter(C=>C!=null)));f.PONumber=R}return f},[t]),d=t||[];return e?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(Skeleton,{className:"h-7 w-48"})," "]}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-[130px]"}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-20"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})]})]})]})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:n})," "]}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:o,data:d,uniqueValues:l})})]})}function formatYYYYMMDDIntToDateString(t){if(t===null||typeof t>"u")return"N/A";const e=t.toString();return e.length===8?`${e.substring(0,4)}-${e.substring(4,6)}-${e.substring(6,8)}`:e}function ReceiptsTable({receipts:t=null,loading:e=!1,title:n="Latest Warehouse Receivings"}){const o=React.useMemo(()=>[{accessorKey:"Location",header:"Location",cell:({row:f})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:f.original.Location??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"ReceiptDate",header:"Date",cell:({row:f})=>formatYYYYMMDDIntToDateString(f.original.ReceiptDate),enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:f})=>f.original.Quantity??"N/A",enableSorting:!0,enableFiltering:!0}],[]),l=React.useMemo(()=>{const f={};if(t){const g=Array.from(new Set(t.map(_=>_.Location).filter(_=>_!=null)));f.Location=g;const b=Array.from(new Set(t.map(_=>formatYYYYMMDDIntToDateString(_.ReceiptDate)).filter(_=>_!=="N/A"&&_!=="Invalid Date"))).sort((_,S)=>new Date(S).getTime()-new Date(_).getTime());f.ReceiptDate=b}return f},[t]),d=t||[];return e?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(Skeleton,{className:"h-7 w-56"})," "]}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-[130px]"}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-20"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})]})]})]})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:n})," "]}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:o,data:d,uniqueValues:l})})]})}function ProductOverviewPage({applicationId:t,sku:e,readonly:n=!1,productDefaultOpportunityNumber:o="",productOnAddToCart:l,productAddingToCart:d=!1,productShopifyHostname:f,productCustomAction:g=jsxRuntime.jsx(jsxRuntime.Fragment,{})}){console.log("ProductOverviewPage","readonly",n);const{data:b}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:t},{skip:!t||!e}),{data:_,isLoading:S}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:t,randmarSku:e,withSpecification:!1},{skip:!t||!e}),{data:R,isLoading:C}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:t,randmarSku:e,withSpecification:!0},{skip:!_});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"grid gap-4 grid-cols-1 md:grid-cols-2 lg:grid-cols-3",children:[jsxRuntime.jsx("div",{className:"lg:col-span-2",children:jsxRuntime.jsx(ProductCard,{applicationId:t,product:R||_,defaultOpportunityNumber:o,onAddToCart:l,addingToCart:d,shopifyHostname:f,customAction:g})}),jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsxs(CardTitle,{children:[jsxRuntime.jsx(Info,{className:"h-5 w-5 inline mr-2"})," Additionnal information"]})}),jsxRuntime.jsx(CardContent,{children:S?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsx(Skeleton,{className:"h-1 w-full my-6"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full mt-2"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full mt-1"})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex justify-between",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Cateory Name"}),jsxRuntime.jsx("span",{className:"font-medium",children:(_==null?void 0:_.ProductType)||"N/A"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Master Carton"}),jsxRuntime.jsx("span",{className:"font-medium",children:(_==null?void 0:_.MasterCarton)||"N/A"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Skid Quantity"}),jsxRuntime.jsx("span",{className:"font-medium",children:(_==null?void 0:_.SkidQuantity)||"N/A"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Automatic Reorder"}),jsxRuntime.jsx("span",{className:"font-medium",children:_!=null&&_.AutoUpdate?"Yes":"No"})]}),((_==null?void 0:_.VoiceoverCaption)||(_==null?void 0:_.BodyHTML))&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("hr",{className:"my-6"}),jsxRuntime.jsx("div",{className:"text-muted-foreground mb-2",children:"Description"}),jsxRuntime.jsxs("div",{className:"max-h-44 overflow-scroll",children:[(_==null?void 0:_.VoiceoverCaption)&&jsxRuntime.jsx("div",{children:_==null?void 0:_.VoiceoverCaption}),(_==null?void 0:_.BodyHTML)&&jsxRuntime.jsx("div",{className:"prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:(_==null?void 0:_.BodyHTML)??""}})]})]})]})})]})]}),jsxRuntime.jsx("div",{className:"my-4",children:S?jsxRuntime.jsx("div",{className:"mx-auto flex justify-center items-center h-32",children:jsxRuntime.jsx(LoaderCircle,{className:"h-8 w-8 animate-spin text-primary"})}):jsxRuntime.jsxs(Tabs,{defaultValue:"stats",children:[jsxRuntime.jsxs(TabsList,{className:"inline-flex h-auto items-center justify-center rounded-none border-b bg-transparent p-0",children:[jsxRuntime.jsx(TabsTrigger,{value:"stats",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Statistics"}),(b==null?void 0:b.IsReseller)&&jsxRuntime.jsx(TabsTrigger,{value:"opportunities",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Opportunities"}),jsxRuntime.jsx(TabsTrigger,{value:"orders",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Orders"}),jsxRuntime.jsx(TabsTrigger,{value:"warehouse",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Latest Warehouse Receiving"})]}),jsxRuntime.jsx(TabsContent,{value:"stats",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(SalesChart,{salesData:(R==null?void 0:R.SalesStatistics)??[],isLoading:C})})}),(b==null?void 0:b.IsReseller)&&jsxRuntime.jsx(TabsContent,{value:"opportunities",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ResellerOpportunitiesTable,{applicationId:t,opportunities:_==null?void 0:_.Opportunities,loading:S})})}),jsxRuntime.jsxs(TabsContent,{value:"orders",children:[jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(OrdersTable,{title:"Open Orders",orders:R==null?void 0:R.ActiveOrderDetails,loading:C})}),jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(OrdersTable,{title:"Completed Orders",orders:R==null?void 0:R.CompletedOrderDetails,loading:C})})]}),jsxRuntime.jsx(TabsContent,{value:"warehouse",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ReceiptsTable,{receipts:R==null?void 0:R.Receipts,loading:C})})})]})})]})}exports.ActiveOrdersCard=ActiveOrdersCard,exports.AiGeneratedContent=AiGeneratedContent,exports.Alert=Alert,exports.AlertDescription=AlertDescription,exports.AlertDialog=AlertDialog,exports.AlertDialogAction=AlertDialogAction,exports.AlertDialogCancel=AlertDialogCancel,exports.AlertDialogContent=AlertDialogContent,exports.AlertDialogDescription=AlertDialogDescription,exports.AlertDialogFooter=AlertDialogFooter,exports.AlertDialogHeader=AlertDialogHeader,exports.AlertDialogTitle=AlertDialogTitle,exports.AlertDialogTrigger=AlertDialogTrigger,exports.AlertTitle=AlertTitle,exports.ApiKeyProvider=ApiKeyProvider,exports.AreaChart=AreaChart,exports.Avatar=Avatar,exports.AvatarFallback=AvatarFallback,exports.AvatarFooter=AvatarFooter,exports.AvatarImage=AvatarImage,exports.Badge=Badge,exports.Button=Button,exports.Card=Card,exports.CardContent=CardContent,exports.CardDescription=CardDescription,exports.CardFooter=CardFooter,exports.CardHeader=CardHeader,exports.CardTitle=CardTitle,exports.ChatLayout=ChatLayout,exports.ChatProvider=ChatProvider,exports.Checkbox=Checkbox,exports.Command=Command,exports.CommandDialog=CommandDialog,exports.CommandEmpty=CommandEmpty,exports.CommandGroup=CommandGroup,exports.CommandInput=CommandInput,exports.CommandItem=CommandItem,exports.CommandList=CommandList,exports.CommandSeparator=CommandSeparator,exports.CommandShortcut=CommandShortcut,exports.CountryFlag=CountryFlag,exports.DataTable=DataTable,exports.Dialog=Dialog,exports.DialogClose=DialogClose,exports.DialogContent=DialogContent,exports.DialogDescription=DialogDescription,exports.DialogFooter=DialogFooter,exports.DialogHeader=DialogHeader,exports.DialogOverlay=DialogOverlay,exports.DialogPortal=DialogPortal,exports.DialogTitle=DialogTitle,exports.DialogTrigger=DialogTrigger,exports.DropdownMenu=DropdownMenu,exports.DropdownMenuCheckboxItem=DropdownMenuCheckboxItem,exports.DropdownMenuContent=DropdownMenuContent,exports.DropdownMenuGroup=DropdownMenuGroup,exports.DropdownMenuItem=DropdownMenuItem,exports.DropdownMenuLabel=DropdownMenuLabel,exports.DropdownMenuPortal=DropdownMenuPortal,exports.DropdownMenuRadioGroup=DropdownMenuRadioGroup,exports.DropdownMenuRadioItem=DropdownMenuRadioItem,exports.DropdownMenuSeparator=DropdownMenuSeparator,exports.DropdownMenuShortcut=DropdownMenuShortcut,exports.DropdownMenuSub=DropdownMenuSub,exports.DropdownMenuSubContent=DropdownMenuSubContent,exports.DropdownMenuSubTrigger=DropdownMenuSubTrigger,exports.DropdownMenuTrigger=DropdownMenuTrigger,exports.ExploreManufacturers=ExploreManufacturers,exports.GeneralDocumentCard=GeneralDocumentCard,exports.Input=Input,exports.InputOTP=InputOTP,exports.InputOTPGroup=InputOTPGroup,exports.InputOTPSeparator=InputOTPSeparator,exports.InputOTPSlot=InputOTPSlot,exports.Label=Label$2,exports.Layout=Layout,exports.ManufacturerCard=ManufacturerCard,exports.ManufacturerGetStartedButton=ManufacturerGetStartedButton,exports.ManufacturerOverviewPage=ManufacturerOverviewPage,exports.ManufacturerReorderingCard=ManufacturerReorderingCard,exports.MultiSelect=MultiSelect,exports.Navbar=Navbar,exports.PageHeader=PageHeader,exports.PartnerCard=PartnerCard,exports.PartnerRelationshipPage=PartnerRelationshipPage,exports.Popover=Popover,exports.PopoverAnchor=PopoverAnchor,exports.PopoverContent=PopoverContent,exports.PopoverTrigger=PopoverTrigger,exports.Preloader=Preloader,exports.ProductCard=ProductCard,exports.ProductImage=ProductImage,exports.ProductInventoryGrid=ProductInventoryGrid,exports.ProductOverviewPage=ProductOverviewPage,exports.Progress=Progress,exports.RadioGroup=RadioGroup$1,exports.RadioGroupItem=RadioGroupItem,exports.ResellerBillingOverviewCard=ResellerBillingOverviewCard,exports.ResellerCard=ResellerCard,exports.ResellerOpportunitiesTable=ResellerOpportunitiesTable,exports.ResellerOverview=ResellerOverview,exports.ResellerQualificationsCard=ResellerQualificationsCard,exports.RichTextEditor=RichTextEditor,exports.SalesChart=SalesChart,exports.SalesOverviewCard=SalesOverviewCard,exports.ScrollArea=ScrollArea,exports.ScrollBar=ScrollBar,exports.Select=Select,exports.SelectContent=SelectContent,exports.SelectGroup=SelectGroup,exports.SelectItem=SelectItem,exports.SelectLabel=SelectLabel,exports.SelectScrollDownButton=SelectScrollDownButton,exports.SelectScrollUpButton=SelectScrollUpButton,exports.SelectTrigger=SelectTrigger,exports.SelectValue=SelectValue,exports.Separator=Separator$1,exports.Sheet=Sheet,exports.SheetClose=SheetClose,exports.SheetContent=SheetContent,exports.SheetDescription=SheetDescription,exports.SheetFooter=SheetFooter,exports.SheetHeader=SheetHeader,exports.SheetOverlay=SheetOverlay,exports.SheetPortal=SheetPortal,exports.SheetTitle=SheetTitle,exports.SheetTrigger=SheetTrigger,exports.Sidebar=Sidebar,exports.SidebarContent=SidebarContent,exports.SidebarFooter=SidebarFooter,exports.SidebarGroup=SidebarGroup,exports.SidebarGroupAction=SidebarGroupAction,exports.SidebarGroupContent=SidebarGroupContent,exports.SidebarGroupLabel=SidebarGroupLabel,exports.SidebarHeader=SidebarHeader,exports.SidebarInput=SidebarInput,exports.SidebarInset=SidebarInset,exports.SidebarMenu=SidebarMenu,exports.SidebarMenuAction=SidebarMenuAction,exports.SidebarMenuBadge=SidebarMenuBadge,exports.SidebarMenuButton=SidebarMenuButton,exports.SidebarMenuItem=SidebarMenuItem,exports.SidebarMenuSkeleton=SidebarMenuSkeleton,exports.SidebarMenuSub=SidebarMenuSub,exports.SidebarMenuSubButton=SidebarMenuSubButton,exports.SidebarMenuSubItem=SidebarMenuSubItem,exports.SidebarProvider=SidebarProvider,exports.SidebarRail=SidebarRail,exports.SidebarSeparator=SidebarSeparator,exports.SidebarTrigger=SidebarTrigger,exports.Skeleton=Skeleton,exports.Switch=Switch,exports.Table=Table,exports.TableBody=TableBody,exports.TableCaption=TableCaption,exports.TableCell=TableCell,exports.TableFooter=TableFooter,exports.TableHead=TableHead,exports.TableHeader=TableHeader,exports.TableRow=TableRow,exports.Tabs=Tabs,exports.TabsContent=TabsContent,exports.TabsList=TabsList,exports.TabsTrigger=TabsTrigger,exports.Textarea=Textarea,exports.Toast=Toast,exports.ToastAction=ToastAction,exports.ToastClose=ToastClose,exports.ToastDescription=ToastDescription,exports.ToastProvider=ToastProvider,exports.ToastTitle=ToastTitle,exports.ToastViewport=ToastViewport,exports.Toaster=Toaster,exports.Tooltip=Tooltip$1,exports.TooltipContent=TooltipContent,exports.TooltipProvider=TooltipProvider,exports.TooltipTrigger=TooltipTrigger,exports.Topbar=Topbar,exports.badgeVariants=badgeVariants,exports.buttonVariants=buttonVariants,exports.toast=toast,exports.useApiKey=useApiKey,exports.useChat=useChat,exports.useIsMobile=useIsMobile,exports.useSidebar=useSidebar,exports.useToast=useToast,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})});
|
|
1274
|
+
`;function RichTextEditor({id:t,name:e,value:n,onChange:o,placeholder:l,className:d,...f}){const[g,b]=React.useState(!1),_=React.useRef(null),S=React.useRef(null),R=useEditor({extensions:[StarterKit,Underline],content:n,editorProps:{attributes:{class:"prose prose-sm sm:prose dark:prose-invert focus:outline-none",id:t??"",name:e??""}},onUpdate:({editor:j})=>{const q=j.getHTML();o({target:{id:t,name:e,value:q}})}});React.useEffect(()=>{R&&n!==R.getHTML()&&R.commands.setContent(n)},[n,R]);const C=React.useCallback(j=>{if(R)if(R.chain().focus(),j==="paragraph")R.chain().setParagraph().run();else{const q=Number.parseInt(j.slice(1));R.chain().setHeading({level:q}).run()}},[R]),E=React.useCallback(j=>{if(R)switch(R.chain().focus(),j){case"bold":R.chain().toggleBold().run();break;case"italic":R.chain().toggleItalic().run();break;case"underline":R.chain().toggleUnderline().run();break;case"strike":R.chain().toggleStrike().run();break;case"bulletList":R.chain().toggleBulletList().run();break;case"orderedList":R.chain().toggleOrderedList().run();break}},[R]),A=React.useCallback(()=>{b(j=>!j)},[]),I=React.useCallback(j=>{const q=j.target.value;R&&R.commands.setContent(q),o({target:{id:t,name:e,value:q}})},[o,R,t,e]),M=React.useCallback(()=>{!g&&R&&R.commands.focus()},[g,R]);return R?jsxRuntime.jsxs("div",{ref:S,className:cn("border border-input rounded-md overflow-hidden focus-within:outline-hidden focus-within:ring-1 focus-within:ring-ring",d),onClick:M,...f,children:[jsxRuntime.jsx("style",{children:editorStyles}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center p-2 border-b border-input gap-2 bg-background",children:[jsxRuntime.jsxs(Select,{onValueChange:C,disabled:g,children:[jsxRuntime.jsx(SelectTrigger,{className:"w-[160px]",children:jsxRuntime.jsx(SelectValue,{placeholder:"Format"})}),jsxRuntime.jsx(SelectContent,{children:formatOptions.map(j=>jsxRuntime.jsx(SelectItem,{value:j.value,children:j.label},j.value))})]}),["bold","italic","underline","strike","bulletList","orderedList"].map(j=>jsxRuntime.jsxs(Button,{type:"button",variant:"ghost",size:"sm",onClick:()=>E(j),className:R.isActive(j)?"bg-muted":"",disabled:g,children:[j==="bold"&&jsxRuntime.jsx(Bold$1,{className:"h-4 w-4"}),j==="italic"&&jsxRuntime.jsx(Italic$1,{className:"h-4 w-4"}),j==="underline"&&jsxRuntime.jsx(Underline$1,{className:"h-4 w-4"}),j==="strike"&&jsxRuntime.jsx(Strikethrough,{className:"h-4 w-4"}),j==="bulletList"&&jsxRuntime.jsx(List$1,{className:"h-4 w-4"}),j==="orderedList"&&jsxRuntime.jsx(ListOrdered,{className:"h-4 w-4"})]},j)),jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"sm",onClick:A,className:g?"bg-muted":"",children:jsxRuntime.jsx(Code$1,{className:"h-4 w-4"})})]}),jsxRuntime.jsx("div",{className:"p-3",children:g?jsxRuntime.jsx(Textarea,{ref:_,id:t,name:e,value:R.getHTML(),onChange:I,className:cn("min-h-[150px] font-mono text-sm resize-none border-0 focus-visible:ring-0 focus-visible:ring-offset-0",d),placeholder:l}):jsxRuntime.jsx(EditorContent,{editor:R})})]}):null}function SalesChart({salesData:t,chartHeight:e=300,units:n="$",unitsPosition:o="left",className:l,isLoading:d=!1}){const[f,g]=React.useState([]),[b,_]=React.useState(!0),S=!d&&!!t&&t.length>0;return React.useEffect(()=>{if(d||!t||t.length===0){g([]);return}const R=t.reduce((Q,F)=>{const V=F.Day??0,te=Math.floor(V).toString();if(te.length!==8||isNaN(Number.parseInt(te)))return console.warn(`Skipping invalid Day format: ${F.Day}`),Q;const ae=te.substring(0,4),se=te.substring(4,6),ge=`${ae}-${se}`;return Q[ge]=(Q[ge]||0)+(F.ExtendedPrice??0),Q},{}),C=Object.keys(R).sort(),E=new Date,A=E.getFullYear(),I=E.getMonth(),M=E.getDate(),j=`${A}-${(I+1).toString().padStart(2,"0")}`,q={...R};if(b&&C.length>0&&C[C.length-1]===j){const Q=q[j],F=new Date(A,I+1,0).getDate();if(M<F&&M>0){const te=Q/M*F;q[j]=te}}const z=C.map(Q=>{const F=q[Q],[V,te]=Q.split("-").map(Number);return{month:new Date(V,te-1).toLocaleString("default",{month:"short",year:"numeric"}),sales:F}});g(z)},[t,b,d]),d?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(Skeleton,{className:"h-6 w-24"})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsx("div",{style:{height:e},children:jsxRuntime.jsx(Skeleton,{className:"h-full w-full rounded-md"})}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2 my-1 pt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-10"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-20"})]}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-3/4 mt-1"})]})]}):f.length===0?jsxRuntime.jsx("div",{style:{height:e},className:l||"p-4 text-center text-muted-foreground flex items-center justify-center",children:"No monthly sales data to display."}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Sales"})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsx(AreaChart,{data:f,units:n,unitsPosition:o,height:e,className:l}),S&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2 my-1 pt-2",children:[jsxRuntime.jsx(Switch,{checked:b,onCheckedChange:_,id:"extrapolate-switch","aria-label":"Toggle sales extrapolation"}),jsxRuntime.jsx(Label$2,{htmlFor:"extrapolate-switch",children:"Extrapolate"})]}),b&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"* Sales for the current month are projected, not actual."})]})]})]})}function getEndDateStatus(t){if(!t)return{text:"No End Date",variant:"neutral",daysRemaining:null};const e=new Date(t);if(isNaN(e.getTime()))return{text:"Invalid Date",variant:"neutral",daysRemaining:null};const n=new Date,o=new Date(e.getFullYear(),e.getMonth(),e.getDate()),l=new Date(n.getFullYear(),n.getMonth(),n.getDate()),d=o.getTime()-l.getTime(),f=Math.ceil(d/(1e3*60*60*24));return f<0?{text:`Ended ${Math.abs(f)}d ago`,variant:"destructive",daysRemaining:f}:f===0?{text:"Ends today",variant:"destructive",daysRemaining:f}:f<=7?{text:`Ends in ${f}d`,variant:"destructive",daysRemaining:f}:f<=30?{text:`Ends in ${f}d`,variant:"warning",daysRemaining:f}:{text:`Ends in ${f}d`,variant:"neutral",daysRemaining:f}}const formatDate=t=>{if(!t)return"N/A";try{const e=new Date(t);return isNaN(e.getTime())?"Invalid Date":e.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return"Invalid Date"}};function ResellerOpportunitiesTable({applicationId:t,opportunities:e=null,loading:n=!1}){var V;const{toast:o}=useToast(),[l,d]=React.useState({}),[f,g]=React.useState(!1),[b,_]=React.useState(""),[S,R]=React.useState(null),C=React.useCallback((te,ae,se)=>{d(ge=>({...ge,[te]:{...ge[te],[ae]:se}}))},[]),[E]=usePutV4ResellerByRouteResellerIdOpportunityAndManufacturerIdDefaultMutation(),A=React.useCallback(async te=>{if(!te.BidNumber){o({title:"Error",description:"Bid Number is missing, cannot set default.",variant:"destructive"});return}const ae=te.BidNumber;C(ae,"isSettingDefault",!0),E({routeResellerId:t,manufacturerId:te.ManufacturerId??"",opportunityNumber:ae}).unwrap().then(()=>{o({title:"Success",description:`Opportunity "${te.OpportunityName||te.Opportunity||ae}" was successfully set as default.`,variant:"success"})}).catch(se=>{var ge;console.error("Set as default error:",se),o({title:"Error",description:((ge=se.data)==null?void 0:ge.message)||se.message||"An error occurred while setting this opportunity as default.",variant:"destructive"})}).finally(()=>{C(ae,"isSettingDefault",!1)})},[t,E,o,C]),[I]=usePostV4ResellerByRouteResellerIdOpportunityAndManufacturerIdBidNumberEmailMutation(),M=React.useCallback(te=>{if(!te.BidNumber){o({title:"Error",description:"Bid Number is missing, cannot prepare report.",variant:"destructive"});return}R(te),_(""),g(!0)},[o]),j=React.useCallback(async()=>{if(!S||!S.BidNumber){o({title:"Error",description:"No opportunity selected or Bid Number is missing.",variant:"destructive"});return}if(!b.trim()||!/\S+@\S+\.\S+/.test(b)){o({title:"Validation Error",description:"Please enter a valid email address.",variant:"destructive"});return}const te=S.BidNumber;C(te,"isSendingReport",!0),I({routeResellerId:t,manufacturerId:S.ManufacturerId??"",bidNumber:te,emailAddress:b}).unwrap().then(()=>{o({title:"Success",description:`A report for "${S.OpportunityName||S.Opportunity||te}" was successfully sent to ${b}.`,variant:"success"}),g(!1)}).catch(ae=>{var se;console.error("Send report by email error:",ae),o({title:"Error",description:((se=ae.data)==null?void 0:se.message)||ae.message||"An error occurred while sending the report by email.",variant:"destructive"})}).finally(()=>{C(te,"isSendingReport",!1),f||(R(null),_(""))})},[S,b,t,I,o,C,g]),q=React.useMemo(()=>[{accessorKey:"ManufacturerId",header:"Manuf.",cell:({row:te})=>jsxRuntime.jsx("div",{className:"w-20 h-8",children:jsxRuntime.jsx(PartnerLogo,{id:te.original.ManufacturerId,width:80,height:32})}),enableSorting:!0,enableFiltering:!0},{id:"opportunityDisplay",accessorFn:te=>te.OpportunityName||te.Opportunity,header:"Opportunity",cell:({getValue:te})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:te()??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"BidNumber",header:"Bid Number",cell:({row:te})=>te.original.BidNumber??"N/A",enableSorting:!0,enableFiltering:!0},{id:"statusInfo",header:"Status",cell:({row:te})=>{const ae=te.original,se=ae.Active===!0,ge=getEndDateStatus(ae.EndDate);let oe="border-gray-400 bg-gray-100 text-gray-600 dark:border-gray-600 dark:bg-gray-800/50 dark:text-gray-400";return ge.variant==="destructive"?oe="border-red-500 bg-red-100 text-red-700 dark:border-red-600 dark:bg-red-900/50 dark:text-red-400":ge.variant==="warning"&&(oe="border-yellow-500 bg-yellow-100 text-yellow-700 dark:border-yellow-600 dark:bg-yellow-900/50 dark:text-yellow-400"),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2 min-w-[200px]",children:[jsxRuntime.jsx(Badge,{variant:"outline",className:se?"border-green-500 bg-green-100 text-green-700 dark:border-green-600 dark:bg-green-900/50 dark:text-green-400 font-medium":"border-gray-400 bg-gray-100 text-gray-600 dark:border-gray-600 dark:bg-gray-800/50 dark:text-gray-400 font-medium",children:se?"Active":"Inactive"}),ae.EndDate&&jsxRuntime.jsx(Badge,{variant:"outline",className:`${oe} font-medium`,children:ge.text}),jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"ghost",size:"icon",className:"h-6 w-6 p-0 data-[state=delayed-open]:bg-accent data-[state=instant-open]:bg-accent",children:jsxRuntime.jsx(Info,{className:"h-4 w-4 text-muted-foreground"})})}),jsxRuntime.jsx(TooltipContent,{side:"top",align:"center",className:"bg-popover text-popover-foreground p-2 rounded shadow-lg",children:jsxRuntime.jsxs("div",{className:"text-sm space-y-1",children:[jsxRuntime.jsxs("p",{children:[jsxRuntime.jsx("strong",{children:"Start:"})," ",formatDate(ae.StartDate)]}),jsxRuntime.jsxs("p",{children:[jsxRuntime.jsx("strong",{children:"End:"})," ",formatDate(ae.EndDate)]}),jsxRuntime.jsxs("p",{children:[jsxRuntime.jsx("strong",{children:"Updated:"})," ",formatDate(ae.LastUpdate)]})]})})]})})]})},enableFiltering:!1},{id:"actions",header:"Actions",cell:({row:te})=>{var je,$e;const ae=te.original;if(!ae.BidNumber)return jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"Actions unavailable"});const se=ae.BidNumber,ge=(je=l[se])==null?void 0:je.isSettingDefault,oe=(S==null?void 0:S.BidNumber)===se&&(($e=l[se])==null?void 0:$e.isSendingReport),Ae=ge||oe,Ne=ae.CanBeSetAsDefault===!0;return jsxRuntime.jsxs("div",{className:"flex space-x-2",children:[jsxRuntime.jsx("a",{href:`/${t}/Opportunity/${ae.ManufacturerId}/${ae.BidNumber}`,children:jsxRuntime.jsxs(Button,{variant:"outline",size:"sm",className:"flex items-center",children:[jsxRuntime.jsx(Star,{className:"mr-2 h-4 w-4"})," View"]})}),jsxRuntime.jsxs(Button,{variant:"outline",size:"sm",onClick:()=>A(ae),disabled:Ae||!Ne,title:Ne?"Set as default":"This opportunity cannot be set as default",className:"flex items-center",children:[ge?jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}):jsxRuntime.jsx(Star,{className:"mr-2 h-4 w-4"})," Set Default"]}),jsxRuntime.jsxs(Button,{variant:"outline",size:"sm",onClick:()=>M(ae),disabled:Ae,title:"Send report by email",className:"flex items-center",children:[oe?jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}):jsxRuntime.jsx(Send,{className:"mr-2 h-4 w-4"})," Send Report"]})]})}}],[l,A,M,S]),z=React.useMemo(()=>{const te={};if(e){const ae=Array.from(new Set(e.map(ge=>ge.ManufacturerId).filter(ge=>ge!=null)));te.ManufacturerId=ae;const se=Array.from(new Set(e.map(ge=>ge.OpportunityName||ge.Opportunity).filter(ge=>ge!=null)));te.opportunityDisplay=se}return te},[e]),Q=e||[],F=S!=null&&S.BidNumber?(V=l[S.BidNumber])==null?void 0:V.isSendingReport:!1;return n?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(Skeleton,{className:"h-7 w-48"})," "]}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-48 w-full rounded-md border"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-[130px]"}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-20"})," ",jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"})," ",jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})," ",jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})]})]})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Opportunities"})," "]}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:q,data:Q,uniqueValues:z})})]}),jsxRuntime.jsx(Dialog,{open:f,onOpenChange:te=>{g(te),te||(R(null),_(""))},children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[425px]",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Send Opportunity Report"}),jsxRuntime.jsxs(DialogDescription,{children:["Enter the email address to send the report for opportunity: ",jsxRuntime.jsx("br",{}),jsxRuntime.jsx("span",{className:"font-semibold",children:(S==null?void 0:S.OpportunityName)||(S==null?void 0:S.Opportunity)||"N/A"}),(S==null?void 0:S.BidNumber)&&jsxRuntime.jsxs("span",{className:"block text-sm text-muted-foreground",children:["Bid Number: ",S.BidNumber]})]})]}),jsxRuntime.jsx("div",{className:"grid gap-4 py-4",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"email",className:"text-right",children:"Email"}),jsxRuntime.jsx(Input,{id:"email",type:"email",value:b,onChange:te=>_(te.target.value),placeholder:"recipient@example.com",className:"col-span-3",disabled:F})]})}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button,{variant:"outline",onClick:()=>g(!1),disabled:F,children:"Cancel"}),jsxRuntime.jsxs(Button,{type:"submit",onClick:j,disabled:F,children:[F&&jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"})," Send Report"]})]})]})})]})}function formatYYYYMMDDIntToDateString$1(t){if(t===null||typeof t>"u")return"N/A";const e=t.toString();return e.length===8?`${e.substring(0,4)}-${e.substring(4,6)}-${e.substring(6,8)}`:e}function formatCurrency(t){return t===null||typeof t>"u"?"N/A":t.toLocaleString(void 0,{style:"currency",currency:"CAD"})}function OrdersTable({orders:t=null,loading:e=!1,title:n="Order Details"}){const o=React.useMemo(()=>[{accessorKey:"DocumentNumber",header:"Document Number",cell:({row:f})=>f.original.DocumentNumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"DocumentDate",header:"Document Date",cell:({row:f})=>formatYYYYMMDDIntToDateString$1(f.original.DocumentDate),enableSorting:!0,enableFiltering:!1},{accessorKey:"OrderNumber",header:"Order Number",cell:({row:f})=>f.original.OrderNumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"PONumber",header:"PO Number",cell:({row:f})=>f.original.PONumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"WarehouseCode",header:"Warehouse",cell:({row:f})=>f.original.WarehouseCode??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:f})=>f.original.Quantity??"N/A",enableSorting:!0,enableFiltering:!1},{accessorKey:"ShipToName",header:"Name",cell:({row:f})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:f.original.ShipToName??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"UnitPrice",header:"Unit Price",cell:({row:f})=>formatCurrency(f.original.UnitPrice),enableSorting:!0,enableFiltering:!1}],[]),l=React.useMemo(()=>{const f={};if(t){const g=Array.from(new Set(t.map(C=>C.WarehouseCode).filter(C=>C!=null)));f.WarehouseCode=g;const b=Array.from(new Set(t.map(C=>C.ShipToName).filter(C=>C!=null)));f.ShipToName=b;const _=Array.from(new Set(t.map(C=>C.DocumentNumber).filter(C=>C!=null)));f.DocumentNumber=_;const S=Array.from(new Set(t.map(C=>C.OrderNumber).filter(C=>C!=null)));f.OrderNumber=S;const R=Array.from(new Set(t.map(C=>C.PONumber).filter(C=>C!=null)));f.PONumber=R}return f},[t]),d=t||[];return e?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(Skeleton,{className:"h-7 w-48"})," "]}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-[130px]"}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-20"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})]})]})]})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:n})," "]}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:o,data:d,uniqueValues:l})})]})}function formatYYYYMMDDIntToDateString(t){if(t===null||typeof t>"u")return"N/A";const e=t.toString();return e.length===8?`${e.substring(0,4)}-${e.substring(4,6)}-${e.substring(6,8)}`:e}function ReceiptsTable({receipts:t=null,loading:e=!1,title:n="Latest Warehouse Receivings"}){const o=React.useMemo(()=>[{accessorKey:"Location",header:"Location",cell:({row:f})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:f.original.Location??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"ReceiptDate",header:"Date",cell:({row:f})=>formatYYYYMMDDIntToDateString(f.original.ReceiptDate),enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:f})=>f.original.Quantity??"N/A",enableSorting:!0,enableFiltering:!0}],[]),l=React.useMemo(()=>{const f={};if(t){const g=Array.from(new Set(t.map(_=>_.Location).filter(_=>_!=null)));f.Location=g;const b=Array.from(new Set(t.map(_=>formatYYYYMMDDIntToDateString(_.ReceiptDate)).filter(_=>_!=="N/A"&&_!=="Invalid Date"))).sort((_,S)=>new Date(S).getTime()-new Date(_).getTime());f.ReceiptDate=b}return f},[t]),d=t||[];return e?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(Skeleton,{className:"h-7 w-56"})," "]}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-[130px]"}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-20"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})]})]})]})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:n})," "]}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:o,data:d,uniqueValues:l})})]})}function ProductOverviewPage({applicationId:t,sku:e,productDefaultOpportunityNumber:n="",productOnAddToCart:o,productAddingToCart:l=!1,productShopifyHostname:d,productCustomAction:f=jsxRuntime.jsx(jsxRuntime.Fragment,{})}){const{data:g}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:t},{skip:!t||!e}),{data:b,isLoading:_}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:t,randmarSku:e,withSpecification:!1},{skip:!t||!e}),{data:S,isLoading:R}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:t,randmarSku:e,withSpecification:!0},{skip:!b}),C=(b==null?void 0:b.ManufacturerId)!==t;return console.log("readonly",C),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"grid gap-4 grid-cols-1 md:grid-cols-2 lg:grid-cols-3",children:[jsxRuntime.jsx("div",{className:"lg:col-span-2",children:jsxRuntime.jsx(ProductCard,{applicationId:t,product:S||b,defaultOpportunityNumber:n,onAddToCart:o,addingToCart:l,shopifyHostname:d,customAction:f})}),jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsxs(CardTitle,{children:[jsxRuntime.jsx(Info,{className:"h-5 w-5 inline mr-2"})," Additionnal information"]})}),jsxRuntime.jsx(CardContent,{children:_?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsx(Skeleton,{className:"h-1 w-full my-6"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full mt-2"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full mt-1"})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex justify-between",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Cateory Name"}),jsxRuntime.jsx("span",{className:"font-medium",children:(b==null?void 0:b.ProductType)||"N/A"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Master Carton"}),jsxRuntime.jsx("span",{className:"font-medium",children:(b==null?void 0:b.MasterCarton)||"N/A"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Skid Quantity"}),jsxRuntime.jsx("span",{className:"font-medium",children:(b==null?void 0:b.SkidQuantity)||"N/A"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Automatic Reorder"}),jsxRuntime.jsx("span",{className:"font-medium",children:b!=null&&b.AutoUpdate?"Yes":"No"})]}),((b==null?void 0:b.VoiceoverCaption)||(b==null?void 0:b.BodyHTML))&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("hr",{className:"my-6"}),jsxRuntime.jsx("div",{className:"text-muted-foreground mb-2",children:"Description"}),jsxRuntime.jsxs("div",{className:"max-h-44 overflow-scroll",children:[(b==null?void 0:b.VoiceoverCaption)&&jsxRuntime.jsx("div",{children:b==null?void 0:b.VoiceoverCaption}),(b==null?void 0:b.BodyHTML)&&jsxRuntime.jsx("div",{className:"prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:(b==null?void 0:b.BodyHTML)??""}})]})]})]})})]})]}),jsxRuntime.jsx("div",{className:"my-4",children:_?jsxRuntime.jsx("div",{className:"mx-auto flex justify-center items-center h-32",children:jsxRuntime.jsx(LoaderCircle,{className:"h-8 w-8 animate-spin text-primary"})}):jsxRuntime.jsxs(Tabs,{defaultValue:"stats",children:[jsxRuntime.jsxs(TabsList,{className:"inline-flex h-auto items-center justify-center rounded-none border-b bg-transparent p-0",children:[jsxRuntime.jsx(TabsTrigger,{value:"stats",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Statistics"}),(g==null?void 0:g.IsReseller)&&jsxRuntime.jsx(TabsTrigger,{value:"opportunities",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Opportunities"}),jsxRuntime.jsx(TabsTrigger,{value:"orders",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Orders"}),jsxRuntime.jsx(TabsTrigger,{value:"warehouse",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Latest Warehouse Receiving"})]}),jsxRuntime.jsx(TabsContent,{value:"stats",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(SalesChart,{salesData:(S==null?void 0:S.SalesStatistics)??[],isLoading:R})})}),(g==null?void 0:g.IsReseller)&&jsxRuntime.jsx(TabsContent,{value:"opportunities",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ResellerOpportunitiesTable,{applicationId:t,opportunities:b==null?void 0:b.Opportunities,loading:_})})}),jsxRuntime.jsxs(TabsContent,{value:"orders",children:[jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(OrdersTable,{title:"Open Orders",orders:S==null?void 0:S.ActiveOrderDetails,loading:R})}),jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(OrdersTable,{title:"Completed Orders",orders:S==null?void 0:S.CompletedOrderDetails,loading:R})})]}),jsxRuntime.jsx(TabsContent,{value:"warehouse",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ReceiptsTable,{receipts:S==null?void 0:S.Receipts,loading:R})})})]})})]})}exports.ActiveOrdersCard=ActiveOrdersCard,exports.AiGeneratedContent=AiGeneratedContent,exports.Alert=Alert,exports.AlertDescription=AlertDescription,exports.AlertDialog=AlertDialog,exports.AlertDialogAction=AlertDialogAction,exports.AlertDialogCancel=AlertDialogCancel,exports.AlertDialogContent=AlertDialogContent,exports.AlertDialogDescription=AlertDialogDescription,exports.AlertDialogFooter=AlertDialogFooter,exports.AlertDialogHeader=AlertDialogHeader,exports.AlertDialogTitle=AlertDialogTitle,exports.AlertDialogTrigger=AlertDialogTrigger,exports.AlertTitle=AlertTitle,exports.ApiKeyProvider=ApiKeyProvider,exports.AreaChart=AreaChart,exports.Avatar=Avatar,exports.AvatarFallback=AvatarFallback,exports.AvatarFooter=AvatarFooter,exports.AvatarImage=AvatarImage,exports.Badge=Badge,exports.Button=Button,exports.Card=Card,exports.CardContent=CardContent,exports.CardDescription=CardDescription,exports.CardFooter=CardFooter,exports.CardHeader=CardHeader,exports.CardTitle=CardTitle,exports.ChatLayout=ChatLayout,exports.ChatProvider=ChatProvider,exports.Checkbox=Checkbox,exports.Command=Command,exports.CommandDialog=CommandDialog,exports.CommandEmpty=CommandEmpty,exports.CommandGroup=CommandGroup,exports.CommandInput=CommandInput,exports.CommandItem=CommandItem,exports.CommandList=CommandList,exports.CommandSeparator=CommandSeparator,exports.CommandShortcut=CommandShortcut,exports.CountryFlag=CountryFlag,exports.DataTable=DataTable,exports.Dialog=Dialog,exports.DialogClose=DialogClose,exports.DialogContent=DialogContent,exports.DialogDescription=DialogDescription,exports.DialogFooter=DialogFooter,exports.DialogHeader=DialogHeader,exports.DialogOverlay=DialogOverlay,exports.DialogPortal=DialogPortal,exports.DialogTitle=DialogTitle,exports.DialogTrigger=DialogTrigger,exports.DropdownMenu=DropdownMenu,exports.DropdownMenuCheckboxItem=DropdownMenuCheckboxItem,exports.DropdownMenuContent=DropdownMenuContent,exports.DropdownMenuGroup=DropdownMenuGroup,exports.DropdownMenuItem=DropdownMenuItem,exports.DropdownMenuLabel=DropdownMenuLabel,exports.DropdownMenuPortal=DropdownMenuPortal,exports.DropdownMenuRadioGroup=DropdownMenuRadioGroup,exports.DropdownMenuRadioItem=DropdownMenuRadioItem,exports.DropdownMenuSeparator=DropdownMenuSeparator,exports.DropdownMenuShortcut=DropdownMenuShortcut,exports.DropdownMenuSub=DropdownMenuSub,exports.DropdownMenuSubContent=DropdownMenuSubContent,exports.DropdownMenuSubTrigger=DropdownMenuSubTrigger,exports.DropdownMenuTrigger=DropdownMenuTrigger,exports.ExploreManufacturers=ExploreManufacturers,exports.GeneralDocumentCard=GeneralDocumentCard,exports.Input=Input,exports.InputOTP=InputOTP,exports.InputOTPGroup=InputOTPGroup,exports.InputOTPSeparator=InputOTPSeparator,exports.InputOTPSlot=InputOTPSlot,exports.Label=Label$2,exports.Layout=Layout,exports.ManufacturerCard=ManufacturerCard,exports.ManufacturerGetStartedButton=ManufacturerGetStartedButton,exports.ManufacturerOverviewPage=ManufacturerOverviewPage,exports.ManufacturerReorderingCard=ManufacturerReorderingCard,exports.MultiSelect=MultiSelect,exports.Navbar=Navbar,exports.PageHeader=PageHeader,exports.PartnerCard=PartnerCard,exports.PartnerRelationshipPage=PartnerRelationshipPage,exports.Popover=Popover,exports.PopoverAnchor=PopoverAnchor,exports.PopoverContent=PopoverContent,exports.PopoverTrigger=PopoverTrigger,exports.Preloader=Preloader,exports.ProductCard=ProductCard,exports.ProductImage=ProductImage,exports.ProductInventoryGrid=ProductInventoryGrid,exports.ProductOverviewPage=ProductOverviewPage,exports.Progress=Progress,exports.RadioGroup=RadioGroup$1,exports.RadioGroupItem=RadioGroupItem,exports.ResellerBillingOverviewCard=ResellerBillingOverviewCard,exports.ResellerCard=ResellerCard,exports.ResellerOpportunitiesTable=ResellerOpportunitiesTable,exports.ResellerOverview=ResellerOverview,exports.ResellerQualificationsCard=ResellerQualificationsCard,exports.RichTextEditor=RichTextEditor,exports.SalesChart=SalesChart,exports.SalesOverviewCard=SalesOverviewCard,exports.ScrollArea=ScrollArea,exports.ScrollBar=ScrollBar,exports.Select=Select,exports.SelectContent=SelectContent,exports.SelectGroup=SelectGroup,exports.SelectItem=SelectItem,exports.SelectLabel=SelectLabel,exports.SelectScrollDownButton=SelectScrollDownButton,exports.SelectScrollUpButton=SelectScrollUpButton,exports.SelectTrigger=SelectTrigger,exports.SelectValue=SelectValue,exports.Separator=Separator$1,exports.Sheet=Sheet,exports.SheetClose=SheetClose,exports.SheetContent=SheetContent,exports.SheetDescription=SheetDescription,exports.SheetFooter=SheetFooter,exports.SheetHeader=SheetHeader,exports.SheetOverlay=SheetOverlay,exports.SheetPortal=SheetPortal,exports.SheetTitle=SheetTitle,exports.SheetTrigger=SheetTrigger,exports.Sidebar=Sidebar,exports.SidebarContent=SidebarContent,exports.SidebarFooter=SidebarFooter,exports.SidebarGroup=SidebarGroup,exports.SidebarGroupAction=SidebarGroupAction,exports.SidebarGroupContent=SidebarGroupContent,exports.SidebarGroupLabel=SidebarGroupLabel,exports.SidebarHeader=SidebarHeader,exports.SidebarInput=SidebarInput,exports.SidebarInset=SidebarInset,exports.SidebarMenu=SidebarMenu,exports.SidebarMenuAction=SidebarMenuAction,exports.SidebarMenuBadge=SidebarMenuBadge,exports.SidebarMenuButton=SidebarMenuButton,exports.SidebarMenuItem=SidebarMenuItem,exports.SidebarMenuSkeleton=SidebarMenuSkeleton,exports.SidebarMenuSub=SidebarMenuSub,exports.SidebarMenuSubButton=SidebarMenuSubButton,exports.SidebarMenuSubItem=SidebarMenuSubItem,exports.SidebarProvider=SidebarProvider,exports.SidebarRail=SidebarRail,exports.SidebarSeparator=SidebarSeparator,exports.SidebarTrigger=SidebarTrigger,exports.Skeleton=Skeleton,exports.Switch=Switch,exports.Table=Table,exports.TableBody=TableBody,exports.TableCaption=TableCaption,exports.TableCell=TableCell,exports.TableFooter=TableFooter,exports.TableHead=TableHead,exports.TableHeader=TableHeader,exports.TableRow=TableRow,exports.Tabs=Tabs,exports.TabsContent=TabsContent,exports.TabsList=TabsList,exports.TabsTrigger=TabsTrigger,exports.Textarea=Textarea,exports.Toast=Toast,exports.ToastAction=ToastAction,exports.ToastClose=ToastClose,exports.ToastDescription=ToastDescription,exports.ToastProvider=ToastProvider,exports.ToastTitle=ToastTitle,exports.ToastViewport=ToastViewport,exports.Toaster=Toaster,exports.Tooltip=Tooltip$1,exports.TooltipContent=TooltipContent,exports.TooltipProvider=TooltipProvider,exports.TooltipTrigger=TooltipTrigger,exports.Topbar=Topbar,exports.badgeVariants=badgeVariants,exports.buttonVariants=buttonVariants,exports.toast=toast,exports.useApiKey=useApiKey,exports.useChat=useChat,exports.useIsMobile=useIsMobile,exports.useSidebar=useSidebar,exports.useToast=useToast,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "randmarcomps",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.248.0",
|
|
5
5
|
"description": "The UI library enabling speed and consistency in Randmar frontends.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
"lucide-react": "^0.479.0",
|
|
107
107
|
"marked": "^15.0.8",
|
|
108
108
|
"md5": "^2.3.0",
|
|
109
|
-
"randmar-api-client": "^1.
|
|
109
|
+
"randmar-api-client": "^1.32.0",
|
|
110
110
|
"react-hook-form": "^7.56.2",
|
|
111
111
|
"react-intl": "^7.1.11",
|
|
112
112
|
"react-jsx-parser": "^2.4.0",
|