randmarcomps 1.248.0 → 1.250.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.
@@ -512,6 +512,14 @@ export declare interface NavRoute {
512
512
  showInNav?: boolean;
513
513
  }
514
514
 
515
+ export declare function OpportunitiesTable({ applicationId, opportunities, loading }: OpportunitiesTableProps): JSX.Element;
516
+
517
+ declare interface OpportunitiesTableProps {
518
+ applicationId: string;
519
+ opportunities?: OpportunityEntry[] | null;
520
+ loading?: boolean;
521
+ }
522
+
515
523
  export declare function PageHeader({ title, children, className }: PageHeaderProps): JSX.Element;
516
524
 
517
525
  export declare interface PageHeaderProps {
@@ -614,14 +622,6 @@ export declare interface ResellerCardProps {
614
622
  loading?: boolean;
615
623
  }
616
624
 
617
- export declare function ResellerOpportunitiesTable({ applicationId, opportunities, loading }: ResellerOpportunitiesTableProps): JSX.Element;
618
-
619
- declare interface ResellerOpportunitiesTableProps {
620
- applicationId: string;
621
- opportunities?: OpportunityEntry[] | null;
622
- loading?: boolean;
623
- }
624
-
625
625
  export declare function ResellerOverview({ appID, reseller, readonly, userEmail, isSuperAdmin, withoutReports }: IProps): JSX.Element;
626
626
 
627
627
  export declare function ResellerQualificationsCard({ qualifications, loading }: ResellerQualificationsCardProps): JSX.Element;
@@ -65764,7 +65764,7 @@ function ResellerOverview({
65764
65764
  }
65765
65765
  ),
65766
65766
  /* @__PURE__ */ jsx(
65767
- ResellerOpportunitiesTable,
65767
+ OpportunitiesTable,
65768
65768
  {
65769
65769
  applicationId: t,
65770
65770
  opportunities: A == null ? void 0 : A.Opportunities,
@@ -83963,53 +83963,63 @@ const formatDate = (t) => {
83963
83963
  return "Invalid Date";
83964
83964
  }
83965
83965
  };
83966
- function ResellerOpportunitiesTable({
83966
+ function OpportunitiesTable({
83967
83967
  applicationId: t,
83968
83968
  opportunities: e = null,
83969
83969
  loading: n = !1
83970
83970
  }) {
83971
- var j;
83972
- const { toast: o } = useToast(), [l, d] = useState({}), [f, g] = useState(!1), [b, S] = useState(""), [_, C] = useState(null), E = useCallback((te, ae, se) => {
83973
- d((ge) => ({
83974
- ...ge,
83975
- [te]: {
83976
- ...ge[te],
83977
- [ae]: se
83971
+ var te;
83972
+ const { toast: o } = useToast(), [l, d] = useState({}), [f, g] = useState(!1), [b, S] = useState(""), [_, C] = useState(null), {
83973
+ data: E
83974
+ } = useGetV4PartnerByApplicationIdAccountQuery({
83975
+ applicationId: t
83976
+ }, {
83977
+ skip: !t
83978
+ }), R = useCallback((ae, se, ge) => {
83979
+ d((oe) => ({
83980
+ ...oe,
83981
+ [ae]: {
83982
+ ...oe[ae],
83983
+ [se]: ge
83978
83984
  }
83979
83985
  }));
83980
- }, []), [R] = usePutV4ResellerByRouteResellerIdOpportunityAndManufacturerIdDefaultMutation(), A = useCallback(async (te) => {
83981
- if (!te.BidNumber) {
83986
+ }, []), [A] = usePutV4ResellerByRouteResellerIdOpportunityAndManufacturerIdDefaultMutation(), I = useCallback(async (ae) => {
83987
+ if (!(E != null && E.IsReseller)) return;
83988
+ if (!ae.BidNumber) {
83982
83989
  o({ title: "Error", description: "Bid Number is missing, cannot set default.", variant: "destructive" });
83983
83990
  return;
83984
83991
  }
83985
- const ae = te.BidNumber;
83986
- E(ae, "isSettingDefault", !0), R({
83992
+ const se = ae.BidNumber;
83993
+ R(se, "isSettingDefault", !0), A({
83987
83994
  routeResellerId: t,
83988
- manufacturerId: te.ManufacturerId ?? "",
83989
- opportunityNumber: ae
83995
+ manufacturerId: ae.ManufacturerId ?? "",
83996
+ opportunityNumber: se
83990
83997
  }).unwrap().then(() => {
83991
83998
  o({
83992
83999
  title: "Success",
83993
- description: `Opportunity "${te.OpportunityName || te.Opportunity || ae}" was successfully set as default.`,
84000
+ description: `Opportunity "${ae.OpportunityName || ae.Opportunity || se}" was successfully set as default.`,
83994
84001
  variant: "success"
83995
84002
  });
83996
- }).catch((se) => {
83997
- var ge;
83998
- console.error("Set as default error:", se), o({
84003
+ }).catch((ge) => {
84004
+ var oe;
84005
+ console.error("Set as default error:", ge), o({
83999
84006
  title: "Error",
84000
- description: ((ge = se.data) == null ? void 0 : ge.message) || se.message || "An error occurred while setting this opportunity as default.",
84007
+ description: ((oe = ge.data) == null ? void 0 : oe.message) || ge.message || "An error occurred while setting this opportunity as default.",
84001
84008
  variant: "destructive"
84002
84009
  });
84003
84010
  }).finally(() => {
84004
- E(ae, "isSettingDefault", !1);
84011
+ R(se, "isSettingDefault", !1);
84005
84012
  });
84006
- }, [t, R, o, E]), [I] = usePostV4ResellerByRouteResellerIdOpportunityAndManufacturerIdBidNumberEmailMutation(), M = useCallback((te) => {
84007
- if (!te.BidNumber) {
84008
- o({ title: "Error", description: "Bid Number is missing, cannot prepare report.", variant: "destructive" });
84009
- return;
84013
+ }, [t, A, o, R]), [M] = usePostV4ResellerByRouteResellerIdOpportunityAndManufacturerIdBidNumberEmailMutation(), O = useCallback((ae) => {
84014
+ if (E != null && E.IsReseller) {
84015
+ if (!ae.BidNumber) {
84016
+ o({ title: "Error", description: "Bid Number is missing, cannot prepare report.", variant: "destructive" });
84017
+ return;
84018
+ }
84019
+ C(ae), S(""), g(!0);
84010
84020
  }
84011
- C(te), S(""), g(!0);
84012
- }, [o]), O = useCallback(async () => {
84021
+ }, [o]), q = useCallback(async () => {
84022
+ if (!(E != null && E.IsReseller)) return;
84013
84023
  if (!_ || !_.BidNumber) {
84014
84024
  o({ title: "Error", description: "No opportunity selected or Bid Number is missing.", variant: "destructive" });
84015
84025
  return;
@@ -84018,37 +84028,37 @@ function ResellerOpportunitiesTable({
84018
84028
  o({ title: "Validation Error", description: "Please enter a valid email address.", variant: "destructive" });
84019
84029
  return;
84020
84030
  }
84021
- const te = _.BidNumber;
84022
- E(te, "isSendingReport", !0), I({
84031
+ const ae = _.BidNumber;
84032
+ R(ae, "isSendingReport", !0), M({
84023
84033
  routeResellerId: t,
84024
84034
  manufacturerId: _.ManufacturerId ?? "",
84025
- bidNumber: te,
84035
+ bidNumber: ae,
84026
84036
  emailAddress: b
84027
84037
  }).unwrap().then(() => {
84028
84038
  o({
84029
84039
  title: "Success",
84030
- description: `A report for "${_.OpportunityName || _.Opportunity || te}" was successfully sent to ${b}.`,
84040
+ description: `A report for "${_.OpportunityName || _.Opportunity || ae}" was successfully sent to ${b}.`,
84031
84041
  variant: "success"
84032
84042
  }), g(!1);
84033
- }).catch((ae) => {
84034
- var se;
84035
- console.error("Send report by email error:", ae), o({
84043
+ }).catch((se) => {
84044
+ var ge;
84045
+ console.error("Send report by email error:", se), o({
84036
84046
  title: "Error",
84037
- description: ((se = ae.data) == null ? void 0 : se.message) || ae.message || "An error occurred while sending the report by email.",
84047
+ description: ((ge = se.data) == null ? void 0 : ge.message) || se.message || "An error occurred while sending the report by email.",
84038
84048
  variant: "destructive"
84039
84049
  });
84040
84050
  }).finally(() => {
84041
- E(te, "isSendingReport", !1), f || (C(null), S(""));
84051
+ R(ae, "isSendingReport", !1), f || (C(null), S(""));
84042
84052
  });
84043
- }, [_, b, t, I, o, E, g]), q = useMemo(
84053
+ }, [_, b, t, M, o, R, g]), z = useMemo(
84044
84054
  () => [
84045
84055
  {
84046
84056
  accessorKey: "ManufacturerId",
84047
84057
  header: "Manuf.",
84048
- cell: ({ row: te }) => /* @__PURE__ */ jsx("div", { className: "w-20 h-8", children: /* @__PURE__ */ jsx(
84058
+ cell: ({ row: ae }) => /* @__PURE__ */ jsx("div", { className: "w-20 h-8", children: /* @__PURE__ */ jsx(
84049
84059
  PartnerLogo,
84050
84060
  {
84051
- id: te.original.ManufacturerId,
84061
+ id: ae.original.ManufacturerId,
84052
84062
  width: 80,
84053
84063
  height: 32
84054
84064
  }
@@ -84058,45 +84068,45 @@ function ResellerOpportunitiesTable({
84058
84068
  },
84059
84069
  {
84060
84070
  id: "opportunityDisplay",
84061
- accessorFn: (te) => te.OpportunityName || te.Opportunity,
84071
+ accessorFn: (ae) => ae.OpportunityName || ae.Opportunity,
84062
84072
  header: "Opportunity",
84063
- cell: ({ getValue: te }) => /* @__PURE__ */ jsx("div", { className: "min-w-[150px]", children: te() ?? "N/A" }),
84073
+ cell: ({ getValue: ae }) => /* @__PURE__ */ jsx("div", { className: "min-w-[150px]", children: ae() ?? "N/A" }),
84064
84074
  enableSorting: !0,
84065
84075
  enableFiltering: !0
84066
84076
  },
84067
84077
  {
84068
84078
  accessorKey: "BidNumber",
84069
84079
  header: "Bid Number",
84070
- cell: ({ row: te }) => te.original.BidNumber ?? "N/A",
84080
+ cell: ({ row: ae }) => ae.original.BidNumber ?? "N/A",
84071
84081
  enableSorting: !0,
84072
84082
  enableFiltering: !0
84073
84083
  },
84074
84084
  {
84075
84085
  id: "statusInfo",
84076
84086
  header: "Status",
84077
- cell: ({ row: te }) => {
84078
- const ae = te.original, se = ae.Active === !0, ge = getEndDateStatus(ae.EndDate);
84079
- let oe = "border-gray-400 bg-gray-100 text-gray-600 dark:border-gray-600 dark:bg-gray-800/50 dark:text-gray-400";
84080
- return ge.variant === "destructive" ? oe = "border-red-500 bg-red-100 text-red-700 dark:border-red-600 dark:bg-red-900/50 dark:text-red-400" : ge.variant === "warning" && (oe = "border-yellow-500 bg-yellow-100 text-yellow-700 dark:border-yellow-600 dark:bg-yellow-900/50 dark:text-yellow-400"), /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2 min-w-[200px]", children: [
84081
- /* @__PURE__ */ jsx(Badge, { variant: "outline", className: se ? "border-green-500 bg-green-100 text-green-700 dark:border-green-600 dark:bg-green-900/50 dark:text-green-400 font-medium" : "border-gray-400 bg-gray-100 text-gray-600 dark:border-gray-600 dark:bg-gray-800/50 dark:text-gray-400 font-medium", children: se ? "Active" : "Inactive" }),
84082
- ae.EndDate && /* @__PURE__ */ jsx(Badge, { variant: "outline", className: `${oe} font-medium`, children: ge.text }),
84087
+ cell: ({ row: ae }) => {
84088
+ const se = ae.original, ge = se.Active === !0, oe = getEndDateStatus(se.EndDate);
84089
+ let Ae = "border-gray-400 bg-gray-100 text-gray-600 dark:border-gray-600 dark:bg-gray-800/50 dark:text-gray-400";
84090
+ return oe.variant === "destructive" ? Ae = "border-red-500 bg-red-100 text-red-700 dark:border-red-600 dark:bg-red-900/50 dark:text-red-400" : oe.variant === "warning" && (Ae = "border-yellow-500 bg-yellow-100 text-yellow-700 dark:border-yellow-600 dark:bg-yellow-900/50 dark:text-yellow-400"), /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2 min-w-[200px]", children: [
84091
+ /* @__PURE__ */ jsx(Badge, { variant: "outline", className: ge ? "border-green-500 bg-green-100 text-green-700 dark:border-green-600 dark:bg-green-900/50 dark:text-green-400 font-medium" : "border-gray-400 bg-gray-100 text-gray-600 dark:border-gray-600 dark:bg-gray-800/50 dark:text-gray-400 font-medium", children: ge ? "Active" : "Inactive" }),
84092
+ se.EndDate && /* @__PURE__ */ jsx(Badge, { variant: "outline", className: `${Ae} font-medium`, children: oe.text }),
84083
84093
  /* @__PURE__ */ jsx(TooltipProvider, { delayDuration: 100, children: /* @__PURE__ */ jsxs(Tooltip$1, { children: [
84084
84094
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6 p-0 data-[state=delayed-open]:bg-accent data-[state=instant-open]:bg-accent", children: /* @__PURE__ */ jsx(Info, { className: "h-4 w-4 text-muted-foreground" }) }) }),
84085
84095
  /* @__PURE__ */ jsx(TooltipContent, { side: "top", align: "center", className: "bg-popover text-popover-foreground p-2 rounded shadow-lg", children: /* @__PURE__ */ jsxs("div", { className: "text-sm space-y-1", children: [
84086
84096
  /* @__PURE__ */ jsxs("p", { children: [
84087
84097
  /* @__PURE__ */ jsx("strong", { children: "Start:" }),
84088
84098
  " ",
84089
- formatDate(ae.StartDate)
84099
+ formatDate(se.StartDate)
84090
84100
  ] }),
84091
84101
  /* @__PURE__ */ jsxs("p", { children: [
84092
84102
  /* @__PURE__ */ jsx("strong", { children: "End:" }),
84093
84103
  " ",
84094
- formatDate(ae.EndDate)
84104
+ formatDate(se.EndDate)
84095
84105
  ] }),
84096
84106
  /* @__PURE__ */ jsxs("p", { children: [
84097
84107
  /* @__PURE__ */ jsx("strong", { children: "Updated:" }),
84098
84108
  " ",
84099
- formatDate(ae.LastUpdate)
84109
+ formatDate(se.LastUpdate)
84100
84110
  ] })
84101
84111
  ] }) })
84102
84112
  ] }) })
@@ -84107,44 +84117,46 @@ function ResellerOpportunitiesTable({
84107
84117
  {
84108
84118
  id: "actions",
84109
84119
  header: "Actions",
84110
- cell: ({ row: te }) => {
84111
- var $e, Oe;
84112
- const ae = te.original;
84113
- if (!ae.BidNumber)
84120
+ cell: ({ row: ae }) => {
84121
+ var Oe, Fe;
84122
+ const se = ae.original;
84123
+ if (!se.BidNumber)
84114
84124
  return /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: "Actions unavailable" });
84115
- const se = ae.BidNumber, ge = ($e = l[se]) == null ? void 0 : $e.isSettingDefault, oe = (_ == null ? void 0 : _.BidNumber) === se && ((Oe = l[se]) == null ? void 0 : Oe.isSendingReport), Ae = ge || oe, Ne = ae.CanBeSetAsDefault === !0;
84125
+ const ge = se.BidNumber, oe = (Oe = l[ge]) == null ? void 0 : Oe.isSettingDefault, Ae = (_ == null ? void 0 : _.BidNumber) === ge && ((Fe = l[ge]) == null ? void 0 : Fe.isSendingReport), Ne = oe || Ae, $e = se.CanBeSetAsDefault === !0;
84116
84126
  return /* @__PURE__ */ jsxs("div", { className: "flex space-x-2", children: [
84117
- /* @__PURE__ */ jsx("a", { href: `/${t}/Opportunity/${ae.ManufacturerId}/${ae.BidNumber}`, children: /* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", className: "flex items-center", children: [
84127
+ /* @__PURE__ */ jsx("a", { href: `/${t}/Opportunity/${se.ManufacturerId}/${se.BidNumber}`, children: /* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", className: "flex items-center", children: [
84118
84128
  /* @__PURE__ */ jsx(Star, { className: "mr-2 h-4 w-4" }),
84119
84129
  " View"
84120
84130
  ] }) }),
84121
- /* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", onClick: () => A(ae), disabled: Ae || !Ne, title: Ne ? "Set as default" : "This opportunity cannot be set as default", className: "flex items-center", children: [
84122
- ge ? /* @__PURE__ */ jsx(LoaderCircle, { className: "mr-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx(Star, { className: "mr-2 h-4 w-4" }),
84123
- " Set Default"
84124
- ] }),
84125
- /* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", onClick: () => M(ae), disabled: Ae, title: "Send report by email", className: "flex items-center", children: [
84126
- oe ? /* @__PURE__ */ jsx(LoaderCircle, { className: "mr-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx(Send, { className: "mr-2 h-4 w-4" }),
84127
- " Send Report"
84131
+ (E == null ? void 0 : E.IsReseller) && /* @__PURE__ */ jsxs(Fragment$1, { children: [
84132
+ /* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", onClick: () => I(se), disabled: Ne || !$e, title: $e ? "Set as default" : "This opportunity cannot be set as default", className: "flex items-center", children: [
84133
+ oe ? /* @__PURE__ */ jsx(LoaderCircle, { className: "mr-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx(Star, { className: "mr-2 h-4 w-4" }),
84134
+ " Set Default"
84135
+ ] }),
84136
+ /* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", onClick: () => O(se), disabled: Ne, title: "Send report by email", className: "flex items-center", children: [
84137
+ Ae ? /* @__PURE__ */ jsx(LoaderCircle, { className: "mr-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx(Send, { className: "mr-2 h-4 w-4" }),
84138
+ " Send Report"
84139
+ ] })
84128
84140
  ] })
84129
84141
  ] });
84130
84142
  }
84131
84143
  }
84132
84144
  ],
84133
- [l, A, M, _]
84134
- ), z = useMemo(() => {
84135
- const te = {};
84145
+ [l, I, O, _]
84146
+ ), Q = useMemo(() => {
84147
+ const ae = {};
84136
84148
  if (e) {
84137
- const ae = Array.from(
84138
- new Set(e.map((ge) => ge.ManufacturerId).filter((ge) => ge != null))
84139
- );
84140
- te.ManufacturerId = ae;
84141
84149
  const se = Array.from(
84142
- new Set(e.map((ge) => ge.OpportunityName || ge.Opportunity).filter((ge) => ge != null))
84150
+ new Set(e.map((oe) => oe.ManufacturerId).filter((oe) => oe != null))
84151
+ );
84152
+ ae.ManufacturerId = se;
84153
+ const ge = Array.from(
84154
+ new Set(e.map((oe) => oe.OpportunityName || oe.Opportunity).filter((oe) => oe != null))
84143
84155
  );
84144
- te.opportunityDisplay = se;
84156
+ ae.opportunityDisplay = ge;
84145
84157
  }
84146
- return te;
84147
- }, [e]), Q = e || [], F = _ != null && _.BidNumber ? (j = l[_.BidNumber]) == null ? void 0 : j.isSendingReport : !1;
84158
+ return ae;
84159
+ }, [e]), F = e || [], j = _ != null && _.BidNumber ? (te = l[_.BidNumber]) == null ? void 0 : te.isSendingReport : !1;
84148
84160
  return n ? /* @__PURE__ */ jsxs(Card, { className: "w-full", children: [
84149
84161
  /* @__PURE__ */ jsxs(CardHeader, { children: [
84150
84162
  " ",
@@ -84174,10 +84186,10 @@ function ResellerOpportunitiesTable({
84174
84186
  /* @__PURE__ */ jsx(CardTitle, { className: "text-1xl font-bold", children: "Opportunities" }),
84175
84187
  " "
84176
84188
  ] }),
84177
- /* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsx(DataTable, { columns: q, data: Q, uniqueValues: z }) })
84189
+ /* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsx(DataTable, { columns: z, data: F, uniqueValues: Q }) })
84178
84190
  ] }),
84179
- /* @__PURE__ */ jsx(Dialog, { open: f, onOpenChange: (te) => {
84180
- g(te), te || (C(null), S(""));
84191
+ /* @__PURE__ */ jsx(Dialog, { open: f, onOpenChange: (ae) => {
84192
+ g(ae), ae || (C(null), S(""));
84181
84193
  }, children: /* @__PURE__ */ jsxs(DialogContent, { className: "sm:max-w-[425px]", children: [
84182
84194
  /* @__PURE__ */ jsxs(DialogHeader, { children: [
84183
84195
  /* @__PURE__ */ jsx(DialogTitle, { children: "Send Opportunity Report" }),
@@ -84193,12 +84205,12 @@ function ResellerOpportunitiesTable({
84193
84205
  ] }),
84194
84206
  /* @__PURE__ */ jsx("div", { className: "grid gap-4 py-4", children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-4 items-center gap-4", children: [
84195
84207
  /* @__PURE__ */ jsx(Label$2, { htmlFor: "email", className: "text-right", children: "Email" }),
84196
- /* @__PURE__ */ jsx(Input, { id: "email", type: "email", value: b, onChange: (te) => S(te.target.value), placeholder: "recipient@example.com", className: "col-span-3", disabled: F })
84208
+ /* @__PURE__ */ jsx(Input, { id: "email", type: "email", value: b, onChange: (ae) => S(ae.target.value), placeholder: "recipient@example.com", className: "col-span-3", disabled: j })
84197
84209
  ] }) }),
84198
84210
  /* @__PURE__ */ jsxs(DialogFooter, { children: [
84199
- /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => g(!1), disabled: F, children: "Cancel" }),
84200
- /* @__PURE__ */ jsxs(Button, { type: "submit", onClick: O, disabled: F, children: [
84201
- F && /* @__PURE__ */ jsx(LoaderCircle, { className: "mr-2 h-4 w-4 animate-spin" }),
84211
+ /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => g(!1), disabled: j, children: "Cancel" }),
84212
+ /* @__PURE__ */ jsxs(Button, { type: "submit", onClick: q, disabled: j, children: [
84213
+ j && /* @__PURE__ */ jsx(LoaderCircle, { className: "mr-2 h-4 w-4 animate-spin" }),
84202
84214
  " Send Report"
84203
84215
  ] })
84204
84216
  ] })
@@ -84427,14 +84439,8 @@ function ProductOverviewPage({
84427
84439
  productCustomAction: f = /* @__PURE__ */ jsx(Fragment$1, {})
84428
84440
  }) {
84429
84441
  const {
84430
- data: g
84431
- } = useGetV4PartnerByApplicationIdAccountQuery({
84432
- applicationId: t
84433
- }, {
84434
- skip: !t || !e
84435
- }), {
84436
- data: b,
84437
- isLoading: S
84442
+ data: g,
84443
+ isLoading: b
84438
84444
  } = useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({
84439
84445
  routeApplicationId: t,
84440
84446
  randmarSku: e,
@@ -84442,22 +84448,22 @@ function ProductOverviewPage({
84442
84448
  }, {
84443
84449
  skip: !t || !e
84444
84450
  }), {
84445
- data: _,
84446
- isLoading: C
84451
+ data: S,
84452
+ isLoading: _
84447
84453
  } = useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({
84448
84454
  routeApplicationId: t,
84449
84455
  randmarSku: e,
84450
84456
  withSpecification: !0
84451
84457
  }, {
84452
- skip: !b
84453
- }), E = (b == null ? void 0 : b.ManufacturerId) !== t;
84454
- return console.log("readonly", E), /* @__PURE__ */ jsxs(Fragment$1, { children: [
84458
+ skip: !g
84459
+ }), C = (g == null ? void 0 : g.ManufacturerId) !== t;
84460
+ return console.log("readonly", C), /* @__PURE__ */ jsxs(Fragment$1, { children: [
84455
84461
  /* @__PURE__ */ jsxs("div", { className: "grid gap-4 grid-cols-1 md:grid-cols-2 lg:grid-cols-3", children: [
84456
84462
  /* @__PURE__ */ jsx("div", { className: "lg:col-span-2", children: /* @__PURE__ */ jsx(
84457
84463
  ProductCard,
84458
84464
  {
84459
84465
  applicationId: t,
84460
- product: _ || b,
84466
+ product: S || g,
84461
84467
  defaultOpportunityNumber: n,
84462
84468
  onAddToCart: o,
84463
84469
  addingToCart: l,
@@ -84465,12 +84471,12 @@ function ProductOverviewPage({
84465
84471
  customAction: f
84466
84472
  }
84467
84473
  ) }),
84468
- /* @__PURE__ */ jsxs(Card, { children: [
84474
+ /* @__PURE__ */ jsxs(Card, { className: "h-full flex flex-col", children: [
84469
84475
  /* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsxs(CardTitle, { children: [
84470
84476
  /* @__PURE__ */ jsx(Info, { className: "h-5 w-5 inline mr-2" }),
84471
- " Additionnal information"
84477
+ " Additional information"
84472
84478
  ] }) }),
84473
- /* @__PURE__ */ jsx(CardContent, { children: S ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
84479
+ /* @__PURE__ */ jsx(CardContent, { className: "flex flex-col flex-1", children: b ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
84474
84480
  /* @__PURE__ */ jsxs("div", { className: "flex justify-between", children: [
84475
84481
  /* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-32" }),
84476
84482
  /* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-24" })
@@ -84487,37 +84493,38 @@ function ProductOverviewPage({
84487
84493
  /* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-32" }),
84488
84494
  /* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-24" })
84489
84495
  ] }),
84490
- /* @__PURE__ */ jsx(Skeleton, { className: "h-1 w-full my-6" }),
84491
- /* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-24" }),
84492
- /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-full mt-2" }),
84493
- /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-full mt-1" })
84496
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col flex-1 mt-4 min-h-0", children: [
84497
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-px w-full my-2" }),
84498
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-24 mb-2" }),
84499
+ /* @__PURE__ */ jsx(Skeleton, { className: "flex-1 w-full min-h-40" })
84500
+ ] })
84494
84501
  ] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
84495
84502
  /* @__PURE__ */ jsxs("div", { className: "flex justify-between", children: [
84496
- /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "Cateory Name" }),
84497
- /* @__PURE__ */ jsx("span", { className: "font-medium", children: (b == null ? void 0 : b.ProductType) || "N/A" })
84503
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "Category Name" }),
84504
+ /* @__PURE__ */ jsx("span", { className: "font-medium", children: (g == null ? void 0 : g.ProductType) || "N/A" })
84498
84505
  ] }),
84499
84506
  /* @__PURE__ */ jsxs("div", { className: "flex justify-between mt-2", children: [
84500
84507
  /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "Master Carton" }),
84501
- /* @__PURE__ */ jsx("span", { className: "font-medium", children: (b == null ? void 0 : b.MasterCarton) || "N/A" })
84508
+ /* @__PURE__ */ jsx("span", { className: "font-medium", children: (g == null ? void 0 : g.MasterCarton) || "N/A" })
84502
84509
  ] }),
84503
84510
  /* @__PURE__ */ jsxs("div", { className: "flex justify-between mt-2", children: [
84504
84511
  /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "Skid Quantity" }),
84505
- /* @__PURE__ */ jsx("span", { className: "font-medium", children: (b == null ? void 0 : b.SkidQuantity) || "N/A" })
84512
+ /* @__PURE__ */ jsx("span", { className: "font-medium", children: (g == null ? void 0 : g.SkidQuantity) || "N/A" })
84506
84513
  ] }),
84507
84514
  /* @__PURE__ */ jsxs("div", { className: "flex justify-between mt-2", children: [
84508
84515
  /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "Automatic Reorder" }),
84509
- /* @__PURE__ */ jsx("span", { className: "font-medium", children: b != null && b.AutoUpdate ? "Yes" : "No" })
84516
+ /* @__PURE__ */ jsx("span", { className: "font-medium", children: g != null && g.AutoUpdate ? "Yes" : "No" })
84510
84517
  ] }),
84511
- ((b == null ? void 0 : b.VoiceoverCaption) || (b == null ? void 0 : b.BodyHTML)) && /* @__PURE__ */ jsxs(Fragment$1, { children: [
84512
- /* @__PURE__ */ jsx("hr", { className: "my-6" }),
84518
+ ((g == null ? void 0 : g.VoiceoverCaption) || (g == null ? void 0 : g.BodyHTML)) && /* @__PURE__ */ jsxs("div", { className: "flex flex-col flex-1 mt-4 min-h-0", children: [
84519
+ /* @__PURE__ */ jsx("hr", { className: "my-2" }),
84513
84520
  /* @__PURE__ */ jsx("div", { className: "text-muted-foreground mb-2", children: "Description" }),
84514
- /* @__PURE__ */ jsxs("div", { className: "max-h-44 overflow-scroll", children: [
84515
- (b == null ? void 0 : b.VoiceoverCaption) && /* @__PURE__ */ jsx("div", { children: b == null ? void 0 : b.VoiceoverCaption }),
84516
- (b == null ? void 0 : b.BodyHTML) && /* @__PURE__ */ jsx(
84521
+ /* @__PURE__ */ jsxs("div", { className: "flex-1 overflow-y-auto min-h-40", children: [
84522
+ (g == null ? void 0 : g.VoiceoverCaption) && /* @__PURE__ */ jsx("div", { className: "mb-2", children: g == null ? void 0 : g.VoiceoverCaption }),
84523
+ (g == null ? void 0 : g.BodyHTML) && /* @__PURE__ */ jsx(
84517
84524
  "div",
84518
84525
  {
84519
84526
  className: "prose prose-sm max-w-none",
84520
- dangerouslySetInnerHTML: { __html: (b == null ? void 0 : b.BodyHTML) ?? "" }
84527
+ dangerouslySetInnerHTML: { __html: (g == null ? void 0 : g.BodyHTML) ?? "" }
84521
84528
  }
84522
84529
  )
84523
84530
  ] })
@@ -84525,7 +84532,7 @@ function ProductOverviewPage({
84525
84532
  ] }) })
84526
84533
  ] })
84527
84534
  ] }),
84528
- /* @__PURE__ */ jsx("div", { className: "my-4", children: S ? /* @__PURE__ */ jsx("div", { className: "mx-auto flex justify-center items-center h-32", children: /* @__PURE__ */ jsx(LoaderCircle, { className: "h-8 w-8 animate-spin text-primary" }) }) : /* @__PURE__ */ jsxs(Tabs, { defaultValue: "stats", children: [
84535
+ /* @__PURE__ */ jsx("div", { className: "my-4", children: b ? /* @__PURE__ */ jsx("div", { className: "mx-auto flex justify-center items-center h-32", children: /* @__PURE__ */ jsx(LoaderCircle, { className: "h-8 w-8 animate-spin text-primary" }) }) : /* @__PURE__ */ jsxs(Tabs, { defaultValue: "stats", children: [
84529
84536
  /* @__PURE__ */ jsxs(TabsList, { className: "inline-flex h-auto items-center justify-center rounded-none border-b bg-transparent p-0", children: [
84530
84537
  /* @__PURE__ */ jsx(
84531
84538
  TabsTrigger,
@@ -84535,7 +84542,7 @@ function ProductOverviewPage({
84535
84542
  children: "Statistics"
84536
84543
  }
84537
84544
  ),
84538
- (g == null ? void 0 : g.IsReseller) && /* @__PURE__ */ jsx(
84545
+ /* @__PURE__ */ jsx(
84539
84546
  TabsTrigger,
84540
84547
  {
84541
84548
  value: "opportunities",
@@ -84563,16 +84570,16 @@ function ProductOverviewPage({
84563
84570
  /* @__PURE__ */ jsx(TabsContent, { value: "stats", children: /* @__PURE__ */ jsx("div", { className: "mt-4", children: /* @__PURE__ */ jsx(
84564
84571
  SalesChart,
84565
84572
  {
84566
- salesData: (_ == null ? void 0 : _.SalesStatistics) ?? [],
84567
- isLoading: C
84573
+ salesData: (S == null ? void 0 : S.SalesStatistics) ?? [],
84574
+ isLoading: _
84568
84575
  }
84569
84576
  ) }) }),
84570
- (g == null ? void 0 : g.IsReseller) && /* @__PURE__ */ jsx(TabsContent, { value: "opportunities", children: /* @__PURE__ */ jsx("div", { className: "mt-4", children: /* @__PURE__ */ jsx(
84571
- ResellerOpportunitiesTable,
84577
+ /* @__PURE__ */ jsx(TabsContent, { value: "opportunities", children: /* @__PURE__ */ jsx("div", { className: "mt-4", children: /* @__PURE__ */ jsx(
84578
+ OpportunitiesTable,
84572
84579
  {
84573
84580
  applicationId: t,
84574
- opportunities: b == null ? void 0 : b.Opportunities,
84575
- loading: S
84581
+ opportunities: g == null ? void 0 : g.Opportunities,
84582
+ loading: b
84576
84583
  }
84577
84584
  ) }) }),
84578
84585
  /* @__PURE__ */ jsxs(TabsContent, { value: "orders", children: [
@@ -84580,24 +84587,24 @@ function ProductOverviewPage({
84580
84587
  OrdersTable,
84581
84588
  {
84582
84589
  title: "Open Orders",
84583
- orders: _ == null ? void 0 : _.ActiveOrderDetails,
84584
- loading: C
84590
+ orders: S == null ? void 0 : S.ActiveOrderDetails,
84591
+ loading: _
84585
84592
  }
84586
84593
  ) }),
84587
84594
  /* @__PURE__ */ jsx("div", { className: "mt-4", children: /* @__PURE__ */ jsx(
84588
84595
  OrdersTable,
84589
84596
  {
84590
84597
  title: "Completed Orders",
84591
- orders: _ == null ? void 0 : _.CompletedOrderDetails,
84592
- loading: C
84598
+ orders: S == null ? void 0 : S.CompletedOrderDetails,
84599
+ loading: _
84593
84600
  }
84594
84601
  ) })
84595
84602
  ] }),
84596
84603
  /* @__PURE__ */ jsx(TabsContent, { value: "warehouse", children: /* @__PURE__ */ jsx("div", { className: "mt-4", children: /* @__PURE__ */ jsx(
84597
84604
  ReceiptsTable,
84598
84605
  {
84599
- receipts: _ == null ? void 0 : _.Receipts,
84600
- loading: C
84606
+ receipts: S == null ? void 0 : S.Receipts,
84607
+ loading: _
84601
84608
  }
84602
84609
  ) }) })
84603
84610
  ] }) })
@@ -84686,6 +84693,7 @@ export {
84686
84693
  ManufacturerReorderingCard,
84687
84694
  MultiSelect,
84688
84695
  Navbar,
84696
+ OpportunitiesTable,
84689
84697
  PageHeader,
84690
84698
  PartnerCard,
84691
84699
  PartnerRelationshipPage,
@@ -84703,7 +84711,6 @@ export {
84703
84711
  RadioGroupItem,
84704
84712
  ResellerBillingOverviewCard,
84705
84713
  ResellerCard,
84706
- ResellerOpportunitiesTable,
84707
84714
  ResellerOverview,
84708
84715
  ResellerQualificationsCard,
84709
84716
  RichTextEditor,
@@ -1061,7 +1061,7 @@ Defaulting to 2020, but this will stop working in the future.`)),e.ecmaVersion=1
1061
1061
  * LICENSE file in the root directory of this source tree.
1062
1062
  */var hasRequiredReactIs_development;function requireReactIs_development(){return hasRequiredReactIs_development||(hasRequiredReactIs_development=1,process.env.NODE_ENV!=="production"&&function(){var t=typeof Symbol=="function"&&Symbol.for,e=t?Symbol.for("react.element"):60103,n=t?Symbol.for("react.portal"):60106,o=t?Symbol.for("react.fragment"):60107,l=t?Symbol.for("react.strict_mode"):60108,d=t?Symbol.for("react.profiler"):60114,f=t?Symbol.for("react.provider"):60109,g=t?Symbol.for("react.context"):60110,b=t?Symbol.for("react.async_mode"):60111,_=t?Symbol.for("react.concurrent_mode"):60111,S=t?Symbol.for("react.forward_ref"):60112,R=t?Symbol.for("react.suspense"):60113,C=t?Symbol.for("react.suspense_list"):60120,E=t?Symbol.for("react.memo"):60115,A=t?Symbol.for("react.lazy"):60116,I=t?Symbol.for("react.block"):60121,M=t?Symbol.for("react.fundamental"):60117,j=t?Symbol.for("react.responder"):60118,q=t?Symbol.for("react.scope"):60119;function z(He){return typeof He=="string"||typeof He=="function"||He===o||He===_||He===d||He===l||He===R||He===C||typeof He=="object"&&He!==null&&(He.$$typeof===A||He.$$typeof===E||He.$$typeof===f||He.$$typeof===g||He.$$typeof===S||He.$$typeof===M||He.$$typeof===j||He.$$typeof===q||He.$$typeof===I)}function Q(He){if(typeof He=="object"&&He!==null){var Rt=He.$$typeof;switch(Rt){case e:var Je=He.type;switch(Je){case b:case _:case o:case d:case l:case R:return Je;default:var mt=Je&&Je.$$typeof;switch(mt){case g:case S:case A:case E:case f:return mt;default:return Rt}}case n:return Rt}}}var F=b,V=_,te=g,ae=f,se=e,ge=S,oe=o,Ae=A,Ne=E,je=n,$e=d,Fe=l,Ue=R,Ve=!1;function Le(He){return Ve||(Ve=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),qe(He)||Q(He)===b}function qe(He){return Q(He)===_}function Ke(He){return Q(He)===g}function ze(He){return Q(He)===f}function Qe(He){return typeof He=="object"&&He!==null&&He.$$typeof===e}function tt(He){return Q(He)===S}function Ye(He){return Q(He)===o}function et(He){return Q(He)===A}function Xe(He){return Q(He)===E}function at(He){return Q(He)===n}function rt(He){return Q(He)===d}function it(He){return Q(He)===l}function st(He){return Q(He)===R}reactIs_development.AsyncMode=F,reactIs_development.ConcurrentMode=V,reactIs_development.ContextConsumer=te,reactIs_development.ContextProvider=ae,reactIs_development.Element=se,reactIs_development.ForwardRef=ge,reactIs_development.Fragment=oe,reactIs_development.Lazy=Ae,reactIs_development.Memo=Ne,reactIs_development.Portal=je,reactIs_development.Profiler=$e,reactIs_development.StrictMode=Fe,reactIs_development.Suspense=Ue,reactIs_development.isAsyncMode=Le,reactIs_development.isConcurrentMode=qe,reactIs_development.isContextConsumer=Ke,reactIs_development.isContextProvider=ze,reactIs_development.isElement=Qe,reactIs_development.isForwardRef=tt,reactIs_development.isFragment=Ye,reactIs_development.isLazy=et,reactIs_development.isMemo=Xe,reactIs_development.isPortal=at,reactIs_development.isProfiler=rt,reactIs_development.isStrictMode=it,reactIs_development.isSuspense=st,reactIs_development.isValidElementType=z,reactIs_development.typeOf=Q}()),reactIs_development}var hasRequiredReactIs;function requireReactIs(){return hasRequiredReactIs||(hasRequiredReactIs=1,process.env.NODE_ENV==="production"?reactIs.exports=requireReactIs_production_min():reactIs.exports=requireReactIs_development()),reactIs.exports}var hoistNonReactStatics_cjs,hasRequiredHoistNonReactStatics_cjs;function requireHoistNonReactStatics_cjs(){if(hasRequiredHoistNonReactStatics_cjs)return hoistNonReactStatics_cjs;hasRequiredHoistNonReactStatics_cjs=1;var t=requireReactIs(),e={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},n={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},o={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},l={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},d={};d[t.ForwardRef]=o,d[t.Memo]=l;function f(A){return t.isMemo(A)?l:d[A.$$typeof]||e}var g=Object.defineProperty,b=Object.getOwnPropertyNames,_=Object.getOwnPropertySymbols,S=Object.getOwnPropertyDescriptor,R=Object.getPrototypeOf,C=Object.prototype;function E(A,I,M){if(typeof I!="string"){if(C){var j=R(I);j&&j!==C&&E(A,j,M)}var q=b(I);_&&(q=q.concat(_(I)));for(var z=f(A),Q=f(I),F=0;F<q.length;++F){var V=q[F];if(!n[V]&&!(M&&M[V])&&!(Q&&Q[V])&&!(z&&z[V])){var te=S(I,V);try{g(A,V,te)}catch{}}}}return A}return hoistNonReactStatics_cjs=E,hoistNonReactStatics_cjs}requireHoistNonReactStatics_cjs();var IntlContext=typeof window<"u"&&!window.__REACT_INTL_BYPASS_GLOBAL_CONTEXT__?window.__REACT_INTL_CONTEXT__||(window.__REACT_INTL_CONTEXT__=React__namespace.createContext(null)):React__namespace.createContext(null);IntlContext.Consumer,IntlContext.Provider;var Context=IntlContext;function useIntl(){var t=React__namespace.useContext(Context);return invariantIntlContext(t),t}var DisplayName;(function(t){t.formatDate="FormattedDate",t.formatTime="FormattedTime",t.formatNumber="FormattedNumber",t.formatList="FormattedList",t.formatDisplayName="FormattedDisplayName"})(DisplayName||(DisplayName={}));var DisplayNameParts;(function(t){t.formatDate="FormattedDateParts",t.formatTime="FormattedTimeParts",t.formatNumber="FormattedNumberParts",t.formatList="FormattedListParts"})(DisplayNameParts||(DisplayNameParts={}));function createFormattedDateTimePartsComponent(t){var e=function(n){var o=useIntl(),l=n.value,d=n.children,f=__rest(n,["value","children"]),g=typeof l=="string"?new Date(l||0):l,b=t==="formatDate"?o.formatDateToParts(g,f):o.formatTimeToParts(g,f);return d(b)};return e.displayName=DisplayNameParts[t],e}function createFormattedComponent(t){var e=function(n){var o=useIntl(),l=n.value,d=n.children,f=__rest(n,["value","children"]),g=o[t](l,f);if(typeof d=="function")return d(g);var b=o.textComponent||React__namespace.Fragment;return React__namespace.createElement(b,null,g)};return e.displayName=DisplayName[t],e}createFormattedComponent("formatDate"),createFormattedComponent("formatTime");var FormattedNumber=createFormattedComponent("formatNumber");createFormattedComponent("formatList"),createFormattedComponent("formatDisplayName"),createFormattedDateTimePartsComponent("formatDate"),createFormattedDateTimePartsComponent("formatTime");function BillingCard({appID:t,reseller:e,isLoading:n,withoutReports:o}){const{Statement:l,CreditLimit:d}=e,f=[{label:"0 - 30 Days",value:jsxRuntime.jsx(FormattedNumber,{value:(l==null?void 0:l.Over0)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:Calendar},{label:"31 - 45 Days",value:jsxRuntime.jsx(FormattedNumber,{value:(l==null?void 0:l.Over30)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:CalendarDays},{label:"45+ Days",value:jsxRuntime.jsx(FormattedNumber,{value:(l==null?void 0:l.Over45)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:CalendarRange},{label:"Total",value:jsxRuntime.jsx(FormattedNumber,{value:(l==null?void 0:l.Total)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:DollarSign},{label:"Credit Limit",value:jsxRuntime.jsx(FormattedNumber,{value:d||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:CreditCard}],g=()=>{const _=`https://dashboard.randmar.io/${t}/PayInvoice`;window.open(_,"_blank","noopener,noreferrer")};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(_=>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"})]},_))}),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(_=>jsxRuntime.jsx("div",{className:_===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"})]})},_))})]}),jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-28 mt-6"})})]})]});const b=!o;return 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:f.slice(0,3).map((_,S)=>jsxRuntime.jsx(BillingItem,{icon:_.icon,label:_.label,value:_.value},S))}),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:f.slice(3).map((_,S)=>jsxRuntime.jsx("div",{className:S===1?"pt-6 mt-6 border-t border-border":"",children:jsxRuntime.jsx(BillingItem,{icon:_.icon,label:_.label,value:_.value})},S))})]}),b&&jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx(Button,{className:"mt-6",onClick:g,children:"Pay Invoices"})})]})]})}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,{variant:"outline",onClick:d,disabled:l,children:"Cancel"}),jsxRuntime.jsx(Button,{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,
1063
1063
  $15 for drop shipped orders under $1,500,
1064
- $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,_]=React.useState(""),[S,{isLoading:R}]=usePostV4PartnerByApplicationIdAccountResellerAndFieldNameMutation(),C=$e=>$e&&{Starter:"starter","E-Commerce":"ecommerce",Commercial:"commercial",Basics:"cws",Novexco:"novexco","Jean Coutu":"jeancoutu",Exclusive:"exclusive"}[$e]||"",E=$e=>$e&&{A:"free",B:"fixed",C:"dropshipped",D:"under1500",E:"fullcharges"}[$e]||"",A=$e=>$e&&{1:"exclusive",2:"ecommerce",3:"commercial",4:"buyinggroup",5:"cost"}[$e]||"",[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)),F=$e=>({starter:"Starter",ecommerce:"E-Commerce",commercial:"Commercial",cws:"Basics",novexco:"Novexco",jeancoutu:"Jean Coutu",exclusive:"Exclusive"})[$e]||$e,V=$e=>({free:"A",fixed:"B",dropshipped:"C",under1500:"D",fullcharges:"E"})[$e]||$e,te=$e=>({exclusive:"1",ecommerce:"2",commercial:"3",buyinggroup:"4",cost:"5"})[$e]||$e;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 ae=async($e,Fe,Ue,Ve)=>{try{(await S({applicationId:o,fieldName:$e,newValue:Fe})).error?d({title:"Error",description:Ve,variant:"destructive"}):d({title:"Success",description:Ue,variant:"success"})}catch{d({title:"Error",description:"An unexpected error occurred",variant:"destructive"})}},se=async $e=>{M($e);const Fe=F($e);ae("Priority",Fe,`Priority updated to ${Fe}`,"Failed to update priority")},ge=async $e=>{q($e);const Fe=V($e);ae("ShippingProfile",Fe,`Shipping profile updated to ${Fe}`,"Failed to update shipping profile")},oe=async $e=>{Q($e);const Fe=te($e);ae("PriceProfile",Fe,`Pricing profile updated to ${Fe}`,"Failed to update pricing profile")},Ae=async()=>{try{const $e=await S({applicationId:o,fieldName:"Tier",newValue:b});$e.error?d({title:"Error",description:"Failed to update reseller",variant:"destructive"}):$e.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),_("")}},Ne=[{name:"Terms",enabled:n.Priority==="Starter"},{name:"E-Commerce",enabled:n.Priority==="Commercial"},{name:"Commercial",enabled:n.Priority==="E-Commerce"},{name:"Exclusive",enabled:t}],je=$e=>{_($e),g(!0)};return l?jsxRuntime.jsxs(Card,{className:"md:col-span-2 xl:col-span-1 md:max-w-xl xl:max-w-[unset]",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($e=>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"})]})]},$e))}),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:"md:col-span-2 xl:col-span-1 md:max-w-xl xl:max-w-[unset]",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,{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,{variant:"outline",className:"flex-1",asChild:!0,children:jsxRuntime.jsxs("a",{href:"https://www.randmar.io/docs/overview/pricingTiers",target:"_blank",rel:"noreferrer",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,{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"}),Ne.map($e=>jsxRuntime.jsx(Button,{variant:"ghost",size:"sm",className:"w-full justify-start h-8",disabled:!$e.enabled,onClick:()=>je($e.name),children:$e.name},$e.name))]})})]})]})]})]}),jsxRuntime.jsx(ChangePricingTierModal,{isLoading:R,open:f,setOpen:g,tier:b,onTierChange:Ae}),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:se,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($e=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:$e.value,id:`priority-${$e.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`priority-${$e.value}`,className:"cursor-pointer text-xs",children:$e.label})]},$e.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:ge,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($e=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:$e.value,id:`shipping-${$e.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`shipping-${$e.value}`,className:"cursor-pointer text-xs",children:$e.label})]},$e.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:oe,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($e=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:$e.value,id:`pricing-${$e.value}`,className:"h-6 w-6 scale-50 antialiased"}),jsxRuntime.jsx(Label$2,{htmlFor:`pricing-${$e.value}`,className:"cursor-pointer text-xs",children:$e.label})]},$e.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),_=g.reduce((I,M)=>I+(M.ExtendedPrice??0),0),S=o.reduce((I,M)=>I+(M.Quantity??0),0),R=o.reduce((I,M)=>I+(M.ExtendedPrice??0),0),C=d+b+S,E=f+_+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:S,amount:R},{name:"Delayed",icon:CircleAlert,color:"bg-red-500",orders:b,amount:_}];return e?jsxRuntime.jsxs(Card,{className:"w-full md:col-span-2 xl:col-span-1",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 md:col-span-2 xl:col-span-1",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 LongMonthName(t){if(!t)return;const e=["","January","February","March","April","May","June","July","August","September","October","November","December"];return t===void 0&&(t=new Date().getMonth()+1),t<1&&(t=12+t),e[t]}function SalesSummary({fiscalYearMonthStart:t,salesData:e,isLoading:n}){const o=(e==null?void 0:e.SalesLast30Days)??0,l=(e==null?void 0:e.SalesLast3Months)??0,d=(e==null?void 0:e.SalesYearToDay)??0,f=LongMonthName(t);return n?jsxRuntime.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3 mb-4",children:[jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-8 w-8 rounded-full"})]}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-32 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-24"})]})]}),jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-28"}),jsxRuntime.jsx(Skeleton,{className:"h-8 w-8 rounded-full"})]}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-32 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-24"})]})]}),jsxRuntime.jsxs(Card,{className:"col-span-2 lg:col-span-1",children:[jsxRuntime.jsxs(CardHeader,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-36"}),jsxRuntime.jsx(Skeleton,{className:"h-8 w-8 rounded-full"})]}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-32 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-24"})]})]})]}):jsxRuntime.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3 mb-4",children:[jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[jsxRuntime.jsx(CardTitle,{className:"text-sm font-medium",children:"Last 30 Days"}),jsxRuntime.jsx("div",{className:"p-2 rounded-full bg-neutral-200",children:jsxRuntime.jsx(TrendingUp,{className:"size-4 shrink-0 text-muted-foreground"})})]}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsx("div",{className:"text-2xl font-bold",children:jsxRuntime.jsx(FormattedNumber,{value:o,style:"currency",currency:"CAD",currencyDisplay:"symbol"})}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground"})]})]}),jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[jsxRuntime.jsx(CardTitle,{className:"text-sm font-medium",children:"Last 3 Months"}),jsxRuntime.jsx("div",{className:"p-2 rounded-full bg-neutral-200",children:jsxRuntime.jsx(Calendar,{className:"size-4 shrink-0 text-muted-foreground"})})]}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsx("div",{className:"text-2xl font-bold",children:jsxRuntime.jsx(FormattedNumber,{value:l,style:"currency",currency:"CAD",currencyDisplay:"symbol"})}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground"})]})]}),f&&jsxRuntime.jsxs(Card,{className:"col-span-2 lg:col-span-1",children:[jsxRuntime.jsxs(CardHeader,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[jsxRuntime.jsxs(CardTitle,{className:"text-sm font-medium",children:["Year to Date (",f,")"]}),jsxRuntime.jsx("div",{className:"p-2 rounded-full bg-neutral-200",children:jsxRuntime.jsx(CalendarDays,{className:"size-4 shrink-0 text-muted-foreground"})})]}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsx("div",{className:"text-2xl font-bold",children:jsxRuntime.jsx(FormattedNumber,{value:d,style:"currency",currency:"CAD",currencyDisplay:"symbol"})}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground"})]})]})]})}function ReportsSection({isLoading:t,userEmail:e,appID:n}){const{toast:o}=useToast(),[l,{isLoading:d}]=usePostV4ResellerByRouteResellerIdReportWalmartTrackingFileEmailMutation(),[f,{isLoading:g}]=usePostV4ResellerByRouteResellerIdReportAmazonTrackingFileEmailMutation(),[b,{isLoading:_}]=usePostV4ResellerByRouteResellerIdReportOpenOrdersEmailMutation(),[S,{isLoading:R}]=usePostV4ResellerByRouteResellerIdReportProductsEmailMutation(),[C,{isLoading:E}]=usePostV4ResellerByRouteResellerIdReportInvoicesEmailMutation(),[A,{isLoading:I}]=usePostV4ResellerByRouteResellerIdDocumentStatementEmailMutation(),[M,j]=React.useState(null),[q,z]=React.useState(e),[Q,F]=React.useState(!1),V=[{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}]}],te=async ge=>{j(ge),F(!0)},ae=async()=>{if(!(!M||!n))try{switch(M.id){case"Products":await S({routeResellerId:n,emailAddress:q}).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"}),F(!1)}catch(ge){console.error("Error requesting report:",ge),o({title:"Error",description:"Failed to request report. Please try again.",variant:"destructive"})}},se=_||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(oe=>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"})]},oe))]},ge))}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:V.map(ge=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx("h3",{className:"text-sm font-semibold",children:ge.name}),ge.reports.map(oe=>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(oe.icon,{className:"h-5 w-5 text-primary"})}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx("h4",{className:"font-semibold text-sm",children:oe.title}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:oe.description})]}),jsxRuntime.jsxs(Button,{variant:"outline",size:"sm",className:"flex items-center gap-1",onClick:()=>te(oe),children:[jsxRuntime.jsx(Download,{className:"h-4 w-4"}),"Request"]})]},oe.id))]},ge.name))})}),jsxRuntime.jsx(Dialog,{open:Q,onOpenChange:F,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"})]}),jsxRuntime.jsx(DialogDescription,{children:"The report will take around 5 minutes to generate."}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button,{variant:"outline",onClick:()=>F(!1),children:"Cancel"}),jsxRuntime.jsx(Button,{onClick:ae,disabled:!q||se,children:se?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):"Send Report"})]})]})})]})}function UnsavedChangesDialog({isOpen:t,onClose:e,onConfirm:n,title:o,description:l,confirmText:d="Confirm",cancelText:f="Cancel"}){return jsxRuntime.jsx(Dialog,{open:t,onOpenChange:e,children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[425px]",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:o}),jsxRuntime.jsx(DialogDescription,{children:l})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button,{variant:"outline",onClick:e,children:f}),jsxRuntime.jsx(Button,{onClick:n,children:d})]})]})})}function useRouterNavigationGuard(t){const[e,n]=React.useState(!1),o=reactRouterDom.useBlocker(React.useCallback(({currentLocation:g,nextLocation:b})=>{const _=g.pathname!==b.pathname||g.search!==b.search||g.hash!==b.hash;return t()&&_},[t]));React.useEffect(()=>{o.state==="blocked"&&n(!0)},[o]),React.useEffect(()=>{const g=b=>{if(t())return b.preventDefault(),"You have unsaved changes. Are you sure you want to leave?"};return window.addEventListener("beforeunload",g),()=>{window.removeEventListener("beforeunload",g)}},[t]);const l=React.useCallback(()=>{n(!1),o.state==="blocked"&&o.proceed()},[o]),d=React.useCallback(()=>{n(!1),o.state==="blocked"&&o.reset()},[o]),f=React.useCallback(()=>jsxRuntime.jsx(UnsavedChangesDialog,{isOpen:e,onClose:d,onConfirm:l,title:"Unsaved Changes",description:"You have unsaved changes. Are you sure you want to leave? Your changes will be lost.",confirmText:"Discard Changes",cancelText:"Stay on Page"}),[e,d,l]);return{showDialog:e,handleConfirm:l,handleCancel:d,NavigationGuardDialog:f}}function ResellerOverview({appID:t,reseller:e,readonly:n,userEmail:o,isSuperAdmin:l,withoutReports:d=!1}){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:_.publicInfo.hasUnsavedChanges,[n,_]),C=React.useCallback((q,z)=>{S(Q=>{var F;return((F=Q[q])==null?void 0:F.hasUnsavedChanges)!==z.hasUnsavedChanges?{...Q,[q]:z}:Q})},[]),{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(jsxRuntime.Fragment,{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 grid-cols-1 lg:grid-cols-2 gap-6",children:[jsxRuntime.jsx(SalesChart,{salesData:(A==null?void 0:A.SalesStatistics)??[],isLoading: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}),jsxRuntime.jsx(PublicInfo,{reseller:A||{},appID:t??"",isLoading:g,readonly:n,onUnsavedChanges:q=>C("publicInfo",{hasUnsavedChanges:q})}),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 grid-cols-1 md:grid-cols-2 gap-4",children:g?Array.from({length:2}).map((q,z)=>jsxRuntime.jsx(ManufacturerCard,{loading:!0},z)):M.map(q=>jsxRuntime.jsx(ManufacturerCard,{manufacturer:q,link:`https://dashboard.randmar.io/${t}/Partner/${q.ManufacturerId}`},q.ManufacturerId))})})]}):jsxRuntime.jsx(ResellerQualificationsCard,{qualifications:j}),jsxRuntime.jsx(ResellerOpportunitiesTable,{applicationId:t,opportunities:A==null?void 0:A.Opportunities,loading:g}),!d&&jsxRuntime.jsx(ReportsSection,{appID:t,userEmail:o,isLoading:g})]}),jsxRuntime.jsx(E,{})]})}/**
1064
+ $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,_]=React.useState(""),[S,{isLoading:R}]=usePostV4PartnerByApplicationIdAccountResellerAndFieldNameMutation(),C=$e=>$e&&{Starter:"starter","E-Commerce":"ecommerce",Commercial:"commercial",Basics:"cws",Novexco:"novexco","Jean Coutu":"jeancoutu",Exclusive:"exclusive"}[$e]||"",E=$e=>$e&&{A:"free",B:"fixed",C:"dropshipped",D:"under1500",E:"fullcharges"}[$e]||"",A=$e=>$e&&{1:"exclusive",2:"ecommerce",3:"commercial",4:"buyinggroup",5:"cost"}[$e]||"",[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)),F=$e=>({starter:"Starter",ecommerce:"E-Commerce",commercial:"Commercial",cws:"Basics",novexco:"Novexco",jeancoutu:"Jean Coutu",exclusive:"Exclusive"})[$e]||$e,V=$e=>({free:"A",fixed:"B",dropshipped:"C",under1500:"D",fullcharges:"E"})[$e]||$e,te=$e=>({exclusive:"1",ecommerce:"2",commercial:"3",buyinggroup:"4",cost:"5"})[$e]||$e;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 ae=async($e,Fe,Ue,Ve)=>{try{(await S({applicationId:o,fieldName:$e,newValue:Fe})).error?d({title:"Error",description:Ve,variant:"destructive"}):d({title:"Success",description:Ue,variant:"success"})}catch{d({title:"Error",description:"An unexpected error occurred",variant:"destructive"})}},se=async $e=>{M($e);const Fe=F($e);ae("Priority",Fe,`Priority updated to ${Fe}`,"Failed to update priority")},ge=async $e=>{q($e);const Fe=V($e);ae("ShippingProfile",Fe,`Shipping profile updated to ${Fe}`,"Failed to update shipping profile")},oe=async $e=>{Q($e);const Fe=te($e);ae("PriceProfile",Fe,`Pricing profile updated to ${Fe}`,"Failed to update pricing profile")},Ae=async()=>{try{const $e=await S({applicationId:o,fieldName:"Tier",newValue:b});$e.error?d({title:"Error",description:"Failed to update reseller",variant:"destructive"}):$e.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),_("")}},Ne=[{name:"Terms",enabled:n.Priority==="Starter"},{name:"E-Commerce",enabled:n.Priority==="Commercial"},{name:"Commercial",enabled:n.Priority==="E-Commerce"},{name:"Exclusive",enabled:t}],je=$e=>{_($e),g(!0)};return l?jsxRuntime.jsxs(Card,{className:"md:col-span-2 xl:col-span-1 md:max-w-xl xl:max-w-[unset]",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($e=>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"})]})]},$e))}),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:"md:col-span-2 xl:col-span-1 md:max-w-xl xl:max-w-[unset]",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,{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,{variant:"outline",className:"flex-1",asChild:!0,children:jsxRuntime.jsxs("a",{href:"https://www.randmar.io/docs/overview/pricingTiers",target:"_blank",rel:"noreferrer",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,{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"}),Ne.map($e=>jsxRuntime.jsx(Button,{variant:"ghost",size:"sm",className:"w-full justify-start h-8",disabled:!$e.enabled,onClick:()=>je($e.name),children:$e.name},$e.name))]})})]})]})]})]}),jsxRuntime.jsx(ChangePricingTierModal,{isLoading:R,open:f,setOpen:g,tier:b,onTierChange:Ae}),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:se,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($e=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:$e.value,id:`priority-${$e.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`priority-${$e.value}`,className:"cursor-pointer text-xs",children:$e.label})]},$e.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:ge,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($e=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:$e.value,id:`shipping-${$e.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`shipping-${$e.value}`,className:"cursor-pointer text-xs",children:$e.label})]},$e.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:oe,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($e=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:$e.value,id:`pricing-${$e.value}`,className:"h-6 w-6 scale-50 antialiased"}),jsxRuntime.jsx(Label$2,{htmlFor:`pricing-${$e.value}`,className:"cursor-pointer text-xs",children:$e.label})]},$e.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),_=g.reduce((I,M)=>I+(M.ExtendedPrice??0),0),S=o.reduce((I,M)=>I+(M.Quantity??0),0),R=o.reduce((I,M)=>I+(M.ExtendedPrice??0),0),C=d+b+S,E=f+_+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:S,amount:R},{name:"Delayed",icon:CircleAlert,color:"bg-red-500",orders:b,amount:_}];return e?jsxRuntime.jsxs(Card,{className:"w-full md:col-span-2 xl:col-span-1",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 md:col-span-2 xl:col-span-1",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 LongMonthName(t){if(!t)return;const e=["","January","February","March","April","May","June","July","August","September","October","November","December"];return t===void 0&&(t=new Date().getMonth()+1),t<1&&(t=12+t),e[t]}function SalesSummary({fiscalYearMonthStart:t,salesData:e,isLoading:n}){const o=(e==null?void 0:e.SalesLast30Days)??0,l=(e==null?void 0:e.SalesLast3Months)??0,d=(e==null?void 0:e.SalesYearToDay)??0,f=LongMonthName(t);return n?jsxRuntime.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3 mb-4",children:[jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-8 w-8 rounded-full"})]}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-32 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-24"})]})]}),jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-28"}),jsxRuntime.jsx(Skeleton,{className:"h-8 w-8 rounded-full"})]}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-32 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-24"})]})]}),jsxRuntime.jsxs(Card,{className:"col-span-2 lg:col-span-1",children:[jsxRuntime.jsxs(CardHeader,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-36"}),jsxRuntime.jsx(Skeleton,{className:"h-8 w-8 rounded-full"})]}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-32 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-24"})]})]})]}):jsxRuntime.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3 mb-4",children:[jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[jsxRuntime.jsx(CardTitle,{className:"text-sm font-medium",children:"Last 30 Days"}),jsxRuntime.jsx("div",{className:"p-2 rounded-full bg-neutral-200",children:jsxRuntime.jsx(TrendingUp,{className:"size-4 shrink-0 text-muted-foreground"})})]}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsx("div",{className:"text-2xl font-bold",children:jsxRuntime.jsx(FormattedNumber,{value:o,style:"currency",currency:"CAD",currencyDisplay:"symbol"})}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground"})]})]}),jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[jsxRuntime.jsx(CardTitle,{className:"text-sm font-medium",children:"Last 3 Months"}),jsxRuntime.jsx("div",{className:"p-2 rounded-full bg-neutral-200",children:jsxRuntime.jsx(Calendar,{className:"size-4 shrink-0 text-muted-foreground"})})]}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsx("div",{className:"text-2xl font-bold",children:jsxRuntime.jsx(FormattedNumber,{value:l,style:"currency",currency:"CAD",currencyDisplay:"symbol"})}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground"})]})]}),f&&jsxRuntime.jsxs(Card,{className:"col-span-2 lg:col-span-1",children:[jsxRuntime.jsxs(CardHeader,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[jsxRuntime.jsxs(CardTitle,{className:"text-sm font-medium",children:["Year to Date (",f,")"]}),jsxRuntime.jsx("div",{className:"p-2 rounded-full bg-neutral-200",children:jsxRuntime.jsx(CalendarDays,{className:"size-4 shrink-0 text-muted-foreground"})})]}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsx("div",{className:"text-2xl font-bold",children:jsxRuntime.jsx(FormattedNumber,{value:d,style:"currency",currency:"CAD",currencyDisplay:"symbol"})}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground"})]})]})]})}function ReportsSection({isLoading:t,userEmail:e,appID:n}){const{toast:o}=useToast(),[l,{isLoading:d}]=usePostV4ResellerByRouteResellerIdReportWalmartTrackingFileEmailMutation(),[f,{isLoading:g}]=usePostV4ResellerByRouteResellerIdReportAmazonTrackingFileEmailMutation(),[b,{isLoading:_}]=usePostV4ResellerByRouteResellerIdReportOpenOrdersEmailMutation(),[S,{isLoading:R}]=usePostV4ResellerByRouteResellerIdReportProductsEmailMutation(),[C,{isLoading:E}]=usePostV4ResellerByRouteResellerIdReportInvoicesEmailMutation(),[A,{isLoading:I}]=usePostV4ResellerByRouteResellerIdDocumentStatementEmailMutation(),[M,j]=React.useState(null),[q,z]=React.useState(e),[Q,F]=React.useState(!1),V=[{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}]}],te=async ge=>{j(ge),F(!0)},ae=async()=>{if(!(!M||!n))try{switch(M.id){case"Products":await S({routeResellerId:n,emailAddress:q}).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"}),F(!1)}catch(ge){console.error("Error requesting report:",ge),o({title:"Error",description:"Failed to request report. Please try again.",variant:"destructive"})}},se=_||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(oe=>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"})]},oe))]},ge))}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:V.map(ge=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx("h3",{className:"text-sm font-semibold",children:ge.name}),ge.reports.map(oe=>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(oe.icon,{className:"h-5 w-5 text-primary"})}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx("h4",{className:"font-semibold text-sm",children:oe.title}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:oe.description})]}),jsxRuntime.jsxs(Button,{variant:"outline",size:"sm",className:"flex items-center gap-1",onClick:()=>te(oe),children:[jsxRuntime.jsx(Download,{className:"h-4 w-4"}),"Request"]})]},oe.id))]},ge.name))})}),jsxRuntime.jsx(Dialog,{open:Q,onOpenChange:F,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"})]}),jsxRuntime.jsx(DialogDescription,{children:"The report will take around 5 minutes to generate."}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button,{variant:"outline",onClick:()=>F(!1),children:"Cancel"}),jsxRuntime.jsx(Button,{onClick:ae,disabled:!q||se,children:se?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):"Send Report"})]})]})})]})}function UnsavedChangesDialog({isOpen:t,onClose:e,onConfirm:n,title:o,description:l,confirmText:d="Confirm",cancelText:f="Cancel"}){return jsxRuntime.jsx(Dialog,{open:t,onOpenChange:e,children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[425px]",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:o}),jsxRuntime.jsx(DialogDescription,{children:l})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button,{variant:"outline",onClick:e,children:f}),jsxRuntime.jsx(Button,{onClick:n,children:d})]})]})})}function useRouterNavigationGuard(t){const[e,n]=React.useState(!1),o=reactRouterDom.useBlocker(React.useCallback(({currentLocation:g,nextLocation:b})=>{const _=g.pathname!==b.pathname||g.search!==b.search||g.hash!==b.hash;return t()&&_},[t]));React.useEffect(()=>{o.state==="blocked"&&n(!0)},[o]),React.useEffect(()=>{const g=b=>{if(t())return b.preventDefault(),"You have unsaved changes. Are you sure you want to leave?"};return window.addEventListener("beforeunload",g),()=>{window.removeEventListener("beforeunload",g)}},[t]);const l=React.useCallback(()=>{n(!1),o.state==="blocked"&&o.proceed()},[o]),d=React.useCallback(()=>{n(!1),o.state==="blocked"&&o.reset()},[o]),f=React.useCallback(()=>jsxRuntime.jsx(UnsavedChangesDialog,{isOpen:e,onClose:d,onConfirm:l,title:"Unsaved Changes",description:"You have unsaved changes. Are you sure you want to leave? Your changes will be lost.",confirmText:"Discard Changes",cancelText:"Stay on Page"}),[e,d,l]);return{showDialog:e,handleConfirm:l,handleCancel:d,NavigationGuardDialog:f}}function ResellerOverview({appID:t,reseller:e,readonly:n,userEmail:o,isSuperAdmin:l,withoutReports:d=!1}){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:_.publicInfo.hasUnsavedChanges,[n,_]),C=React.useCallback((q,z)=>{S(Q=>{var F;return((F=Q[q])==null?void 0:F.hasUnsavedChanges)!==z.hasUnsavedChanges?{...Q,[q]:z}:Q})},[]),{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(jsxRuntime.Fragment,{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 grid-cols-1 lg:grid-cols-2 gap-6",children:[jsxRuntime.jsx(SalesChart,{salesData:(A==null?void 0:A.SalesStatistics)??[],isLoading: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}),jsxRuntime.jsx(PublicInfo,{reseller:A||{},appID:t??"",isLoading:g,readonly:n,onUnsavedChanges:q=>C("publicInfo",{hasUnsavedChanges:q})}),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 grid-cols-1 md:grid-cols-2 gap-4",children:g?Array.from({length:2}).map((q,z)=>jsxRuntime.jsx(ManufacturerCard,{loading:!0},z)):M.map(q=>jsxRuntime.jsx(ManufacturerCard,{manufacturer:q,link:`https://dashboard.randmar.io/${t}/Partner/${q.ManufacturerId}`},q.ManufacturerId))})})]}):jsxRuntime.jsx(ResellerQualificationsCard,{qualifications:j}),jsxRuntime.jsx(OpportunitiesTable,{applicationId:t,opportunities:A==null?void 0:A.Opportunities,loading:g}),!d&&jsxRuntime.jsx(ReportsSection,{appID:t,userEmail:o,isLoading:g})]}),jsxRuntime.jsx(E,{})]})}/**
1065
1065
  * table-core
1066
1066
  *
1067
1067
  * Copyright (c) TanStack
@@ -1271,4 +1271,4 @@ img.ProseMirror-separator {
1271
1271
  .ProseMirror p {
1272
1272
  margin-bottom: 0.5em;
1273
1273
  }
1274
- `;function RichTextEditor({id:t,name:e,value:n,onChange:o,placeholder:l,className:d,...f}){const[g,b]=React.useState(!1),_=React.useRef(null),S=React.useRef(null),R=useEditor({extensions:[StarterKit,Underline],content:n,editorProps:{attributes:{class:"prose prose-sm sm:prose dark:prose-invert focus:outline-none",id:t??"",name:e??""}},onUpdate:({editor:j})=>{const q=j.getHTML();o({target:{id:t,name:e,value:q}})}});React.useEffect(()=>{R&&n!==R.getHTML()&&R.commands.setContent(n)},[n,R]);const C=React.useCallback(j=>{if(R)if(R.chain().focus(),j==="paragraph")R.chain().setParagraph().run();else{const q=Number.parseInt(j.slice(1));R.chain().setHeading({level:q}).run()}},[R]),E=React.useCallback(j=>{if(R)switch(R.chain().focus(),j){case"bold":R.chain().toggleBold().run();break;case"italic":R.chain().toggleItalic().run();break;case"underline":R.chain().toggleUnderline().run();break;case"strike":R.chain().toggleStrike().run();break;case"bulletList":R.chain().toggleBulletList().run();break;case"orderedList":R.chain().toggleOrderedList().run();break}},[R]),A=React.useCallback(()=>{b(j=>!j)},[]),I=React.useCallback(j=>{const q=j.target.value;R&&R.commands.setContent(q),o({target:{id:t,name:e,value:q}})},[o,R,t,e]),M=React.useCallback(()=>{!g&&R&&R.commands.focus()},[g,R]);return R?jsxRuntime.jsxs("div",{ref:S,className:cn("border border-input rounded-md overflow-hidden focus-within:outline-hidden focus-within:ring-1 focus-within:ring-ring",d),onClick:M,...f,children:[jsxRuntime.jsx("style",{children:editorStyles}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center p-2 border-b border-input gap-2 bg-background",children:[jsxRuntime.jsxs(Select,{onValueChange:C,disabled:g,children:[jsxRuntime.jsx(SelectTrigger,{className:"w-[160px]",children:jsxRuntime.jsx(SelectValue,{placeholder:"Format"})}),jsxRuntime.jsx(SelectContent,{children:formatOptions.map(j=>jsxRuntime.jsx(SelectItem,{value:j.value,children:j.label},j.value))})]}),["bold","italic","underline","strike","bulletList","orderedList"].map(j=>jsxRuntime.jsxs(Button,{type:"button",variant:"ghost",size:"sm",onClick:()=>E(j),className:R.isActive(j)?"bg-muted":"",disabled:g,children:[j==="bold"&&jsxRuntime.jsx(Bold$1,{className:"h-4 w-4"}),j==="italic"&&jsxRuntime.jsx(Italic$1,{className:"h-4 w-4"}),j==="underline"&&jsxRuntime.jsx(Underline$1,{className:"h-4 w-4"}),j==="strike"&&jsxRuntime.jsx(Strikethrough,{className:"h-4 w-4"}),j==="bulletList"&&jsxRuntime.jsx(List$1,{className:"h-4 w-4"}),j==="orderedList"&&jsxRuntime.jsx(ListOrdered,{className:"h-4 w-4"})]},j)),jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"sm",onClick:A,className:g?"bg-muted":"",children:jsxRuntime.jsx(Code$1,{className:"h-4 w-4"})})]}),jsxRuntime.jsx("div",{className:"p-3",children:g?jsxRuntime.jsx(Textarea,{ref:_,id:t,name:e,value:R.getHTML(),onChange:I,className:cn("min-h-[150px] font-mono text-sm resize-none border-0 focus-visible:ring-0 focus-visible:ring-offset-0",d),placeholder:l}):jsxRuntime.jsx(EditorContent,{editor:R})})]}):null}function SalesChart({salesData:t,chartHeight:e=300,units:n="$",unitsPosition:o="left",className:l,isLoading:d=!1}){const[f,g]=React.useState([]),[b,_]=React.useState(!0),S=!d&&!!t&&t.length>0;return React.useEffect(()=>{if(d||!t||t.length===0){g([]);return}const R=t.reduce((Q,F)=>{const V=F.Day??0,te=Math.floor(V).toString();if(te.length!==8||isNaN(Number.parseInt(te)))return console.warn(`Skipping invalid Day format: ${F.Day}`),Q;const ae=te.substring(0,4),se=te.substring(4,6),ge=`${ae}-${se}`;return Q[ge]=(Q[ge]||0)+(F.ExtendedPrice??0),Q},{}),C=Object.keys(R).sort(),E=new Date,A=E.getFullYear(),I=E.getMonth(),M=E.getDate(),j=`${A}-${(I+1).toString().padStart(2,"0")}`,q={...R};if(b&&C.length>0&&C[C.length-1]===j){const Q=q[j],F=new Date(A,I+1,0).getDate();if(M<F&&M>0){const te=Q/M*F;q[j]=te}}const z=C.map(Q=>{const F=q[Q],[V,te]=Q.split("-").map(Number);return{month:new Date(V,te-1).toLocaleString("default",{month:"short",year:"numeric"}),sales:F}});g(z)},[t,b,d]),d?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(Skeleton,{className:"h-6 w-24"})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsx("div",{style:{height:e},children:jsxRuntime.jsx(Skeleton,{className:"h-full w-full rounded-md"})}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2 my-1 pt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-10"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-20"})]}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-3/4 mt-1"})]})]}):f.length===0?jsxRuntime.jsx("div",{style:{height:e},className:l||"p-4 text-center text-muted-foreground flex items-center justify-center",children:"No monthly sales data to display."}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Sales"})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsx(AreaChart,{data:f,units:n,unitsPosition:o,height:e,className:l}),S&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2 my-1 pt-2",children:[jsxRuntime.jsx(Switch,{checked:b,onCheckedChange:_,id:"extrapolate-switch","aria-label":"Toggle sales extrapolation"}),jsxRuntime.jsx(Label$2,{htmlFor:"extrapolate-switch",children:"Extrapolate"})]}),b&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"* Sales for the current month are projected, not actual."})]})]})]})}function getEndDateStatus(t){if(!t)return{text:"No End Date",variant:"neutral",daysRemaining:null};const e=new Date(t);if(isNaN(e.getTime()))return{text:"Invalid Date",variant:"neutral",daysRemaining:null};const n=new Date,o=new Date(e.getFullYear(),e.getMonth(),e.getDate()),l=new Date(n.getFullYear(),n.getMonth(),n.getDate()),d=o.getTime()-l.getTime(),f=Math.ceil(d/(1e3*60*60*24));return f<0?{text:`Ended ${Math.abs(f)}d ago`,variant:"destructive",daysRemaining:f}:f===0?{text:"Ends today",variant:"destructive",daysRemaining:f}:f<=7?{text:`Ends in ${f}d`,variant:"destructive",daysRemaining:f}:f<=30?{text:`Ends in ${f}d`,variant:"warning",daysRemaining:f}:{text:`Ends in ${f}d`,variant:"neutral",daysRemaining:f}}const formatDate=t=>{if(!t)return"N/A";try{const e=new Date(t);return isNaN(e.getTime())?"Invalid Date":e.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return"Invalid Date"}};function ResellerOpportunitiesTable({applicationId:t,opportunities:e=null,loading:n=!1}){var V;const{toast:o}=useToast(),[l,d]=React.useState({}),[f,g]=React.useState(!1),[b,_]=React.useState(""),[S,R]=React.useState(null),C=React.useCallback((te,ae,se)=>{d(ge=>({...ge,[te]:{...ge[te],[ae]:se}}))},[]),[E]=usePutV4ResellerByRouteResellerIdOpportunityAndManufacturerIdDefaultMutation(),A=React.useCallback(async te=>{if(!te.BidNumber){o({title:"Error",description:"Bid Number is missing, cannot set default.",variant:"destructive"});return}const ae=te.BidNumber;C(ae,"isSettingDefault",!0),E({routeResellerId:t,manufacturerId:te.ManufacturerId??"",opportunityNumber:ae}).unwrap().then(()=>{o({title:"Success",description:`Opportunity "${te.OpportunityName||te.Opportunity||ae}" was successfully set as default.`,variant:"success"})}).catch(se=>{var ge;console.error("Set as default error:",se),o({title:"Error",description:((ge=se.data)==null?void 0:ge.message)||se.message||"An error occurred while setting this opportunity as default.",variant:"destructive"})}).finally(()=>{C(ae,"isSettingDefault",!1)})},[t,E,o,C]),[I]=usePostV4ResellerByRouteResellerIdOpportunityAndManufacturerIdBidNumberEmailMutation(),M=React.useCallback(te=>{if(!te.BidNumber){o({title:"Error",description:"Bid Number is missing, cannot prepare report.",variant:"destructive"});return}R(te),_(""),g(!0)},[o]),j=React.useCallback(async()=>{if(!S||!S.BidNumber){o({title:"Error",description:"No opportunity selected or Bid Number is missing.",variant:"destructive"});return}if(!b.trim()||!/\S+@\S+\.\S+/.test(b)){o({title:"Validation Error",description:"Please enter a valid email address.",variant:"destructive"});return}const te=S.BidNumber;C(te,"isSendingReport",!0),I({routeResellerId:t,manufacturerId:S.ManufacturerId??"",bidNumber:te,emailAddress:b}).unwrap().then(()=>{o({title:"Success",description:`A report for "${S.OpportunityName||S.Opportunity||te}" was successfully sent to ${b}.`,variant:"success"}),g(!1)}).catch(ae=>{var se;console.error("Send report by email error:",ae),o({title:"Error",description:((se=ae.data)==null?void 0:se.message)||ae.message||"An error occurred while sending the report by email.",variant:"destructive"})}).finally(()=>{C(te,"isSendingReport",!1),f||(R(null),_(""))})},[S,b,t,I,o,C,g]),q=React.useMemo(()=>[{accessorKey:"ManufacturerId",header:"Manuf.",cell:({row:te})=>jsxRuntime.jsx("div",{className:"w-20 h-8",children:jsxRuntime.jsx(PartnerLogo,{id:te.original.ManufacturerId,width:80,height:32})}),enableSorting:!0,enableFiltering:!0},{id:"opportunityDisplay",accessorFn:te=>te.OpportunityName||te.Opportunity,header:"Opportunity",cell:({getValue:te})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:te()??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"BidNumber",header:"Bid Number",cell:({row:te})=>te.original.BidNumber??"N/A",enableSorting:!0,enableFiltering:!0},{id:"statusInfo",header:"Status",cell:({row:te})=>{const ae=te.original,se=ae.Active===!0,ge=getEndDateStatus(ae.EndDate);let oe="border-gray-400 bg-gray-100 text-gray-600 dark:border-gray-600 dark:bg-gray-800/50 dark:text-gray-400";return ge.variant==="destructive"?oe="border-red-500 bg-red-100 text-red-700 dark:border-red-600 dark:bg-red-900/50 dark:text-red-400":ge.variant==="warning"&&(oe="border-yellow-500 bg-yellow-100 text-yellow-700 dark:border-yellow-600 dark:bg-yellow-900/50 dark:text-yellow-400"),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2 min-w-[200px]",children:[jsxRuntime.jsx(Badge,{variant:"outline",className:se?"border-green-500 bg-green-100 text-green-700 dark:border-green-600 dark:bg-green-900/50 dark:text-green-400 font-medium":"border-gray-400 bg-gray-100 text-gray-600 dark:border-gray-600 dark:bg-gray-800/50 dark:text-gray-400 font-medium",children:se?"Active":"Inactive"}),ae.EndDate&&jsxRuntime.jsx(Badge,{variant:"outline",className:`${oe} font-medium`,children:ge.text}),jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"ghost",size:"icon",className:"h-6 w-6 p-0 data-[state=delayed-open]:bg-accent data-[state=instant-open]:bg-accent",children:jsxRuntime.jsx(Info,{className:"h-4 w-4 text-muted-foreground"})})}),jsxRuntime.jsx(TooltipContent,{side:"top",align:"center",className:"bg-popover text-popover-foreground p-2 rounded shadow-lg",children:jsxRuntime.jsxs("div",{className:"text-sm space-y-1",children:[jsxRuntime.jsxs("p",{children:[jsxRuntime.jsx("strong",{children:"Start:"})," ",formatDate(ae.StartDate)]}),jsxRuntime.jsxs("p",{children:[jsxRuntime.jsx("strong",{children:"End:"})," ",formatDate(ae.EndDate)]}),jsxRuntime.jsxs("p",{children:[jsxRuntime.jsx("strong",{children:"Updated:"})," ",formatDate(ae.LastUpdate)]})]})})]})})]})},enableFiltering:!1},{id:"actions",header:"Actions",cell:({row:te})=>{var je,$e;const ae=te.original;if(!ae.BidNumber)return jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"Actions unavailable"});const se=ae.BidNumber,ge=(je=l[se])==null?void 0:je.isSettingDefault,oe=(S==null?void 0:S.BidNumber)===se&&(($e=l[se])==null?void 0:$e.isSendingReport),Ae=ge||oe,Ne=ae.CanBeSetAsDefault===!0;return jsxRuntime.jsxs("div",{className:"flex space-x-2",children:[jsxRuntime.jsx("a",{href:`/${t}/Opportunity/${ae.ManufacturerId}/${ae.BidNumber}`,children:jsxRuntime.jsxs(Button,{variant:"outline",size:"sm",className:"flex items-center",children:[jsxRuntime.jsx(Star,{className:"mr-2 h-4 w-4"})," View"]})}),jsxRuntime.jsxs(Button,{variant:"outline",size:"sm",onClick:()=>A(ae),disabled:Ae||!Ne,title:Ne?"Set as default":"This opportunity cannot be set as default",className:"flex items-center",children:[ge?jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}):jsxRuntime.jsx(Star,{className:"mr-2 h-4 w-4"})," Set Default"]}),jsxRuntime.jsxs(Button,{variant:"outline",size:"sm",onClick:()=>M(ae),disabled:Ae,title:"Send report by email",className:"flex items-center",children:[oe?jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}):jsxRuntime.jsx(Send,{className:"mr-2 h-4 w-4"})," Send Report"]})]})}}],[l,A,M,S]),z=React.useMemo(()=>{const te={};if(e){const ae=Array.from(new Set(e.map(ge=>ge.ManufacturerId).filter(ge=>ge!=null)));te.ManufacturerId=ae;const se=Array.from(new Set(e.map(ge=>ge.OpportunityName||ge.Opportunity).filter(ge=>ge!=null)));te.opportunityDisplay=se}return te},[e]),Q=e||[],F=S!=null&&S.BidNumber?(V=l[S.BidNumber])==null?void 0:V.isSendingReport:!1;return n?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(Skeleton,{className:"h-7 w-48"})," "]}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-48 w-full rounded-md border"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-[130px]"}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-20"})," ",jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"})," ",jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})," ",jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})]})]})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Opportunities"})," "]}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:q,data:Q,uniqueValues:z})})]}),jsxRuntime.jsx(Dialog,{open:f,onOpenChange:te=>{g(te),te||(R(null),_(""))},children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[425px]",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Send Opportunity Report"}),jsxRuntime.jsxs(DialogDescription,{children:["Enter the email address to send the report for opportunity: ",jsxRuntime.jsx("br",{}),jsxRuntime.jsx("span",{className:"font-semibold",children:(S==null?void 0:S.OpportunityName)||(S==null?void 0:S.Opportunity)||"N/A"}),(S==null?void 0:S.BidNumber)&&jsxRuntime.jsxs("span",{className:"block text-sm text-muted-foreground",children:["Bid Number: ",S.BidNumber]})]})]}),jsxRuntime.jsx("div",{className:"grid gap-4 py-4",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"email",className:"text-right",children:"Email"}),jsxRuntime.jsx(Input,{id:"email",type:"email",value:b,onChange:te=>_(te.target.value),placeholder:"recipient@example.com",className:"col-span-3",disabled:F})]})}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button,{variant:"outline",onClick:()=>g(!1),disabled:F,children:"Cancel"}),jsxRuntime.jsxs(Button,{type:"submit",onClick:j,disabled:F,children:[F&&jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"})," Send Report"]})]})]})})]})}function formatYYYYMMDDIntToDateString$1(t){if(t===null||typeof t>"u")return"N/A";const e=t.toString();return e.length===8?`${e.substring(0,4)}-${e.substring(4,6)}-${e.substring(6,8)}`:e}function formatCurrency(t){return t===null||typeof t>"u"?"N/A":t.toLocaleString(void 0,{style:"currency",currency:"CAD"})}function OrdersTable({orders:t=null,loading:e=!1,title:n="Order Details"}){const o=React.useMemo(()=>[{accessorKey:"DocumentNumber",header:"Document Number",cell:({row:f})=>f.original.DocumentNumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"DocumentDate",header:"Document Date",cell:({row:f})=>formatYYYYMMDDIntToDateString$1(f.original.DocumentDate),enableSorting:!0,enableFiltering:!1},{accessorKey:"OrderNumber",header:"Order Number",cell:({row:f})=>f.original.OrderNumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"PONumber",header:"PO Number",cell:({row:f})=>f.original.PONumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"WarehouseCode",header:"Warehouse",cell:({row:f})=>f.original.WarehouseCode??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:f})=>f.original.Quantity??"N/A",enableSorting:!0,enableFiltering:!1},{accessorKey:"ShipToName",header:"Name",cell:({row:f})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:f.original.ShipToName??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"UnitPrice",header:"Unit Price",cell:({row:f})=>formatCurrency(f.original.UnitPrice),enableSorting:!0,enableFiltering:!1}],[]),l=React.useMemo(()=>{const f={};if(t){const g=Array.from(new Set(t.map(C=>C.WarehouseCode).filter(C=>C!=null)));f.WarehouseCode=g;const b=Array.from(new Set(t.map(C=>C.ShipToName).filter(C=>C!=null)));f.ShipToName=b;const _=Array.from(new Set(t.map(C=>C.DocumentNumber).filter(C=>C!=null)));f.DocumentNumber=_;const S=Array.from(new Set(t.map(C=>C.OrderNumber).filter(C=>C!=null)));f.OrderNumber=S;const R=Array.from(new Set(t.map(C=>C.PONumber).filter(C=>C!=null)));f.PONumber=R}return f},[t]),d=t||[];return e?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(Skeleton,{className:"h-7 w-48"})," "]}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-[130px]"}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-20"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})]})]})]})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:n})," "]}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:o,data:d,uniqueValues:l})})]})}function formatYYYYMMDDIntToDateString(t){if(t===null||typeof t>"u")return"N/A";const e=t.toString();return e.length===8?`${e.substring(0,4)}-${e.substring(4,6)}-${e.substring(6,8)}`:e}function ReceiptsTable({receipts:t=null,loading:e=!1,title:n="Latest Warehouse Receivings"}){const o=React.useMemo(()=>[{accessorKey:"Location",header:"Location",cell:({row:f})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:f.original.Location??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"ReceiptDate",header:"Date",cell:({row:f})=>formatYYYYMMDDIntToDateString(f.original.ReceiptDate),enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:f})=>f.original.Quantity??"N/A",enableSorting:!0,enableFiltering:!0}],[]),l=React.useMemo(()=>{const f={};if(t){const g=Array.from(new Set(t.map(_=>_.Location).filter(_=>_!=null)));f.Location=g;const b=Array.from(new Set(t.map(_=>formatYYYYMMDDIntToDateString(_.ReceiptDate)).filter(_=>_!=="N/A"&&_!=="Invalid Date"))).sort((_,S)=>new Date(S).getTime()-new Date(_).getTime());f.ReceiptDate=b}return f},[t]),d=t||[];return e?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(Skeleton,{className:"h-7 w-56"})," "]}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-[130px]"}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-20"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})]})]})]})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:n})," "]}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:o,data:d,uniqueValues:l})})]})}function ProductOverviewPage({applicationId:t,sku:e,productDefaultOpportunityNumber:n="",productOnAddToCart:o,productAddingToCart:l=!1,productShopifyHostname:d,productCustomAction:f=jsxRuntime.jsx(jsxRuntime.Fragment,{})}){const{data:g}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:t},{skip:!t||!e}),{data:b,isLoading:_}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:t,randmarSku:e,withSpecification:!1},{skip:!t||!e}),{data:S,isLoading:R}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:t,randmarSku:e,withSpecification:!0},{skip:!b}),C=(b==null?void 0:b.ManufacturerId)!==t;return console.log("readonly",C),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"grid gap-4 grid-cols-1 md:grid-cols-2 lg:grid-cols-3",children:[jsxRuntime.jsx("div",{className:"lg:col-span-2",children:jsxRuntime.jsx(ProductCard,{applicationId:t,product:S||b,defaultOpportunityNumber:n,onAddToCart:o,addingToCart:l,shopifyHostname:d,customAction:f})}),jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsxs(CardTitle,{children:[jsxRuntime.jsx(Info,{className:"h-5 w-5 inline mr-2"})," Additionnal information"]})}),jsxRuntime.jsx(CardContent,{children:_?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsx(Skeleton,{className:"h-1 w-full my-6"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full mt-2"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full mt-1"})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex justify-between",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Cateory Name"}),jsxRuntime.jsx("span",{className:"font-medium",children:(b==null?void 0:b.ProductType)||"N/A"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Master Carton"}),jsxRuntime.jsx("span",{className:"font-medium",children:(b==null?void 0:b.MasterCarton)||"N/A"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Skid Quantity"}),jsxRuntime.jsx("span",{className:"font-medium",children:(b==null?void 0:b.SkidQuantity)||"N/A"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Automatic Reorder"}),jsxRuntime.jsx("span",{className:"font-medium",children:b!=null&&b.AutoUpdate?"Yes":"No"})]}),((b==null?void 0:b.VoiceoverCaption)||(b==null?void 0:b.BodyHTML))&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("hr",{className:"my-6"}),jsxRuntime.jsx("div",{className:"text-muted-foreground mb-2",children:"Description"}),jsxRuntime.jsxs("div",{className:"max-h-44 overflow-scroll",children:[(b==null?void 0:b.VoiceoverCaption)&&jsxRuntime.jsx("div",{children:b==null?void 0:b.VoiceoverCaption}),(b==null?void 0:b.BodyHTML)&&jsxRuntime.jsx("div",{className:"prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:(b==null?void 0:b.BodyHTML)??""}})]})]})]})})]})]}),jsxRuntime.jsx("div",{className:"my-4",children:_?jsxRuntime.jsx("div",{className:"mx-auto flex justify-center items-center h-32",children:jsxRuntime.jsx(LoaderCircle,{className:"h-8 w-8 animate-spin text-primary"})}):jsxRuntime.jsxs(Tabs,{defaultValue:"stats",children:[jsxRuntime.jsxs(TabsList,{className:"inline-flex h-auto items-center justify-center rounded-none border-b bg-transparent p-0",children:[jsxRuntime.jsx(TabsTrigger,{value:"stats",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Statistics"}),(g==null?void 0:g.IsReseller)&&jsxRuntime.jsx(TabsTrigger,{value:"opportunities",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Opportunities"}),jsxRuntime.jsx(TabsTrigger,{value:"orders",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Orders"}),jsxRuntime.jsx(TabsTrigger,{value:"warehouse",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Latest Warehouse Receiving"})]}),jsxRuntime.jsx(TabsContent,{value:"stats",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(SalesChart,{salesData:(S==null?void 0:S.SalesStatistics)??[],isLoading:R})})}),(g==null?void 0:g.IsReseller)&&jsxRuntime.jsx(TabsContent,{value:"opportunities",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ResellerOpportunitiesTable,{applicationId:t,opportunities:b==null?void 0:b.Opportunities,loading:_})})}),jsxRuntime.jsxs(TabsContent,{value:"orders",children:[jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(OrdersTable,{title:"Open Orders",orders:S==null?void 0:S.ActiveOrderDetails,loading:R})}),jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(OrdersTable,{title:"Completed Orders",orders:S==null?void 0:S.CompletedOrderDetails,loading:R})})]}),jsxRuntime.jsx(TabsContent,{value:"warehouse",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ReceiptsTable,{receipts:S==null?void 0:S.Receipts,loading:R})})})]})})]})}exports.ActiveOrdersCard=ActiveOrdersCard,exports.AiGeneratedContent=AiGeneratedContent,exports.Alert=Alert,exports.AlertDescription=AlertDescription,exports.AlertDialog=AlertDialog,exports.AlertDialogAction=AlertDialogAction,exports.AlertDialogCancel=AlertDialogCancel,exports.AlertDialogContent=AlertDialogContent,exports.AlertDialogDescription=AlertDialogDescription,exports.AlertDialogFooter=AlertDialogFooter,exports.AlertDialogHeader=AlertDialogHeader,exports.AlertDialogTitle=AlertDialogTitle,exports.AlertDialogTrigger=AlertDialogTrigger,exports.AlertTitle=AlertTitle,exports.ApiKeyProvider=ApiKeyProvider,exports.AreaChart=AreaChart,exports.Avatar=Avatar,exports.AvatarFallback=AvatarFallback,exports.AvatarFooter=AvatarFooter,exports.AvatarImage=AvatarImage,exports.Badge=Badge,exports.Button=Button,exports.Card=Card,exports.CardContent=CardContent,exports.CardDescription=CardDescription,exports.CardFooter=CardFooter,exports.CardHeader=CardHeader,exports.CardTitle=CardTitle,exports.ChatLayout=ChatLayout,exports.ChatProvider=ChatProvider,exports.Checkbox=Checkbox,exports.Command=Command,exports.CommandDialog=CommandDialog,exports.CommandEmpty=CommandEmpty,exports.CommandGroup=CommandGroup,exports.CommandInput=CommandInput,exports.CommandItem=CommandItem,exports.CommandList=CommandList,exports.CommandSeparator=CommandSeparator,exports.CommandShortcut=CommandShortcut,exports.CountryFlag=CountryFlag,exports.DataTable=DataTable,exports.Dialog=Dialog,exports.DialogClose=DialogClose,exports.DialogContent=DialogContent,exports.DialogDescription=DialogDescription,exports.DialogFooter=DialogFooter,exports.DialogHeader=DialogHeader,exports.DialogOverlay=DialogOverlay,exports.DialogPortal=DialogPortal,exports.DialogTitle=DialogTitle,exports.DialogTrigger=DialogTrigger,exports.DropdownMenu=DropdownMenu,exports.DropdownMenuCheckboxItem=DropdownMenuCheckboxItem,exports.DropdownMenuContent=DropdownMenuContent,exports.DropdownMenuGroup=DropdownMenuGroup,exports.DropdownMenuItem=DropdownMenuItem,exports.DropdownMenuLabel=DropdownMenuLabel,exports.DropdownMenuPortal=DropdownMenuPortal,exports.DropdownMenuRadioGroup=DropdownMenuRadioGroup,exports.DropdownMenuRadioItem=DropdownMenuRadioItem,exports.DropdownMenuSeparator=DropdownMenuSeparator,exports.DropdownMenuShortcut=DropdownMenuShortcut,exports.DropdownMenuSub=DropdownMenuSub,exports.DropdownMenuSubContent=DropdownMenuSubContent,exports.DropdownMenuSubTrigger=DropdownMenuSubTrigger,exports.DropdownMenuTrigger=DropdownMenuTrigger,exports.ExploreManufacturers=ExploreManufacturers,exports.GeneralDocumentCard=GeneralDocumentCard,exports.Input=Input,exports.InputOTP=InputOTP,exports.InputOTPGroup=InputOTPGroup,exports.InputOTPSeparator=InputOTPSeparator,exports.InputOTPSlot=InputOTPSlot,exports.Label=Label$2,exports.Layout=Layout,exports.ManufacturerCard=ManufacturerCard,exports.ManufacturerGetStartedButton=ManufacturerGetStartedButton,exports.ManufacturerOverviewPage=ManufacturerOverviewPage,exports.ManufacturerReorderingCard=ManufacturerReorderingCard,exports.MultiSelect=MultiSelect,exports.Navbar=Navbar,exports.PageHeader=PageHeader,exports.PartnerCard=PartnerCard,exports.PartnerRelationshipPage=PartnerRelationshipPage,exports.Popover=Popover,exports.PopoverAnchor=PopoverAnchor,exports.PopoverContent=PopoverContent,exports.PopoverTrigger=PopoverTrigger,exports.Preloader=Preloader,exports.ProductCard=ProductCard,exports.ProductImage=ProductImage,exports.ProductInventoryGrid=ProductInventoryGrid,exports.ProductOverviewPage=ProductOverviewPage,exports.Progress=Progress,exports.RadioGroup=RadioGroup$1,exports.RadioGroupItem=RadioGroupItem,exports.ResellerBillingOverviewCard=ResellerBillingOverviewCard,exports.ResellerCard=ResellerCard,exports.ResellerOpportunitiesTable=ResellerOpportunitiesTable,exports.ResellerOverview=ResellerOverview,exports.ResellerQualificationsCard=ResellerQualificationsCard,exports.RichTextEditor=RichTextEditor,exports.SalesChart=SalesChart,exports.SalesOverviewCard=SalesOverviewCard,exports.ScrollArea=ScrollArea,exports.ScrollBar=ScrollBar,exports.Select=Select,exports.SelectContent=SelectContent,exports.SelectGroup=SelectGroup,exports.SelectItem=SelectItem,exports.SelectLabel=SelectLabel,exports.SelectScrollDownButton=SelectScrollDownButton,exports.SelectScrollUpButton=SelectScrollUpButton,exports.SelectTrigger=SelectTrigger,exports.SelectValue=SelectValue,exports.Separator=Separator$1,exports.Sheet=Sheet,exports.SheetClose=SheetClose,exports.SheetContent=SheetContent,exports.SheetDescription=SheetDescription,exports.SheetFooter=SheetFooter,exports.SheetHeader=SheetHeader,exports.SheetOverlay=SheetOverlay,exports.SheetPortal=SheetPortal,exports.SheetTitle=SheetTitle,exports.SheetTrigger=SheetTrigger,exports.Sidebar=Sidebar,exports.SidebarContent=SidebarContent,exports.SidebarFooter=SidebarFooter,exports.SidebarGroup=SidebarGroup,exports.SidebarGroupAction=SidebarGroupAction,exports.SidebarGroupContent=SidebarGroupContent,exports.SidebarGroupLabel=SidebarGroupLabel,exports.SidebarHeader=SidebarHeader,exports.SidebarInput=SidebarInput,exports.SidebarInset=SidebarInset,exports.SidebarMenu=SidebarMenu,exports.SidebarMenuAction=SidebarMenuAction,exports.SidebarMenuBadge=SidebarMenuBadge,exports.SidebarMenuButton=SidebarMenuButton,exports.SidebarMenuItem=SidebarMenuItem,exports.SidebarMenuSkeleton=SidebarMenuSkeleton,exports.SidebarMenuSub=SidebarMenuSub,exports.SidebarMenuSubButton=SidebarMenuSubButton,exports.SidebarMenuSubItem=SidebarMenuSubItem,exports.SidebarProvider=SidebarProvider,exports.SidebarRail=SidebarRail,exports.SidebarSeparator=SidebarSeparator,exports.SidebarTrigger=SidebarTrigger,exports.Skeleton=Skeleton,exports.Switch=Switch,exports.Table=Table,exports.TableBody=TableBody,exports.TableCaption=TableCaption,exports.TableCell=TableCell,exports.TableFooter=TableFooter,exports.TableHead=TableHead,exports.TableHeader=TableHeader,exports.TableRow=TableRow,exports.Tabs=Tabs,exports.TabsContent=TabsContent,exports.TabsList=TabsList,exports.TabsTrigger=TabsTrigger,exports.Textarea=Textarea,exports.Toast=Toast,exports.ToastAction=ToastAction,exports.ToastClose=ToastClose,exports.ToastDescription=ToastDescription,exports.ToastProvider=ToastProvider,exports.ToastTitle=ToastTitle,exports.ToastViewport=ToastViewport,exports.Toaster=Toaster,exports.Tooltip=Tooltip$1,exports.TooltipContent=TooltipContent,exports.TooltipProvider=TooltipProvider,exports.TooltipTrigger=TooltipTrigger,exports.Topbar=Topbar,exports.badgeVariants=badgeVariants,exports.buttonVariants=buttonVariants,exports.toast=toast,exports.useApiKey=useApiKey,exports.useChat=useChat,exports.useIsMobile=useIsMobile,exports.useSidebar=useSidebar,exports.useToast=useToast,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})});
1274
+ `;function RichTextEditor({id:t,name:e,value:n,onChange:o,placeholder:l,className:d,...f}){const[g,b]=React.useState(!1),_=React.useRef(null),S=React.useRef(null),R=useEditor({extensions:[StarterKit,Underline],content:n,editorProps:{attributes:{class:"prose prose-sm sm:prose dark:prose-invert focus:outline-none",id:t??"",name:e??""}},onUpdate:({editor:j})=>{const q=j.getHTML();o({target:{id:t,name:e,value:q}})}});React.useEffect(()=>{R&&n!==R.getHTML()&&R.commands.setContent(n)},[n,R]);const C=React.useCallback(j=>{if(R)if(R.chain().focus(),j==="paragraph")R.chain().setParagraph().run();else{const q=Number.parseInt(j.slice(1));R.chain().setHeading({level:q}).run()}},[R]),E=React.useCallback(j=>{if(R)switch(R.chain().focus(),j){case"bold":R.chain().toggleBold().run();break;case"italic":R.chain().toggleItalic().run();break;case"underline":R.chain().toggleUnderline().run();break;case"strike":R.chain().toggleStrike().run();break;case"bulletList":R.chain().toggleBulletList().run();break;case"orderedList":R.chain().toggleOrderedList().run();break}},[R]),A=React.useCallback(()=>{b(j=>!j)},[]),I=React.useCallback(j=>{const q=j.target.value;R&&R.commands.setContent(q),o({target:{id:t,name:e,value:q}})},[o,R,t,e]),M=React.useCallback(()=>{!g&&R&&R.commands.focus()},[g,R]);return R?jsxRuntime.jsxs("div",{ref:S,className:cn("border border-input rounded-md overflow-hidden focus-within:outline-hidden focus-within:ring-1 focus-within:ring-ring",d),onClick:M,...f,children:[jsxRuntime.jsx("style",{children:editorStyles}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center p-2 border-b border-input gap-2 bg-background",children:[jsxRuntime.jsxs(Select,{onValueChange:C,disabled:g,children:[jsxRuntime.jsx(SelectTrigger,{className:"w-[160px]",children:jsxRuntime.jsx(SelectValue,{placeholder:"Format"})}),jsxRuntime.jsx(SelectContent,{children:formatOptions.map(j=>jsxRuntime.jsx(SelectItem,{value:j.value,children:j.label},j.value))})]}),["bold","italic","underline","strike","bulletList","orderedList"].map(j=>jsxRuntime.jsxs(Button,{type:"button",variant:"ghost",size:"sm",onClick:()=>E(j),className:R.isActive(j)?"bg-muted":"",disabled:g,children:[j==="bold"&&jsxRuntime.jsx(Bold$1,{className:"h-4 w-4"}),j==="italic"&&jsxRuntime.jsx(Italic$1,{className:"h-4 w-4"}),j==="underline"&&jsxRuntime.jsx(Underline$1,{className:"h-4 w-4"}),j==="strike"&&jsxRuntime.jsx(Strikethrough,{className:"h-4 w-4"}),j==="bulletList"&&jsxRuntime.jsx(List$1,{className:"h-4 w-4"}),j==="orderedList"&&jsxRuntime.jsx(ListOrdered,{className:"h-4 w-4"})]},j)),jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"sm",onClick:A,className:g?"bg-muted":"",children:jsxRuntime.jsx(Code$1,{className:"h-4 w-4"})})]}),jsxRuntime.jsx("div",{className:"p-3",children:g?jsxRuntime.jsx(Textarea,{ref:_,id:t,name:e,value:R.getHTML(),onChange:I,className:cn("min-h-[150px] font-mono text-sm resize-none border-0 focus-visible:ring-0 focus-visible:ring-offset-0",d),placeholder:l}):jsxRuntime.jsx(EditorContent,{editor:R})})]}):null}function SalesChart({salesData:t,chartHeight:e=300,units:n="$",unitsPosition:o="left",className:l,isLoading:d=!1}){const[f,g]=React.useState([]),[b,_]=React.useState(!0),S=!d&&!!t&&t.length>0;return React.useEffect(()=>{if(d||!t||t.length===0){g([]);return}const R=t.reduce((Q,F)=>{const V=F.Day??0,te=Math.floor(V).toString();if(te.length!==8||isNaN(Number.parseInt(te)))return console.warn(`Skipping invalid Day format: ${F.Day}`),Q;const ae=te.substring(0,4),se=te.substring(4,6),ge=`${ae}-${se}`;return Q[ge]=(Q[ge]||0)+(F.ExtendedPrice??0),Q},{}),C=Object.keys(R).sort(),E=new Date,A=E.getFullYear(),I=E.getMonth(),M=E.getDate(),j=`${A}-${(I+1).toString().padStart(2,"0")}`,q={...R};if(b&&C.length>0&&C[C.length-1]===j){const Q=q[j],F=new Date(A,I+1,0).getDate();if(M<F&&M>0){const te=Q/M*F;q[j]=te}}const z=C.map(Q=>{const F=q[Q],[V,te]=Q.split("-").map(Number);return{month:new Date(V,te-1).toLocaleString("default",{month:"short",year:"numeric"}),sales:F}});g(z)},[t,b,d]),d?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(Skeleton,{className:"h-6 w-24"})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsx("div",{style:{height:e},children:jsxRuntime.jsx(Skeleton,{className:"h-full w-full rounded-md"})}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2 my-1 pt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-10"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-20"})]}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-3/4 mt-1"})]})]}):f.length===0?jsxRuntime.jsx("div",{style:{height:e},className:l||"p-4 text-center text-muted-foreground flex items-center justify-center",children:"No monthly sales data to display."}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Sales"})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsx(AreaChart,{data:f,units:n,unitsPosition:o,height:e,className:l}),S&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2 my-1 pt-2",children:[jsxRuntime.jsx(Switch,{checked:b,onCheckedChange:_,id:"extrapolate-switch","aria-label":"Toggle sales extrapolation"}),jsxRuntime.jsx(Label$2,{htmlFor:"extrapolate-switch",children:"Extrapolate"})]}),b&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"* Sales for the current month are projected, not actual."})]})]})]})}function getEndDateStatus(t){if(!t)return{text:"No End Date",variant:"neutral",daysRemaining:null};const e=new Date(t);if(isNaN(e.getTime()))return{text:"Invalid Date",variant:"neutral",daysRemaining:null};const n=new Date,o=new Date(e.getFullYear(),e.getMonth(),e.getDate()),l=new Date(n.getFullYear(),n.getMonth(),n.getDate()),d=o.getTime()-l.getTime(),f=Math.ceil(d/(1e3*60*60*24));return f<0?{text:`Ended ${Math.abs(f)}d ago`,variant:"destructive",daysRemaining:f}:f===0?{text:"Ends today",variant:"destructive",daysRemaining:f}:f<=7?{text:`Ends in ${f}d`,variant:"destructive",daysRemaining:f}:f<=30?{text:`Ends in ${f}d`,variant:"warning",daysRemaining:f}:{text:`Ends in ${f}d`,variant:"neutral",daysRemaining:f}}const formatDate=t=>{if(!t)return"N/A";try{const e=new Date(t);return isNaN(e.getTime())?"Invalid Date":e.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return"Invalid Date"}};function OpportunitiesTable({applicationId:t,opportunities:e=null,loading:n=!1}){var te;const{toast:o}=useToast(),[l,d]=React.useState({}),[f,g]=React.useState(!1),[b,_]=React.useState(""),[S,R]=React.useState(null),{data:C}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:t},{skip:!t}),E=React.useCallback((ae,se,ge)=>{d(oe=>({...oe,[ae]:{...oe[ae],[se]:ge}}))},[]),[A]=usePutV4ResellerByRouteResellerIdOpportunityAndManufacturerIdDefaultMutation(),I=React.useCallback(async ae=>{if(!(C!=null&&C.IsReseller))return;if(!ae.BidNumber){o({title:"Error",description:"Bid Number is missing, cannot set default.",variant:"destructive"});return}const se=ae.BidNumber;E(se,"isSettingDefault",!0),A({routeResellerId:t,manufacturerId:ae.ManufacturerId??"",opportunityNumber:se}).unwrap().then(()=>{o({title:"Success",description:`Opportunity "${ae.OpportunityName||ae.Opportunity||se}" was successfully set as default.`,variant:"success"})}).catch(ge=>{var oe;console.error("Set as default error:",ge),o({title:"Error",description:((oe=ge.data)==null?void 0:oe.message)||ge.message||"An error occurred while setting this opportunity as default.",variant:"destructive"})}).finally(()=>{E(se,"isSettingDefault",!1)})},[t,A,o,E]),[M]=usePostV4ResellerByRouteResellerIdOpportunityAndManufacturerIdBidNumberEmailMutation(),j=React.useCallback(ae=>{if(C!=null&&C.IsReseller){if(!ae.BidNumber){o({title:"Error",description:"Bid Number is missing, cannot prepare report.",variant:"destructive"});return}R(ae),_(""),g(!0)}},[o]),q=React.useCallback(async()=>{if(!(C!=null&&C.IsReseller))return;if(!S||!S.BidNumber){o({title:"Error",description:"No opportunity selected or Bid Number is missing.",variant:"destructive"});return}if(!b.trim()||!/\S+@\S+\.\S+/.test(b)){o({title:"Validation Error",description:"Please enter a valid email address.",variant:"destructive"});return}const ae=S.BidNumber;E(ae,"isSendingReport",!0),M({routeResellerId:t,manufacturerId:S.ManufacturerId??"",bidNumber:ae,emailAddress:b}).unwrap().then(()=>{o({title:"Success",description:`A report for "${S.OpportunityName||S.Opportunity||ae}" was successfully sent to ${b}.`,variant:"success"}),g(!1)}).catch(se=>{var ge;console.error("Send report by email error:",se),o({title:"Error",description:((ge=se.data)==null?void 0:ge.message)||se.message||"An error occurred while sending the report by email.",variant:"destructive"})}).finally(()=>{E(ae,"isSendingReport",!1),f||(R(null),_(""))})},[S,b,t,M,o,E,g]),z=React.useMemo(()=>[{accessorKey:"ManufacturerId",header:"Manuf.",cell:({row:ae})=>jsxRuntime.jsx("div",{className:"w-20 h-8",children:jsxRuntime.jsx(PartnerLogo,{id:ae.original.ManufacturerId,width:80,height:32})}),enableSorting:!0,enableFiltering:!0},{id:"opportunityDisplay",accessorFn:ae=>ae.OpportunityName||ae.Opportunity,header:"Opportunity",cell:({getValue:ae})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:ae()??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"BidNumber",header:"Bid Number",cell:({row:ae})=>ae.original.BidNumber??"N/A",enableSorting:!0,enableFiltering:!0},{id:"statusInfo",header:"Status",cell:({row:ae})=>{const se=ae.original,ge=se.Active===!0,oe=getEndDateStatus(se.EndDate);let Ae="border-gray-400 bg-gray-100 text-gray-600 dark:border-gray-600 dark:bg-gray-800/50 dark:text-gray-400";return oe.variant==="destructive"?Ae="border-red-500 bg-red-100 text-red-700 dark:border-red-600 dark:bg-red-900/50 dark:text-red-400":oe.variant==="warning"&&(Ae="border-yellow-500 bg-yellow-100 text-yellow-700 dark:border-yellow-600 dark:bg-yellow-900/50 dark:text-yellow-400"),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2 min-w-[200px]",children:[jsxRuntime.jsx(Badge,{variant:"outline",className:ge?"border-green-500 bg-green-100 text-green-700 dark:border-green-600 dark:bg-green-900/50 dark:text-green-400 font-medium":"border-gray-400 bg-gray-100 text-gray-600 dark:border-gray-600 dark:bg-gray-800/50 dark:text-gray-400 font-medium",children:ge?"Active":"Inactive"}),se.EndDate&&jsxRuntime.jsx(Badge,{variant:"outline",className:`${Ae} font-medium`,children:oe.text}),jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"ghost",size:"icon",className:"h-6 w-6 p-0 data-[state=delayed-open]:bg-accent data-[state=instant-open]:bg-accent",children:jsxRuntime.jsx(Info,{className:"h-4 w-4 text-muted-foreground"})})}),jsxRuntime.jsx(TooltipContent,{side:"top",align:"center",className:"bg-popover text-popover-foreground p-2 rounded shadow-lg",children:jsxRuntime.jsxs("div",{className:"text-sm space-y-1",children:[jsxRuntime.jsxs("p",{children:[jsxRuntime.jsx("strong",{children:"Start:"})," ",formatDate(se.StartDate)]}),jsxRuntime.jsxs("p",{children:[jsxRuntime.jsx("strong",{children:"End:"})," ",formatDate(se.EndDate)]}),jsxRuntime.jsxs("p",{children:[jsxRuntime.jsx("strong",{children:"Updated:"})," ",formatDate(se.LastUpdate)]})]})})]})})]})},enableFiltering:!1},{id:"actions",header:"Actions",cell:({row:ae})=>{var $e,Fe;const se=ae.original;if(!se.BidNumber)return jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"Actions unavailable"});const ge=se.BidNumber,oe=($e=l[ge])==null?void 0:$e.isSettingDefault,Ae=(S==null?void 0:S.BidNumber)===ge&&((Fe=l[ge])==null?void 0:Fe.isSendingReport),Ne=oe||Ae,je=se.CanBeSetAsDefault===!0;return jsxRuntime.jsxs("div",{className:"flex space-x-2",children:[jsxRuntime.jsx("a",{href:`/${t}/Opportunity/${se.ManufacturerId}/${se.BidNumber}`,children:jsxRuntime.jsxs(Button,{variant:"outline",size:"sm",className:"flex items-center",children:[jsxRuntime.jsx(Star,{className:"mr-2 h-4 w-4"})," View"]})}),(C==null?void 0:C.IsReseller)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Button,{variant:"outline",size:"sm",onClick:()=>I(se),disabled:Ne||!je,title:je?"Set as default":"This opportunity cannot be set as default",className:"flex items-center",children:[oe?jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}):jsxRuntime.jsx(Star,{className:"mr-2 h-4 w-4"})," Set Default"]}),jsxRuntime.jsxs(Button,{variant:"outline",size:"sm",onClick:()=>j(se),disabled:Ne,title:"Send report by email",className:"flex items-center",children:[Ae?jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}):jsxRuntime.jsx(Send,{className:"mr-2 h-4 w-4"})," Send Report"]})]})]})}}],[l,I,j,S]),Q=React.useMemo(()=>{const ae={};if(e){const se=Array.from(new Set(e.map(oe=>oe.ManufacturerId).filter(oe=>oe!=null)));ae.ManufacturerId=se;const ge=Array.from(new Set(e.map(oe=>oe.OpportunityName||oe.Opportunity).filter(oe=>oe!=null)));ae.opportunityDisplay=ge}return ae},[e]),F=e||[],V=S!=null&&S.BidNumber?(te=l[S.BidNumber])==null?void 0:te.isSendingReport:!1;return n?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(Skeleton,{className:"h-7 w-48"})," "]}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-48 w-full rounded-md border"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-[130px]"}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-20"})," ",jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"})," ",jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})," ",jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})]})]})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Opportunities"})," "]}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:z,data:F,uniqueValues:Q})})]}),jsxRuntime.jsx(Dialog,{open:f,onOpenChange:ae=>{g(ae),ae||(R(null),_(""))},children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[425px]",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Send Opportunity Report"}),jsxRuntime.jsxs(DialogDescription,{children:["Enter the email address to send the report for opportunity: ",jsxRuntime.jsx("br",{}),jsxRuntime.jsx("span",{className:"font-semibold",children:(S==null?void 0:S.OpportunityName)||(S==null?void 0:S.Opportunity)||"N/A"}),(S==null?void 0:S.BidNumber)&&jsxRuntime.jsxs("span",{className:"block text-sm text-muted-foreground",children:["Bid Number: ",S.BidNumber]})]})]}),jsxRuntime.jsx("div",{className:"grid gap-4 py-4",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"email",className:"text-right",children:"Email"}),jsxRuntime.jsx(Input,{id:"email",type:"email",value:b,onChange:ae=>_(ae.target.value),placeholder:"recipient@example.com",className:"col-span-3",disabled:V})]})}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button,{variant:"outline",onClick:()=>g(!1),disabled:V,children:"Cancel"}),jsxRuntime.jsxs(Button,{type:"submit",onClick:q,disabled:V,children:[V&&jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"})," Send Report"]})]})]})})]})}function formatYYYYMMDDIntToDateString$1(t){if(t===null||typeof t>"u")return"N/A";const e=t.toString();return e.length===8?`${e.substring(0,4)}-${e.substring(4,6)}-${e.substring(6,8)}`:e}function formatCurrency(t){return t===null||typeof t>"u"?"N/A":t.toLocaleString(void 0,{style:"currency",currency:"CAD"})}function OrdersTable({orders:t=null,loading:e=!1,title:n="Order Details"}){const o=React.useMemo(()=>[{accessorKey:"DocumentNumber",header:"Document Number",cell:({row:f})=>f.original.DocumentNumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"DocumentDate",header:"Document Date",cell:({row:f})=>formatYYYYMMDDIntToDateString$1(f.original.DocumentDate),enableSorting:!0,enableFiltering:!1},{accessorKey:"OrderNumber",header:"Order Number",cell:({row:f})=>f.original.OrderNumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"PONumber",header:"PO Number",cell:({row:f})=>f.original.PONumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"WarehouseCode",header:"Warehouse",cell:({row:f})=>f.original.WarehouseCode??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:f})=>f.original.Quantity??"N/A",enableSorting:!0,enableFiltering:!1},{accessorKey:"ShipToName",header:"Name",cell:({row:f})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:f.original.ShipToName??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"UnitPrice",header:"Unit Price",cell:({row:f})=>formatCurrency(f.original.UnitPrice),enableSorting:!0,enableFiltering:!1}],[]),l=React.useMemo(()=>{const f={};if(t){const g=Array.from(new Set(t.map(C=>C.WarehouseCode).filter(C=>C!=null)));f.WarehouseCode=g;const b=Array.from(new Set(t.map(C=>C.ShipToName).filter(C=>C!=null)));f.ShipToName=b;const _=Array.from(new Set(t.map(C=>C.DocumentNumber).filter(C=>C!=null)));f.DocumentNumber=_;const S=Array.from(new Set(t.map(C=>C.OrderNumber).filter(C=>C!=null)));f.OrderNumber=S;const R=Array.from(new Set(t.map(C=>C.PONumber).filter(C=>C!=null)));f.PONumber=R}return f},[t]),d=t||[];return e?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(Skeleton,{className:"h-7 w-48"})," "]}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-[130px]"}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-20"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})]})]})]})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:n})," "]}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:o,data:d,uniqueValues:l})})]})}function formatYYYYMMDDIntToDateString(t){if(t===null||typeof t>"u")return"N/A";const e=t.toString();return e.length===8?`${e.substring(0,4)}-${e.substring(4,6)}-${e.substring(6,8)}`:e}function ReceiptsTable({receipts:t=null,loading:e=!1,title:n="Latest Warehouse Receivings"}){const o=React.useMemo(()=>[{accessorKey:"Location",header:"Location",cell:({row:f})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:f.original.Location??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"ReceiptDate",header:"Date",cell:({row:f})=>formatYYYYMMDDIntToDateString(f.original.ReceiptDate),enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:f})=>f.original.Quantity??"N/A",enableSorting:!0,enableFiltering:!0}],[]),l=React.useMemo(()=>{const f={};if(t){const g=Array.from(new Set(t.map(_=>_.Location).filter(_=>_!=null)));f.Location=g;const b=Array.from(new Set(t.map(_=>formatYYYYMMDDIntToDateString(_.ReceiptDate)).filter(_=>_!=="N/A"&&_!=="Invalid Date"))).sort((_,S)=>new Date(S).getTime()-new Date(_).getTime());f.ReceiptDate=b}return f},[t]),d=t||[];return e?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(Skeleton,{className:"h-7 w-56"})," "]}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-[130px]"}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-20"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})]})]})]})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:n})," "]}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:o,data:d,uniqueValues:l})})]})}function ProductOverviewPage({applicationId:t,sku:e,productDefaultOpportunityNumber:n="",productOnAddToCart:o,productAddingToCart:l=!1,productShopifyHostname:d,productCustomAction:f=jsxRuntime.jsx(jsxRuntime.Fragment,{})}){const{data:g,isLoading:b}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:t,randmarSku:e,withSpecification:!1},{skip:!t||!e}),{data:_,isLoading:S}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:t,randmarSku:e,withSpecification:!0},{skip:!g}),R=(g==null?void 0:g.ManufacturerId)!==t;return console.log("readonly",R),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"grid gap-4 grid-cols-1 md:grid-cols-2 lg:grid-cols-3",children:[jsxRuntime.jsx("div",{className:"lg:col-span-2",children:jsxRuntime.jsx(ProductCard,{applicationId:t,product:_||g,defaultOpportunityNumber:n,onAddToCart:o,addingToCart:l,shopifyHostname:d,customAction:f})}),jsxRuntime.jsxs(Card,{className:"h-full flex flex-col",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsxs(CardTitle,{children:[jsxRuntime.jsx(Info,{className:"h-5 w-5 inline mr-2"})," Additional information"]})}),jsxRuntime.jsx(CardContent,{className:"flex flex-col flex-1",children:b?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex flex-col flex-1 mt-4 min-h-0",children:[jsxRuntime.jsx(Skeleton,{className:"h-px w-full my-2"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"flex-1 w-full min-h-40"})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex justify-between",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Category Name"}),jsxRuntime.jsx("span",{className:"font-medium",children:(g==null?void 0:g.ProductType)||"N/A"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Master Carton"}),jsxRuntime.jsx("span",{className:"font-medium",children:(g==null?void 0:g.MasterCarton)||"N/A"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Skid Quantity"}),jsxRuntime.jsx("span",{className:"font-medium",children:(g==null?void 0:g.SkidQuantity)||"N/A"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Automatic Reorder"}),jsxRuntime.jsx("span",{className:"font-medium",children:g!=null&&g.AutoUpdate?"Yes":"No"})]}),((g==null?void 0:g.VoiceoverCaption)||(g==null?void 0:g.BodyHTML))&&jsxRuntime.jsxs("div",{className:"flex flex-col flex-1 mt-4 min-h-0",children:[jsxRuntime.jsx("hr",{className:"my-2"}),jsxRuntime.jsx("div",{className:"text-muted-foreground mb-2",children:"Description"}),jsxRuntime.jsxs("div",{className:"flex-1 overflow-y-auto min-h-40",children:[(g==null?void 0:g.VoiceoverCaption)&&jsxRuntime.jsx("div",{className:"mb-2",children:g==null?void 0:g.VoiceoverCaption}),(g==null?void 0:g.BodyHTML)&&jsxRuntime.jsx("div",{className:"prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:(g==null?void 0:g.BodyHTML)??""}})]})]})]})})]})]}),jsxRuntime.jsx("div",{className:"my-4",children:b?jsxRuntime.jsx("div",{className:"mx-auto flex justify-center items-center h-32",children:jsxRuntime.jsx(LoaderCircle,{className:"h-8 w-8 animate-spin text-primary"})}):jsxRuntime.jsxs(Tabs,{defaultValue:"stats",children:[jsxRuntime.jsxs(TabsList,{className:"inline-flex h-auto items-center justify-center rounded-none border-b bg-transparent p-0",children:[jsxRuntime.jsx(TabsTrigger,{value:"stats",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Statistics"}),jsxRuntime.jsx(TabsTrigger,{value:"opportunities",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Opportunities"}),jsxRuntime.jsx(TabsTrigger,{value:"orders",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Orders"}),jsxRuntime.jsx(TabsTrigger,{value:"warehouse",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Latest Warehouse Receiving"})]}),jsxRuntime.jsx(TabsContent,{value:"stats",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(SalesChart,{salesData:(_==null?void 0:_.SalesStatistics)??[],isLoading:S})})}),jsxRuntime.jsx(TabsContent,{value:"opportunities",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(OpportunitiesTable,{applicationId:t,opportunities:g==null?void 0:g.Opportunities,loading:b})})}),jsxRuntime.jsxs(TabsContent,{value:"orders",children:[jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(OrdersTable,{title:"Open Orders",orders:_==null?void 0:_.ActiveOrderDetails,loading:S})}),jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(OrdersTable,{title:"Completed Orders",orders:_==null?void 0:_.CompletedOrderDetails,loading:S})})]}),jsxRuntime.jsx(TabsContent,{value:"warehouse",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ReceiptsTable,{receipts:_==null?void 0:_.Receipts,loading:S})})})]})})]})}exports.ActiveOrdersCard=ActiveOrdersCard,exports.AiGeneratedContent=AiGeneratedContent,exports.Alert=Alert,exports.AlertDescription=AlertDescription,exports.AlertDialog=AlertDialog,exports.AlertDialogAction=AlertDialogAction,exports.AlertDialogCancel=AlertDialogCancel,exports.AlertDialogContent=AlertDialogContent,exports.AlertDialogDescription=AlertDialogDescription,exports.AlertDialogFooter=AlertDialogFooter,exports.AlertDialogHeader=AlertDialogHeader,exports.AlertDialogTitle=AlertDialogTitle,exports.AlertDialogTrigger=AlertDialogTrigger,exports.AlertTitle=AlertTitle,exports.ApiKeyProvider=ApiKeyProvider,exports.AreaChart=AreaChart,exports.Avatar=Avatar,exports.AvatarFallback=AvatarFallback,exports.AvatarFooter=AvatarFooter,exports.AvatarImage=AvatarImage,exports.Badge=Badge,exports.Button=Button,exports.Card=Card,exports.CardContent=CardContent,exports.CardDescription=CardDescription,exports.CardFooter=CardFooter,exports.CardHeader=CardHeader,exports.CardTitle=CardTitle,exports.ChatLayout=ChatLayout,exports.ChatProvider=ChatProvider,exports.Checkbox=Checkbox,exports.Command=Command,exports.CommandDialog=CommandDialog,exports.CommandEmpty=CommandEmpty,exports.CommandGroup=CommandGroup,exports.CommandInput=CommandInput,exports.CommandItem=CommandItem,exports.CommandList=CommandList,exports.CommandSeparator=CommandSeparator,exports.CommandShortcut=CommandShortcut,exports.CountryFlag=CountryFlag,exports.DataTable=DataTable,exports.Dialog=Dialog,exports.DialogClose=DialogClose,exports.DialogContent=DialogContent,exports.DialogDescription=DialogDescription,exports.DialogFooter=DialogFooter,exports.DialogHeader=DialogHeader,exports.DialogOverlay=DialogOverlay,exports.DialogPortal=DialogPortal,exports.DialogTitle=DialogTitle,exports.DialogTrigger=DialogTrigger,exports.DropdownMenu=DropdownMenu,exports.DropdownMenuCheckboxItem=DropdownMenuCheckboxItem,exports.DropdownMenuContent=DropdownMenuContent,exports.DropdownMenuGroup=DropdownMenuGroup,exports.DropdownMenuItem=DropdownMenuItem,exports.DropdownMenuLabel=DropdownMenuLabel,exports.DropdownMenuPortal=DropdownMenuPortal,exports.DropdownMenuRadioGroup=DropdownMenuRadioGroup,exports.DropdownMenuRadioItem=DropdownMenuRadioItem,exports.DropdownMenuSeparator=DropdownMenuSeparator,exports.DropdownMenuShortcut=DropdownMenuShortcut,exports.DropdownMenuSub=DropdownMenuSub,exports.DropdownMenuSubContent=DropdownMenuSubContent,exports.DropdownMenuSubTrigger=DropdownMenuSubTrigger,exports.DropdownMenuTrigger=DropdownMenuTrigger,exports.ExploreManufacturers=ExploreManufacturers,exports.GeneralDocumentCard=GeneralDocumentCard,exports.Input=Input,exports.InputOTP=InputOTP,exports.InputOTPGroup=InputOTPGroup,exports.InputOTPSeparator=InputOTPSeparator,exports.InputOTPSlot=InputOTPSlot,exports.Label=Label$2,exports.Layout=Layout,exports.ManufacturerCard=ManufacturerCard,exports.ManufacturerGetStartedButton=ManufacturerGetStartedButton,exports.ManufacturerOverviewPage=ManufacturerOverviewPage,exports.ManufacturerReorderingCard=ManufacturerReorderingCard,exports.MultiSelect=MultiSelect,exports.Navbar=Navbar,exports.OpportunitiesTable=OpportunitiesTable,exports.PageHeader=PageHeader,exports.PartnerCard=PartnerCard,exports.PartnerRelationshipPage=PartnerRelationshipPage,exports.Popover=Popover,exports.PopoverAnchor=PopoverAnchor,exports.PopoverContent=PopoverContent,exports.PopoverTrigger=PopoverTrigger,exports.Preloader=Preloader,exports.ProductCard=ProductCard,exports.ProductImage=ProductImage,exports.ProductInventoryGrid=ProductInventoryGrid,exports.ProductOverviewPage=ProductOverviewPage,exports.Progress=Progress,exports.RadioGroup=RadioGroup$1,exports.RadioGroupItem=RadioGroupItem,exports.ResellerBillingOverviewCard=ResellerBillingOverviewCard,exports.ResellerCard=ResellerCard,exports.ResellerOverview=ResellerOverview,exports.ResellerQualificationsCard=ResellerQualificationsCard,exports.RichTextEditor=RichTextEditor,exports.SalesChart=SalesChart,exports.SalesOverviewCard=SalesOverviewCard,exports.ScrollArea=ScrollArea,exports.ScrollBar=ScrollBar,exports.Select=Select,exports.SelectContent=SelectContent,exports.SelectGroup=SelectGroup,exports.SelectItem=SelectItem,exports.SelectLabel=SelectLabel,exports.SelectScrollDownButton=SelectScrollDownButton,exports.SelectScrollUpButton=SelectScrollUpButton,exports.SelectTrigger=SelectTrigger,exports.SelectValue=SelectValue,exports.Separator=Separator$1,exports.Sheet=Sheet,exports.SheetClose=SheetClose,exports.SheetContent=SheetContent,exports.SheetDescription=SheetDescription,exports.SheetFooter=SheetFooter,exports.SheetHeader=SheetHeader,exports.SheetOverlay=SheetOverlay,exports.SheetPortal=SheetPortal,exports.SheetTitle=SheetTitle,exports.SheetTrigger=SheetTrigger,exports.Sidebar=Sidebar,exports.SidebarContent=SidebarContent,exports.SidebarFooter=SidebarFooter,exports.SidebarGroup=SidebarGroup,exports.SidebarGroupAction=SidebarGroupAction,exports.SidebarGroupContent=SidebarGroupContent,exports.SidebarGroupLabel=SidebarGroupLabel,exports.SidebarHeader=SidebarHeader,exports.SidebarInput=SidebarInput,exports.SidebarInset=SidebarInset,exports.SidebarMenu=SidebarMenu,exports.SidebarMenuAction=SidebarMenuAction,exports.SidebarMenuBadge=SidebarMenuBadge,exports.SidebarMenuButton=SidebarMenuButton,exports.SidebarMenuItem=SidebarMenuItem,exports.SidebarMenuSkeleton=SidebarMenuSkeleton,exports.SidebarMenuSub=SidebarMenuSub,exports.SidebarMenuSubButton=SidebarMenuSubButton,exports.SidebarMenuSubItem=SidebarMenuSubItem,exports.SidebarProvider=SidebarProvider,exports.SidebarRail=SidebarRail,exports.SidebarSeparator=SidebarSeparator,exports.SidebarTrigger=SidebarTrigger,exports.Skeleton=Skeleton,exports.Switch=Switch,exports.Table=Table,exports.TableBody=TableBody,exports.TableCaption=TableCaption,exports.TableCell=TableCell,exports.TableFooter=TableFooter,exports.TableHead=TableHead,exports.TableHeader=TableHeader,exports.TableRow=TableRow,exports.Tabs=Tabs,exports.TabsContent=TabsContent,exports.TabsList=TabsList,exports.TabsTrigger=TabsTrigger,exports.Textarea=Textarea,exports.Toast=Toast,exports.ToastAction=ToastAction,exports.ToastClose=ToastClose,exports.ToastDescription=ToastDescription,exports.ToastProvider=ToastProvider,exports.ToastTitle=ToastTitle,exports.ToastViewport=ToastViewport,exports.Toaster=Toaster,exports.Tooltip=Tooltip$1,exports.TooltipContent=TooltipContent,exports.TooltipProvider=TooltipProvider,exports.TooltipTrigger=TooltipTrigger,exports.Topbar=Topbar,exports.badgeVariants=badgeVariants,exports.buttonVariants=buttonVariants,exports.toast=toast,exports.useApiKey=useApiKey,exports.useChat=useChat,exports.useIsMobile=useIsMobile,exports.useSidebar=useSidebar,exports.useToast=useToast,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "randmarcomps",
3
3
  "private": false,
4
- "version": "1.248.0",
4
+ "version": "1.250.0",
5
5
  "description": "The UI library enabling speed and consistency in Randmar frontends.",
6
6
  "type": "module",
7
7
  "files": [