randmarcomps 1.126.0 → 1.127.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.
@@ -23,6 +23,7 @@ import { ReactNode } from 'react';
23
23
  import { RefAttributes } from 'react';
24
24
  import { Reseller } from 'randmar-api-client';
25
25
  import { SalesData } from 'randmar-api-client';
26
+ import { SalesStatistic } from 'randmar-api-client';
26
27
  import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
27
28
  import * as SelectPrimitive from '@radix-ui/react-select';
28
29
  import * as SeparatorPrimitive from '@radix-ui/react-separator';
@@ -354,10 +355,11 @@ declare interface ResellerQualificationsCardProps {
354
355
  loading?: boolean;
355
356
  }
356
357
 
357
- export declare function SalesOverviewCard({ salesData, loading }: SalesOverviewCardProps): JSX.Element;
358
+ export declare function SalesOverviewCard({ salesData, salesStatistics, loading }: SalesOverviewCardProps): JSX.Element;
358
359
 
359
360
  declare interface SalesOverviewCardProps {
360
361
  salesData?: SalesData;
362
+ salesStatistics?: SalesStatistic[];
361
363
  loading?: boolean;
362
364
  }
363
365
 
@@ -54511,53 +54511,93 @@ function ActiveOrdersCard({ orders: t, loading: e = !1 }) {
54511
54511
  ] }, l.name)) })
54512
54512
  ] });
54513
54513
  }
