randmarcomps 1.396.0 → 1.397.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.
@@ -67346,7 +67346,7 @@ function ProductInventoryButton({
67346
67346
  routeResellerId: t ?? "",
67347
67347
  randmarSku: e ?? ""
67348
67348
  }).then((Ne) => {
67349
- Ne.error || Ne.data === !1 ? f({ title: "Warning", description: "Product is already in the process of being ordered with the manufacturer. You can reach out to Randmar's team to confirm.", variant: "warnng" }) : f({ title: "Success", description: "Qualification successfully submitted.", variant: "success" }), _(!1);
67349
+ Ne.error || Ne.data === !1 ? f({ title: "Warning", description: "Reorder is pending or requires manual approval. Contact the Randmar team for details.", variant: "warning" }) : f({ title: "Success", description: "Qualification successfully submitted.", variant: "success" }), _(!1);
67350
67350
  }).catch((Ne) => {
67351
67351
  console.error(Ne), f({ title: "Error", description: "Error submitting your qualification.", variant: "destructive" });
67352
67352
  }).finally(() => {
@@ -1184,7 +1184,7 @@ Defaulting to \`null\`.`}var Root$2=Progress$1,Indicator=ProgressIndicator;const
1184
1184
  \`\`\`
1185
1185
  `,[d,f]);return jsxRuntime.jsxs("div",{className:"@container",children:[jsxRuntime.jsxs("div",{className:"grid gap-4 @2xl:grid-cols-2",children:[jsxRuntime.jsx(PartnerCard,{account:f,loading:g||b,withAbout:!0,withVoice:!1,action:" "}),jsxRuntime.jsxs("div",{className:"grid gap-4",children:[((f==null?void 0:f.Manufacturer)||g||b)&&jsxRuntime.jsx(ManufacturerCard,{manufacturer:f==null?void 0:f.Manufacturer,loading:g||b,mainAction:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[(f==null?void 0:f.Manufacturer)&&jsxRuntime.jsx(ManufacturerGetStartedButton,{applicationId:t,manufacturer:f==null?void 0:f.Manufacturer}),o&&((z=(q=f==null?void 0:f.Manufacturer)==null?void 0:q.Categories)==null?void 0:z.findIndex(V=>V.AvailableToBuy))!==-1&&jsxRuntime.jsxs(Dialog,{open:E,onOpenChange:A,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{className:"bg-green-600 hover:bg-green-700 ml-2",disabled:R,children:R?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 "',(Q=f==null?void 0:f.Manufacturer)==null?void 0:Q.PublicName,'" to Shopify? This will add all products from this manufacturer to your Shopify store.']})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>A(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{className:"bg-green-600 hover:bg-green-700",onClick:I,disabled:R,children:R?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):"Confirm Sync"})]})]})]})]})}),(f==null?void 0:f.Reseller)&&jsxRuntime.jsx(ResellerCard,{reseller:f==null?void 0:f.Reseller,loading:g||b})]})]}),((f==null?void 0:f.Reseller)||(f==null?void 0:f.Manufacturer))&&!g&&!b&&jsxRuntime.jsx("div",{className:"max-w-6xl mx-auto p-4",children:jsxRuntime.jsxs(Tabs,{defaultValue:M(),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:[(f==null?void 0:f.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"}),(f==null?void 0:f.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"}),(f==null?void 0:f.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"}),jsxRuntime.jsxs(TabsTrigger,{value:"assistant",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:[jsxRuntime.jsx(Bot,{className:"mr-2 w-4 h-4"}),"Assistant"]})]}),(f==null?void 0:f.Reseller)&&jsxRuntime.jsx(TabsContent,{value:"reseller-overview",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ResellerOverview,{readonly:!0,appID:f.ApplicationId||"",reseller:f==null?void 0:f.Reseller,userEmail:n,isSuperAdmin:l,withoutReports:!0})})}),(f==null?void 0:f.Manufacturer)&&jsxRuntime.jsx(TabsContent,{value:"manufacturer-overview",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ManufacturerOverviewPage,{readonly:!0,manufacturer:f==null?void 0:f.Manufacturer,applicationId:t,userEmail:n})})}),(f==null?void 0:f.Manufacturer)&&jsxRuntime.jsx(TabsContent,{value:"products",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ManufacturerProducts,{applicationId:t,manufacturer:f.Manufacturer,shopifyHostName:o})})}),jsxRuntime.jsx(TabsContent,{value:"assistant",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(AssistantInsight,{prompt:j,thinkingPlaceholderText:"Thinking about the relationship..."})})})]})}),(g||b)&&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"})})]})}const PublicInfo=({reseller:t,appID:e,isLoading:n,readonly:o,onUnsavedChanges:l})=>{const{toast:d}=useToast(),[f]=usePostV4PartnerByApplicationIdAccountResellerAndFieldNameMutation(),[g,b]=React.useState({}),S=React.useMemo(()=>({publicEmail:t.PublicEmail??"",contactName:t.ContactName??"",phone:t.Phone??"",website:t.Website??""}),[t]),{register:_,handleSubmit:R,reset:C,watch:E,formState:{errors:A,isSubmitting:I}}=useForm({defaultValues:S}),M=E(),j=React.useCallback(()=>g?JSON.stringify(M)!==JSON.stringify(g):!1,[M,g]);React.useEffect(()=>{l&&l(j())},[j,l]),React.useEffect(()=>{t&&Object.keys(t).length>0&&(C(S),b(S))},[t,C,S]);const q=async Q=>{let V=!0,O=!1;const te=Object.keys(Q).map(ne=>({key:ne,keyApi:ne.charAt(0).toUpperCase()+ne.slice(1)}));for(const ne of te){const ae=Q[ne.key],Ve=t[ne.keyApi];if(ae!==Ve&&ae!==void 0){O=!0;try{await f({applicationId:e,fieldName:ne.keyApi,newValue:String(ae)}).unwrap()||(V=!1)}catch(Ne){console.error(`Error updating ${ne.keyApi}:`,Ne),V=!1}}}V&&O?(d({title:"Public info",description:"Information updated successfully",variant:"success"}),b({...Q}),l&&l(!1)):V||d({title:"Updation error",description:"Failed to update",variant:"destructive"})},z=Q=>!Q||Q.trim()==="";return n?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Public Information"})}),jsxRuntime.jsx(CardContent,{children: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-32"}),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-20"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-28"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-20"})})]})})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsxs(CardTitle,{className:"text-1xl font-bold",children:["Public Information ",o?"(read only)":""]})}),jsxRuntime.jsxs(CardContent,{children:[(z(E("contactName"))||z(E("publicEmail"))||z(E("website"))||z(E("phone")))&&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 Manufacturers."})]}),jsxRuntime.jsxs("form",{onSubmit:R(q),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",{className:"text-sm font-medium leading-none",htmlFor:"contactName",children:"Main Representative *"}),jsxRuntime.jsx(Input,{id:"contactName",placeholder:"John Doe",readOnly:o,..._("contactName",{}),className:A.contactName||z(E("contactName"))?"input-error-indicator":""}),A.contactName&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:A.contactName.message})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium leading-none",htmlFor:"publicEmail",children:"Public Email *"}),jsxRuntime.jsx(Input,{id:"publicEmail",placeholder:"contact@company.com",readOnly:o,..._("publicEmail",{pattern:{value:/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,message:"Invalid email address"}}),className:A.publicEmail||z(E("publicEmail"))?"input-error-indicator":""}),A.publicEmail&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:A.publicEmail.message})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium leading-none",htmlFor:"website",children:"Website *"}),jsxRuntime.jsx(Input,{id:"website",placeholder:"https://company.com",readOnly:o,..._("website",{pattern:{value:/^.{7,}$/,message:"Must be at least 7 characters"}}),className:A.website||z(E("website"))?"input-error-indicator":""}),A.website&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:A.website.message})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium leading-none",htmlFor:"phone",children:"Phone Number *"}),jsxRuntime.jsx(Input,{id:"phone",placeholder:"+1 (555) 123-4567",readOnly:o,..._("phone",{pattern:{value:/^.{7,}$/,message:"Must be at least 7 characters"}}),className:A.phone||z(E("phone"))?"input-error-indicator":""}),A.phone&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:A.phone.message})]}),jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx(Button$1,{type:"submit",disabled:I||o,className:o?"hidden":"",children:I?"Saving...":"Save"})})]})]})]})};function BillingCard({appID:t,reseller:e,isLoading:n,withoutReports:o,userEmail:l,isSuperAdmin:d}){const{toast:f}=useToast(),{Statement:g,CreditLimit:b}=e,[S,_]=React.useState(!1),[R,C]=React.useState(!1),[E,A]=React.useState(!1),[I,M]=React.useState(!1),[j,q]=React.useState(l||""),[z,Q]=React.useState(!1),[V,O]=React.useState((b==null?void 0:b.toString())||""),[te,{isLoading:ne}]=usePostV4PartnerByApplicationIdAccountResellerCreditLimitMutation(),ae=[{label:"0 - 30 Days",value:jsxRuntime.jsx(FormattedNumber,{value:(g==null?void 0:g.Over0)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:Calendar$1},{label:"31 - 45 Days",value:jsxRuntime.jsx(FormattedNumber,{value:(g==null?void 0:g.Over30)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:CalendarDays},{label:"45+ Days",value:jsxRuntime.jsx(FormattedNumber,{value:(g==null?void 0:g.Over45)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:CalendarRange},{label:"Total",value:jsxRuntime.jsx(FormattedNumber,{value:(g==null?void 0:g.Total)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:DollarSign},{label:"Credit Limit",value:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(FormattedNumber,{value:b||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),d&&jsxRuntime.jsx(Button$1,{size:"icon",variant:"outline",className:"ml-2",onClick:()=>{Q(!0),O((b==null?void 0:b.toString())||"")},children:jsxRuntime.jsx(SquarePen,{})})]}),icon:CreditCard}],[Ve]=useLazyGetV4ResellerByRouteResellerIdDocumentAndDocumentNumberPdfQuery(),Ne=async je=>{je?_(!0):C(!0);try{const Fe=(await Ve({routeResellerId:t,documentNumber:`ST${t}`})).data;if(!Fe)throw new Error("No data received for download.");if(je)window.open(Fe);else{const $e=document.createElement("a");$e.href=Fe,$e.download=`ST${t}.pdf`,document.body.appendChild($e),$e.click(),$e.remove()}f({title:"Success",description:"Statement downloaded successfully.",variant:"success"})}catch(Le){console.error("Download Error:",Le),f({title:"Error",description:"An error occurred while downloading the statement. Please try again.",variant:"destructive"})}finally{je?_(!1):C(!1)}},[se]=usePostV4ResellerByRouteResellerIdDocumentStatementEmailMutation(),Ae=async()=>{if(!j||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(j)){f({title:"Invalid Email",description:"Please enter a valid email address.",variant:"destructive"});return}A(!0);try{await se({routeResellerId:t,emailAddress:j}).unwrap(),f({title:"Success",description:`Statement sent to ${j} successfully.`,variant:"success"}),M(!1)}catch(Le){console.error("Send Email Error:",Le),f({title:"Error",description:"An error occurred while sending the statement. Please try again.",variant:"destructive"})}finally{A(!1)}};if(n)return jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{className:"border-b p-6 md:p-5",children:jsxRuntime.jsx(Skeleton,{className:"h-6 w-36"})}),jsxRuntime.jsxs(CardContent,{className:"p-6 md:p-5",children:[jsxRuntime.jsxs("div",{className:"grid sm:grid-cols-2 sm:divide-x divide-border",children:[jsxRuntime.jsx("div",{className:"space-y-6 sm:pe-4",children:[1,2,3].map(je=>jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap gap-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-24"})]}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 ms-auto"})]},je))}),jsxRuntime.jsx("div",{className:"space-y-6 sm:ps-4 pt-6 sm:pt-0 mt-6 sm:mt-0 border-t sm:border-t-0 border-border",children:[1,2].map(je=>jsxRuntime.jsx("div",{className:je===2?"pt-6 mt-6 border-t border-border":"",children:jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap gap-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-24"})]}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 ms-auto"})]})},je))})]}),jsxRuntime.jsxs("div",{className:"flex justify-end mt-6 gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-28"})]})]})]});const ge=!o;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{className:"border-b p-6 md:p-5",children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Billing Overview"})}),jsxRuntime.jsxs(CardContent,{className:"p-6 md:p-5",children:[jsxRuntime.jsxs("div",{className:"grid sm:grid-cols-2 sm:divide-x divide-border",children:[jsxRuntime.jsx("div",{className:"space-y-6 sm:pe-4",children:ae.slice(0,3).map((je,Le)=>jsxRuntime.jsx(BillingItem,{icon:je.icon,label:je.label,value:je.value},Le))}),jsxRuntime.jsx("div",{className:"space-y-6 sm:ps-4 pt-6 sm:pt-0 mt-6 sm:mt-0 border-t sm:border-t-0 border-border",children:ae.slice(3).map((je,Le)=>jsxRuntime.jsx("div",{className:Le===1?"pt-6 mt-6 border-t border-border":"",children:jsxRuntime.jsx(BillingItem,{icon:je.icon,label:je.label,value:je.value})},Le))})]}),ge&&jsxRuntime.jsxs("div",{className:"flex justify-end mt-6 gap-2",children:[jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"outline",size:"icon",onClick:()=>Ne(!0),disabled:S,children:S?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}):jsxRuntime.jsx(Printer,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Print Statement"})})]})}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"outline",size:"icon",onClick:()=>Ne(!1),disabled:R,children:R?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}):jsxRuntime.jsx(Download,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Download Statement"})})]})}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"outline",size:"icon",onClick:()=>M(!0),disabled:E,children:E?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}):jsxRuntime.jsx(Mail,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Email Statement"})})]})}),jsxRuntime.jsx(reactRouterDom.Link,{to:`${window.location.hostname==="dashboard.randmar.io"?"":"https://dashboard.randmar.io"}/${t}/PayInvoice`,target:window.location.hostname==="dashboard.randmar.io"?"_self":"_blank",children:jsxRuntime.jsxs(Button$1,{children:[jsxRuntime.jsx(CreditCard,{className:"mr-2 h-4 w-4"}),"Pay Invoices"]})})]})]})]}),jsxRuntime.jsx(Dialog,{open:I,onOpenChange:M,children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[425px]",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Send Statement by Email"}),jsxRuntime.jsx(DialogDescription,{children:"Enter the recipient's email address below. The statement will be sent as a PDF attachment."})]}),jsxRuntime.jsx("div",{className:"grid gap-4 py-4",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"email",className:"text-right",children:"Email"}),jsxRuntime.jsx(Input,{id:"email",type:"email",value:j,onChange:je=>q(je.target.value),className:"col-span-3",placeholder:"recipient@example.com"})]})}),jsxRuntime.jsx(DialogFooter,{children:jsxRuntime.jsx(Button$1,{type:"submit",onClick:Ae,disabled:E||!j,children:E?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Send,{className:"mr-2 h-4 w-4"}),"Send"]})})})]})}),jsxRuntime.jsx(Dialog,{open:z,onOpenChange:Q,children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[425px]",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Edit Credit Limit"}),jsxRuntime.jsx(DialogDescription,{children:"Enter the new credit limit for this reseller."})]}),jsxRuntime.jsx("div",{className:"grid gap-4 py-4",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"creditLimit",className:"text-right",children:"Amount"}),jsxRuntime.jsx(Input,{id:"creditLimit",type:"number",value:V,onChange:je=>O(je.target.value),className:"col-span-3",placeholder:"0.00"})]})}),jsxRuntime.jsx(DialogFooter,{children:jsxRuntime.jsx(Button$1,{type:"submit",onClick:async()=>{const je=Number(V);if(isNaN(je)){f({title:"Invalid Amount",description:"Please enter a valid number for credit limit.",variant:"destructive"});return}try{await te({applicationId:t,newValue:je}).unwrap(),Q(!1),f({title:"Success",description:"Credit limit updated successfully.",variant:"success"})}catch(Le){console.error("Update Credit Limit Error:",Le),f({title:"Error",description:"Failed to update credit limit. Please try again.",variant:"destructive"})}},disabled:ne,children:ne?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save"})})]})})]})}function BillingItem({icon:t,label:e,value:n}){return jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap gap-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(t,{className:"size-4 text-muted-foreground"}),jsxRuntime.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:e})]}),jsxRuntime.jsx("span",{className:"text-base font-semibold ms-auto",children:n})]})}function ChangePricingTierModal({open:t,setOpen:e,tier:n,onTierChange:o,isLoading:l}){const d=()=>{e(!1)};return jsxRuntime.jsx(Dialog,{open:t,onOpenChange:e,children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[425px]",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsx(DialogTitle,{children:"Change Pricing Tier"})}),jsxRuntime.jsxs("div",{className:"grid gap-1.5 py-2",children:[jsxRuntime.jsxs("p",{className:"text-lg text-muted-foreground",children:["Requested Pricing Tier: ",jsxRuntime.jsx("span",{className:"font-bold",children:n})]}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"If your account qualifies, your pricing will update immediately."}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"If not, we'll review your request and notify you of the decision."})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:d,disabled:l,children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:o,disabled:l,children:l?"Loading...":`Apply for ${n}`})]})]})})}const getPricingText=t=>t===1?"The Best":t===2?"Fixed 12.5% GP on all items":t===3?"Advantageous":t===4?"Buying Group":t===5?"Cost":t,getShippingText=t=>t==="A"?"Free or Custom":t==="B"?"Fixed $10 anywhere":t==="C"?`Free shipping on $150+ orders to your location,
1186
1186
  $15 for drop shipped orders under $1,500,
1187
- $10 with opportunities under $1,000`:t==="D"?"$15 under $1,500":t==="E"?"Full shipping charges":t,getTermsText=t=>t==="STRIPE"?"Credit card payment":t==="NET30"?"Net 30 days":t,AccountTier=({isSuperAdmin:t,readonly:e,reseller:n,appID:o,isLoading:l})=>{const{toast:d}=useToast(),[f,g]=React.useState(!1),[b,S]=React.useState(""),[_,{isLoading:R}]=usePostV4PartnerByApplicationIdAccountResellerAndFieldNameMutation(),C=je=>je&&{Starter:"starter","E-Commerce":"ecommerce",Commercial:"commercial",Basics:"cws",Novexco:"novexco","Jean Coutu":"jeancoutu",Exclusive:"exclusive"}[je]||"",E=je=>je&&{A:"free",B:"fixed",C:"dropshipped",D:"under1500",E:"fullcharges"}[je]||"",A=je=>je&&{1:"exclusive",2:"ecommerce",3:"commercial",4:"buyinggroup",5:"cost"}[je]||"",[I,M]=React.useState(C((n==null?void 0:n.Priority)??"")),[j,q]=React.useState(E((n==null?void 0:n.ShippingProfile)??"")),[z,Q]=React.useState(A(n==null?void 0:n.PriceProfile)),V=je=>({starter:"Starter",ecommerce:"E-Commerce",commercial:"Commercial",cws:"Basics",novexco:"Novexco",jeancoutu:"Jean Coutu",exclusive:"Exclusive"})[je]||je,O=je=>({free:"A",fixed:"B",dropshipped:"C",under1500:"D",fullcharges:"E"})[je]||je,te=je=>({exclusive:"1",ecommerce:"2",commercial:"3",buyinggroup:"4",cost:"5"})[je]||je;React.useEffect(()=>{M(C((n==null?void 0:n.Priority)??"")),q(E((n==null?void 0:n.ShippingProfile)??"")),Q(A(n==null?void 0:n.PriceProfile))},[n]);const ne=async(je,Le,Fe,$e)=>{try{(await _({applicationId:o,fieldName:je,newValue:Le})).error?d({title:"Error",description:$e,variant:"destructive"}):d({title:"Success",description:Fe,variant:"success"})}catch{d({title:"Error",description:"An unexpected error occurred",variant:"destructive"})}},ae=async je=>{M(je);const Le=V(je);ne("Priority",Le,`Priority updated to ${Le}`,"Failed to update priority")},Ve=async je=>{q(je);const Le=O(je);ne("ShippingProfile",Le,`Shipping profile updated to ${Le}`,"Failed to update shipping profile")},Ne=async je=>{Q(je);const Le=te(je);ne("PriceProfile",Le,`Pricing profile updated to ${Le}`,"Failed to update pricing profile")},se=async()=>{try{const je=await _({applicationId:o,fieldName:"Tier",newValue:b});je.error?d({title:"Error",description:"Failed to update reseller",variant:"destructive"}):je.data?d({title:"Success",description:`Pricing Tier changed to ${b}`,variant:"success"}):d({title:"Considered",description:"Request being considered",variant:"success"})}catch{d({title:"Error",description:"An unexpected error occurred",variant:"destructive"})}finally{g(!1),S("")}},Ae=[{name:"Terms",enabled:n.Priority==="Starter"},{name:"E-Commerce",enabled:n.Priority==="Commercial"},{name:"Commercial",enabled:n.Priority==="E-Commerce"},{name:"Exclusive",enabled:t}],ge=je=>{S(je),g(!0)};return l?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{className:"pb-2",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-28"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-16 rounded-full"})]})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsxs("div",{className:"mb-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-40 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-56"})]}),jsxRuntime.jsx("div",{className:"grid gap-3",children:[1,2,3].map(je=>jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-8 rounded-full shrink-0"}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full"})]})]},je))}),jsxRuntime.jsxs("div",{className:"flex gap-2 mt-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{className:"pb-2 pt-4 px-4 flex flex-row items-center justify-between",children:[jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Account Tier"}),jsxRuntime.jsx(Badge,{variant:"secondary",className:"bg-green-100 text-green-700 hover:bg-green-200 text-xs",children:"Active"})]}),jsxRuntime.jsxs(CardContent,{className:"pt-2 px-4 pb-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-3 bg-primary/5 p-4 rounded-lg",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("h3",{className:"text-lg font-bold text-primary",children:[(n==null?void 0:n.Priority)||""," Tier"]}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Optimized for online retail"})]}),jsxRuntime.jsx(CircleCheck,{className:"h-6 w-6 text-green-600"})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 gap-2 mb-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Package2,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Pricing"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground truncate",children:getPricingText(n.PriceProfile||0)})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Truck,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Shipping"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:getShippingText(n.ShippingProfile||"").split(".")[0]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Calendar$1,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Payment terms"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:getTermsText((n==null?void 0:n.Terms)||"")})]})]})]}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[!e&&jsxRuntime.jsx(Button$1,{variant:"outline",className:"flex-1",asChild:!0,children:jsxRuntime.jsxs(reactRouterDom.Link,{to:"https://www.randmar.io/docs/overview/pricingTiers",target:"_blank",children:[jsxRuntime.jsx(ExternalLink,{className:"h-4 w-4 mr-1"}),"Pricing Tiers"]})}),jsxRuntime.jsxs(Popover,{children:[jsxRuntime.jsx(PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{disabled:e,className:e?"hidden":"flex-1",children:["Upgrade Tier ",jsxRuntime.jsx(ChevronRight,{className:"h-3 w-3 ml-1"})]})}),jsxRuntime.jsx(PopoverContent,{className:"w-56 p-2",children:jsxRuntime.jsxs("div",{className:"grid gap-1",children:[jsxRuntime.jsx("h4",{className:"font-medium text-xs mb-1",children:"Select a tier"}),Ae.map(je=>jsxRuntime.jsx(Button$1,{variant:"ghost",size:"sm",className:"w-full justify-start h-8",disabled:!je.enabled,onClick:()=>ge(je.name),children:je.name},je.name))]})})]})]})]})]}),jsxRuntime.jsx(ChangePricingTierModal,{isLoading:R,open:f,setOpen:g,tier:b,onTierChange:se}),t&&!e&&jsxRuntime.jsxs(Card,{className:"mt-4",children:[jsxRuntime.jsx(CardHeader,{className:"pb-2 pt-3 px-4",children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Admin Configuration"})}),jsxRuntime.jsx(CardContent,{className:"pt-2 px-4 pb-4",children:jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsxs("div",{className:"bg-muted/30 p-2 rounded-lg",children:[jsxRuntime.jsx(Label$2,{className:"block mb-1 text-xs font-medium",children:"Priority"}),jsxRuntime.jsx(RadioGroup$1,{value:I,onValueChange:ae,className:"grid grid-cols-2 @sm:grid-cols-3 @md:grid-cols-4 gap-1",children:[{value:"starter",label:"Starter"},{value:"ecommerce",label:"E-Commerce"},{value:"commercial",label:"Commercial"},{value:"cws",label:"CWS (Basics)"},{value:"novexco",label:"Novexco"},{value:"jeancoutu",label:"Jean Coutu"},{value:"exclusive",label:"Exclusive"}].map(je=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:je.value,id:`priority-${je.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`priority-${je.value}`,className:"cursor-pointer text-xs",children:je.label})]},je.value))})]}),jsxRuntime.jsxs("div",{className:"bg-muted/30 p-2 rounded-lg",children:[jsxRuntime.jsx(Label$2,{className:"block mb-1 text-xs font-medium",children:"Shipping Profile"}),jsxRuntime.jsx(RadioGroup$1,{value:j,onValueChange:Ve,className:"grid grid-cols-1 @md:grid-cols-2 gap-1",children:[{value:"free",label:"Free (A)"},{value:"fixed",label:"Fixed $10 Shipping (B)"},{value:"dropshipped",label:"$15 for drop shipped (C)"},{value:"under1500",label:"15$ under 1,500 (D)"},{value:"fullcharges",label:"Full shipping charges (E)"}].map(je=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:je.value,id:`shipping-${je.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`shipping-${je.value}`,className:"cursor-pointer text-xs",children:je.label})]},je.value))})]}),jsxRuntime.jsxs("div",{className:"bg-muted/30 p-2 rounded-lg",children:[jsxRuntime.jsx(Label$2,{className:"block mb-1 text-xs font-medium",children:"Pricing Profile"}),jsxRuntime.jsx(RadioGroup$1,{value:z,onValueChange:Ne,className:"grid grid-cols-2 @sm:grid-cols-3 gap-1",children:[{value:"exclusive",label:"Exclusive (1)"},{value:"ecommerce",label:"E-Commerce (2)"},{value:"commercial",label:"Commercial (3)"},{value:"buyinggroup",label:"Buying Group (4)"},{value:"cost",label:"Cost (5)"}].map(je=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:je.value,id:`pricing-${je.value}`,className:"h-6 w-6 scale-50 antialiased"}),jsxRuntime.jsx(Label$2,{htmlFor:`pricing-${je.value}`,className:"cursor-pointer text-xs",children:je.label})]},je.value))})]})]})})]})]})};function OrderCategories({openOrders:t=[],isLoading:e=!1}){const n=(t==null?void 0:t.filter(I=>I.DocumentType==="Order"))||[],o=(t==null?void 0:t.filter(I=>I.DocumentType==="Shipment"))||[],l=n.filter(I=>I.WarehouseCode!=="3PLE"),d=l.reduce((I,M)=>I+(M.Quantity??0),0),f=l.reduce((I,M)=>I+(M.ExtendedPrice??0),0),g=n.filter(I=>I.WarehouseCode==="3PLE"),b=g.reduce((I,M)=>I+(M.Quantity??0),0),S=g.reduce((I,M)=>I+(M.ExtendedPrice??0),0),_=o.reduce((I,M)=>I+(M.Quantity??0),0),R=o.reduce((I,M)=>I+(M.ExtendedPrice??0),0),C=d+b+_,E=f+S+R,A=[{name:"All",icon:Package,color:"bg-blue-500",orders:C,amount:E},{name:"Processing",icon:RefreshCcw,color:"bg-yellow-500",orders:d,amount:f},{name:"Shipped",icon:Truck,color:"bg-green-500",orders:_,amount:R},{name:"Delayed",icon:CircleAlert,color:"bg-red-500",orders:b,amount:S}];return e?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(Skeleton,{className:"h-7 w-40"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-3.5",children:[1,2,3,4].map(I=>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:"bg-gray-200 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(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-8 w-8 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-12"})]}),jsxRuntime.jsxs("div",{className:"text-end",children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]})]})]})]})},I))})})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Order Categories"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-3.5",children:A.map(I=>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:`${I.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:I.name}),jsxRuntime.jsx("div",{className:`${I.color} bg-opacity-90 p-2 rounded-full`,children:jsxRuntime.jsx(I.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:I.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:I.amount,style:"currency",currency:"CAD",currencyDisplay:"symbol"})})]})]})]})]})},I.name))})})]})}function ReportsSection({isLoading:t,userEmail:e,appID:n}){const{toast:o}=useToast(),[l,{isLoading:d}]=usePostV4ResellerByRouteResellerIdReportWalmartTrackingFileEmailMutation(),[f,{isLoading:g}]=usePostV4ResellerByRouteResellerIdReportAmazonTrackingFileEmailMutation(),[b,{isLoading:S}]=usePostV4ResellerByRouteResellerIdReportOpenOrdersEmailMutation(),[_,{isLoading:R}]=usePostV4ResellerByRouteResellerIdReportProductsEmailMutation(),[C,{isLoading:E}]=usePostV4ResellerByRouteResellerIdReportInvoicesEmailMutation(),[A,{isLoading:I}]=usePostV4ResellerByRouteResellerIdDocumentStatementEmailMutation(),[M,j]=React.useState(null),[q,z]=React.useState(e),[Q,V]=React.useState(!1),[O,te]=React.useState("all"),{data:ne,isLoading:ae}=useGetV4PartnerByRouteApplicationIdManufacturersQuery({routeApplicationId:n,withSpecification:!1}),Ve=[{name:"Products",reports:[{id:"Products",title:"Universal Product List",description:"A comprehensive overview of your product list with detailed specifications and pricing information.",icon:Package}]},{name:"Operation Details",reports:[{id:"OpenOrders",title:"Order Details",description:"A detailed report of all your orders and shipments, including status, tracking information, and delivery estimates.",icon:ShoppingCart},{id:"Invoices",title:"Invoices and Credits Report",description:"Detailed overview of your invoices and credits within a specific date range. It also contains reports about additional charges, serial numbers, and other relevant information.",icon:ScrollText},{id:"Statement",title:"Statement and RMAs Report",description:"A detailed report of all unpaid invoices and active RMAs.",icon:Banknote}]},{name:"Tracking Files",reports:[{id:"AmazonTrackingFile",title:"Amazon Tracking File",description:"Track products sold on Amazon marketplace with detailed sales and inventory information.",icon:ChartNoAxesColumnIncreasing},{id:"WalmartTrackingFile",title:"Walmart Tracking File",description:"Track products sold on Walmart marketplace with detailed sales and inventory information.",icon:ChartNoAxesColumnIncreasing}]}],Ne=async ge=>{j(ge),ge.id==="Products"&&te("all"),V(!0)},se=async()=>{if(!(!M||!n))try{switch(M.id){case"Products":{const ge={routeResellerId:n,emailAddress:q};O&&O!=="all"&&(ge.manufacturerId=O),await _(ge).unwrap();break}case"AmazonTrackingFile":await f({routeResellerId:n,emailAddress:q}).unwrap();break;case"WalmartTrackingFile":await l({routeResellerId:n,emailAddress:q}).unwrap();break;case"OpenOrders":await b({routeResellerId:n,emailAddress:q}).unwrap();break;case"Invoices":await C({routeResellerId:n,emailAddress:q}).unwrap();break;case"Statement":await A({routeResellerId:n,emailAddress:q}).unwrap();break;default:throw new Error("invalid report id")}o({title:"Report requested",description:`The ${M.title} will be sent to ${q} shortly.`,variant:"success"}),V(!1)}catch(ge){console.error("Error requesting report:",ge),o({title:"Error",description:"Failed to request report. Please try again.",variant:"destructive"})}},Ae=S||R||g||d||I||E;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 Product List to your Order Details."})]}),jsxRuntime.jsx(CardContent,{className:"space-y-6",children:t?jsxRuntime.jsx(jsxRuntime.Fragment,{children:[1,2,3].map(ge=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-48"}),[1,2].map(je=>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"})]},je))]},ge))}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:Ve.map(ge=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx("h3",{className:"text-sm font-semibold",children:ge.name}),ge.reports.map(je=>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(je.icon,{className:"h-5 w-5 text-primary"})}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx("h4",{className:"font-semibold text-sm",children:je.title}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:je.description})]}),jsxRuntime.jsxs(Button$1,{variant:"outline",size:"sm",className:"flex items-center gap-1",onClick:()=>Ne(je),children:[jsxRuntime.jsx(Download,{className:"h-4 w-4"}),"Request"]})]},je.id))]},ge.name))})}),jsxRuntime.jsx(Dialog,{open:Q,onOpenChange:V,children:jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsxs(DialogTitle,{children:["Request ",M==null?void 0:M.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:q,onChange:ge=>z(ge.target.value),placeholder:"your@email.com",className:"mt-2"})]}),(M==null?void 0:M.id)==="Products"&&jsxRuntime.jsxs("div",{className:"py-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"manufacturer",children:"Manufacturer"}),jsxRuntime.jsxs("select",{id:"manufacturer",className:"mt-2 block w-full rounded-md border border-input bg-background px-3 py-2 text-sm",value:O,onChange:ge=>te(ge.target.value),disabled:ae,children:[jsxRuntime.jsx("option",{value:"all",children:"All manufacturers"}),!ae&&Array.isArray(ne)&&ne.slice().sort((ge,je)=>(ge.PublicName||ge.Name||"").localeCompare(je.PublicName||je.Name||"")).map(ge=>ge!=null&&ge.ManufacturerId?jsxRuntime.jsx("option",{value:ge.ManufacturerId,children:(ge.PublicName||ge.Name||ge.ManufacturerId)+(ge.OpenToWork?" (Open to Work)":"")},ge.ManufacturerId):null)]})]}),jsxRuntime.jsx(DialogDescription,{children:"The report will take around 5 minutes to generate."}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>V(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:se,disabled:!q||Ae,children:Ae?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):"Send Report"})]})]})})]})}function QualificationBadge({qualification:t}){return!t.QualificationId||t.QualificationId==="Suspended"?null:t.QualificationId==="Do Not Sell"?jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs(Badge,{variant:"destructive",children:[jsxRuntime.jsx(X$1,{className:"h-3 w-3 mr-1"}),"Do Not Sell"]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Qualification"})})]})}):jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs(Badge,{variant:"info",className:t.DefaultOpportunityNumber?"pr-1":"",children:[jsxRuntime.jsx(BadgeCheck,{className:"h-3 w-3 mr-1"}),t.QualificationId,t.DefaultOpportunityNumber&&jsxRuntime.jsx(Badge,{variant:"secondary",size:"sm",className:"ml-1",children:t.DefaultOpportunityNumber})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Qualification"})})]})})}function SalesChart({statistics:t,mode:e="month",chartHeight:n,loading:o=!1,size:l="default"}){const[d,f]=React.useState([]),[g,b]=React.useState(!1),S=[{name:"dollarVolume",label:"Dollar Volume",color:"var(--primary)",yAxisId:"left",format:"money"},{name:"unitsSold",label:"Units Sold",color:"#888",units:" units",yAxisId:"right",format:"integer"}];return React.useEffect(()=>{if(o||!t){f([]);return}let _=[];if(e==="week"){const R=new Map;t.forEach(C=>{var A;const E=((A=C.Day)==null?void 0:A.toString())||"";if(E.length===8){const I=parseInt(E.substring(0,4),10),M=parseInt(E.substring(4,6),10)-1,j=parseInt(E.substring(6,8),10),q=new Date(I,M,j),z=new Date(q);z.setDate(q.getDate()-q.getDay());const Q=`${z.getFullYear()}-${String(z.getMonth()+1).padStart(2,"0")}-${String(z.getDate()).padStart(2,"0")}`,V=R.get(Q)||{price:0,quantity:0};V.price+=C.ExtendedPrice||0,V.quantity+=C.Quantity||0,R.set(Q,V)}}),_=Array.from(R).sort(([C],[E])=>C.localeCompare(E)).map(([C,E])=>({date:`${C.substring(5,7)}/${C.substring(8,10)}`,dollarVolume:E.price,unitsSold:E.quantity}))}else{const R=new Date,C=R.getFullYear(),E=R.getMonth(),A=R.getDate(),I=`${C}-${(E+1).toString().padStart(2,"0")}`,M=Array.from({length:12},(q,z)=>{const Q=new Date(C,E-(11-z),1);return`${Q.getFullYear()}-${(Q.getMonth()+1).toString().padStart(2,"0")}`}),j=Object.fromEntries(M.map(q=>[q,{price:0,quantity:0}]));if(t.forEach(q=>{const z=String(q.Day??0);if(z.length!==8)return;const Q=`${z.substring(0,4)}-${z.substring(4,6)}`;j[Q]&&(j[Q].price+=q.ExtendedPrice??0,j[Q].quantity+=q.Quantity??0)}),_=M.map(q=>{const z=j[q],[Q,V]=q.split("-").map(Number);return{date:new Date(Q,V-1).toLocaleString("default",{month:"short",year:"numeric"}),dollarVolume:z.price,unitsSold:z.quantity}}),g){const q=j[I];if(q&&q.price>0&&A>0){const z=new Date(C,E+1,0).getDate();if(A<z){const Q=q.price/A,V=q.quantity/A,O=Q*z,te=V*z,ne=_[_.length-1];ne&&(ne.dollarVolume=O,ne.unitsSold=te)}}}}f(_)},[t,e,g,o]),o?jsxRuntime.jsx("div",{style:{height:n},children:jsxRuntime.jsx(Skeleton,{className:"h-full w-full rounded-md"})}):d.length===0?jsxRuntime.jsx("div",{style:{height:n},className:"flex items-center justify-center text-muted-foreground",children:"No sales data available."}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(AreaChart,{data:d,series:S,height:n,size:l}),l==="default"&&e==="month"&&jsxRuntime.jsxs("div",{className:"mt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Switch,{checked:g,onCheckedChange:b,id:"extrapolate-switch"}),jsxRuntime.jsx(Label$2,{htmlFor:"extrapolate-switch",children:"Extrapolate Current Month"})]}),g&&jsxRuntime.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["* Values for ",new Date().toLocaleString("default",{month:"long"})," are projected estimates."]})]})]})}function PartnerCardHeader({type:t,applicationId:e,publicName:n,name:o,location:l,link:d,linkNewTab:f=!0,children:g}){const[b,S]=React.useState(!1),_=C=>{C.preventDefault(),C.stopPropagation(),navigator.clipboard.writeText(e),S(!0),setTimeout(()=>S(!1),2e3)},R=jsxRuntime.jsxs(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"h-12 w-12 overflow-hidden rounded-md",children:jsxRuntime.jsx(PartnerLogo,{id:e,width:48,height:48},`partner_logo_${e}`)}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs text-primary",children:t}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"|"}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{delayDuration:300,children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{className:"flex cursor-pointer items-center gap-1",onClick:_,children:[jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:e}),b?jsxRuntime.jsx(Check,{className:"h-3 w-3 text-green-500"}):jsxRuntime.jsx(Copy,{className:"h-3 w-3 text-muted-foreground"})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:b?"Copied!":"Copy ID"})})]})})]}),jsxRuntime.jsx("h3",{className:"font-semibold",children:n||"N/A"}),o&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:o}),l&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:l})]})]}),g&&jsxRuntime.jsx("div",{className:"flex flex-col items-end gap-2",children:g})]});return d?jsxRuntime.jsx(reactRouterDom.Link,{to:d,target:f?"_blank":"_self",children:R}):R}function ManufacturerCard({manufacturer:t,link:e,linkNewTab:n=!0,actions:o,mainAction:l,loading:d=!1,appID:f}){var Q,V,O;const{toast:g}=useToast(),[b,{isLoading:S}]=usePostV4ResellerByRouteResellerIdReportProductsEmailMutation(),[_,R]=React.useState(!1),[C,E]=React.useState(""),{data:A}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:f||""},{skip:!f}),I=A==null?void 0:A.IsReseller;if(d||!t)return jsxRuntime.jsxs(Card,{className:"flex flex-col h-full",children:[jsxRuntime.jsxs(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-12 rounded-md"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-24 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-40 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-48"})]})]}),jsxRuntime.jsx(Skeleton,{className:"h-16 w-24"})]}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsxs("div",{className:"flex flex-col space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-16 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-14 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-40"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-36"})]})]})]})}),jsxRuntime.jsxs(CardFooter,{className:"flex justify-between pt-2 gap-2 mt-auto",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-40"})]})]});const M=[t.City,t.Province,t.Country].filter(Boolean),j=M.length>0?M.join(", "):"",q=((Q=t.Tags)==null?void 0:Q.split(",").map(te=>te.trim()).filter(Boolean))||[],z=async()=>{if(!(!(t!=null&&t.ManufacturerId)||!f||!C))try{await b({routeResellerId:f,emailAddress:C,manufacturerId:t.ManufacturerId}).unwrap(),g({title:"Report requested",description:`The Universal Product List for this manufacturer will be sent to ${C} shortly.`,variant:"success"}),R(!1)}catch(te){console.error("Error requesting product list:",te),g({title:"Error",description:"Failed to request product list. Please try again.",variant:"destructive"})}};return jsxRuntime.jsxs(Card,{className:"manufacturer-theme flex flex-col h-full",children:[jsxRuntime.jsx(PartnerCardHeader,{type:"Manufacturer",applicationId:t.ManufacturerId,publicName:t.PublicName,name:t.Name,location:j,link:e,linkNewTab:n,children:jsxRuntime.jsx("div",{className:"flex flex-col items-end gap-2",children:t.SalesStatistics&&t.SalesStatistics.length>0&&jsxRuntime.jsx("div",{className:"h-16 w-24",children:jsxRuntime.jsx(SalesChart,{statistics:t.SalesStatistics,size:"mini"})})})}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsxs("div",{className:"flex",children:[jsxRuntime.jsxs("div",{className:"flex flex-col flex-1 space-y-2",children:[(!!((V=t.Qualification)!=null&&V.QualificationId)&&((O=t.Qualification)==null?void 0:O.QualificationId)!=="Suspended"||!!t.OpenToWork||!!t.OnHold&&t.OnHold!==0||q.length>0)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(QualificationBadge,{qualification:t.Qualification??{}}),!!t.OpenToWork&&jsxRuntime.jsxs(Badge,{variant:"success",children:[jsxRuntime.jsx(HardHat,{className:"h-3 w-3 mr-1"}),"Open To Work"]}),!!t.OnHold&&t.OnHold!==0&&jsxRuntime.jsx(Badge,{variant:"warning",children:"On Hold"}),q.map((te,ne)=>jsxRuntime.jsx(Badge,{variant:"outline",children:te},ne))]}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[t.Phone&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`tel:${t.Phone}`,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Phone,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:t.Phone})]}),t.PublicEmail&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`mailto:${t.PublicEmail}`,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Mail,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:t.PublicEmail})]}),t.Website&&jsxRuntime.jsxs(reactRouterDom.Link,{to:t.Website,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Globe,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:t.Website})]}),t.CurrencyCode&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(DollarSign,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:t.CurrencyCode})]})]})]}),t.SalesData&&jsxRuntime.jsxs("div",{className:"border-l pl-2 ml-2 flex flex-col text-sm",children:[jsxRuntime.jsx("strong",{className:"",children:"YTD"}),jsxRuntime.jsx("p",{children:t.SalesData.SalesYearToDay?formatMoney(t.SalesData.SalesYearToDay):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"3 mo."}),jsxRuntime.jsx("p",{children:t.SalesData.SalesLast3Months?formatMoney(t.SalesData.SalesLast3Months):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"30 days"}),jsxRuntime.jsx("p",{children:t.SalesData.SalesLast30Days?formatMoney(t.SalesData.SalesLast30Days):"—"})]})]})}),(o||l||t.PublicResourcesLink||I&&f&&t.ManufacturerId)&&jsxRuntime.jsxs(CardFooter,{className:"flex pt-2 gap-2 justify-between mt-auto",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[o&&o,I&&f&&t.ManufacturerId&&jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{size:"icon",onClick:()=>R(!0),disabled:S,children:S?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}):jsxRuntime.jsx(Download,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Email Product List"})})]})}),t.PublicResourcesLink&&jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:t.PublicResourcesLink,target:"_blank",children:jsxRuntime.jsx(Button$1,{size:"icon",children:jsxRuntime.jsx(HardDriveDownload,{className:"h-4 w-4"})})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Public Resources Link"})})]})})]}),l&&jsxRuntime.jsx("div",{children:l})]}),jsxRuntime.jsx(Dialog,{open:_,onOpenChange:R,children:jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Request Universal Product List"}),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:C,onChange:te=>E(te.target.value),placeholder:"your@email.com",className:"mt-2"})]}),jsxRuntime.jsx(DialogDescription,{children:"The report will take around 5 minutes to generate."}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>R(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:z,disabled:!C||S,children:S?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):"Send Report"})]})]})})]})}function ProductInventoryButton({applicationId:t,randmarSku:e,inventory:n,buttonSize:o="default"}){var Ve;const l=React.useRef(null),d=useIntersectionObserver({elementRef:l,threshold:.1,rootMargin:"100px",freezeOnceVisible:!0}),{toast:f}=useToast(),[g,b]=React.useState(!1),[S,_]=React.useState(!1),[R,C]=React.useState(!1),{data:E,isLoading:A,isFetching:I}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:t},{skip:!t||!d}),{data:M,isLoading:j,isFetching:q}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:t,randmarSku:e,withSpecification:!1},{skip:!!n||!d}),[z]=usePutV4ResellerByRouteResellerIdProductAndRandmarSkuRequisitionMutation(),Q=n??((Ve=M==null?void 0:M.Distribution)==null?void 0:Ve.Inventory);React.useEffect(()=>{b(!1)},[e]);const{inventoryQuantity:V,totalIncomingQuantity:O}=React.useMemo(()=>{if(!Q||Q.length===0)return{inventoryQuantity:0,totalIncomingQuantity:0};const Ne=Q.reduce((Ae,ge)=>Ae+(ge.AvailableQuantity||0),0),se=Q.reduce((Ae,ge)=>Ae+(ge.PurchaseOrderQuantity||0),0);return{inventoryQuantity:Ne,totalIncomingQuantity:se}},[Q]);if(A||I||j||q)return jsxRuntime.jsx("div",{ref:l,children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-36 rounded-md"})});const ne=()=>{R||!(E!=null&&E.IsReseller)||(C(!0),z({routeResellerId:t??"",randmarSku:e??""}).then(Ne=>{Ne.error||Ne.data===!1?f({title:"Warning",description:"Product is already in the process of being ordered with the manufacturer. You can reach out to Randmar's team to confirm.",variant:"warnng"}):f({title:"Success",description:"Qualification successfully submitted.",variant:"success"}),_(!1)}).catch(Ne=>{console.error(Ne),f({title:"Error",description:"Error submitting your qualification.",variant:"destructive"})}).finally(()=>{C(!1)}))};if(!Q)return jsxRuntime.jsx("div",{ref:l,children:jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx("span",{tabIndex:0,children:jsxRuntime.jsxs(Button$1,{disabled:!0,size:o,variant:"outline",className:"text-sm",children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),"No data"]})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"No inventory data could be found for this product."})})]})})});if(E!=null&&E.IsReseller&&V<=0&&O<=0)return jsxRuntime.jsx("div",{ref:l,children:jsxRuntime.jsxs(Dialog,{open:S,onOpenChange:_,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{variant:"outline",size:o,className:"text-sm reseller-theme text-primary",children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),"Request to stock"]})}),jsxRuntime.jsxs(DialogContent,{className:"max-w-md",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsx(DialogTitle,{children:"Request to stock"})}),jsxRuntime.jsx("p",{className:"py-4",children:"Are you sure you want to request this product to be stocked?"}),jsxRuntime.jsxs("div",{className:"flex justify-end gap-2",children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>_(!1),disabled:R,children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:ne,disabled:R,children:R?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin mr-2"}),"Requesting..."]}):"Confirm"})]})]})]})});const ae=V<=0&&O>0;return jsxRuntime.jsx("div",{ref:l,children:jsxRuntime.jsxs(Dialog,{open:g,onOpenChange:b,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{variant:"outline",size:o,className:`text-sm ${ae?"manufacturer-theme text-primary":V>0?"text-green-700":"text-red-700"}`,children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),ae?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[formatNumber(O)," Incoming"]}):V>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[formatNumber(V)," in stock"]}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Out of stock"})]})}),jsxRuntime.jsxs(DialogContent,{className:"max-w-4xl",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsxs(DialogTitle,{className:"flex items-center",children:[jsxRuntime.jsx(Warehouse,{className:"mr-2",size:18}),"Inventory Information"]})}),jsxRuntime.jsx(ProductInventoryGrid,{inventory:Q})]})]})})}function OrdersCard({applicationId:t,orders:e=null,loading:n=!1,title:o="Order Details"}){const l=React.useMemo(()=>[{accessorKey:"OrderNumber",header:"Order Number",cell:({row:g})=>g.original.OrderNumber?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${t}/GeneralDocument/${g.original.OrderNumber}`,className:"font-medium text-primary hover:underline",children:g.original.OrderNumber})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for order ",g.original.OrderNumber]})})]})}):"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"DocumentNumber",header:"Document Number",cell:({row:g})=>g.original.DocumentNumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"DocumentDate",header:"Document Date",cell:({row:g})=>formatYYYYMMDDIntToDateString(g.original.DocumentDate),enableSorting:!0,enableFiltering:!1},{accessorKey:"PONumber",header:"PO Number",cell:({row:g})=>g.original.PONumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"WarehouseCode",header:"Warehouse",cell:({row:g})=>g.original.WarehouseCode??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"MPN",header:"MPN",cell:({row:g})=>g.original.MPN?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${t}/Product/${g.original.MPN}`,className:"font-medium text-primary hover:underline",children:g.original.MPN})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for MPN ",g.original.MPN]})})]})}):"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:g})=>g.original.Quantity??"N/A",enableSorting:!0,enableFiltering:!1},{accessorKey:"ShipToName",header:"Name",cell:({row:g})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:g.original.ShipToName??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"UnitPrice",header:"Unit Price",cell:({row:g})=>g.original.UnitPrice?formatMoney(g.original.UnitPrice):"N/A",enableSorting:!0,enableFiltering:!1},{id:"actions",header:"Actions",cell:({row:g})=>jsxRuntime.jsx("div",{className:"flex space-x-2",children:jsxRuntime.jsx(ProductInventoryButton,{applicationId:t,randmarSku:g.original.RandmarSKU??"",buttonSize:"sm"})})}],[t]),d=React.useMemo(()=>{const g={};if(e){const b=Array.from(new Set(e.map(A=>A.WarehouseCode).filter(A=>A!=null)));g.WarehouseCode=b;const S=Array.from(new Set(e.map(A=>A.ShipToName).filter(A=>A!=null)));g.ShipToName=S;const _=Array.from(new Set(e.map(A=>A.DocumentNumber).filter(A=>A!=null)));g.DocumentNumber=_;const R=Array.from(new Set(e.map(A=>A.OrderNumber).filter(A=>A!=null)));g.OrderNumber=R;const C=Array.from(new Set(e.map(A=>A.PONumber).filter(A=>A!=null)));g.PONumber=C;const E=Array.from(new Set(e.map(A=>A.MPN).filter(A=>A!=null)));g.MPN=E}return g},[e]),f=e||[];return n?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(Skeleton,{className:"h-7 w-48"})," "]}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-[130px]"}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-20"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})]})]})]})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:o})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:l,data:f,uniqueValues:d})})]})}function ResellerOverview({appID:t,reseller:e,readonly:n,userEmail:o,isSuperAdmin:l,withoutReports:d=!1}){var q,z,Q,V;const{data:f,isLoading:g,isError:b}=useGetV4PartnerByApplicationIdAccountResellerQuery({applicationId:t??"",withSpecification:!0},{skip:!!e}),[S,_]=React.useState({publicInfo:{hasUnsavedChanges:!1}}),R=React.useCallback(()=>n?!1:S.publicInfo.hasUnsavedChanges,[n,S]),C=React.useCallback((O,te)=>{_(ne=>{var ae;return((ae=ne[O])==null?void 0:ae.hasUnsavedChanges)!==te.hasUnsavedChanges?{...ne,[O]:te}:ne})},[]),{NavigationGuardDialog:E}=useRouterNavigationGuard(R),A=e??f,I=!n||!!(A!=null&&A.Statement)&&(A.Statement.Total??0)>0,M=(A==null?void 0:A.QualifiedManufacturers)??[],j=(A==null?void 0:A.Qualifications)??[];return jsxRuntime.jsxs("div",{className:"@container",children:[b?jsxRuntime.jsx(Card,{className:"p-6",children:jsxRuntime.jsxs(Alert,{variant:"destructive",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Error"}),jsxRuntime.jsx(AlertDescription,{children:"There was an error loading your reseller information. Please try again later."})]})}):jsxRuntime.jsxs("div",{className:"space-y-6 mb-6",children:[jsxRuntime.jsx(SalesSummary,{fiscalYearMonthStart:(A==null?void 0:A.FiscalYearMonthStart)||1,salesData:A==null?void 0:A.SalesData,isLoading:g}),jsxRuntime.jsxs("div",{className:"grid @lg:grid-cols-2 gap-6",children:[jsxRuntime.jsx(SalesChartCard,{statistics:(A==null?void 0:A.SalesStatistics)??[],loading:g}),jsxRuntime.jsx(OrderCategories,{openOrders:(A==null?void 0:A.ActiveOrderDetails)??[],isLoading:g}),I&&jsxRuntime.jsx(BillingCard,{appID:t,reseller:A||{},withoutReports:d,isLoading:g,userEmail:o,isSuperAdmin:l}),jsxRuntime.jsx(PublicInfo,{reseller:A||{},appID:t??"",isLoading:g,readonly:n,onUnsavedChanges:O=>C("publicInfo",{hasUnsavedChanges:O})}),jsxRuntime.jsx(AccountTier,{isSuperAdmin:l,readonly:n,reseller:A||{},appID:t??"",isLoading:g})]}),g||M.length>0?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Manufacturers you are qualified for"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid @lg:grid-cols-2 gap-4",children:g?Array.from({length:2}).map((O,te)=>jsxRuntime.jsx(ManufacturerCard,{loading:!0},te)):M.map(O=>jsxRuntime.jsx(ManufacturerCard,{manufacturer:O,link:`https://dashboard.randmar.io/${t}/Partner/${O.ManufacturerId}`},O.ManufacturerId))})})]}):j.length>0&&jsxRuntime.jsx(ResellerQualificationsCard,{qualifications:j}),(((q=A==null?void 0:A.Opportunities)==null?void 0:q.length)??0)>0&&jsxRuntime.jsx(OpportunitiesTable,{applicationId:t,opportunities:A==null?void 0:A.Opportunities,loading:g}),(((z=A==null?void 0:A.ActiveOrderDetails)==null?void 0:z.length)??0)>0&&jsxRuntime.jsx(OrdersCard,{applicationId:t,title:"Active Orders",orders:A==null?void 0:A.ActiveOrderDetails,loading:g}),(((Q=A==null?void 0:A.CompletedOrderDetails)==null?void 0:Q.length)??0)>0&&jsxRuntime.jsx(OrdersCard,{applicationId:t,title:"Completed Orders",orders:A==null?void 0:A.CompletedOrderDetails,loading:g}),(((V=A==null?void 0:A.Returns)==null?void 0:V.length)??0)>0&&jsxRuntime.jsx(ReturnsTable,{applicationId:t,returns:A==null?void 0:A.Returns,loading:g}),!d&&jsxRuntime.jsx(ReportsSection,{appID:t,userEmail:o,isLoading:g})]}),jsxRuntime.jsx(E,{})]})}const alertVariants=cva("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",success:"border-green-500/50 bg-green-50 text-green-700 dark:border-green-500 dark:bg-green-950 dark:text-green-400 [&>svg]:text-green-500",warning:"border-yellow-500/50 bg-yellow-50 text-yellow-700 dark:border-yellow-500 dark:bg-yellow-950 dark:text-yellow-400 [&>svg]:text-yellow-500",info:"border-blue-500/50 bg-blue-50 text-blue-700 dark:border-blue-500 dark:bg-blue-950 dark:text-blue-400 [&>svg]:text-blue-500"}},defaultVariants:{variant:"default"}}),Alert=React__namespace.forwardRef(({className:t,variant:e,...n},o)=>jsxRuntime.jsx("div",{ref:o,role:"alert",className:cn(alertVariants({variant:e}),t),...n}));Alert.displayName="Alert";const AlertTitle=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("h5",{ref:n,className:cn("mb-1 font-medium leading-none tracking-tight",t),...e}));AlertTitle.displayName="AlertTitle";const AlertDescription=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("text-sm [&_p]:leading-relaxed",t),...e}));AlertDescription.displayName="AlertDescription";/**
1187
+ $10 with opportunities under $1,000`:t==="D"?"$15 under $1,500":t==="E"?"Full shipping charges":t,getTermsText=t=>t==="STRIPE"?"Credit card payment":t==="NET30"?"Net 30 days":t,AccountTier=({isSuperAdmin:t,readonly:e,reseller:n,appID:o,isLoading:l})=>{const{toast:d}=useToast(),[f,g]=React.useState(!1),[b,S]=React.useState(""),[_,{isLoading:R}]=usePostV4PartnerByApplicationIdAccountResellerAndFieldNameMutation(),C=je=>je&&{Starter:"starter","E-Commerce":"ecommerce",Commercial:"commercial",Basics:"cws",Novexco:"novexco","Jean Coutu":"jeancoutu",Exclusive:"exclusive"}[je]||"",E=je=>je&&{A:"free",B:"fixed",C:"dropshipped",D:"under1500",E:"fullcharges"}[je]||"",A=je=>je&&{1:"exclusive",2:"ecommerce",3:"commercial",4:"buyinggroup",5:"cost"}[je]||"",[I,M]=React.useState(C((n==null?void 0:n.Priority)??"")),[j,q]=React.useState(E((n==null?void 0:n.ShippingProfile)??"")),[z,Q]=React.useState(A(n==null?void 0:n.PriceProfile)),V=je=>({starter:"Starter",ecommerce:"E-Commerce",commercial:"Commercial",cws:"Basics",novexco:"Novexco",jeancoutu:"Jean Coutu",exclusive:"Exclusive"})[je]||je,O=je=>({free:"A",fixed:"B",dropshipped:"C",under1500:"D",fullcharges:"E"})[je]||je,te=je=>({exclusive:"1",ecommerce:"2",commercial:"3",buyinggroup:"4",cost:"5"})[je]||je;React.useEffect(()=>{M(C((n==null?void 0:n.Priority)??"")),q(E((n==null?void 0:n.ShippingProfile)??"")),Q(A(n==null?void 0:n.PriceProfile))},[n]);const ne=async(je,Le,Fe,$e)=>{try{(await _({applicationId:o,fieldName:je,newValue:Le})).error?d({title:"Error",description:$e,variant:"destructive"}):d({title:"Success",description:Fe,variant:"success"})}catch{d({title:"Error",description:"An unexpected error occurred",variant:"destructive"})}},ae=async je=>{M(je);const Le=V(je);ne("Priority",Le,`Priority updated to ${Le}`,"Failed to update priority")},Ve=async je=>{q(je);const Le=O(je);ne("ShippingProfile",Le,`Shipping profile updated to ${Le}`,"Failed to update shipping profile")},Ne=async je=>{Q(je);const Le=te(je);ne("PriceProfile",Le,`Pricing profile updated to ${Le}`,"Failed to update pricing profile")},se=async()=>{try{const je=await _({applicationId:o,fieldName:"Tier",newValue:b});je.error?d({title:"Error",description:"Failed to update reseller",variant:"destructive"}):je.data?d({title:"Success",description:`Pricing Tier changed to ${b}`,variant:"success"}):d({title:"Considered",description:"Request being considered",variant:"success"})}catch{d({title:"Error",description:"An unexpected error occurred",variant:"destructive"})}finally{g(!1),S("")}},Ae=[{name:"Terms",enabled:n.Priority==="Starter"},{name:"E-Commerce",enabled:n.Priority==="Commercial"},{name:"Commercial",enabled:n.Priority==="E-Commerce"},{name:"Exclusive",enabled:t}],ge=je=>{S(je),g(!0)};return l?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{className:"pb-2",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-28"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-16 rounded-full"})]})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsxs("div",{className:"mb-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-40 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-56"})]}),jsxRuntime.jsx("div",{className:"grid gap-3",children:[1,2,3].map(je=>jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-8 rounded-full shrink-0"}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full"})]})]},je))}),jsxRuntime.jsxs("div",{className:"flex gap-2 mt-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{className:"pb-2 pt-4 px-4 flex flex-row items-center justify-between",children:[jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Account Tier"}),jsxRuntime.jsx(Badge,{variant:"secondary",className:"bg-green-100 text-green-700 hover:bg-green-200 text-xs",children:"Active"})]}),jsxRuntime.jsxs(CardContent,{className:"pt-2 px-4 pb-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-3 bg-primary/5 p-4 rounded-lg",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("h3",{className:"text-lg font-bold text-primary",children:[(n==null?void 0:n.Priority)||""," Tier"]}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Optimized for online retail"})]}),jsxRuntime.jsx(CircleCheck,{className:"h-6 w-6 text-green-600"})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 gap-2 mb-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Package2,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Pricing"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground truncate",children:getPricingText(n.PriceProfile||0)})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Truck,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Shipping"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:getShippingText(n.ShippingProfile||"").split(".")[0]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Calendar$1,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Payment terms"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:getTermsText((n==null?void 0:n.Terms)||"")})]})]})]}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[!e&&jsxRuntime.jsx(Button$1,{variant:"outline",className:"flex-1",asChild:!0,children:jsxRuntime.jsxs(reactRouterDom.Link,{to:"https://www.randmar.io/docs/overview/pricingTiers",target:"_blank",children:[jsxRuntime.jsx(ExternalLink,{className:"h-4 w-4 mr-1"}),"Pricing Tiers"]})}),jsxRuntime.jsxs(Popover,{children:[jsxRuntime.jsx(PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{disabled:e,className:e?"hidden":"flex-1",children:["Upgrade Tier ",jsxRuntime.jsx(ChevronRight,{className:"h-3 w-3 ml-1"})]})}),jsxRuntime.jsx(PopoverContent,{className:"w-56 p-2",children:jsxRuntime.jsxs("div",{className:"grid gap-1",children:[jsxRuntime.jsx("h4",{className:"font-medium text-xs mb-1",children:"Select a tier"}),Ae.map(je=>jsxRuntime.jsx(Button$1,{variant:"ghost",size:"sm",className:"w-full justify-start h-8",disabled:!je.enabled,onClick:()=>ge(je.name),children:je.name},je.name))]})})]})]})]})]}),jsxRuntime.jsx(ChangePricingTierModal,{isLoading:R,open:f,setOpen:g,tier:b,onTierChange:se}),t&&!e&&jsxRuntime.jsxs(Card,{className:"mt-4",children:[jsxRuntime.jsx(CardHeader,{className:"pb-2 pt-3 px-4",children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Admin Configuration"})}),jsxRuntime.jsx(CardContent,{className:"pt-2 px-4 pb-4",children:jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsxs("div",{className:"bg-muted/30 p-2 rounded-lg",children:[jsxRuntime.jsx(Label$2,{className:"block mb-1 text-xs font-medium",children:"Priority"}),jsxRuntime.jsx(RadioGroup$1,{value:I,onValueChange:ae,className:"grid grid-cols-2 @sm:grid-cols-3 @md:grid-cols-4 gap-1",children:[{value:"starter",label:"Starter"},{value:"ecommerce",label:"E-Commerce"},{value:"commercial",label:"Commercial"},{value:"cws",label:"CWS (Basics)"},{value:"novexco",label:"Novexco"},{value:"jeancoutu",label:"Jean Coutu"},{value:"exclusive",label:"Exclusive"}].map(je=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:je.value,id:`priority-${je.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`priority-${je.value}`,className:"cursor-pointer text-xs",children:je.label})]},je.value))})]}),jsxRuntime.jsxs("div",{className:"bg-muted/30 p-2 rounded-lg",children:[jsxRuntime.jsx(Label$2,{className:"block mb-1 text-xs font-medium",children:"Shipping Profile"}),jsxRuntime.jsx(RadioGroup$1,{value:j,onValueChange:Ve,className:"grid grid-cols-1 @md:grid-cols-2 gap-1",children:[{value:"free",label:"Free (A)"},{value:"fixed",label:"Fixed $10 Shipping (B)"},{value:"dropshipped",label:"$15 for drop shipped (C)"},{value:"under1500",label:"15$ under 1,500 (D)"},{value:"fullcharges",label:"Full shipping charges (E)"}].map(je=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:je.value,id:`shipping-${je.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`shipping-${je.value}`,className:"cursor-pointer text-xs",children:je.label})]},je.value))})]}),jsxRuntime.jsxs("div",{className:"bg-muted/30 p-2 rounded-lg",children:[jsxRuntime.jsx(Label$2,{className:"block mb-1 text-xs font-medium",children:"Pricing Profile"}),jsxRuntime.jsx(RadioGroup$1,{value:z,onValueChange:Ne,className:"grid grid-cols-2 @sm:grid-cols-3 gap-1",children:[{value:"exclusive",label:"Exclusive (1)"},{value:"ecommerce",label:"E-Commerce (2)"},{value:"commercial",label:"Commercial (3)"},{value:"buyinggroup",label:"Buying Group (4)"},{value:"cost",label:"Cost (5)"}].map(je=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:je.value,id:`pricing-${je.value}`,className:"h-6 w-6 scale-50 antialiased"}),jsxRuntime.jsx(Label$2,{htmlFor:`pricing-${je.value}`,className:"cursor-pointer text-xs",children:je.label})]},je.value))})]})]})})]})]})};function OrderCategories({openOrders:t=[],isLoading:e=!1}){const n=(t==null?void 0:t.filter(I=>I.DocumentType==="Order"))||[],o=(t==null?void 0:t.filter(I=>I.DocumentType==="Shipment"))||[],l=n.filter(I=>I.WarehouseCode!=="3PLE"),d=l.reduce((I,M)=>I+(M.Quantity??0),0),f=l.reduce((I,M)=>I+(M.ExtendedPrice??0),0),g=n.filter(I=>I.WarehouseCode==="3PLE"),b=g.reduce((I,M)=>I+(M.Quantity??0),0),S=g.reduce((I,M)=>I+(M.ExtendedPrice??0),0),_=o.reduce((I,M)=>I+(M.Quantity??0),0),R=o.reduce((I,M)=>I+(M.ExtendedPrice??0),0),C=d+b+_,E=f+S+R,A=[{name:"All",icon:Package,color:"bg-blue-500",orders:C,amount:E},{name:"Processing",icon:RefreshCcw,color:"bg-yellow-500",orders:d,amount:f},{name:"Shipped",icon:Truck,color:"bg-green-500",orders:_,amount:R},{name:"Delayed",icon:CircleAlert,color:"bg-red-500",orders:b,amount:S}];return e?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(Skeleton,{className:"h-7 w-40"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-3.5",children:[1,2,3,4].map(I=>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:"bg-gray-200 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(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-8 w-8 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-12"})]}),jsxRuntime.jsxs("div",{className:"text-end",children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]})]})]})]})},I))})})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Order Categories"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-3.5",children:A.map(I=>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:`${I.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:I.name}),jsxRuntime.jsx("div",{className:`${I.color} bg-opacity-90 p-2 rounded-full`,children:jsxRuntime.jsx(I.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:I.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:I.amount,style:"currency",currency:"CAD",currencyDisplay:"symbol"})})]})]})]})]})},I.name))})})]})}function ReportsSection({isLoading:t,userEmail:e,appID:n}){const{toast:o}=useToast(),[l,{isLoading:d}]=usePostV4ResellerByRouteResellerIdReportWalmartTrackingFileEmailMutation(),[f,{isLoading:g}]=usePostV4ResellerByRouteResellerIdReportAmazonTrackingFileEmailMutation(),[b,{isLoading:S}]=usePostV4ResellerByRouteResellerIdReportOpenOrdersEmailMutation(),[_,{isLoading:R}]=usePostV4ResellerByRouteResellerIdReportProductsEmailMutation(),[C,{isLoading:E}]=usePostV4ResellerByRouteResellerIdReportInvoicesEmailMutation(),[A,{isLoading:I}]=usePostV4ResellerByRouteResellerIdDocumentStatementEmailMutation(),[M,j]=React.useState(null),[q,z]=React.useState(e),[Q,V]=React.useState(!1),[O,te]=React.useState("all"),{data:ne,isLoading:ae}=useGetV4PartnerByRouteApplicationIdManufacturersQuery({routeApplicationId:n,withSpecification:!1}),Ve=[{name:"Products",reports:[{id:"Products",title:"Universal Product List",description:"A comprehensive overview of your product list with detailed specifications and pricing information.",icon:Package}]},{name:"Operation Details",reports:[{id:"OpenOrders",title:"Order Details",description:"A detailed report of all your orders and shipments, including status, tracking information, and delivery estimates.",icon:ShoppingCart},{id:"Invoices",title:"Invoices and Credits Report",description:"Detailed overview of your invoices and credits within a specific date range. It also contains reports about additional charges, serial numbers, and other relevant information.",icon:ScrollText},{id:"Statement",title:"Statement and RMAs Report",description:"A detailed report of all unpaid invoices and active RMAs.",icon:Banknote}]},{name:"Tracking Files",reports:[{id:"AmazonTrackingFile",title:"Amazon Tracking File",description:"Track products sold on Amazon marketplace with detailed sales and inventory information.",icon:ChartNoAxesColumnIncreasing},{id:"WalmartTrackingFile",title:"Walmart Tracking File",description:"Track products sold on Walmart marketplace with detailed sales and inventory information.",icon:ChartNoAxesColumnIncreasing}]}],Ne=async ge=>{j(ge),ge.id==="Products"&&te("all"),V(!0)},se=async()=>{if(!(!M||!n))try{switch(M.id){case"Products":{const ge={routeResellerId:n,emailAddress:q};O&&O!=="all"&&(ge.manufacturerId=O),await _(ge).unwrap();break}case"AmazonTrackingFile":await f({routeResellerId:n,emailAddress:q}).unwrap();break;case"WalmartTrackingFile":await l({routeResellerId:n,emailAddress:q}).unwrap();break;case"OpenOrders":await b({routeResellerId:n,emailAddress:q}).unwrap();break;case"Invoices":await C({routeResellerId:n,emailAddress:q}).unwrap();break;case"Statement":await A({routeResellerId:n,emailAddress:q}).unwrap();break;default:throw new Error("invalid report id")}o({title:"Report requested",description:`The ${M.title} will be sent to ${q} shortly.`,variant:"success"}),V(!1)}catch(ge){console.error("Error requesting report:",ge),o({title:"Error",description:"Failed to request report. Please try again.",variant:"destructive"})}},Ae=S||R||g||d||I||E;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 Product List to your Order Details."})]}),jsxRuntime.jsx(CardContent,{className:"space-y-6",children:t?jsxRuntime.jsx(jsxRuntime.Fragment,{children:[1,2,3].map(ge=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-48"}),[1,2].map(je=>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"})]},je))]},ge))}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:Ve.map(ge=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx("h3",{className:"text-sm font-semibold",children:ge.name}),ge.reports.map(je=>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(je.icon,{className:"h-5 w-5 text-primary"})}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx("h4",{className:"font-semibold text-sm",children:je.title}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:je.description})]}),jsxRuntime.jsxs(Button$1,{variant:"outline",size:"sm",className:"flex items-center gap-1",onClick:()=>Ne(je),children:[jsxRuntime.jsx(Download,{className:"h-4 w-4"}),"Request"]})]},je.id))]},ge.name))})}),jsxRuntime.jsx(Dialog,{open:Q,onOpenChange:V,children:jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsxs(DialogTitle,{children:["Request ",M==null?void 0:M.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:q,onChange:ge=>z(ge.target.value),placeholder:"your@email.com",className:"mt-2"})]}),(M==null?void 0:M.id)==="Products"&&jsxRuntime.jsxs("div",{className:"py-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"manufacturer",children:"Manufacturer"}),jsxRuntime.jsxs("select",{id:"manufacturer",className:"mt-2 block w-full rounded-md border border-input bg-background px-3 py-2 text-sm",value:O,onChange:ge=>te(ge.target.value),disabled:ae,children:[jsxRuntime.jsx("option",{value:"all",children:"All manufacturers"}),!ae&&Array.isArray(ne)&&ne.slice().sort((ge,je)=>(ge.PublicName||ge.Name||"").localeCompare(je.PublicName||je.Name||"")).map(ge=>ge!=null&&ge.ManufacturerId?jsxRuntime.jsx("option",{value:ge.ManufacturerId,children:(ge.PublicName||ge.Name||ge.ManufacturerId)+(ge.OpenToWork?" (Open to Work)":"")},ge.ManufacturerId):null)]})]}),jsxRuntime.jsx(DialogDescription,{children:"The report will take around 5 minutes to generate."}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>V(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:se,disabled:!q||Ae,children:Ae?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):"Send Report"})]})]})})]})}function QualificationBadge({qualification:t}){return!t.QualificationId||t.QualificationId==="Suspended"?null:t.QualificationId==="Do Not Sell"?jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs(Badge,{variant:"destructive",children:[jsxRuntime.jsx(X$1,{className:"h-3 w-3 mr-1"}),"Do Not Sell"]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Qualification"})})]})}):jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs(Badge,{variant:"info",className:t.DefaultOpportunityNumber?"pr-1":"",children:[jsxRuntime.jsx(BadgeCheck,{className:"h-3 w-3 mr-1"}),t.QualificationId,t.DefaultOpportunityNumber&&jsxRuntime.jsx(Badge,{variant:"secondary",size:"sm",className:"ml-1",children:t.DefaultOpportunityNumber})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Qualification"})})]})})}function SalesChart({statistics:t,mode:e="month",chartHeight:n,loading:o=!1,size:l="default"}){const[d,f]=React.useState([]),[g,b]=React.useState(!1),S=[{name:"dollarVolume",label:"Dollar Volume",color:"var(--primary)",yAxisId:"left",format:"money"},{name:"unitsSold",label:"Units Sold",color:"#888",units:" units",yAxisId:"right",format:"integer"}];return React.useEffect(()=>{if(o||!t){f([]);return}let _=[];if(e==="week"){const R=new Map;t.forEach(C=>{var A;const E=((A=C.Day)==null?void 0:A.toString())||"";if(E.length===8){const I=parseInt(E.substring(0,4),10),M=parseInt(E.substring(4,6),10)-1,j=parseInt(E.substring(6,8),10),q=new Date(I,M,j),z=new Date(q);z.setDate(q.getDate()-q.getDay());const Q=`${z.getFullYear()}-${String(z.getMonth()+1).padStart(2,"0")}-${String(z.getDate()).padStart(2,"0")}`,V=R.get(Q)||{price:0,quantity:0};V.price+=C.ExtendedPrice||0,V.quantity+=C.Quantity||0,R.set(Q,V)}}),_=Array.from(R).sort(([C],[E])=>C.localeCompare(E)).map(([C,E])=>({date:`${C.substring(5,7)}/${C.substring(8,10)}`,dollarVolume:E.price,unitsSold:E.quantity}))}else{const R=new Date,C=R.getFullYear(),E=R.getMonth(),A=R.getDate(),I=`${C}-${(E+1).toString().padStart(2,"0")}`,M=Array.from({length:12},(q,z)=>{const Q=new Date(C,E-(11-z),1);return`${Q.getFullYear()}-${(Q.getMonth()+1).toString().padStart(2,"0")}`}),j=Object.fromEntries(M.map(q=>[q,{price:0,quantity:0}]));if(t.forEach(q=>{const z=String(q.Day??0);if(z.length!==8)return;const Q=`${z.substring(0,4)}-${z.substring(4,6)}`;j[Q]&&(j[Q].price+=q.ExtendedPrice??0,j[Q].quantity+=q.Quantity??0)}),_=M.map(q=>{const z=j[q],[Q,V]=q.split("-").map(Number);return{date:new Date(Q,V-1).toLocaleString("default",{month:"short",year:"numeric"}),dollarVolume:z.price,unitsSold:z.quantity}}),g){const q=j[I];if(q&&q.price>0&&A>0){const z=new Date(C,E+1,0).getDate();if(A<z){const Q=q.price/A,V=q.quantity/A,O=Q*z,te=V*z,ne=_[_.length-1];ne&&(ne.dollarVolume=O,ne.unitsSold=te)}}}}f(_)},[t,e,g,o]),o?jsxRuntime.jsx("div",{style:{height:n},children:jsxRuntime.jsx(Skeleton,{className:"h-full w-full rounded-md"})}):d.length===0?jsxRuntime.jsx("div",{style:{height:n},className:"flex items-center justify-center text-muted-foreground",children:"No sales data available."}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(AreaChart,{data:d,series:S,height:n,size:l}),l==="default"&&e==="month"&&jsxRuntime.jsxs("div",{className:"mt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Switch,{checked:g,onCheckedChange:b,id:"extrapolate-switch"}),jsxRuntime.jsx(Label$2,{htmlFor:"extrapolate-switch",children:"Extrapolate Current Month"})]}),g&&jsxRuntime.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["* Values for ",new Date().toLocaleString("default",{month:"long"})," are projected estimates."]})]})]})}function PartnerCardHeader({type:t,applicationId:e,publicName:n,name:o,location:l,link:d,linkNewTab:f=!0,children:g}){const[b,S]=React.useState(!1),_=C=>{C.preventDefault(),C.stopPropagation(),navigator.clipboard.writeText(e),S(!0),setTimeout(()=>S(!1),2e3)},R=jsxRuntime.jsxs(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"h-12 w-12 overflow-hidden rounded-md",children:jsxRuntime.jsx(PartnerLogo,{id:e,width:48,height:48},`partner_logo_${e}`)}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs text-primary",children:t}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"|"}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{delayDuration:300,children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{className:"flex cursor-pointer items-center gap-1",onClick:_,children:[jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:e}),b?jsxRuntime.jsx(Check,{className:"h-3 w-3 text-green-500"}):jsxRuntime.jsx(Copy,{className:"h-3 w-3 text-muted-foreground"})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:b?"Copied!":"Copy ID"})})]})})]}),jsxRuntime.jsx("h3",{className:"font-semibold",children:n||"N/A"}),o&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:o}),l&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:l})]})]}),g&&jsxRuntime.jsx("div",{className:"flex flex-col items-end gap-2",children:g})]});return d?jsxRuntime.jsx(reactRouterDom.Link,{to:d,target:f?"_blank":"_self",children:R}):R}function ManufacturerCard({manufacturer:t,link:e,linkNewTab:n=!0,actions:o,mainAction:l,loading:d=!1,appID:f}){var Q,V,O;const{toast:g}=useToast(),[b,{isLoading:S}]=usePostV4ResellerByRouteResellerIdReportProductsEmailMutation(),[_,R]=React.useState(!1),[C,E]=React.useState(""),{data:A}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:f||""},{skip:!f}),I=A==null?void 0:A.IsReseller;if(d||!t)return jsxRuntime.jsxs(Card,{className:"flex flex-col h-full",children:[jsxRuntime.jsxs(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-12 rounded-md"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-24 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-40 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-48"})]})]}),jsxRuntime.jsx(Skeleton,{className:"h-16 w-24"})]}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsxs("div",{className:"flex flex-col space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-16 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-14 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-40"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-36"})]})]})]})}),jsxRuntime.jsxs(CardFooter,{className:"flex justify-between pt-2 gap-2 mt-auto",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-40"})]})]});const M=[t.City,t.Province,t.Country].filter(Boolean),j=M.length>0?M.join(", "):"",q=((Q=t.Tags)==null?void 0:Q.split(",").map(te=>te.trim()).filter(Boolean))||[],z=async()=>{if(!(!(t!=null&&t.ManufacturerId)||!f||!C))try{await b({routeResellerId:f,emailAddress:C,manufacturerId:t.ManufacturerId}).unwrap(),g({title:"Report requested",description:`The Universal Product List for this manufacturer will be sent to ${C} shortly.`,variant:"success"}),R(!1)}catch(te){console.error("Error requesting product list:",te),g({title:"Error",description:"Failed to request product list. Please try again.",variant:"destructive"})}};return jsxRuntime.jsxs(Card,{className:"manufacturer-theme flex flex-col h-full",children:[jsxRuntime.jsx(PartnerCardHeader,{type:"Manufacturer",applicationId:t.ManufacturerId,publicName:t.PublicName,name:t.Name,location:j,link:e,linkNewTab:n,children:jsxRuntime.jsx("div",{className:"flex flex-col items-end gap-2",children:t.SalesStatistics&&t.SalesStatistics.length>0&&jsxRuntime.jsx("div",{className:"h-16 w-24",children:jsxRuntime.jsx(SalesChart,{statistics:t.SalesStatistics,size:"mini"})})})}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsxs("div",{className:"flex",children:[jsxRuntime.jsxs("div",{className:"flex flex-col flex-1 space-y-2",children:[(!!((V=t.Qualification)!=null&&V.QualificationId)&&((O=t.Qualification)==null?void 0:O.QualificationId)!=="Suspended"||!!t.OpenToWork||!!t.OnHold&&t.OnHold!==0||q.length>0)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(QualificationBadge,{qualification:t.Qualification??{}}),!!t.OpenToWork&&jsxRuntime.jsxs(Badge,{variant:"success",children:[jsxRuntime.jsx(HardHat,{className:"h-3 w-3 mr-1"}),"Open To Work"]}),!!t.OnHold&&t.OnHold!==0&&jsxRuntime.jsx(Badge,{variant:"warning",children:"On Hold"}),q.map((te,ne)=>jsxRuntime.jsx(Badge,{variant:"outline",children:te},ne))]}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[t.Phone&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`tel:${t.Phone}`,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Phone,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:t.Phone})]}),t.PublicEmail&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`mailto:${t.PublicEmail}`,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Mail,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:t.PublicEmail})]}),t.Website&&jsxRuntime.jsxs(reactRouterDom.Link,{to:t.Website,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Globe,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:t.Website})]}),t.CurrencyCode&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(DollarSign,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:t.CurrencyCode})]})]})]}),t.SalesData&&jsxRuntime.jsxs("div",{className:"border-l pl-2 ml-2 flex flex-col text-sm",children:[jsxRuntime.jsx("strong",{className:"",children:"YTD"}),jsxRuntime.jsx("p",{children:t.SalesData.SalesYearToDay?formatMoney(t.SalesData.SalesYearToDay):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"3 mo."}),jsxRuntime.jsx("p",{children:t.SalesData.SalesLast3Months?formatMoney(t.SalesData.SalesLast3Months):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"30 days"}),jsxRuntime.jsx("p",{children:t.SalesData.SalesLast30Days?formatMoney(t.SalesData.SalesLast30Days):"—"})]})]})}),(o||l||t.PublicResourcesLink||I&&f&&t.ManufacturerId)&&jsxRuntime.jsxs(CardFooter,{className:"flex pt-2 gap-2 justify-between mt-auto",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[o&&o,I&&f&&t.ManufacturerId&&jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{size:"icon",onClick:()=>R(!0),disabled:S,children:S?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}):jsxRuntime.jsx(Download,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Email Product List"})})]})}),t.PublicResourcesLink&&jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:t.PublicResourcesLink,target:"_blank",children:jsxRuntime.jsx(Button$1,{size:"icon",children:jsxRuntime.jsx(HardDriveDownload,{className:"h-4 w-4"})})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Public Resources Link"})})]})})]}),l&&jsxRuntime.jsx("div",{children:l})]}),jsxRuntime.jsx(Dialog,{open:_,onOpenChange:R,children:jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Request Universal Product List"}),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:C,onChange:te=>E(te.target.value),placeholder:"your@email.com",className:"mt-2"})]}),jsxRuntime.jsx(DialogDescription,{children:"The report will take around 5 minutes to generate."}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>R(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:z,disabled:!C||S,children:S?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):"Send Report"})]})]})})]})}function ProductInventoryButton({applicationId:t,randmarSku:e,inventory:n,buttonSize:o="default"}){var Ve;const l=React.useRef(null),d=useIntersectionObserver({elementRef:l,threshold:.1,rootMargin:"100px",freezeOnceVisible:!0}),{toast:f}=useToast(),[g,b]=React.useState(!1),[S,_]=React.useState(!1),[R,C]=React.useState(!1),{data:E,isLoading:A,isFetching:I}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:t},{skip:!t||!d}),{data:M,isLoading:j,isFetching:q}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:t,randmarSku:e,withSpecification:!1},{skip:!!n||!d}),[z]=usePutV4ResellerByRouteResellerIdProductAndRandmarSkuRequisitionMutation(),Q=n??((Ve=M==null?void 0:M.Distribution)==null?void 0:Ve.Inventory);React.useEffect(()=>{b(!1)},[e]);const{inventoryQuantity:V,totalIncomingQuantity:O}=React.useMemo(()=>{if(!Q||Q.length===0)return{inventoryQuantity:0,totalIncomingQuantity:0};const Ne=Q.reduce((Ae,ge)=>Ae+(ge.AvailableQuantity||0),0),se=Q.reduce((Ae,ge)=>Ae+(ge.PurchaseOrderQuantity||0),0);return{inventoryQuantity:Ne,totalIncomingQuantity:se}},[Q]);if(A||I||j||q)return jsxRuntime.jsx("div",{ref:l,children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-36 rounded-md"})});const ne=()=>{R||!(E!=null&&E.IsReseller)||(C(!0),z({routeResellerId:t??"",randmarSku:e??""}).then(Ne=>{Ne.error||Ne.data===!1?f({title:"Warning",description:"Reorder is pending or requires manual approval. Contact the Randmar team for details.",variant:"warning"}):f({title:"Success",description:"Qualification successfully submitted.",variant:"success"}),_(!1)}).catch(Ne=>{console.error(Ne),f({title:"Error",description:"Error submitting your qualification.",variant:"destructive"})}).finally(()=>{C(!1)}))};if(!Q)return jsxRuntime.jsx("div",{ref:l,children:jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx("span",{tabIndex:0,children:jsxRuntime.jsxs(Button$1,{disabled:!0,size:o,variant:"outline",className:"text-sm",children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),"No data"]})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"No inventory data could be found for this product."})})]})})});if(E!=null&&E.IsReseller&&V<=0&&O<=0)return jsxRuntime.jsx("div",{ref:l,children:jsxRuntime.jsxs(Dialog,{open:S,onOpenChange:_,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{variant:"outline",size:o,className:"text-sm reseller-theme text-primary",children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),"Request to stock"]})}),jsxRuntime.jsxs(DialogContent,{className:"max-w-md",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsx(DialogTitle,{children:"Request to stock"})}),jsxRuntime.jsx("p",{className:"py-4",children:"Are you sure you want to request this product to be stocked?"}),jsxRuntime.jsxs("div",{className:"flex justify-end gap-2",children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>_(!1),disabled:R,children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:ne,disabled:R,children:R?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin mr-2"}),"Requesting..."]}):"Confirm"})]})]})]})});const ae=V<=0&&O>0;return jsxRuntime.jsx("div",{ref:l,children:jsxRuntime.jsxs(Dialog,{open:g,onOpenChange:b,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{variant:"outline",size:o,className:`text-sm ${ae?"manufacturer-theme text-primary":V>0?"text-green-700":"text-red-700"}`,children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),ae?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[formatNumber(O)," Incoming"]}):V>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[formatNumber(V)," in stock"]}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Out of stock"})]})}),jsxRuntime.jsxs(DialogContent,{className:"max-w-4xl",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsxs(DialogTitle,{className:"flex items-center",children:[jsxRuntime.jsx(Warehouse,{className:"mr-2",size:18}),"Inventory Information"]})}),jsxRuntime.jsx(ProductInventoryGrid,{inventory:Q})]})]})})}function OrdersCard({applicationId:t,orders:e=null,loading:n=!1,title:o="Order Details"}){const l=React.useMemo(()=>[{accessorKey:"OrderNumber",header:"Order Number",cell:({row:g})=>g.original.OrderNumber?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${t}/GeneralDocument/${g.original.OrderNumber}`,className:"font-medium text-primary hover:underline",children:g.original.OrderNumber})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for order ",g.original.OrderNumber]})})]})}):"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"DocumentNumber",header:"Document Number",cell:({row:g})=>g.original.DocumentNumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"DocumentDate",header:"Document Date",cell:({row:g})=>formatYYYYMMDDIntToDateString(g.original.DocumentDate),enableSorting:!0,enableFiltering:!1},{accessorKey:"PONumber",header:"PO Number",cell:({row:g})=>g.original.PONumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"WarehouseCode",header:"Warehouse",cell:({row:g})=>g.original.WarehouseCode??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"MPN",header:"MPN",cell:({row:g})=>g.original.MPN?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${t}/Product/${g.original.MPN}`,className:"font-medium text-primary hover:underline",children:g.original.MPN})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for MPN ",g.original.MPN]})})]})}):"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:g})=>g.original.Quantity??"N/A",enableSorting:!0,enableFiltering:!1},{accessorKey:"ShipToName",header:"Name",cell:({row:g})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:g.original.ShipToName??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"UnitPrice",header:"Unit Price",cell:({row:g})=>g.original.UnitPrice?formatMoney(g.original.UnitPrice):"N/A",enableSorting:!0,enableFiltering:!1},{id:"actions",header:"Actions",cell:({row:g})=>jsxRuntime.jsx("div",{className:"flex space-x-2",children:jsxRuntime.jsx(ProductInventoryButton,{applicationId:t,randmarSku:g.original.RandmarSKU??"",buttonSize:"sm"})})}],[t]),d=React.useMemo(()=>{const g={};if(e){const b=Array.from(new Set(e.map(A=>A.WarehouseCode).filter(A=>A!=null)));g.WarehouseCode=b;const S=Array.from(new Set(e.map(A=>A.ShipToName).filter(A=>A!=null)));g.ShipToName=S;const _=Array.from(new Set(e.map(A=>A.DocumentNumber).filter(A=>A!=null)));g.DocumentNumber=_;const R=Array.from(new Set(e.map(A=>A.OrderNumber).filter(A=>A!=null)));g.OrderNumber=R;const C=Array.from(new Set(e.map(A=>A.PONumber).filter(A=>A!=null)));g.PONumber=C;const E=Array.from(new Set(e.map(A=>A.MPN).filter(A=>A!=null)));g.MPN=E}return g},[e]),f=e||[];return n?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(Skeleton,{className:"h-7 w-48"})," "]}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-[130px]"}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-20"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})]})]})]})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:o})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:l,data:f,uniqueValues:d})})]})}function ResellerOverview({appID:t,reseller:e,readonly:n,userEmail:o,isSuperAdmin:l,withoutReports:d=!1}){var q,z,Q,V;const{data:f,isLoading:g,isError:b}=useGetV4PartnerByApplicationIdAccountResellerQuery({applicationId:t??"",withSpecification:!0},{skip:!!e}),[S,_]=React.useState({publicInfo:{hasUnsavedChanges:!1}}),R=React.useCallback(()=>n?!1:S.publicInfo.hasUnsavedChanges,[n,S]),C=React.useCallback((O,te)=>{_(ne=>{var ae;return((ae=ne[O])==null?void 0:ae.hasUnsavedChanges)!==te.hasUnsavedChanges?{...ne,[O]:te}:ne})},[]),{NavigationGuardDialog:E}=useRouterNavigationGuard(R),A=e??f,I=!n||!!(A!=null&&A.Statement)&&(A.Statement.Total??0)>0,M=(A==null?void 0:A.QualifiedManufacturers)??[],j=(A==null?void 0:A.Qualifications)??[];return jsxRuntime.jsxs("div",{className:"@container",children:[b?jsxRuntime.jsx(Card,{className:"p-6",children:jsxRuntime.jsxs(Alert,{variant:"destructive",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Error"}),jsxRuntime.jsx(AlertDescription,{children:"There was an error loading your reseller information. Please try again later."})]})}):jsxRuntime.jsxs("div",{className:"space-y-6 mb-6",children:[jsxRuntime.jsx(SalesSummary,{fiscalYearMonthStart:(A==null?void 0:A.FiscalYearMonthStart)||1,salesData:A==null?void 0:A.SalesData,isLoading:g}),jsxRuntime.jsxs("div",{className:"grid @lg:grid-cols-2 gap-6",children:[jsxRuntime.jsx(SalesChartCard,{statistics:(A==null?void 0:A.SalesStatistics)??[],loading:g}),jsxRuntime.jsx(OrderCategories,{openOrders:(A==null?void 0:A.ActiveOrderDetails)??[],isLoading:g}),I&&jsxRuntime.jsx(BillingCard,{appID:t,reseller:A||{},withoutReports:d,isLoading:g,userEmail:o,isSuperAdmin:l}),jsxRuntime.jsx(PublicInfo,{reseller:A||{},appID:t??"",isLoading:g,readonly:n,onUnsavedChanges:O=>C("publicInfo",{hasUnsavedChanges:O})}),jsxRuntime.jsx(AccountTier,{isSuperAdmin:l,readonly:n,reseller:A||{},appID:t??"",isLoading:g})]}),g||M.length>0?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Manufacturers you are qualified for"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid @lg:grid-cols-2 gap-4",children:g?Array.from({length:2}).map((O,te)=>jsxRuntime.jsx(ManufacturerCard,{loading:!0},te)):M.map(O=>jsxRuntime.jsx(ManufacturerCard,{manufacturer:O,link:`https://dashboard.randmar.io/${t}/Partner/${O.ManufacturerId}`},O.ManufacturerId))})})]}):j.length>0&&jsxRuntime.jsx(ResellerQualificationsCard,{qualifications:j}),(((q=A==null?void 0:A.Opportunities)==null?void 0:q.length)??0)>0&&jsxRuntime.jsx(OpportunitiesTable,{applicationId:t,opportunities:A==null?void 0:A.Opportunities,loading:g}),(((z=A==null?void 0:A.ActiveOrderDetails)==null?void 0:z.length)??0)>0&&jsxRuntime.jsx(OrdersCard,{applicationId:t,title:"Active Orders",orders:A==null?void 0:A.ActiveOrderDetails,loading:g}),(((Q=A==null?void 0:A.CompletedOrderDetails)==null?void 0:Q.length)??0)>0&&jsxRuntime.jsx(OrdersCard,{applicationId:t,title:"Completed Orders",orders:A==null?void 0:A.CompletedOrderDetails,loading:g}),(((V=A==null?void 0:A.Returns)==null?void 0:V.length)??0)>0&&jsxRuntime.jsx(ReturnsTable,{applicationId:t,returns:A==null?void 0:A.Returns,loading:g}),!d&&jsxRuntime.jsx(ReportsSection,{appID:t,userEmail:o,isLoading:g})]}),jsxRuntime.jsx(E,{})]})}const alertVariants=cva("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",success:"border-green-500/50 bg-green-50 text-green-700 dark:border-green-500 dark:bg-green-950 dark:text-green-400 [&>svg]:text-green-500",warning:"border-yellow-500/50 bg-yellow-50 text-yellow-700 dark:border-yellow-500 dark:bg-yellow-950 dark:text-yellow-400 [&>svg]:text-yellow-500",info:"border-blue-500/50 bg-blue-50 text-blue-700 dark:border-blue-500 dark:bg-blue-950 dark:text-blue-400 [&>svg]:text-blue-500"}},defaultVariants:{variant:"default"}}),Alert=React__namespace.forwardRef(({className:t,variant:e,...n},o)=>jsxRuntime.jsx("div",{ref:o,role:"alert",className:cn(alertVariants({variant:e}),t),...n}));Alert.displayName="Alert";const AlertTitle=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("h5",{ref:n,className:cn("mb-1 font-medium leading-none tracking-tight",t),...e}));AlertTitle.displayName="AlertTitle";const AlertDescription=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("text-sm [&_p]:leading-relaxed",t),...e}));AlertDescription.displayName="AlertDescription";/**
1188
1188
  * table-core
1189
1189
  *
1190
1190
  * Copyright (c) TanStack
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "randmarcomps",
3
3
  "private": false,
4
- "version": "1.396.0",
4
+ "version": "1.397.0",
5
5
  "description": "The UI library enabling speed and consistency in Randmar frontends.",
6
6
  "type": "module",
7
7
  "files": [