randmarcomps 1.291.0 → 1.294.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 +9 -0
- package/dist/randmarcomps.js +146 -5
- package/dist/randmarcomps.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/randmarcomps.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ import * as React_2 from 'react';
|
|
|
30
30
|
import { ReactNode } from 'react';
|
|
31
31
|
import { RefAttributes } from 'react';
|
|
32
32
|
import { Reseller } from 'randmar-api-client';
|
|
33
|
+
import { Return } from 'randmar-api-client';
|
|
33
34
|
import { SalesData } from 'randmar-api-client';
|
|
34
35
|
import { SalesStatistic } from 'randmar-api-client';
|
|
35
36
|
import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
|
|
@@ -641,6 +642,14 @@ declare interface ResellerQualificationsCardProps {
|
|
|
641
642
|
loading?: boolean;
|
|
642
643
|
}
|
|
643
644
|
|
|
645
|
+
export declare function ReturnsTable({ applicationId, returns, loading }: ReturnsTableProps): JSX.Element;
|
|
646
|
+
|
|
647
|
+
declare interface ReturnsTableProps {
|
|
648
|
+
applicationId: string;
|
|
649
|
+
returns?: Return[] | null;
|
|
650
|
+
loading?: boolean;
|
|
651
|
+
}
|
|
652
|
+
|
|
644
653
|
export declare function RichTextEditor({ id, name, value, onChange, placeholder, className, ...props }: RichTextEditorProps): JSX.Element | null;
|
|
645
654
|
|
|
646
655
|
export declare interface RichTextEditorProps extends Omit<default_2.InputHTMLAttributes<HTMLInputElement>, "onChange"> {
|
package/dist/randmarcomps.js
CHANGED
|
@@ -91519,6 +91519,138 @@ function ReceiptsTable({
|
|
|
91519
91519
|
/* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsx(DataTable, { columns: o, data: d, uniqueValues: l }) })
|
|
91520
91520
|
] });
|
|
91521
91521
|
}
|
|
91522
|
+
const formatDate$1 = (t) => {
|
|
91523
|
+
if (!t) return "N/A";
|
|
91524
|
+
try {
|
|
91525
|
+
const e = new Date(t);
|
|
91526
|
+
return isNaN(e.getTime()) ? "Invalid Date" : e.toLocaleDateString(void 0, {
|
|
91527
|
+
year: "numeric",
|
|
91528
|
+
month: "short",
|
|
91529
|
+
day: "numeric"
|
|
91530
|
+
});
|
|
91531
|
+
} catch {
|
|
91532
|
+
return "Invalid Date";
|
|
91533
|
+
}
|
|
91534
|
+
}, getStatusVariant = (t) => {
|
|
91535
|
+
const e = (t == null ? void 0 : t.toLowerCase()) || "";
|
|
91536
|
+
return e.includes("accepted") ? "success" : e.includes("error") || e.includes("rejected") ? "destructive" : "neutral";
|
|
91537
|
+
};
|
|
91538
|
+
function ReturnsTable({
|
|
91539
|
+
applicationId: t,
|
|
91540
|
+
returns: e = null,
|
|
91541
|
+
loading: n = !1
|
|
91542
|
+
}) {
|
|
91543
|
+
const o = useMemo(() => [
|
|
91544
|
+
{
|
|
91545
|
+
accessorKey: "ReturnNumber1",
|
|
91546
|
+
header: "RMA Number",
|
|
91547
|
+
cell: ({ row: f }) => {
|
|
91548
|
+
const g = f.original.ReturnNumber1 || f.original.ReturnNumber;
|
|
91549
|
+
return g ? /* @__PURE__ */ jsx(TooltipProvider, { delayDuration: 100, children: /* @__PURE__ */ jsxs(Tooltip$1, { children: [
|
|
91550
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(Link, { to: `/${t}/Return/${g}`, className: "font-medium text-blue-600 hover:underline dark:text-blue-400", children: g }) }),
|
|
91551
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsxs("p", { children: [
|
|
91552
|
+
"View details for return ",
|
|
91553
|
+
g
|
|
91554
|
+
] }) })
|
|
91555
|
+
] }) }) : "N/A";
|
|
91556
|
+
},
|
|
91557
|
+
enableSorting: !0,
|
|
91558
|
+
enableFiltering: !0
|
|
91559
|
+
},
|
|
91560
|
+
{
|
|
91561
|
+
accessorKey: "RequestDate",
|
|
91562
|
+
header: "Request Date",
|
|
91563
|
+
cell: ({ row: f }) => formatDate$1(f.original.RequestDate),
|
|
91564
|
+
enableSorting: !0
|
|
91565
|
+
},
|
|
91566
|
+
{
|
|
91567
|
+
accessorKey: "InvoiceNumber",
|
|
91568
|
+
header: "Invoice Number",
|
|
91569
|
+
cell: ({ row: f }) => {
|
|
91570
|
+
const g = f.original.InvoiceNumber;
|
|
91571
|
+
return g ? /* @__PURE__ */ jsx(TooltipProvider, { delayDuration: 100, children: /* @__PURE__ */ jsxs(Tooltip$1, { children: [
|
|
91572
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(Link, { to: `/${t}/Document/${g}`, className: "text-blue-600 hover:underline dark:text-blue-400", children: g }) }),
|
|
91573
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsxs("p", { children: [
|
|
91574
|
+
"View details for invoice ",
|
|
91575
|
+
g
|
|
91576
|
+
] }) })
|
|
91577
|
+
] }) }) : "N/A";
|
|
91578
|
+
},
|
|
91579
|
+
enableSorting: !0,
|
|
91580
|
+
enableFiltering: !0
|
|
91581
|
+
},
|
|
91582
|
+
{
|
|
91583
|
+
accessorKey: "Quantity",
|
|
91584
|
+
header: "Quantity",
|
|
91585
|
+
cell: ({ row: f }) => f.original.Quantity ?? "0",
|
|
91586
|
+
enableSorting: !0
|
|
91587
|
+
},
|
|
91588
|
+
{
|
|
91589
|
+
accessorKey: "ReasonForReturn",
|
|
91590
|
+
header: "Return Reason",
|
|
91591
|
+
cell: ({ row: f }) => /* @__PURE__ */ jsx("div", { className: "min-w-[150px]", children: f.original.ReasonForReturn ?? "—" }),
|
|
91592
|
+
enableSorting: !0,
|
|
91593
|
+
enableFiltering: !0
|
|
91594
|
+
},
|
|
91595
|
+
{
|
|
91596
|
+
accessorKey: "Status",
|
|
91597
|
+
header: "Status",
|
|
91598
|
+
cell: ({ row: f }) => {
|
|
91599
|
+
const g = f.original.Status, b = getStatusVariant(g);
|
|
91600
|
+
let S = "border-gray-400 bg-gray-100 text-gray-600 dark:border-gray-600 dark:bg-gray-800/50 dark:text-gray-400";
|
|
91601
|
+
return b === "success" ? S = "border-green-500 bg-green-100 text-green-700 dark:border-green-600 dark:bg-green-900/50 dark:text-green-400" : b === "destructive" && (S = "border-red-500 bg-red-100 text-red-700 dark:border-red-600 dark:bg-red-900/50 dark:text-red-400"), g ? /* @__PURE__ */ jsx(Badge, { variant: "outline", className: `${S} font-medium`, children: g }) : "—";
|
|
91602
|
+
},
|
|
91603
|
+
enableSorting: !0,
|
|
91604
|
+
enableFiltering: !0
|
|
91605
|
+
},
|
|
91606
|
+
{
|
|
91607
|
+
accessorKey: "WarehouseLocation",
|
|
91608
|
+
header: "Warehouse",
|
|
91609
|
+
cell: ({ row: f }) => f.original.WarehouseLocation ?? "—",
|
|
91610
|
+
enableSorting: !0,
|
|
91611
|
+
enableFiltering: !0
|
|
91612
|
+
},
|
|
91613
|
+
{
|
|
91614
|
+
accessorKey: "LastUpdatedDate",
|
|
91615
|
+
header: "Last Update",
|
|
91616
|
+
cell: ({ row: f }) => formatDate$1(f.original.LastUpdatedDate) !== "N/A" ? formatDate$1(f.original.LastUpdatedDate) : "—",
|
|
91617
|
+
enableSorting: !0
|
|
91618
|
+
}
|
|
91619
|
+
], [t]), l = useMemo(() => {
|
|
91620
|
+
const f = {};
|
|
91621
|
+
if (e) {
|
|
91622
|
+
const g = Array.from(new Set(e.map((_) => _.Status).filter(Boolean)));
|
|
91623
|
+
f.Status = g;
|
|
91624
|
+
const b = Array.from(new Set(e.map((_) => _.ReasonForReturn).filter(Boolean)));
|
|
91625
|
+
f.ReasonForReturn = b;
|
|
91626
|
+
const S = Array.from(new Set(e.map((_) => _.WarehouseLocation).filter(Boolean)));
|
|
91627
|
+
f.WarehouseLocation = S;
|
|
91628
|
+
}
|
|
91629
|
+
return f;
|
|
91630
|
+
}, [e]), d = useMemo(() => e ? [...e].sort((g, b) => (b.ReturnNumber1 || b.ReturnNumber || "").localeCompare(g.ReturnNumber1 || g.ReturnNumber || "")) : [], [e]);
|
|
91631
|
+
return n ? /* @__PURE__ */ jsxs(Card, { className: "w-full", children: [
|
|
91632
|
+
/* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-48" }) }),
|
|
91633
|
+
/* @__PURE__ */ jsxs(CardContent, { className: "space-y-4", children: [
|
|
91634
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-12 w-full rounded-md border" }),
|
|
91635
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-48 w-full rounded-md border" }),
|
|
91636
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between pt-4", children: [
|
|
91637
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-9 w-[130px]" }),
|
|
91638
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
|
|
91639
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-9 w-20" }),
|
|
91640
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-9 w-24" }),
|
|
91641
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-9 w-9" }),
|
|
91642
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-9 w-9" })
|
|
91643
|
+
] })
|
|
91644
|
+
] })
|
|
91645
|
+
] })
|
|
91646
|
+
] }) : !d || d.length === 0 ? /* @__PURE__ */ jsxs(Card, { className: "w-full", children: [
|
|
91647
|
+
/* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { className: "text-1xl font-bold", children: "Returns" }) }),
|
|
91648
|
+
/* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsx("div", { className: "flex justify-center items-center h-24", children: /* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: "There are no returns to display." }) }) })
|
|
91649
|
+
] }) : /* @__PURE__ */ jsxs(Card, { className: "w-full", children: [
|
|
91650
|
+
/* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { className: "text-1xl font-bold", children: "Returns" }) }),
|
|
91651
|
+
/* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsx(DataTable, { columns: o, data: d, uniqueValues: l }) })
|
|
91652
|
+
] });
|
|
91653
|
+
}
|
|
91522
91654
|
function ProductOverviewPage({
|
|
91523
91655
|
applicationId: t,
|
|
91524
91656
|
sku: e,
|
|
@@ -91529,7 +91661,7 @@ function ProductOverviewPage({
|
|
|
91529
91661
|
productShopifyHostname: d,
|
|
91530
91662
|
productCustomAction: f = /* @__PURE__ */ jsx(Fragment$1, {})
|
|
91531
91663
|
}) {
|
|
91532
|
-
var E, R, A, I, M, O, q;
|
|
91664
|
+
var E, R, A, I, M, O, q, z, Q;
|
|
91533
91665
|
const {
|
|
91534
91666
|
data: g,
|
|
91535
91667
|
isLoading: b
|
|
@@ -91646,7 +91778,7 @@ function ProductOverviewPage({
|
|
|
91646
91778
|
{
|
|
91647
91779
|
value: "orders",
|
|
91648
91780
|
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",
|
|
91649
|
-
disabled: !_ && (((A = S == null ? void 0 : S.ActiveOrderDetails) == null ? void 0 : A.length) ?? 0) <= 0 && (((I = S == null ? void 0 : S.CompletedOrderDetails) == null ? void 0 : I.length) ?? 0) <= 0,
|
|
91781
|
+
disabled: !_ && (((A = S == null ? void 0 : S.ActiveOrderDetails) == null ? void 0 : A.length) ?? 0) <= 0 && (((I = S == null ? void 0 : S.CompletedOrderDetails) == null ? void 0 : I.length) ?? 0) <= 0 && (((M = S == null ? void 0 : S.Returns) == null ? void 0 : M.length) ?? 0) <= 0,
|
|
91650
91782
|
children: "Orders"
|
|
91651
91783
|
}
|
|
91652
91784
|
),
|
|
@@ -91655,7 +91787,7 @@ function ProductOverviewPage({
|
|
|
91655
91787
|
{
|
|
91656
91788
|
value: "warehouse",
|
|
91657
91789
|
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",
|
|
91658
|
-
disabled: !_ && (((
|
|
91790
|
+
disabled: !_ && (((O = S == null ? void 0 : S.Receipts) == null ? void 0 : O.length) ?? 0) <= 0,
|
|
91659
91791
|
children: "Latest Warehouse Receiving"
|
|
91660
91792
|
}
|
|
91661
91793
|
)
|
|
@@ -91677,7 +91809,7 @@ function ProductOverviewPage({
|
|
|
91677
91809
|
}
|
|
91678
91810
|
) }) }),
|
|
91679
91811
|
/* @__PURE__ */ jsxs(TabsContent, { value: "orders", children: [
|
|
91680
|
-
|
|
91812
|
+
(_ || ((q = S == null ? void 0 : S.ActiveOrderDetails) == null ? void 0 : q.length) !== 0) && /* @__PURE__ */ jsx("div", { className: "mt-4", children: /* @__PURE__ */ jsx(
|
|
91681
91813
|
OrdersTable,
|
|
91682
91814
|
{
|
|
91683
91815
|
title: "Open Orders",
|
|
@@ -91685,13 +91817,21 @@ function ProductOverviewPage({
|
|
|
91685
91817
|
loading: _
|
|
91686
91818
|
}
|
|
91687
91819
|
) }),
|
|
91688
|
-
|
|
91820
|
+
(_ || ((z = S == null ? void 0 : S.CompletedOrderDetails) == null ? void 0 : z.length) !== 0) && /* @__PURE__ */ jsx("div", { className: "mt-4", children: /* @__PURE__ */ jsx(
|
|
91689
91821
|
OrdersTable,
|
|
91690
91822
|
{
|
|
91691
91823
|
title: "Completed Orders",
|
|
91692
91824
|
orders: S == null ? void 0 : S.CompletedOrderDetails,
|
|
91693
91825
|
loading: _
|
|
91694
91826
|
}
|
|
91827
|
+
) }),
|
|
91828
|
+
(_ || ((Q = S == null ? void 0 : S.CompletedOrderDetails) == null ? void 0 : Q.length) !== 0) && /* @__PURE__ */ jsx("div", { className: "mt-4", children: /* @__PURE__ */ jsx(
|
|
91829
|
+
ReturnsTable,
|
|
91830
|
+
{
|
|
91831
|
+
applicationId: t,
|
|
91832
|
+
returns: S == null ? void 0 : S.Returns,
|
|
91833
|
+
loading: _
|
|
91834
|
+
}
|
|
91695
91835
|
) })
|
|
91696
91836
|
] }),
|
|
91697
91837
|
/* @__PURE__ */ jsx(TabsContent, { value: "warehouse", children: /* @__PURE__ */ jsx("div", { className: "mt-4", children: /* @__PURE__ */ jsx(
|
|
@@ -92177,6 +92317,7 @@ export {
|
|
|
92177
92317
|
ResellerCard,
|
|
92178
92318
|
ResellerOverview,
|
|
92179
92319
|
ResellerQualificationsCard,
|
|
92320
|
+
ReturnsTable,
|
|
92180
92321
|
RichTextEditor,
|
|
92181
92322
|
SalesChart,
|
|
92182
92323
|
SalesOverviewCard,
|
|
@@ -1314,4 +1314,4 @@ img.ProseMirror-separator {
|
|
|
1314
1314
|
.ProseMirror p {
|
|
1315
1315
|
margin-bottom: 0.5em;
|
|
1316
1316
|
}
|
|
1317
|
-
`;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 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 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})=>f.original.UnitPrice?formatMoney(f.original.UnitPrice):"N/A",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,{})}){var C,E,A,I,M,j,q;const{data:g,isLoading:b}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:t,randmarSku:e,withSpecification:!1},{skip:!t||!e}),{data:_,isLoading:S}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:t,randmarSku:e,withSpecification:!0},{skip:!g}),R=(g==null?void 0:g.ManufacturerId)!==t;return console.log("readonly",R),jsxRuntime.jsxs("div",{className:"@container",children:[jsxRuntime.jsxs("div",{className:"grid gap-4 grid-cols-1 @sm:grid-cols-2 @md:grid-cols-3",children:[jsxRuntime.jsx("div",{className:"@md:col-span-2",children:jsxRuntime.jsx(ProductCard,{applicationId:t,product:_||g,defaultOpportunityNumber:n,onAddToCart:o,addingToCart:l,shopifyHostname:d,customAction:f})}),jsxRuntime.jsxs(Card,{className:"flex flex-col",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,{className:"basis-0 grow overflow-y-auto",children:b?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:(g==null?void 0:g.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:(g==null?void 0:g.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:(g==null?void 0:g.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:g!=null&&g.AutoUpdate?"Yes":"No"})]}),((g==null?void 0:g.VoiceoverCaption)||(g==null?void 0:g.BodyHTML))&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("hr",{className:"my-6"}),jsxRuntime.jsx("div",{className:"text-muted-foreground mb-2",children:"Description"}),(g==null?void 0:g.VoiceoverCaption)&&jsxRuntime.jsx("div",{children:g==null?void 0:g.VoiceoverCaption}),(g==null?void 0:g.BodyHTML)&&jsxRuntime.jsx("div",{className:"prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:(g==null?void 0:g.BodyHTML)??""}})]})]})})]})]}),jsxRuntime.jsx("div",{className:"my-4",children:b?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",disabled:!S&&(((C=_==null?void 0:_.SalesStatistics)==null?void 0:C.length)??0)<=0,children:"Statistics"}),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",disabled:!S&&(((E=_==null?void 0:_.Opportunities)==null?void 0:E.length)??0)<=0,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",disabled:!S&&(((A=_==null?void 0:_.ActiveOrderDetails)==null?void 0:A.length)??0)<=0&&(((I=_==null?void 0:_.CompletedOrderDetails)==null?void 0:I.length)??0)<=0,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",disabled:!S&&(((M=_==null?void 0:_.Receipts)==null?void 0:M.length)??0)<=0,children:"Latest Warehouse Receiving"})]}),jsxRuntime.jsx(TabsContent,{value:"stats",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(SalesChart,{salesData:(_==null?void 0:_.SalesStatistics)??[],isLoading:S,units:""})})}),jsxRuntime.jsx(TabsContent,{value:"opportunities",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(OpportunitiesTable,{applicationId:t,opportunities:g==null?void 0:g.Opportunities,loading:b})})}),jsxRuntime.jsxs(TabsContent,{value:"orders",children:[jsxRuntime.jsx("div",{className:"mt-4",children:(S||((j=_==null?void 0:_.ActiveOrderDetails)==null?void 0:j.length)!==0)&&jsxRuntime.jsx(OrdersTable,{title:"Open Orders",orders:_==null?void 0:_.ActiveOrderDetails,loading:S})}),jsxRuntime.jsx("div",{className:"mt-4",children:(S||((q=_==null?void 0:_.CompletedOrderDetails)==null?void 0:q.length)!==0)&&jsxRuntime.jsx(OrdersTable,{title:"Completed Orders",orders:_==null?void 0:_.CompletedOrderDetails,loading:S})})]}),jsxRuntime.jsx(TabsContent,{value:"warehouse",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ReceiptsTable,{receipts:_==null?void 0:_.Receipts,loading:S})})})]})})]})}function AssistantChat(t){return jsxRuntime.jsx(Card,{className:"max-w-6xl",children:jsxRuntime.jsx(ChatLayout,{className:"h-[40em]",userId:t.userId,userName:t.userName,assistantOnly:!0,initialPrompt:t.initialPrompt})})}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 OpportunitiesTable({applicationId:t,opportunities:e=null,loading:n=!1}){var te;const{toast:o}=useToast(),[l,d]=React.useState({}),[f,g]=React.useState(!1),[b,_]=React.useState(""),[S,R]=React.useState(null),{data:C}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:t},{skip:!t}),E=React.useCallback((ne,se,ge)=>{d(oe=>({...oe,[ne]:{...oe[ne],[se]:ge}}))},[]),[A]=usePutV4ResellerByRouteResellerIdOpportunityAndManufacturerIdDefaultMutation(),I=React.useCallback(async ne=>{if(!(C!=null&&C.IsReseller))return;if(!ne.BidNumber){o({title:"Error",description:"Bid Number is missing, cannot set default.",variant:"destructive"});return}const se=ne.BidNumber;E(se,"isSettingDefault",!0),A({routeResellerId:t,manufacturerId:ne.ManufacturerId??"",opportunityNumber:se}).unwrap().then(()=>{o({title:"Success",description:`Opportunity "${ne.OpportunityName||ne.Opportunity||se}" was successfully set as default.`,variant:"success"})}).catch(ge=>{var oe;console.error("Set as default error:",ge),o({title:"Error",description:((oe=ge.data)==null?void 0:oe.message)||ge.message||"An error occurred while setting this opportunity as default.",variant:"destructive"})}).finally(()=>{E(se,"isSettingDefault",!1)})},[t,A,o,E]),[M]=usePostV4ResellerByRouteResellerIdOpportunityAndManufacturerIdBidNumberEmailMutation(),j=React.useCallback(ne=>{if(C!=null&&C.IsReseller){if(!ne.BidNumber){o({title:"Error",description:"Bid Number is missing, cannot prepare report.",variant:"destructive"});return}R(ne),_(""),g(!0)}},[o]),q=React.useCallback(async()=>{if(!(C!=null&&C.IsReseller))return;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 ne=S.BidNumber;E(ne,"isSendingReport",!0),M({routeResellerId:t,manufacturerId:S.ManufacturerId??"",bidNumber:ne,emailAddress:b}).unwrap().then(()=>{o({title:"Success",description:`A report for "${S.OpportunityName||S.Opportunity||ne}" was successfully sent to ${b}.`,variant:"success"}),g(!1)}).catch(se=>{var ge;console.error("Send report by email error:",se),o({title:"Error",description:((ge=se.data)==null?void 0:ge.message)||se.message||"An error occurred while sending the report by email.",variant:"destructive"})}).finally(()=>{E(ne,"isSendingReport",!1),f||(R(null),_(""))})},[S,b,t,M,o,E,g]),z=React.useMemo(()=>[{accessorKey:"ManufacturerId",header:"Manuf.",cell:({row:ne})=>jsxRuntime.jsx("div",{className:"w-20 h-8",children:jsxRuntime.jsx(PartnerLogo,{id:ne.original.ManufacturerId,width:80,height:32})}),enableSorting:!0,enableFiltering:!0},{id:"opportunityDisplay",accessorFn:ne=>ne.OpportunityName||ne.Opportunity,header:"Opportunity",cell:({getValue:ne})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:ne()??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"BidNumber",header:"Bid Number",cell:({row:ne})=>ne.original.BidNumber??"N/A",enableSorting:!0,enableFiltering:!0},{id:"statusInfo",header:"Status",cell:({row:ne})=>{const se=ne.original,ge=se.Active===!0,oe=getEndDateStatus(se.EndDate);let Ae="border-gray-400 bg-gray-100 text-gray-600 dark:border-gray-600 dark:bg-gray-800/50 dark:text-gray-400";return oe.variant==="destructive"?Ae="border-red-500 bg-red-100 text-red-700 dark:border-red-600 dark:bg-red-900/50 dark:text-red-400":oe.variant==="warning"&&(Ae="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:ge?"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:ge?"Active":"Inactive"}),se.EndDate&&jsxRuntime.jsx(Badge,{variant:"outline",className:`${Ae} font-medium`,children:oe.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(se.StartDate)]}),jsxRuntime.jsxs("p",{children:[jsxRuntime.jsx("strong",{children:"End:"})," ",formatDate(se.EndDate)]}),jsxRuntime.jsxs("p",{children:[jsxRuntime.jsx("strong",{children:"Updated:"})," ",formatDate(se.LastUpdate)]})]})})]})})]})},enableFiltering:!1},{id:"actions",header:"Actions",cell:({row:ne})=>{var Oe,Fe;const se=ne.original;if(!se.BidNumber)return jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"Actions unavailable"});const ge=se.BidNumber,oe=(Oe=l[ge])==null?void 0:Oe.isSettingDefault,Ae=(S==null?void 0:S.BidNumber)===ge&&((Fe=l[ge])==null?void 0:Fe.isSendingReport),je=oe||Ae,Ne=se.CanBeSetAsDefault===!0;return jsxRuntime.jsxs("div",{className:"flex space-x-2",children:[jsxRuntime.jsx("a",{href:`/${t}/Opportunity/${se.ManufacturerId}/${se.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"]})}),(C==null?void 0:C.IsReseller)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Button,{variant:"outline",size:"sm",onClick:()=>I(se),disabled:je||!Ne,title:Ne?"Set as default":"This opportunity cannot be set as default",className:"flex items-center",children:[oe?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:()=>j(se),disabled:je,title:"Send report by email",className:"flex items-center",children:[Ae?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,I,j,S]),Q=React.useMemo(()=>{const ne={};if(e){const se=Array.from(new Set(e.map(oe=>oe.ManufacturerId).filter(oe=>oe!=null)));ne.ManufacturerId=se;const ge=Array.from(new Set(e.map(oe=>oe.OpportunityName||oe.Opportunity).filter(oe=>oe!=null)));ne.opportunityDisplay=ge}return ne},[e]),F=e||[],V=S!=null&&S.BidNumber?(te=l[S.BidNumber])==null?void 0:te.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:z,data:F,uniqueValues:Q})})]}),jsxRuntime.jsx(Dialog,{open:f,onOpenChange:ne=>{g(ne),ne||(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:ne=>_(ne.target.value),placeholder:"recipient@example.com",className:"col-span-3",disabled:V})]})}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button,{variant:"outline",onClick:()=>g(!1),disabled:V,children:"Cancel"}),jsxRuntime.jsxs(Button,{type:"submit",onClick:q,disabled:V,children:[V&&jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"})," Send Report"]})]})]})})]})}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(!1),S=!d;return React.useEffect(()=>{if(d){g([]);return}const R=new Date,C=R.getFullYear(),E=R.getMonth(),A=R.getDate(),I=`${C}-${(E+1).toString().padStart(2,"0")}`,M=[];for(let Q=11;Q>=0;Q--){const F=new Date(C,E-Q,1),V=F.getFullYear(),te=(F.getMonth()+1).toString().padStart(2,"0");M.push(`${V}-${te}`)}const j={};M.forEach(Q=>{j[Q]=0}),t&&t.length>0&&t.forEach(Q=>{const F=Q.Day??0,V=Math.floor(F).toString();if(V.length!==8||isNaN(Number.parseInt(V))){console.warn(`Skipping invalid Day format: ${Q.Day}`);return}const te=V.substring(0,4),ne=V.substring(4,6),se=`${te}-${ne}`;M.includes(se)&&(j[se]=(j[se]||0)+(Q.ExtendedPrice??0))});const q={...j};if(b&&j[I]>0){const Q=q[I],F=new Date(C,E+1,0).getDate();if(A<F&&A>0){const te=Q/A*F;q[I]=te}}const z=M.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"})]})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Sales"})}),jsxRuntime.jsx(CardContent,{children:f.length>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{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."})]})]}):jsxRuntime.jsx("div",{style:{height:e},className:l||"p-4 text-center text-muted-foreground flex items-center justify-center",children:"No sales data available."})})]})}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.AreaChart=AreaChart,exports.AssistantChat=AssistantChat,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.GeminiApiKeyProvider=GeminiApiKeyProvider,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.OpportunitiesTable=OpportunitiesTable,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.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.useChat=useChat,exports.useGeminiApiKey=useGeminiApiKey,exports.useIsMobile=useIsMobile,exports.useSidebar=useSidebar,exports.useToast=useToast,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})});
|
|
1317
|
+
`;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 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 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})=>f.original.UnitPrice?formatMoney(f.original.UnitPrice):"N/A",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})})]})}const formatDate$1=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"}},getStatusVariant=t=>{const e=(t==null?void 0:t.toLowerCase())||"";return e.includes("accepted")?"success":e.includes("error")||e.includes("rejected")?"destructive":"neutral"};function ReturnsTable({applicationId:t,returns:e=null,loading:n=!1}){const o=React.useMemo(()=>[{accessorKey:"ReturnNumber1",header:"RMA Number",cell:({row:f})=>{const g=f.original.ReturnNumber1||f.original.ReturnNumber;return g?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${t}/Return/${g}`,className:"font-medium text-blue-600 hover:underline dark:text-blue-400",children:g})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for return ",g]})})]})}):"N/A"},enableSorting:!0,enableFiltering:!0},{accessorKey:"RequestDate",header:"Request Date",cell:({row:f})=>formatDate$1(f.original.RequestDate),enableSorting:!0},{accessorKey:"InvoiceNumber",header:"Invoice Number",cell:({row:f})=>{const g=f.original.InvoiceNumber;return g?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${t}/Document/${g}`,className:"text-blue-600 hover:underline dark:text-blue-400",children:g})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for invoice ",g]})})]})}):"N/A"},enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:f})=>f.original.Quantity??"0",enableSorting:!0},{accessorKey:"ReasonForReturn",header:"Return Reason",cell:({row:f})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:f.original.ReasonForReturn??"—"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"Status",header:"Status",cell:({row:f})=>{const g=f.original.Status,b=getStatusVariant(g);let _="border-gray-400 bg-gray-100 text-gray-600 dark:border-gray-600 dark:bg-gray-800/50 dark:text-gray-400";return b==="success"?_="border-green-500 bg-green-100 text-green-700 dark:border-green-600 dark:bg-green-900/50 dark:text-green-400":b==="destructive"&&(_="border-red-500 bg-red-100 text-red-700 dark:border-red-600 dark:bg-red-900/50 dark:text-red-400"),g?jsxRuntime.jsx(Badge,{variant:"outline",className:`${_} font-medium`,children:g}):"—"},enableSorting:!0,enableFiltering:!0},{accessorKey:"WarehouseLocation",header:"Warehouse",cell:({row:f})=>f.original.WarehouseLocation??"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"LastUpdatedDate",header:"Last Update",cell:({row:f})=>formatDate$1(f.original.LastUpdatedDate)!=="N/A"?formatDate$1(f.original.LastUpdatedDate):"—",enableSorting:!0}],[t]),l=React.useMemo(()=>{const f={};if(e){const g=Array.from(new Set(e.map(S=>S.Status).filter(Boolean)));f.Status=g;const b=Array.from(new Set(e.map(S=>S.ReasonForReturn).filter(Boolean)));f.ReasonForReturn=b;const _=Array.from(new Set(e.map(S=>S.WarehouseLocation).filter(Boolean)));f.WarehouseLocation=_}return f},[e]),d=React.useMemo(()=>e?[...e].sort((g,b)=>(b.ReturnNumber1||b.ReturnNumber||"").localeCompare(g.ReturnNumber1||g.ReturnNumber||"")):[],[e]);return n?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(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"})]})]})]})]}):!d||d.length===0?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Returns"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"flex justify-center items-center h-24",children:jsxRuntime.jsx("p",{className:"text-muted-foreground",children:"There are no returns to display."})})})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Returns"})}),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,{})}){var C,E,A,I,M,j,q,z,Q;const{data:g,isLoading:b}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:t,randmarSku:e,withSpecification:!1},{skip:!t||!e}),{data:_,isLoading:S}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:t,randmarSku:e,withSpecification:!0},{skip:!g}),R=(g==null?void 0:g.ManufacturerId)!==t;return console.log("readonly",R),jsxRuntime.jsxs("div",{className:"@container",children:[jsxRuntime.jsxs("div",{className:"grid gap-4 grid-cols-1 @sm:grid-cols-2 @md:grid-cols-3",children:[jsxRuntime.jsx("div",{className:"@md:col-span-2",children:jsxRuntime.jsx(ProductCard,{applicationId:t,product:_||g,defaultOpportunityNumber:n,onAddToCart:o,addingToCart:l,shopifyHostname:d,customAction:f})}),jsxRuntime.jsxs(Card,{className:"flex flex-col",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,{className:"basis-0 grow overflow-y-auto",children:b?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:(g==null?void 0:g.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:(g==null?void 0:g.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:(g==null?void 0:g.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:g!=null&&g.AutoUpdate?"Yes":"No"})]}),((g==null?void 0:g.VoiceoverCaption)||(g==null?void 0:g.BodyHTML))&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("hr",{className:"my-6"}),jsxRuntime.jsx("div",{className:"text-muted-foreground mb-2",children:"Description"}),(g==null?void 0:g.VoiceoverCaption)&&jsxRuntime.jsx("div",{children:g==null?void 0:g.VoiceoverCaption}),(g==null?void 0:g.BodyHTML)&&jsxRuntime.jsx("div",{className:"prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:(g==null?void 0:g.BodyHTML)??""}})]})]})})]})]}),jsxRuntime.jsx("div",{className:"my-4",children:b?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",disabled:!S&&(((C=_==null?void 0:_.SalesStatistics)==null?void 0:C.length)??0)<=0,children:"Statistics"}),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",disabled:!S&&(((E=_==null?void 0:_.Opportunities)==null?void 0:E.length)??0)<=0,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",disabled:!S&&(((A=_==null?void 0:_.ActiveOrderDetails)==null?void 0:A.length)??0)<=0&&(((I=_==null?void 0:_.CompletedOrderDetails)==null?void 0:I.length)??0)<=0&&(((M=_==null?void 0:_.Returns)==null?void 0:M.length)??0)<=0,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",disabled:!S&&(((j=_==null?void 0:_.Receipts)==null?void 0:j.length)??0)<=0,children:"Latest Warehouse Receiving"})]}),jsxRuntime.jsx(TabsContent,{value:"stats",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(SalesChart,{salesData:(_==null?void 0:_.SalesStatistics)??[],isLoading:S,units:""})})}),jsxRuntime.jsx(TabsContent,{value:"opportunities",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(OpportunitiesTable,{applicationId:t,opportunities:g==null?void 0:g.Opportunities,loading:b})})}),jsxRuntime.jsxs(TabsContent,{value:"orders",children:[(S||((q=_==null?void 0:_.ActiveOrderDetails)==null?void 0:q.length)!==0)&&jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(OrdersTable,{title:"Open Orders",orders:_==null?void 0:_.ActiveOrderDetails,loading:S})}),(S||((z=_==null?void 0:_.CompletedOrderDetails)==null?void 0:z.length)!==0)&&jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(OrdersTable,{title:"Completed Orders",orders:_==null?void 0:_.CompletedOrderDetails,loading:S})}),(S||((Q=_==null?void 0:_.CompletedOrderDetails)==null?void 0:Q.length)!==0)&&jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ReturnsTable,{applicationId:t,returns:_==null?void 0:_.Returns,loading:S})})]}),jsxRuntime.jsx(TabsContent,{value:"warehouse",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ReceiptsTable,{receipts:_==null?void 0:_.Receipts,loading:S})})})]})})]})}function AssistantChat(t){return jsxRuntime.jsx(Card,{className:"max-w-6xl",children:jsxRuntime.jsx(ChatLayout,{className:"h-[40em]",userId:t.userId,userName:t.userName,assistantOnly:!0,initialPrompt:t.initialPrompt})})}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 OpportunitiesTable({applicationId:t,opportunities:e=null,loading:n=!1}){var te;const{toast:o}=useToast(),[l,d]=React.useState({}),[f,g]=React.useState(!1),[b,_]=React.useState(""),[S,R]=React.useState(null),{data:C}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:t},{skip:!t}),E=React.useCallback((ne,se,ge)=>{d(oe=>({...oe,[ne]:{...oe[ne],[se]:ge}}))},[]),[A]=usePutV4ResellerByRouteResellerIdOpportunityAndManufacturerIdDefaultMutation(),I=React.useCallback(async ne=>{if(!(C!=null&&C.IsReseller))return;if(!ne.BidNumber){o({title:"Error",description:"Bid Number is missing, cannot set default.",variant:"destructive"});return}const se=ne.BidNumber;E(se,"isSettingDefault",!0),A({routeResellerId:t,manufacturerId:ne.ManufacturerId??"",opportunityNumber:se}).unwrap().then(()=>{o({title:"Success",description:`Opportunity "${ne.OpportunityName||ne.Opportunity||se}" was successfully set as default.`,variant:"success"})}).catch(ge=>{var oe;console.error("Set as default error:",ge),o({title:"Error",description:((oe=ge.data)==null?void 0:oe.message)||ge.message||"An error occurred while setting this opportunity as default.",variant:"destructive"})}).finally(()=>{E(se,"isSettingDefault",!1)})},[t,A,o,E]),[M]=usePostV4ResellerByRouteResellerIdOpportunityAndManufacturerIdBidNumberEmailMutation(),j=React.useCallback(ne=>{if(C!=null&&C.IsReseller){if(!ne.BidNumber){o({title:"Error",description:"Bid Number is missing, cannot prepare report.",variant:"destructive"});return}R(ne),_(""),g(!0)}},[o]),q=React.useCallback(async()=>{if(!(C!=null&&C.IsReseller))return;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 ne=S.BidNumber;E(ne,"isSendingReport",!0),M({routeResellerId:t,manufacturerId:S.ManufacturerId??"",bidNumber:ne,emailAddress:b}).unwrap().then(()=>{o({title:"Success",description:`A report for "${S.OpportunityName||S.Opportunity||ne}" was successfully sent to ${b}.`,variant:"success"}),g(!1)}).catch(se=>{var ge;console.error("Send report by email error:",se),o({title:"Error",description:((ge=se.data)==null?void 0:ge.message)||se.message||"An error occurred while sending the report by email.",variant:"destructive"})}).finally(()=>{E(ne,"isSendingReport",!1),f||(R(null),_(""))})},[S,b,t,M,o,E,g]),z=React.useMemo(()=>[{accessorKey:"ManufacturerId",header:"Manuf.",cell:({row:ne})=>jsxRuntime.jsx("div",{className:"w-20 h-8",children:jsxRuntime.jsx(PartnerLogo,{id:ne.original.ManufacturerId,width:80,height:32})}),enableSorting:!0,enableFiltering:!0},{id:"opportunityDisplay",accessorFn:ne=>ne.OpportunityName||ne.Opportunity,header:"Opportunity",cell:({getValue:ne})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:ne()??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"BidNumber",header:"Bid Number",cell:({row:ne})=>ne.original.BidNumber??"N/A",enableSorting:!0,enableFiltering:!0},{id:"statusInfo",header:"Status",cell:({row:ne})=>{const se=ne.original,ge=se.Active===!0,oe=getEndDateStatus(se.EndDate);let Ae="border-gray-400 bg-gray-100 text-gray-600 dark:border-gray-600 dark:bg-gray-800/50 dark:text-gray-400";return oe.variant==="destructive"?Ae="border-red-500 bg-red-100 text-red-700 dark:border-red-600 dark:bg-red-900/50 dark:text-red-400":oe.variant==="warning"&&(Ae="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:ge?"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:ge?"Active":"Inactive"}),se.EndDate&&jsxRuntime.jsx(Badge,{variant:"outline",className:`${Ae} font-medium`,children:oe.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(se.StartDate)]}),jsxRuntime.jsxs("p",{children:[jsxRuntime.jsx("strong",{children:"End:"})," ",formatDate(se.EndDate)]}),jsxRuntime.jsxs("p",{children:[jsxRuntime.jsx("strong",{children:"Updated:"})," ",formatDate(se.LastUpdate)]})]})})]})})]})},enableFiltering:!1},{id:"actions",header:"Actions",cell:({row:ne})=>{var Oe,Fe;const se=ne.original;if(!se.BidNumber)return jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"Actions unavailable"});const ge=se.BidNumber,oe=(Oe=l[ge])==null?void 0:Oe.isSettingDefault,Ae=(S==null?void 0:S.BidNumber)===ge&&((Fe=l[ge])==null?void 0:Fe.isSendingReport),je=oe||Ae,Ne=se.CanBeSetAsDefault===!0;return jsxRuntime.jsxs("div",{className:"flex space-x-2",children:[jsxRuntime.jsx("a",{href:`/${t}/Opportunity/${se.ManufacturerId}/${se.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"]})}),(C==null?void 0:C.IsReseller)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Button,{variant:"outline",size:"sm",onClick:()=>I(se),disabled:je||!Ne,title:Ne?"Set as default":"This opportunity cannot be set as default",className:"flex items-center",children:[oe?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:()=>j(se),disabled:je,title:"Send report by email",className:"flex items-center",children:[Ae?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,I,j,S]),Q=React.useMemo(()=>{const ne={};if(e){const se=Array.from(new Set(e.map(oe=>oe.ManufacturerId).filter(oe=>oe!=null)));ne.ManufacturerId=se;const ge=Array.from(new Set(e.map(oe=>oe.OpportunityName||oe.Opportunity).filter(oe=>oe!=null)));ne.opportunityDisplay=ge}return ne},[e]),F=e||[],V=S!=null&&S.BidNumber?(te=l[S.BidNumber])==null?void 0:te.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:z,data:F,uniqueValues:Q})})]}),jsxRuntime.jsx(Dialog,{open:f,onOpenChange:ne=>{g(ne),ne||(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:ne=>_(ne.target.value),placeholder:"recipient@example.com",className:"col-span-3",disabled:V})]})}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button,{variant:"outline",onClick:()=>g(!1),disabled:V,children:"Cancel"}),jsxRuntime.jsxs(Button,{type:"submit",onClick:q,disabled:V,children:[V&&jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"})," Send Report"]})]})]})})]})}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(!1),S=!d;return React.useEffect(()=>{if(d){g([]);return}const R=new Date,C=R.getFullYear(),E=R.getMonth(),A=R.getDate(),I=`${C}-${(E+1).toString().padStart(2,"0")}`,M=[];for(let Q=11;Q>=0;Q--){const F=new Date(C,E-Q,1),V=F.getFullYear(),te=(F.getMonth()+1).toString().padStart(2,"0");M.push(`${V}-${te}`)}const j={};M.forEach(Q=>{j[Q]=0}),t&&t.length>0&&t.forEach(Q=>{const F=Q.Day??0,V=Math.floor(F).toString();if(V.length!==8||isNaN(Number.parseInt(V))){console.warn(`Skipping invalid Day format: ${Q.Day}`);return}const te=V.substring(0,4),ne=V.substring(4,6),se=`${te}-${ne}`;M.includes(se)&&(j[se]=(j[se]||0)+(Q.ExtendedPrice??0))});const q={...j};if(b&&j[I]>0){const Q=q[I],F=new Date(C,E+1,0).getDate();if(A<F&&A>0){const te=Q/A*F;q[I]=te}}const z=M.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"})]})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Sales"})}),jsxRuntime.jsx(CardContent,{children:f.length>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{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."})]})]}):jsxRuntime.jsx("div",{style:{height:e},className:l||"p-4 text-center text-muted-foreground flex items-center justify-center",children:"No sales data available."})})]})}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.AreaChart=AreaChart,exports.AssistantChat=AssistantChat,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.GeminiApiKeyProvider=GeminiApiKeyProvider,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.OpportunitiesTable=OpportunitiesTable,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.ResellerOverview=ResellerOverview,exports.ResellerQualificationsCard=ResellerQualificationsCard,exports.ReturnsTable=ReturnsTable,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.useChat=useChat,exports.useGeminiApiKey=useGeminiApiKey,exports.useIsMobile=useIsMobile,exports.useSidebar=useSidebar,exports.useToast=useToast,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})});
|