54514
- function SalesOverviewCard({ salesData: t, loading: e = !1 }) {
54515
- const n = (o) => new Intl.NumberFormat("en-CA", {
54514
+ function SalesOverviewCard({ salesData: t, salesStatistics: e = [], loading: n = !1 }) {
54515
+ return n || !t ? /* @__PURE__ */ jsx(SalesOverviewSkeleton, {}) : /* @__PURE__ */ jsx(SalesOverviewData, { salesData: t, salesStatistics: e });
54516
+ }
54517
+ function SalesOverviewSkeleton() {
54518
+ return /* @__PURE__ */ jsxs(Card, { children: [
54519
+ /* @__PURE__ */ jsx(CardHeader, { className: "pb-0", children: /* @__PURE__ */ jsx(CardTitle, { className: "text-lg sm:text-xl", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-40" }) }) }),
54520
+ /* @__PURE__ */ jsxs(CardContent, { className: "pt-4 px-3 sm:px-6", children: [
54521
+ /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4", children: Array(3).fill(0).map((t, e) => /* @__PURE__ */ jsxs("div", { className: "border rounded-lg p-4", children: [
54522
+ /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-center mb-4", children: [
54523
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-24" }),
54524
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-9 w-9 rounded-full" })
54525
+ ] }),
54526
+ /* @__PURE__ */ jsxs("div", { children: [
54527
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-20 mb-1" }),
54528
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-28" })
54529
+ ] })
54530
+ ] }, e)) }),
54531
+ /* @__PURE__ */ jsx("div", { className: "mt-6", children: /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
54532
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-32" }),
54533
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-[250px] w-full rounded-lg" })
54534
+ ] }) })
54535
+ ] })
54536
+ ] });
54537
+ }
54538
+ function SalesOverviewData({
54539
+ salesData: t,
54540
+ salesStatistics: e = []
54541
+ }) {
54542
+ const n = (l) => new Intl.NumberFormat("en-CA", {
54516
54543
  style: "currency",
54517
54544
  currency: "CAD",
54518
54545
  minimumFractionDigits: 2,
54519
54546
  maximumFractionDigits: 2
54520
- }).format(o), i = [
54547
+ }).format(l), i = [
54521
54548
  {
54522
54549
  title: "Last 30 days",
54523
- amount: (t == null ? void 0 : t.SalesLast30Days) || 0,
54550
+ amount: t.SalesLast30Days || 0,
54524
54551
  icon: /* @__PURE__ */ jsx(Calendar, { className: "h-5 w-5 text-white" }),
54525
54552
  color: "bg-blue-500"
54526
54553
  },
54527
54554
  {
54528
54555
  title: "Last 3 months",
54529
- amount: (t == null ? void 0 : t.SalesLast3Months) || 0,
54556
+ amount: t.SalesLast3Months || 0,
54530
54557
  icon: /* @__PURE__ */ jsx(Calendar, { className: "h-5 w-5 text-white" }),
54531
54558
  color: "bg-amber-500"
54532
54559
  },
54533
54560
  {
54534
54561
  title: "Year to date",
54535
- amount: (t == null ? void 0 : t.SalesYearToDay) || 0,
54562
+ amount: t.SalesYearToDay || 0,
54536
54563
  icon: /* @__PURE__ */ jsx(Calendar, { className: "h-5 w-5 text-white" }),
54537
54564
  color: "bg-emerald-500"
54538
54565
  }
54539
- ];
54566
+ ], o = e.sort((l, u) => (l.Day || 0) - (u.Day || 0)).map((l) => {
54567
+ var m;
54568
+ const u = ((m = l.Day) == null ? void 0 : m.toString()) || "", d = u.substring(4, 6), f = u.substring(6, 8);
54569
+ return {
54570
+ date: `${d}/${f}`,
54571
+ amount: l.ExtendedPrice || 0,
54572
+ quantity: l.Quantity || 0
54573
+ };
54574
+ });
54540
54575
  return /* @__PURE__ */ jsxs(Card, { children: [
54541
54576
  /* @__PURE__ */ jsx(CardHeader, { className: "pb-0", children: /* @__PURE__ */ jsx(CardTitle, { className: "text-lg sm:text-xl", children: "Sales Overview" }) }),
54542
- /* @__PURE__ */ jsx(CardContent, { className: "pt-4 px-3 sm:px-6", children: e || !t ? /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4", children: Array(3).fill(0).map((o, l) => /* @__PURE__ */ jsxs("div", { className: "border rounded-lg p-4", children: [
54543
- /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-center mb-4", children: [
54544
- /* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-24" }),
54545
- /* @__PURE__ */ jsx(Skeleton, { className: "h-9 w-9 rounded-full" })
54546
- ] }),
54547
- /* @__PURE__ */ jsxs("div", { children: [
54548
- /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-20 mb-1" }),
54549
- /* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-28" })
54550
- ] })
54551
- ] }, l)) }) : /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4", children: i.map((o, l) => /* @__PURE__ */ jsxs("div", { className: "border rounded-lg p-4", children: [
54552
- /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-center mb-4", children: [
54553
- /* @__PURE__ */ jsx("h3", { className: "text-sm sm:text-base font-medium", children: o.title }),
54554
- /* @__PURE__ */ jsx("div", { className: `p-2 rounded-full ${o.color}`, children: o.icon })
54555
- ] }),
54556
- /* @__PURE__ */ jsxs("div", { children: [
54557
- /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Total Amount" }),
54558
- /* @__PURE__ */ jsx("p", { className: "text-base sm:text-lg font-bold", children: n(o.amount) })
54559
- ] })
54560
- ] }, l)) }) })
54577
+ /* @__PURE__ */ jsxs(CardContent, { className: "pt-4 px-3 sm:px-6", children: [
54578
+ /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4", children: i.map((l, u) => /* @__PURE__ */ jsxs("div", { className: "border rounded-lg p-4", children: [
54579
+ /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-center mb-4", children: [
54580
+ /* @__PURE__ */ jsx("h3", { className: "text-sm sm:text-base font-medium", children: l.title }),
54581
+ /* @__PURE__ */ jsx("div", { className: `p-2 rounded-full ${l.color}`, children: l.icon })
54582
+ ] }),
54583
+ /* @__PURE__ */ jsxs("div", { children: [
54584
+ /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Total Amount" }),
54585
+ /* @__PURE__ */ jsx("p", { className: "text-base sm:text-lg font-bold", children: n(l.amount) })
54586
+ ] })
54587
+ ] }, u)) }),
54588
+ /* @__PURE__ */ jsx("div", { className: "mt-6", children: e && e.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
54589
+ /* @__PURE__ */ jsx("h3", { className: "text-sm font-medium mb-4", children: "Sales Trend" }),
54590
+ /* @__PURE__ */ jsx("div", { className: "space-y-6", children: /* @__PURE__ */ jsx(
54591
+ AreaChart,
54592
+ {
54593
+ data: o,
54594
+ units: "$",
54595
+ unitsPosition: "left",
54596
+ height: 200
54597
+ }
54598
+ ) })
54599
+ ] }) })
54600
+ ] })
54561
54601
  ] });
54562
54602
  }
54563
54603
  function ResellerQualificationsCard({ qualifications: t = [], loading: e = !1 }) {