randmarcomps 1.242.0 → 1.243.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.js +30 -30
- package/dist/randmarcomps.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/randmarcomps.js
CHANGED
|
@@ -67881,44 +67881,44 @@ function ManufacturerProducts({
|
|
|
67881
67881
|
manufacturer: e,
|
|
67882
67882
|
shopifyHostName: n
|
|
67883
67883
|
}) {
|
|
67884
|
-
var
|
|
67885
|
-
const [o] =
|
|
67886
|
-
data:
|
|
67887
|
-
isLoading:
|
|
67888
|
-
isFetching:
|
|
67884
|
+
var M, O, q, z;
|
|
67885
|
+
const [o] = usePostV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeShopifyMutation(), [l, d] = useState(((O = (M = e.Categories) == null ? void 0 : M[0]) == null ? void 0 : O.CategoryCode) || ""), [f, g] = useState(!1), [b, S] = useState(!1), { toast: _ } = useToast(), {
|
|
67886
|
+
data: C,
|
|
67887
|
+
isLoading: E,
|
|
67888
|
+
isFetching: R
|
|
67889
67889
|
} = useGetV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeQuery(
|
|
67890
67890
|
{
|
|
67891
67891
|
routeResellerId: t,
|
|
67892
67892
|
manufacturerId: e.ManufacturerId,
|
|
67893
|
-
categoryCode:
|
|
67893
|
+
categoryCode: l ?? ""
|
|
67894
67894
|
},
|
|
67895
67895
|
{
|
|
67896
|
-
skip: !e.ManufacturerId || !
|
|
67896
|
+
skip: !e.ManufacturerId || !l
|
|
67897
67897
|
}
|
|
67898
|
-
),
|
|
67898
|
+
), A = async () => {
|
|
67899
67899
|
try {
|
|
67900
|
-
|
|
67900
|
+
g(!0), S(!1), await o({
|
|
67901
67901
|
routeResellerId: t,
|
|
67902
67902
|
manufacturerId: e.ManufacturerId ?? "",
|
|
67903
|
-
categoryCode:
|
|
67903
|
+
categoryCode: l,
|
|
67904
67904
|
shopifyHostName: n
|
|
67905
|
-
}).unwrap() &&
|
|
67905
|
+
}).unwrap() && _({
|
|
67906
67906
|
title: "Success",
|
|
67907
67907
|
description: "Category synced to Shopify successfully",
|
|
67908
67908
|
variant: "success"
|
|
67909
67909
|
});
|
|
67910
|
-
} catch (
|
|
67911
|
-
console.error("Error syncing to Shopify:",
|
|
67910
|
+
} catch (Q) {
|
|
67911
|
+
console.error("Error syncing to Shopify:", Q), _({
|
|
67912
67912
|
title: "Error",
|
|
67913
67913
|
description: "Error syncing category to Shopify.",
|
|
67914
67914
|
variant: "destructive"
|
|
67915
67915
|
});
|
|
67916
67916
|
} finally {
|
|
67917
|
-
|
|
67917
|
+
g(!1);
|
|
67918
67918
|
}
|
|
67919
|
-
},
|
|
67920
|
-
var
|
|
67921
|
-
return ((
|
|
67919
|
+
}, I = () => {
|
|
67920
|
+
var Q, F;
|
|
67921
|
+
return ((F = (Q = e.Categories) == null ? void 0 : Q.find((j) => j.CategoryCode === l)) == null ? void 0 : F.CategoryName) || l;
|
|
67922
67922
|
};
|
|
67923
67923
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
67924
67924
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
@@ -67926,12 +67926,12 @@ function ManufacturerProducts({
|
|
|
67926
67926
|
ManufacturerCategories,
|
|
67927
67927
|
{
|
|
67928
67928
|
categories: e.Categories || [],
|
|
67929
|
-
activeCategory:
|
|
67930
|
-
onSelectCategory:
|
|
67929
|
+
activeCategory: l,
|
|
67930
|
+
onSelectCategory: d
|
|
67931
67931
|
}
|
|
67932
67932
|
),
|
|
67933
|
-
n && ((
|
|
67934
|
-
/* @__PURE__ */ jsx(DialogTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(Button, { className: "bg-green-600 hover:bg-green-700 mb-4", disabled:
|
|
67933
|
+
n && ((q = e.Categories) == null ? void 0 : q.findIndex((Q) => Q.AvailableToBuy)) !== -1 && /* @__PURE__ */ jsxs(Dialog, { open: b, onOpenChange: S, children: [
|
|
67934
|
+
/* @__PURE__ */ jsx(DialogTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(Button, { className: "bg-green-600 hover:bg-green-700 mb-4", disabled: f, children: f ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
67935
67935
|
/* @__PURE__ */ jsx(LoaderCircle, { className: "mr-2 h-4 w-4 animate-spin" }),
|
|
67936
67936
|
"Syncing..."
|
|
67937
67937
|
] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
@@ -67943,19 +67943,19 @@ function ManufacturerProducts({
|
|
|
67943
67943
|
/* @__PURE__ */ jsx(DialogTitle, { children: "Confirm Sync to Shopify" }),
|
|
67944
67944
|
/* @__PURE__ */ jsxs(DialogDescription, { children: [
|
|
67945
67945
|
'Are you sure you want to sync the category "',
|
|
67946
|
-
|
|
67946
|
+
I(),
|
|
67947
67947
|
'" to Shopify? This will add all products in this category to your Shopify store.'
|
|
67948
67948
|
] })
|
|
67949
67949
|
] }),
|
|
67950
67950
|
/* @__PURE__ */ jsxs(DialogFooter, { children: [
|
|
67951
|
-
/* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () =>
|
|
67951
|
+
/* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => S(!1), children: "Cancel" }),
|
|
67952
67952
|
/* @__PURE__ */ jsx(
|
|
67953
67953
|
Button,
|
|
67954
67954
|
{
|
|
67955
67955
|
className: "bg-green-600 hover:bg-green-700",
|
|
67956
|
-
onClick:
|
|
67957
|
-
disabled:
|
|
67958
|
-
children:
|
|
67956
|
+
onClick: A,
|
|
67957
|
+
disabled: f,
|
|
67958
|
+
children: f ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
67959
67959
|
/* @__PURE__ */ jsx(LoaderCircle, { className: "mr-2 h-4 w-4 animate-spin" }),
|
|
67960
67960
|
"Syncing..."
|
|
67961
67961
|
] }) : "Confirm Sync"
|
|
@@ -67965,15 +67965,15 @@ function ManufacturerProducts({
|
|
|
67965
67965
|
] })
|
|
67966
67966
|
] })
|
|
67967
67967
|
] }),
|
|
67968
|
-
/* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-2 gap-4 mb-4", children:
|
|
67968
|
+
/* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-2 gap-4 mb-4", children: E || R ? Array.from({ length: 4 }).map((Q, F) => /* @__PURE__ */ jsx(ProductCard, {}, F)) : C != null && C.Products && (C == null ? void 0 : C.Products.length) > 0 ? (z = C == null ? void 0 : C.Products) == null ? void 0 : z.map((Q) => /* @__PURE__ */ jsx(
|
|
67969
67969
|
ProductCard,
|
|
67970
67970
|
{
|
|
67971
67971
|
applicationId: t,
|
|
67972
|
-
product:
|
|
67973
|
-
viewProductLink: `/${t}/Product/${
|
|
67972
|
+
product: Q,
|
|
67973
|
+
viewProductLink: `/${t}/Product/${Q.RandmarSKU}`,
|
|
67974
67974
|
shopifyHostname: n
|
|
67975
67975
|
},
|
|
67976
|
-
|
|
67976
|
+
Q.RandmarSKU
|
|
67977
67977
|
)) : /* @__PURE__ */ jsxs(Alert, { variant: "warning", children: [
|
|
67978
67978
|
/* @__PURE__ */ jsx(CircleAlert, { className: "h-4 w-4" }),
|
|
67979
67979
|
/* @__PURE__ */ jsx(AlertTitle, { children: "Warning" }),
|
|
@@ -1082,7 +1082,7 @@ $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 z,Q,F,V;const[o]=usePostV4ResellerByRouteResellerIdProductAndRandmarSkuShopifyMutation(),[l]=usePostV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeShopifyMutation(),[d,f]=React.useState(((Q=(z=e.Categories)==null?void 0:z[0])==null?void 0:Q.CategoryCode)||""),[g,b]=React.useState(null),[_,S]=React.useState(!1),[R,C]=React.useState(!1),{toast:E}=useToast(),{data:A,isLoading:I,isFetching:M}=useGetV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeQuery({routeResellerId:t,manufacturerId:e.ManufacturerId,categoryCode:d??""},{skip:!e.ManufacturerId||!d}),j=async()=>{try{S(!0),C(!1),await l({routeResellerId:t,manufacturerId:e.ManufacturerId??"",categoryCode:d,shopifyHostName:n}).unwrap()&&E({title:"Success",description:"Category synced to Shopify successfully",variant:"success"})}catch(te){console.error("Error syncing to Shopify:",te),E({title:"Error",description:"Error syncing category to Shopify.",variant:"destructive"})}finally{S(!1)}},q=()=>{var te,ae;return((ae=(te=e.Categories)==null?void 0:te.find(se=>se.CategoryCode===d))==null?void 0:ae.CategoryName)||d};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(ManufacturerCategories,{categories:e.Categories||[],activeCategory:d,onSelectCategory:f}),n&&((F=e.Categories)==null?void 0:F.findIndex(te=>te.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 mb-4",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 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 "',q(),'" to Shopify? This will add all products in this category 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:j,disabled:_,children:_?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:I||M?Array.from({length:4}).map((te,ae)=>jsxRuntime.jsx(ProductCard,{},ae)):A!=null&&A.Products&&(A==null?void 0:A.Products.length)>0?(V=A==null?void 0:A.Products)==null?void 0:V.map(te=>jsxRuntime.jsx(ProductCard,{applicationId:t,product:te,viewProductLink:`/${t}/Product/${te.RandmarSKU}`,shopifyHostname:n},te.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}=useGetV4PartnerByApplicationIdPartnerAndPartnerIdQuery({applicationId: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}=useGetV4PartnerByApplicationIdPartnerAndPartnerIdQuery({applicationId: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:
|
|
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.
|