@burdenoff/microfe-healthybowl 2026.819.9 → 2026.820.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/healthybowl/components/StatCard.js +11 -10
- package/dist/healthybowl/components/StatCard.js.map +1 -1
- package/dist/healthybowl/pages/distribution/CsaPlansPage.js +2 -0
- package/dist/healthybowl/pages/distribution/CsaPlansPage.js.map +1 -1
- package/dist/healthybowl/pages/distribution/DeliveryRouteDetailPage.js +3 -0
- package/dist/healthybowl/pages/distribution/DeliveryRouteDetailPage.js.map +1 -1
- package/dist/healthybowl/pages/distribution/DistributionNav.js +8 -0
- package/dist/healthybowl/pages/distribution/DistributionNav.js.map +1 -1
- package/dist/healthybowl/pages/distribution/DistributionOverviewPage.js +29 -10
- package/dist/healthybowl/pages/distribution/DistributionOverviewPage.js.map +1 -1
- package/dist/healthybowl/pages/market/MarketPricesPage.js +8 -0
- package/dist/healthybowl/pages/market/MarketPricesPage.js.map +1 -1
- package/dist/healthybowl/pages/marketplace/CartPage.js +2 -2
- package/dist/healthybowl/pages/marketplace/CartPage.js.map +1 -1
- package/dist/healthybowl/pages/marketplace/MarketplacePage.js +11 -0
- package/dist/healthybowl/pages/marketplace/MarketplacePage.js.map +1 -1
- package/dist/healthybowl/pages/marketplace/OrdersPage.js +77 -72
- package/dist/healthybowl/pages/marketplace/OrdersPage.js.map +1 -1
- package/dist/healthybowl/pages/marketplace/ProductDetailPage.js +166 -165
- package/dist/healthybowl/pages/marketplace/ProductDetailPage.js.map +1 -1
- package/dist/healthybowl/pages/marketplace/WishlistPage.js +145 -144
- package/dist/healthybowl/pages/marketplace/WishlistPage.js.map +1 -1
- package/package.json +1 -1
|
@@ -7,12 +7,13 @@ var u = {
|
|
|
7
7
|
up: "success",
|
|
8
8
|
down: "destructive",
|
|
9
9
|
stable: "secondary"
|
|
10
|
-
}, d = ({ label: d, value: f, previousValue: p, unit: m, currency: h, icon: g, trend: _, change: v, hero: y = !1, className: b }) => {
|
|
11
|
-
let x = v ?? (p ? Math.round(((typeof f == "number" ? f : 0) - p) / p * 100) : 0),
|
|
10
|
+
}, d = ({ label: d, value: f, previousValue: p, unit: m, currency: h, icon: g, trend: _, change: v, hero: y = !1, className: b, ...x }) => {
|
|
11
|
+
let S = Object.fromEntries(Object.entries(x).filter(([e]) => e.startsWith("data-"))), C = v ?? (p ? Math.round(((typeof f == "number" ? f : 0) - p) / p * 100) : 0), w = _ ?? (C > 0 ? "up" : C < 0 ? "down" : "stable"), T = typeof f == "string" ? f : h ? t(f, h) : `${n(f)}${m ? ` ${m}` : ""}`;
|
|
12
12
|
return /* @__PURE__ */ s(l, {
|
|
13
13
|
treatment: y ? "glass" : "metric",
|
|
14
14
|
glow: y,
|
|
15
15
|
className: e("border-border-seam p-4", b),
|
|
16
|
+
...S,
|
|
16
17
|
children: [
|
|
17
18
|
/* @__PURE__ */ s("div", {
|
|
18
19
|
className: "flex items-center justify-between",
|
|
@@ -28,23 +29,23 @@ var u = {
|
|
|
28
29
|
className: "mt-2 flex items-baseline gap-2",
|
|
29
30
|
children: /* @__PURE__ */ o("span", {
|
|
30
31
|
className: "text-3xl font-semibold tabular-nums text-text-primary",
|
|
31
|
-
children:
|
|
32
|
+
children: T
|
|
32
33
|
})
|
|
33
34
|
}),
|
|
34
|
-
|
|
35
|
+
C !== 0 && /* @__PURE__ */ s("div", {
|
|
35
36
|
className: "mt-2 flex items-center gap-2",
|
|
36
37
|
children: [/* @__PURE__ */ s(c, {
|
|
37
|
-
variant: u[
|
|
38
|
+
variant: u[w],
|
|
38
39
|
className: "gap-1",
|
|
39
40
|
children: [
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
w === "up" && /* @__PURE__ */ o(a, { className: "h-3 w-3" }),
|
|
42
|
+
w === "down" && /* @__PURE__ */ o(i, { className: "h-3 w-3" }),
|
|
43
|
+
w === "stable" && /* @__PURE__ */ o(r, { className: "h-3 w-3" }),
|
|
43
44
|
/* @__PURE__ */ s("span", {
|
|
44
45
|
className: "tabular-nums",
|
|
45
46
|
children: [
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
C > 0 ? "+" : "",
|
|
48
|
+
C,
|
|
48
49
|
"%"
|
|
49
50
|
]
|
|
50
51
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StatCard.js","names":[],"sources":["../../../src/healthybowl/components/StatCard.tsx"],"sourcesContent":["import type { FC, ReactNode } from 'react';\nimport { TrendingUp, TrendingDown, Minus } from 'lucide-react';\nimport { GlassCard, Badge } from '@burdenoff/fe-libs/ui';\nimport { cn, formatNumber, formatCurrency } from '../utils/helpers';\n\ninterface StatCardProps {\n label: string;\n value: number | string;\n previousValue?: number;\n unit?: string;\n /**\n * Render a numeric `value` as money in this ISO 4217 currency (e.g. `'INR'`).\n * Replaces the old dollar-sign prefix flag, which formatted every tile it\n * touched as US dollars regardless of what the amount actually was.\n */\n currency?: string;\n icon?: ReactNode;\n trend?: 'up' | 'down' | 'stable';\n change?: number;\n /** Render this tile as the page's hero metric (glass treatment + accent glow). */\n hero?: boolean;\n className?: string;\n}\n\n/**\n * KPI tile re-based onto the Boff UI 2.0 `GlassCard` \"metric\" treatment (accent\n * wash + seam border + soft pop) so every metric reads as elevated-but-quiet\n * glass. The single hero metric per page may opt into the richer \"glass\"\n * treatment with an accent glow via `hero`. A large `tabular-nums` value plus an\n * optional period-over-period delta rendered as a `Badge`. Money tiles opt in\n * with `currency` (ISO 4217); everything else formats as a plain number with an\n * optional `unit`. No hover movement — GlassCard only intensifies its shadow.\n * Semantic tokens only — no raw colors.\n */\nconst trendBadgeVariant: Record<'up' | 'down' | 'stable', 'success' | 'destructive' | 'secondary'> = {\n up: 'success',\n down: 'destructive',\n stable: 'secondary',\n};\n\nexport const StatCard: FC<StatCardProps> = ({\n label,\n value,\n previousValue,\n unit,\n currency,\n icon,\n trend,\n change,\n hero = false,\n className,\n}) => {\n const numericValue = typeof value === 'number' ? value : 0;\n const computedChange =\n change ?? (previousValue ? Math.round(((numericValue - previousValue) / previousValue) * 100) : 0);\n const computedTrend = trend ?? (computedChange > 0 ? 'up' : computedChange < 0 ? 'down' : 'stable');\n\n const displayValue =\n typeof value === 'string'\n ? value\n : currency\n ? formatCurrency(value, currency)\n : `${formatNumber(value)}${unit ? ` ${unit}` : ''}`;\n\n return (\n <GlassCard
|
|
1
|
+
{"version":3,"file":"StatCard.js","names":[],"sources":["../../../src/healthybowl/components/StatCard.tsx"],"sourcesContent":["import type { FC, ReactNode } from 'react';\nimport { TrendingUp, TrendingDown, Minus } from 'lucide-react';\nimport { GlassCard, Badge } from '@burdenoff/fe-libs/ui';\nimport { cn, formatNumber, formatCurrency } from '../utils/helpers';\n\ninterface StatCardProps {\n label: string;\n value: number | string;\n previousValue?: number;\n unit?: string;\n /**\n * Render a numeric `value` as money in this ISO 4217 currency (e.g. `'INR'`).\n * Replaces the old dollar-sign prefix flag, which formatted every tile it\n * touched as US dollars regardless of what the amount actually was.\n */\n currency?: string;\n icon?: ReactNode;\n trend?: 'up' | 'down' | 'stable';\n change?: number;\n /** Render this tile as the page's hero metric (glass treatment + accent glow). */\n hero?: boolean;\n className?: string;\n /**\n * Arbitrary `data-*` attributes, forwarded to the card's root (BOFF-6065).\n *\n * KPI tiles are what several E2E journeys assert MOVED — \"the stat cards reflect the new\n * listing\". Reading that off rendered text means parsing a localised, `formatNumber`-formatted\n * string, which breaks the moment the locale or the thousands separator changes. A\n * `data-value` carrying the raw number is stable in every language.\n *\n * Typed as an index signature rather than spread `...rest`, so a typo in a real prop name is\n * still a type error instead of silently becoming an unknown attribute.\n */\n [dataAttr: `data-${string}`]: string | number | boolean | undefined;\n}\n\n/**\n * KPI tile re-based onto the Boff UI 2.0 `GlassCard` \"metric\" treatment (accent\n * wash + seam border + soft pop) so every metric reads as elevated-but-quiet\n * glass. The single hero metric per page may opt into the richer \"glass\"\n * treatment with an accent glow via `hero`. A large `tabular-nums` value plus an\n * optional period-over-period delta rendered as a `Badge`. Money tiles opt in\n * with `currency` (ISO 4217); everything else formats as a plain number with an\n * optional `unit`. No hover movement — GlassCard only intensifies its shadow.\n * Semantic tokens only — no raw colors.\n */\nconst trendBadgeVariant: Record<'up' | 'down' | 'stable', 'success' | 'destructive' | 'secondary'> = {\n up: 'success',\n down: 'destructive',\n stable: 'secondary',\n};\n\nexport const StatCard: FC<StatCardProps> = ({\n label,\n value,\n previousValue,\n unit,\n currency,\n icon,\n trend,\n change,\n hero = false,\n className,\n ...rest\n}) => {\n // Only `data-*` survives the spread. Anything else reaching the root would be an unknown DOM\n // attribute React warns about at runtime — the index signature above already constrains the\n // type, and this makes the value match it.\n const dataAttrs = Object.fromEntries(Object.entries(rest).filter(([k]) => k.startsWith('data-')));\n const numericValue = typeof value === 'number' ? value : 0;\n const computedChange =\n change ?? (previousValue ? Math.round(((numericValue - previousValue) / previousValue) * 100) : 0);\n const computedTrend = trend ?? (computedChange > 0 ? 'up' : computedChange < 0 ? 'down' : 'stable');\n\n const displayValue =\n typeof value === 'string'\n ? value\n : currency\n ? formatCurrency(value, currency)\n : `${formatNumber(value)}${unit ? ` ${unit}` : ''}`;\n\n return (\n <GlassCard\n treatment={hero ? 'glass' : 'metric'}\n glow={hero}\n className={cn('border-border-seam p-4', className)}\n {...dataAttrs}\n >\n <div className=\"flex items-center justify-between\">\n <span className=\"text-sm font-medium text-text-secondary\">{label}</span>\n {icon && (\n <span className=\"flex size-8 items-center justify-center rounded-lg bg-[var(--color-accent-soft)] text-text-primary [&>svg]:size-4\">\n {icon}\n </span>\n )}\n </div>\n <div className=\"mt-2 flex items-baseline gap-2\">\n <span className=\"text-3xl font-semibold tabular-nums text-text-primary\">{displayValue}</span>\n </div>\n {computedChange !== 0 && (\n <div className=\"mt-2 flex items-center gap-2\">\n <Badge variant={trendBadgeVariant[computedTrend]} className=\"gap-1\">\n {computedTrend === 'up' && <TrendingUp className=\"h-3 w-3\" />}\n {computedTrend === 'down' && <TrendingDown className=\"h-3 w-3\" />}\n {computedTrend === 'stable' && <Minus className=\"h-3 w-3\" />}\n <span className=\"tabular-nums\">\n {computedChange > 0 ? '+' : ''}\n {computedChange}%\n </span>\n </Badge>\n <span className=\"text-xs text-text-secondary\">vs last period</span>\n </div>\n )}\n </GlassCard>\n );\n};\n"],"mappings":";;;;;AA8CA,IAAM,IAA+F;CACnG,IAAI;CACJ,MAAM;CACN,QAAQ;AACV,GAEa,KAA+B,EAC1C,UACA,UACA,kBACA,SACA,aACA,SACA,UACA,WACA,UAAO,IACP,cACA,GAAG,QACC;CAIJ,IAAM,IAAY,OAAO,YAAY,OAAO,QAAQ,CAAI,EAAE,QAAQ,CAAC,OAAO,EAAE,WAAW,OAAO,CAAC,CAAC,GAE1F,IACJ,MAAW,IAAgB,KAAK,QAFb,OAAO,KAAU,WAAW,IAAQ,KAEA,KAAiB,IAAiB,GAAG,IAAI,IAC5F,IAAgB,MAAU,IAAiB,IAAI,OAAO,IAAiB,IAAI,SAAS,WAEpF,IACJ,OAAO,KAAU,WACb,IACA,IACE,EAAe,GAAO,CAAQ,IAC9B,GAAG,EAAa,CAAK,IAAI,IAAO,IAAI,MAAS;CAErD,OACE,kBAAC,GAAD;EACE,WAAW,IAAO,UAAU;EAC5B,MAAM;EACN,WAAW,EAAG,0BAA0B,CAAS;EACjD,GAAI;YAJN;GAME,kBAAC,OAAD;IAAK,WAAU;cAAf,CACE,kBAAC,QAAD;KAAM,WAAU;eAA2C;IAAY,CAAA,GACtE,KACC,kBAAC,QAAD;KAAM,WAAU;eACb;IACG,CAAA,CAEL;;GACL,kBAAC,OAAD;IAAK,WAAU;cACb,kBAAC,QAAD;KAAM,WAAU;eAAyD;IAAmB,CAAA;GACzF,CAAA;GACJ,MAAmB,KAClB,kBAAC,OAAD;IAAK,WAAU;cAAf,CACE,kBAAC,GAAD;KAAO,SAAS,EAAkB;KAAgB,WAAU;eAA5D;MACG,MAAkB,QAAQ,kBAAC,GAAD,EAAY,WAAU,UAAW,CAAA;MAC3D,MAAkB,UAAU,kBAAC,GAAD,EAAc,WAAU,UAAW,CAAA;MAC/D,MAAkB,YAAY,kBAAC,GAAD,EAAO,WAAU,UAAW,CAAA;MAC3D,kBAAC,QAAD;OAAM,WAAU;iBAAhB;QACG,IAAiB,IAAI,MAAM;QAC3B;QAAe;OACZ;;KACD;QACP,kBAAC,QAAD;KAAM,WAAU;eAA8B;IAAoB,CAAA,CAC/D;;EAEE;;AAEf"}
|
|
@@ -129,6 +129,8 @@ var k = () => {
|
|
|
129
129
|
header: k("healthybowl.distribution.csa.table.billing", "Billing"),
|
|
130
130
|
render: (e) => /* @__PURE__ */ D("div", {
|
|
131
131
|
className: "flex items-center gap-2",
|
|
132
|
+
"data-testid": "csa-plan-billing",
|
|
133
|
+
"data-status": e.billingSyncStatus,
|
|
132
134
|
children: [/* @__PURE__ */ E(o, {
|
|
133
135
|
variant: m(e.billingSyncStatus),
|
|
134
136
|
label: e.billingSyncStatus
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CsaPlansPage.js","names":[],"sources":["../../../../src/healthybowl/pages/distribution/CsaPlansPage.tsx"],"sourcesContent":["/**\n * CSA subscription plans (BOFF-2884).\n * Each row is a real CsaPlan; billing sync status reflects the platform billing\n * service registration. A FAILED sync exposes a re-save affordance that re-persists\n * the plan and reports the true resulting billing status. No fabricated data.\n */\nimport { useState } from 'react';\nimport { useNavigate } from 'react-router';\nimport { Boxes, Pencil, Plus, RefreshCw, Trash2 } from 'lucide-react';\nimport { Button } from '@burdenoff/fe-libs/ui';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport {\n PageLayout,\n StatCard,\n DataTable,\n StatusBadge,\n EmptyState,\n ErrorState,\n PageLoader,\n useConfirm,\n} from '../../components';\nimport type { Column } from '../../components';\nimport { useToast } from '../../hooks/useToast';\nimport { useBasePath } from '../../hooks/useBasePath';\nimport { cn, formatCurrency } from '../../utils/helpers';\nimport { useHealthyBowlDistribution, type CsaPlan } from '../../hooks/useHealthyBowlDistribution';\nimport { DistributionNav } from './DistributionNav';\nimport { CsaPlanFormModal } from './CsaPlanFormModal';\nimport { billingStatusVariant, planStatusVariant } from './labels';\n\nexport const CsaPlansPage = () => {\n const { t } = useI18n();\n const navigate = useNavigate();\n const { buildPath } = useBasePath();\n const { toast } = useToast();\n const confirm = useConfirm();\n\n const { plans, loading, errors, refetchPlans, createPlan, updatePlan, deletePlan } = useHealthyBowlDistribution({\n plans: true,\n });\n\n const [formOpen, setFormOpen] = useState(false);\n const [editingPlan, setEditingPlan] = useState<CsaPlan | null>(null);\n const [busyId, setBusyId] = useState<string | null>(null);\n\n const openCreate = () => {\n setEditingPlan(null);\n setFormOpen(true);\n };\n const openEdit = (plan: CsaPlan) => {\n setEditingPlan(plan);\n setFormOpen(true);\n };\n\n const handleSubmit = async (input: Record<string, unknown>) => {\n if (editingPlan) {\n await updatePlan(input);\n toast({\n title: t('healthybowl.distribution.csa.toast.updated', 'Plan updated'),\n description: String(input.name ?? editingPlan.name),\n variant: 'success',\n });\n } else {\n const created = await createPlan(input);\n toast({\n title: t('healthybowl.distribution.csa.toast.created', 'Subscription plan created'),\n description:\n created && created.billingSyncStatus === 'FAILED'\n ? t(\n 'healthybowl.distribution.csa.toast.createdBillingFailed',\n 'Plan saved, but billing registration failed — retry from the plan row.'\n )\n : t('healthybowl.distribution.csa.toast.createdOk', 'Plan saved and billing registered.'),\n variant: created && created.billingSyncStatus === 'FAILED' ? 'warning' : 'success',\n });\n }\n };\n\n const handleRetryBilling = async (plan: CsaPlan) => {\n setBusyId(plan.id);\n try {\n const updated = await updatePlan({ id: plan.id, name: plan.name });\n const synced = updated?.billingSyncStatus === 'SYNCED';\n toast({\n title: synced\n ? t('healthybowl.distribution.csa.toast.billingSynced', 'Billing synced')\n : t('healthybowl.distribution.csa.toast.billingStill', 'Billing still needs attention'),\n description: synced\n ? plan.name\n : (updated?.billingSyncError ??\n t('healthybowl.distribution.csa.toast.billingRetryHint', 'The billing service did not confirm the plan.')),\n variant: synced ? 'success' : 'warning',\n });\n } catch (err) {\n toast({\n title: t('healthybowl.distribution.csa.toast.retryFailed', 'Retry failed'),\n description: err instanceof Error ? err.message : String(err),\n variant: 'error',\n });\n } finally {\n setBusyId(null);\n }\n };\n\n const handleDelete = async (plan: CsaPlan) => {\n if (\n !(await confirm({\n title: t('healthybowl.distribution.csa.confirm.deleteTitle', 'Delete plan?'),\n message: t(\n 'healthybowl.distribution.csa.confirm.delete',\n 'Delete \"{{name}}\"? Plans with active members must have them cancelled first.',\n { name: plan.name }\n ),\n }))\n )\n return;\n setBusyId(plan.id);\n try {\n await deletePlan(plan.id);\n toast({\n title: t('healthybowl.distribution.csa.toast.deleted', 'Plan deleted'),\n description: plan.name,\n variant: 'success',\n });\n } catch (err) {\n toast({\n title: t('healthybowl.distribution.csa.toast.deleteFailed', 'Could not delete plan'),\n description: err instanceof Error ? err.message : String(err),\n variant: 'error',\n });\n } finally {\n setBusyId(null);\n }\n };\n\n const columns: Column<CsaPlan>[] = [\n {\n key: 'name',\n header: t('healthybowl.distribution.csa.table.plan', 'Plan'),\n render: (p) => (\n <div>\n <div className=\"font-medium text-text-primary\">{p.name}</div>\n <div className=\"text-xs text-text-secondary\">\n {p.boxSize} · {p.frequency}\n </div>\n </div>\n ),\n },\n {\n key: 'status',\n header: t('healthybowl.distribution.csa.table.status', 'Status'),\n render: (p) => <StatusBadge variant={planStatusVariant(p.status)} label={p.status} dot />,\n },\n {\n key: 'price',\n header: t('healthybowl.distribution.csa.table.price', 'Price'),\n render: (p) => <span className=\"tabular-nums\">{formatCurrency(p.price, p.currency || 'INR')}</span>,\n },\n {\n // BOFF-6088 — assignedMemberCount (ACTIVE+PAUSED) is the figure the enrolment gate counts\n // against; activeMemberCount alone would show room the plan does not actually have.\n key: 'members',\n header: t('healthybowl.distribution.csa.table.members', 'Members'),\n render: (p) => (\n <span className={cn('tabular-nums', p.atCapacity && 'font-medium text-[color:var(--color-warning)]')}>\n {p.assignedMemberCount}\n {p.capacity !== null ? ` / ${p.capacity}` : ''}\n </span>\n ),\n },\n {\n key: 'billing',\n header: t('healthybowl.distribution.csa.table.billing', 'Billing'),\n render: (p) => (\n <div className=\"flex items-center gap-2\">\n <StatusBadge variant={billingStatusVariant(p.billingSyncStatus)} label={p.billingSyncStatus} />\n {p.billingSyncStatus === 'FAILED' ? (\n <Button\n variant=\"outline\"\n size=\"sm\"\n disabled={busyId === p.id}\n onClick={(e) => {\n e.stopPropagation();\n void handleRetryBilling(p);\n }}\n className=\"text-status-warning-text\"\n >\n <RefreshCw className=\"h-3.5 w-3.5\" /> {t('healthybowl.distribution.csa.actions.retry', 'Retry')}\n </Button>\n ) : null}\n </div>\n ),\n },\n {\n key: 'actions',\n header: '',\n render: (p) => (\n <div className=\"flex items-center justify-end gap-1\">\n <Button\n variant=\"ghost\"\n size=\"icon-sm\"\n disabled={busyId === p.id}\n onClick={(e) => {\n e.stopPropagation();\n openEdit(p);\n }}\n aria-label={t('healthybowl.distribution.csa.actions.edit', 'Edit plan')}\n >\n <Pencil className=\"h-4 w-4\" />\n </Button>\n <Button\n variant=\"ghost\"\n size=\"icon-sm\"\n disabled={busyId === p.id}\n onClick={(e) => {\n e.stopPropagation();\n void handleDelete(p);\n }}\n aria-label={t('healthybowl.distribution.csa.actions.delete', 'Delete plan')}\n className=\"text-text-secondary hover:text-status-error-text\"\n >\n <Trash2 className=\"h-4 w-4\" />\n </Button>\n </div>\n ),\n },\n ];\n\n const activePlans = plans.filter((p) => p.status === 'ACTIVE').length;\n const totalMembers = plans.reduce((sum, p) => sum + p.activeMemberCount, 0);\n\n if (loading.plans && plans.length === 0) {\n return <PageLoader />;\n }\n\n return (\n <PageLayout\n title={t('healthybowl.distribution.csa.title', 'CSA Subscription Boxes')}\n description={t(\n 'healthybowl.distribution.csa.description',\n 'Recurring produce boxes billed on a schedule through the platform billing service.'\n )}\n actions={\n <Button onClick={openCreate}>\n <Plus className=\"h-4 w-4\" />\n {t('healthybowl.distribution.csa.actions.new', 'New Subscription Plan')}\n </Button>\n }\n >\n <DistributionNav />\n\n {errors.plans && plans.length === 0 ? (\n <ErrorState description={errors.plans.message} onRetry={() => void refetchPlans()} />\n ) : (\n <>\n <div className=\"mt-4 grid grid-cols-1 gap-3 sm:grid-cols-3\">\n <StatCard\n label={t('healthybowl.distribution.csa.stats.plans', 'Active plans')}\n value={activePlans}\n icon={<Boxes className=\"h-5 w-5\" />}\n hero\n />\n <StatCard label={t('healthybowl.distribution.csa.stats.total', 'Total plans')} value={plans.length} />\n <StatCard label={t('healthybowl.distribution.csa.stats.members', 'Active members')} value={totalMembers} />\n </div>\n\n {plans.length === 0 ? (\n <EmptyState\n icon={<Boxes className=\"h-8 w-8 text-text-secondary\" />}\n title={t('healthybowl.distribution.csa.empty.title', 'No subscription plans yet')}\n description={t(\n 'healthybowl.distribution.csa.empty.description',\n 'Create a CSA plan to offer recurring produce boxes with scheduled billing and delivery.'\n )}\n action={\n <Button onClick={openCreate}>\n <Plus className=\"h-4 w-4\" />\n {t('healthybowl.distribution.csa.actions.new', 'New Subscription Plan')}\n </Button>\n }\n />\n ) : (\n <DataTable\n columns={columns}\n data={plans}\n keyField=\"id\"\n pageSize={10}\n onRowClick={(p) => navigate(buildPath(`distribution/csa/${p.id}`))}\n />\n )}\n </>\n )}\n\n <CsaPlanFormModal open={formOpen} onClose={() => setFormOpen(false)} plan={editingPlan} onSubmit={handleSubmit} />\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA8BA,IAAa,UAAqB;CAChC,IAAM,EAAE,SAAM,EAAQ,GAChB,IAAW,EAAY,GACvB,EAAE,iBAAc,EAAY,GAC5B,EAAE,aAAU,EAAS,GACrB,IAAU,EAAW,GAErB,EAAE,UAAO,YAAS,WAAQ,iBAAc,eAAY,eAAY,kBAAe,EAA2B,EAC9G,OAAO,GACT,CAAC,GAEK,CAAC,GAAU,KAAe,EAAS,EAAK,GACxC,CAAC,GAAa,KAAkB,EAAyB,IAAI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AC,GAAD,EAAM,WAAU,UAAW,CAAA,GAC1B,EAAE,4CAA4C,uBAAuB,CAChE;;YAVZ;GAaE,kBAAC,GAAD,CAAkB,CAAA;GAEjB,EAAO,SAAS,EAAM,WAAW,IAChC,kBAAC,GAAD;IAAY,aAAa,EAAO,MAAM;IAAS,eAAe,KAAK,EAAa;GAAI,CAAA,IAEpF,kBAAA,GAAA,EAAA,UAAA,CACE,kBAAC,OAAD;IAAK,WAAU;cAAf;KACE,kBAAC,GAAD;MACE,OAAO,EAAE,4CAA4C,cAAc;MACnE,OAAO;MACP,MAAM,kBAAC,GAAD,EAAO,WAAU,UAAW,CAAA;MAClC,MAAA;KACD,CAAA;KACD,kBAAC,GAAD;MAAU,OAAO,EAAE,4CAA4C,aAAa;MAAG,OAAO,EAAM;KAAS,CAAA;KACrG,kBAAC,GAAD;MAAU,OAAO,EAAE,8CAA8C,gBAAgB;MAAG,OAAO;KAAe,CAAA;IACvG;OAEJ,EAAM,WAAW,IAChB,kBAAC,GAAD;IACE,MAAM,kBAAC,GAAD,EAAO,WAAU,8BAA+B,CAAA;IACtD,OAAO,EAAE,4CAA4C,2BAA2B;IAChF,aAAa,EACX,kDACA,yFACF;IACA,QACE,kBAAC,GAAD;KAAQ,SAAS;eAAjB,CACE,kBAAC,GAAD,EAAM,WAAU,UAAW,CAAA,GAC1B,EAAE,4CAA4C,uBAAuB,CAChE;;GAEX,CAAA,IAED,kBAAC,GAAD;IACW;IACT,MAAM;IACN,UAAS;IACT,UAAU;IACV,aAAa,MAAM,EAAS,EAAU,oBAAoB,EAAE,IAAI,CAAC;GAClE,CAAA,CAEH,EAAA,CAAA;GAGJ,kBAAC,GAAD;IAAkB,MAAM;IAAU,eAAe,EAAY,EAAK;IAAG,MAAM;IAAa,UAAU;GAAe,CAAA;EACvG;;AAEhB"}
|
|
1
|
+
{"version":3,"file":"CsaPlansPage.js","names":[],"sources":["../../../../src/healthybowl/pages/distribution/CsaPlansPage.tsx"],"sourcesContent":["/**\n * CSA subscription plans (BOFF-2884).\n * Each row is a real CsaPlan; billing sync status reflects the platform billing\n * service registration. A FAILED sync exposes a re-save affordance that re-persists\n * the plan and reports the true resulting billing status. No fabricated data.\n */\nimport { useState } from 'react';\nimport { useNavigate } from 'react-router';\nimport { Boxes, Pencil, Plus, RefreshCw, Trash2 } from 'lucide-react';\nimport { Button } from '@burdenoff/fe-libs/ui';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport {\n PageLayout,\n StatCard,\n DataTable,\n StatusBadge,\n EmptyState,\n ErrorState,\n PageLoader,\n useConfirm,\n} from '../../components';\nimport type { Column } from '../../components';\nimport { useToast } from '../../hooks/useToast';\nimport { useBasePath } from '../../hooks/useBasePath';\nimport { cn, formatCurrency } from '../../utils/helpers';\nimport { useHealthyBowlDistribution, type CsaPlan } from '../../hooks/useHealthyBowlDistribution';\nimport { DistributionNav } from './DistributionNav';\nimport { CsaPlanFormModal } from './CsaPlanFormModal';\nimport { billingStatusVariant, planStatusVariant } from './labels';\n\nexport const CsaPlansPage = () => {\n const { t } = useI18n();\n const navigate = useNavigate();\n const { buildPath } = useBasePath();\n const { toast } = useToast();\n const confirm = useConfirm();\n\n const { plans, loading, errors, refetchPlans, createPlan, updatePlan, deletePlan } = useHealthyBowlDistribution({\n plans: true,\n });\n\n const [formOpen, setFormOpen] = useState(false);\n const [editingPlan, setEditingPlan] = useState<CsaPlan | null>(null);\n const [busyId, setBusyId] = useState<string | null>(null);\n\n const openCreate = () => {\n setEditingPlan(null);\n setFormOpen(true);\n };\n const openEdit = (plan: CsaPlan) => {\n setEditingPlan(plan);\n setFormOpen(true);\n };\n\n const handleSubmit = async (input: Record<string, unknown>) => {\n if (editingPlan) {\n await updatePlan(input);\n toast({\n title: t('healthybowl.distribution.csa.toast.updated', 'Plan updated'),\n description: String(input.name ?? editingPlan.name),\n variant: 'success',\n });\n } else {\n const created = await createPlan(input);\n toast({\n title: t('healthybowl.distribution.csa.toast.created', 'Subscription plan created'),\n description:\n created && created.billingSyncStatus === 'FAILED'\n ? t(\n 'healthybowl.distribution.csa.toast.createdBillingFailed',\n 'Plan saved, but billing registration failed — retry from the plan row.'\n )\n : t('healthybowl.distribution.csa.toast.createdOk', 'Plan saved and billing registered.'),\n variant: created && created.billingSyncStatus === 'FAILED' ? 'warning' : 'success',\n });\n }\n };\n\n const handleRetryBilling = async (plan: CsaPlan) => {\n setBusyId(plan.id);\n try {\n const updated = await updatePlan({ id: plan.id, name: plan.name });\n const synced = updated?.billingSyncStatus === 'SYNCED';\n toast({\n title: synced\n ? t('healthybowl.distribution.csa.toast.billingSynced', 'Billing synced')\n : t('healthybowl.distribution.csa.toast.billingStill', 'Billing still needs attention'),\n description: synced\n ? plan.name\n : (updated?.billingSyncError ??\n t('healthybowl.distribution.csa.toast.billingRetryHint', 'The billing service did not confirm the plan.')),\n variant: synced ? 'success' : 'warning',\n });\n } catch (err) {\n toast({\n title: t('healthybowl.distribution.csa.toast.retryFailed', 'Retry failed'),\n description: err instanceof Error ? err.message : String(err),\n variant: 'error',\n });\n } finally {\n setBusyId(null);\n }\n };\n\n const handleDelete = async (plan: CsaPlan) => {\n if (\n !(await confirm({\n title: t('healthybowl.distribution.csa.confirm.deleteTitle', 'Delete plan?'),\n message: t(\n 'healthybowl.distribution.csa.confirm.delete',\n 'Delete \"{{name}}\"? Plans with active members must have them cancelled first.',\n { name: plan.name }\n ),\n }))\n )\n return;\n setBusyId(plan.id);\n try {\n await deletePlan(plan.id);\n toast({\n title: t('healthybowl.distribution.csa.toast.deleted', 'Plan deleted'),\n description: plan.name,\n variant: 'success',\n });\n } catch (err) {\n toast({\n title: t('healthybowl.distribution.csa.toast.deleteFailed', 'Could not delete plan'),\n description: err instanceof Error ? err.message : String(err),\n variant: 'error',\n });\n } finally {\n setBusyId(null);\n }\n };\n\n const columns: Column<CsaPlan>[] = [\n {\n key: 'name',\n header: t('healthybowl.distribution.csa.table.plan', 'Plan'),\n render: (p) => (\n <div>\n <div className=\"font-medium text-text-primary\">{p.name}</div>\n <div className=\"text-xs text-text-secondary\">\n {p.boxSize} · {p.frequency}\n </div>\n </div>\n ),\n },\n {\n key: 'status',\n header: t('healthybowl.distribution.csa.table.status', 'Status'),\n render: (p) => <StatusBadge variant={planStatusVariant(p.status)} label={p.status} dot />,\n },\n {\n key: 'price',\n header: t('healthybowl.distribution.csa.table.price', 'Price'),\n render: (p) => <span className=\"tabular-nums\">{formatCurrency(p.price, p.currency || 'INR')}</span>,\n },\n {\n // BOFF-6088 — assignedMemberCount (ACTIVE+PAUSED) is the figure the enrolment gate counts\n // against; activeMemberCount alone would show room the plan does not actually have.\n key: 'members',\n header: t('healthybowl.distribution.csa.table.members', 'Members'),\n render: (p) => (\n <span className={cn('tabular-nums', p.atCapacity && 'font-medium text-[color:var(--color-warning)]')}>\n {p.assignedMemberCount}\n {p.capacity !== null ? ` / ${p.capacity}` : ''}\n </span>\n ),\n },\n {\n key: 'billing',\n header: t('healthybowl.distribution.csa.table.billing', 'Billing'),\n render: (p) => (\n // BOFF-6065 — the whole point of this cell is that the global-billing plan was really\n // registered, so the journey asserts SYNCED-or-FAILED and specifically that it is not\n // blank. The badge label is the status string; the attribute is what a spec reads.\n <div className=\"flex items-center gap-2\" data-testid=\"csa-plan-billing\" data-status={p.billingSyncStatus}>\n <StatusBadge variant={billingStatusVariant(p.billingSyncStatus)} label={p.billingSyncStatus} />\n {p.billingSyncStatus === 'FAILED' ? (\n <Button\n variant=\"outline\"\n size=\"sm\"\n disabled={busyId === p.id}\n onClick={(e) => {\n e.stopPropagation();\n void handleRetryBilling(p);\n }}\n className=\"text-status-warning-text\"\n >\n <RefreshCw className=\"h-3.5 w-3.5\" /> {t('healthybowl.distribution.csa.actions.retry', 'Retry')}\n </Button>\n ) : null}\n </div>\n ),\n },\n {\n key: 'actions',\n header: '',\n render: (p) => (\n <div className=\"flex items-center justify-end gap-1\">\n <Button\n variant=\"ghost\"\n size=\"icon-sm\"\n disabled={busyId === p.id}\n onClick={(e) => {\n e.stopPropagation();\n openEdit(p);\n }}\n aria-label={t('healthybowl.distribution.csa.actions.edit', 'Edit plan')}\n >\n <Pencil className=\"h-4 w-4\" />\n </Button>\n <Button\n variant=\"ghost\"\n size=\"icon-sm\"\n disabled={busyId === p.id}\n onClick={(e) => {\n e.stopPropagation();\n void handleDelete(p);\n }}\n aria-label={t('healthybowl.distribution.csa.actions.delete', 'Delete plan')}\n className=\"text-text-secondary hover:text-status-error-text\"\n >\n <Trash2 className=\"h-4 w-4\" />\n </Button>\n </div>\n ),\n },\n ];\n\n const activePlans = plans.filter((p) => p.status === 'ACTIVE').length;\n const totalMembers = plans.reduce((sum, p) => sum + p.activeMemberCount, 0);\n\n if (loading.plans && plans.length === 0) {\n return <PageLoader />;\n }\n\n return (\n <PageLayout\n title={t('healthybowl.distribution.csa.title', 'CSA Subscription Boxes')}\n description={t(\n 'healthybowl.distribution.csa.description',\n 'Recurring produce boxes billed on a schedule through the platform billing service.'\n )}\n actions={\n <Button onClick={openCreate}>\n <Plus className=\"h-4 w-4\" />\n {t('healthybowl.distribution.csa.actions.new', 'New Subscription Plan')}\n </Button>\n }\n >\n <DistributionNav />\n\n {errors.plans && plans.length === 0 ? (\n <ErrorState description={errors.plans.message} onRetry={() => void refetchPlans()} />\n ) : (\n <>\n <div className=\"mt-4 grid grid-cols-1 gap-3 sm:grid-cols-3\">\n <StatCard\n label={t('healthybowl.distribution.csa.stats.plans', 'Active plans')}\n value={activePlans}\n icon={<Boxes className=\"h-5 w-5\" />}\n hero\n />\n <StatCard label={t('healthybowl.distribution.csa.stats.total', 'Total plans')} value={plans.length} />\n <StatCard label={t('healthybowl.distribution.csa.stats.members', 'Active members')} value={totalMembers} />\n </div>\n\n {plans.length === 0 ? (\n <EmptyState\n icon={<Boxes className=\"h-8 w-8 text-text-secondary\" />}\n title={t('healthybowl.distribution.csa.empty.title', 'No subscription plans yet')}\n description={t(\n 'healthybowl.distribution.csa.empty.description',\n 'Create a CSA plan to offer recurring produce boxes with scheduled billing and delivery.'\n )}\n action={\n <Button onClick={openCreate}>\n <Plus className=\"h-4 w-4\" />\n {t('healthybowl.distribution.csa.actions.new', 'New Subscription Plan')}\n </Button>\n }\n />\n ) : (\n <DataTable\n columns={columns}\n data={plans}\n keyField=\"id\"\n pageSize={10}\n onRowClick={(p) => navigate(buildPath(`distribution/csa/${p.id}`))}\n />\n )}\n </>\n )}\n\n <CsaPlanFormModal open={formOpen} onClose={() => setFormOpen(false)} plan={editingPlan} onSubmit={handleSubmit} />\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA8BA,IAAa,UAAqB;CAChC,IAAM,EAAE,SAAM,EAAQ,GAChB,IAAW,EAAY,GACvB,EAAE,iBAAc,EAAY,GAC5B,EAAE,aAAU,EAAS,GACrB,IAAU,EAAW,GAErB,EAAE,UAAO,YAAS,WAAQ,iBAAc,eAAY,eAAY,kBAAe,EAA2B,EAC9G,OAAO,GACT,CAAC,GAEK,CAAC,GAAU,KAAe,EAAS,EAAK,GACxC,CAAC,GAAa,KAAkB,EAAyB,IAAI,GAC7D,CAAC,GAAQ,KAAa,EAAwB,IAAI,GAElD,UAAmB;EAEvB,AADA,EAAe,IAAI,GACnB,EAAY,EAAI;CAClB,GACM,KAAY,MAAkB;EAElC,AADA,EAAe,CAAI,GACnB,EAAY,EAAI;CAClB,GAEM,IAAe,OAAO,MAAmC;EAC7D,IAAI,GAEF,AADA,MAAM,EAAW,CAAK,GACtB,EAAM;GACJ,OAAO,EAAE,8CAA8C,cAAc;GACrE,aAAa,OAAO,EAAM,QAAQ,EAAY,IAAI;GAClD,SAAS;EACX,CAAC;OACI;GACL,IAAM,IAAU,MAAM,EAAW,CAAK;GACtC,EAAM;IACJ,OAAO,EAAE,8CAA8C,2BAA2B;IAClF,aACE,KAAW,EAAQ,sBAAsB,WACrC,EACE,2DACA,wEACF,IACA,EAAE,gDAAgD,oCAAoC;IAC5F,SAAS,KAAW,EAAQ,sBAAsB,WAAW,YAA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AU,OAAO,EAAE,8CAA8C,gBAAgB;MAAG,OAAO;KAAe,CAAA;IACvG;OAEJ,EAAM,WAAW,IAChB,kBAAC,GAAD;IACE,MAAM,kBAAC,GAAD,EAAO,WAAU,8BAA+B,CAAA;IACtD,OAAO,EAAE,4CAA4C,2BAA2B;IAChF,aAAa,EACX,kDACA,yFACF;IACA,QACE,kBAAC,GAAD;KAAQ,SAAS;eAAjB,CACE,kBAAC,GAAD,EAAM,WAAU,UAAW,CAAA,GAC1B,EAAE,4CAA4C,uBAAuB,CAChE;;GAEX,CAAA,IAED,kBAAC,GAAD;IACW;IACT,MAAM;IACN,UAAS;IACT,UAAU;IACV,aAAa,MAAM,EAAS,EAAU,oBAAoB,EAAE,IAAI,CAAC;GAClE,CAAA,CAEH,EAAA,CAAA;GAGJ,kBAAC,GAAD;IAAkB,MAAM;IAAU,eAAe,EAAY,EAAK;IAAG,MAAM;IAAa,UAAU;GAAe,CAAA;EACvG;;AAEhB"}
|
|
@@ -183,6 +183,9 @@ var A = (e) => new Date(e).toLocaleString("en-US", {
|
|
|
183
183
|
children: G.map((e) => {
|
|
184
184
|
let t = j(e.status);
|
|
185
185
|
return /* @__PURE__ */ D("li", {
|
|
186
|
+
"data-testid": "route-stop",
|
|
187
|
+
"data-sequence": e.sequence,
|
|
188
|
+
"data-status": e.status,
|
|
186
189
|
className: "flex flex-col gap-3 rounded-lg border border-border-subtle bg-bg-surface p-4 sm:flex-row sm:items-center sm:justify-between",
|
|
187
190
|
children: [/* @__PURE__ */ D("div", {
|
|
188
191
|
className: "flex items-start gap-3",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeliveryRouteDetailPage.js","names":[],"sources":["../../../../src/healthybowl/pages/distribution/DeliveryRouteDetailPage.tsx"],"sourcesContent":["/**\n * Delivery route detail (BOFF-2884).\n * Numbered route map + ordered stop list. \"Dispatch & notify members\" flips the\n * route to IN_PROGRESS, marks each stop's CSA delivery DISPATCHED and triggers the\n * FluidGrids notification flow (one run per member). Per-stop status is drivable.\n */\nimport { useMemo, useState } from 'react';\nimport { useParams } from 'react-router';\nimport { useQuery } from '@apollo/client/react';\nimport { BellRing, CheckCircle, MapPin, Send, Truck, XCircle } from 'lucide-react';\nimport { Button } from '@burdenoff/fe-libs/ui';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport {\n PageLayout,\n StatCard,\n StatusBadge,\n EmptyState,\n ErrorState,\n PageLoader,\n Breadcrumbs,\n DeliveryRouteMap,\n type DeliveryRouteMapStop,\n} from '../../components';\nimport { useToast } from '../../hooks/useToast';\nimport { useBasePath } from '../../hooks/useBasePath';\nimport { formatDateOnly } from '../../utils/helpers';\nimport {\n useHealthyBowlDistribution,\n GET_DELIVERY_ROUTE,\n type DeliveryStop,\n type DeliveryRouteData,\n} from '../../hooks/useHealthyBowlDistribution';\nimport { DistributionNav } from './DistributionNav';\nimport { routeStatusVariant, stopStatusVariant } from './labels';\n\nconst formatDateTime = (iso: string): string =>\n new Date(iso).toLocaleString('en-US', {\n month: 'short',\n day: 'numeric',\n hour: '2-digit',\n minute: '2-digit',\n });\n\n/** Next drivable status for a stop, or null when the stop is terminal. */\nconst nextStopAction = (status: string): { value: string; label: string } | null => {\n switch (status) {\n case 'PENDING':\n return { value: 'ARRIVED', label: 'Mark arrived' };\n case 'ARRIVED':\n return { value: 'DELIVERED', label: 'Mark delivered' };\n default:\n return null;\n }\n};\n\nexport const DeliveryRouteDetailPage = () => {\n const { t } = useI18n();\n const { routeId } = useParams<{ routeId: string }>();\n const { buildPath } = useBasePath();\n const { toast } = useToast();\n\n const { context, dispatchRoute, updateStop } = useHealthyBowlDistribution({});\n\n const routeQuery = useQuery<DeliveryRouteData, { context: { workspaceId: string }; id: string }>(GET_DELIVERY_ROUTE, {\n variables: { context, id: routeId ?? '' },\n skip: !routeId,\n fetchPolicy: 'cache-and-network',\n });\n\n const [dispatching, setDispatching] = useState(false);\n const [busyStopId, setBusyStopId] = useState<string | null>(null);\n\n const route = routeQuery.data?.getHealthyBowlDeliveryRoute ?? null;\n\n const orderedStops = useMemo(() => (route ? [...route.stops].sort((a, b) => a.sequence - b.sequence) : []), [route]);\n\n const mapStops = useMemo<DeliveryRouteMapStop[]>(\n () =>\n orderedStops.map((s) => ({\n id: s.id,\n sequence: s.sequence,\n lat: s.lat,\n lng: s.lng,\n label: s.label,\n status: s.status,\n })),\n [orderedStops]\n );\n\n const handleDispatch = async () => {\n if (!route) return;\n setDispatching(true);\n try {\n const updated = await dispatchRoute(route.id);\n await routeQuery.refetch().catch(() => undefined);\n toast({\n title: t('healthybowl.distribution.routeDetail.toast.dispatched', 'Route dispatched'),\n description: t(\n 'healthybowl.distribution.routeDetail.toast.dispatchedDesc',\n 'Members are being notified for {{count}} stop(s).',\n { count: updated?.stopCount ?? route.stopCount }\n ),\n variant: 'success',\n });\n } catch (err) {\n toast({\n title: t('healthybowl.distribution.routeDetail.toast.dispatchFailed', 'Dispatch failed'),\n description: err instanceof Error ? err.message : String(err),\n variant: 'error',\n });\n } finally {\n setDispatching(false);\n }\n };\n\n const handleStopStatus = async (stop: DeliveryStop, status: string) => {\n setBusyStopId(stop.id);\n try {\n await updateStop({ id: stop.id, status });\n await routeQuery.refetch().catch(() => undefined);\n toast({\n title: t('healthybowl.distribution.routeDetail.toast.stopUpdated', 'Stop updated'),\n description: t('healthybowl.distribution.routeDetail.toast.stopUpdatedDesc', '{{label}} is now {{status}}.', {\n label: stop.label,\n status,\n }),\n variant: 'success',\n });\n } catch (err) {\n toast({\n title: t('healthybowl.distribution.routeDetail.toast.stopFailed', 'Could not update stop'),\n description: err instanceof Error ? err.message : String(err),\n variant: 'error',\n });\n } finally {\n setBusyStopId(null);\n }\n };\n\n if (routeQuery.loading && !route) {\n return <PageLoader />;\n }\n\n if (routeQuery.error && !route) {\n return (\n <PageLayout title={t('healthybowl.distribution.routeDetail.title', 'Delivery route')}>\n <DistributionNav />\n <ErrorState description={routeQuery.error.message} onRetry={() => void routeQuery.refetch()} />\n </PageLayout>\n );\n }\n\n if (!route) {\n return (\n <PageLayout title={t('healthybowl.distribution.routeDetail.title', 'Delivery route')}>\n <DistributionNav />\n <EmptyState\n title={t('healthybowl.distribution.routeDetail.notFound.title', 'Route not found')}\n description={t('healthybowl.distribution.routeDetail.notFound.description', 'This route no longer exists.')}\n />\n </PageLayout>\n );\n }\n\n const canDispatch = route.status === 'PLANNED';\n\n return (\n <PageLayout\n title={route.name}\n description={t('healthybowl.distribution.routeDetail.subtitle', '{{count}} stops · {{date}}', {\n count: route.stopCount,\n date: formatDateOnly(route.routeDate),\n })}\n actions={\n <Button onClick={handleDispatch} disabled={!canDispatch || dispatching || route.stopCount === 0}>\n <Send className={dispatching ? 'h-4 w-4 animate-pulse' : 'h-4 w-4'} />\n {dispatching\n ? t('healthybowl.distribution.routeDetail.actions.dispatching', 'Dispatching…')\n : route.status === 'PLANNED'\n ? t('healthybowl.distribution.routeDetail.actions.dispatch', 'Dispatch & notify members')\n : t('healthybowl.distribution.routeDetail.actions.dispatched', 'Dispatched')}\n </Button>\n }\n >\n <Breadcrumbs\n items={[\n { label: t('healthybowl.distribution.nav.routes', 'Routes'), href: buildPath('distribution/routes') },\n { label: route.name },\n ]}\n />\n\n <div className=\"flex flex-wrap items-center gap-2\">\n <StatusBadge variant={routeStatusVariant(route.status)} label={route.status} dot />\n <StatusBadge\n variant=\"info\"\n label={t('healthybowl.distribution.routeDetail.stopCount', '{{count}} stops', { count: route.stopCount })}\n />\n {route.dispatchedAt ? (\n <span className=\"inline-flex items-center gap-1.5 rounded-full border border-border-subtle bg-bg-sunken/60 px-3 py-1 text-xs text-text-secondary\">\n <BellRing className=\"h-3.5 w-3.5\" />\n {t('healthybowl.distribution.routeDetail.dispatchedAt', 'Dispatched {{when}}', {\n when: formatDateTime(route.dispatchedAt),\n })}\n </span>\n ) : null}\n </div>\n\n <div className=\"grid grid-cols-1 gap-3 sm:grid-cols-3\">\n <StatCard\n label={t('healthybowl.distribution.routeDetail.stats.stops', 'Stops')}\n value={route.stopCount}\n icon={<MapPin className=\"h-5 w-5\" />}\n hero\n />\n <StatCard\n label={t('healthybowl.distribution.routeDetail.stats.distance', 'Distance')}\n value={route.totalDistanceKm !== null ? `${route.totalDistanceKm.toFixed(1)} km` : '—'}\n />\n <StatCard\n label={t('healthybowl.distribution.routeDetail.stats.driver', 'Driver')}\n value={route.driverName ?? t('healthybowl.distribution.routeDetail.stats.unassigned', 'Unassigned')}\n />\n </div>\n\n {mapStops.length > 0 ? (\n <DeliveryRouteMap stops={mapStops} startLat={route.startLat} startLng={route.startLng} />\n ) : null}\n\n <div>\n <h2 className=\"mb-3 text-lg font-semibold text-text-primary\">\n {t('healthybowl.distribution.routeDetail.stopsTitle', 'Stops in order')}\n </h2>\n {orderedStops.length === 0 ? (\n <EmptyState\n icon={<Truck className=\"h-8 w-8 text-text-secondary\" />}\n title={t('healthybowl.distribution.routeDetail.empty.title', 'No stops on this route')}\n description={t(\n 'healthybowl.distribution.routeDetail.empty.description',\n 'This route has no scheduled delivery stops.'\n )}\n />\n ) : (\n <ol className=\"space-y-3\">\n {orderedStops.map((stop) => {\n const next = nextStopAction(stop.status);\n return (\n <li\n key={stop.id}\n className=\"flex flex-col gap-3 rounded-lg border border-border-subtle bg-bg-surface p-4 sm:flex-row sm:items-center sm:justify-between\"\n >\n <div className=\"flex items-start gap-3\">\n <span className=\"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-bg-sunken text-sm font-semibold tabular-nums text-text-primary\">\n {stop.sequence}\n </span>\n <div className=\"min-w-0\">\n <div className=\"font-medium text-text-primary\">{stop.memberName ?? stop.label}</div>\n {stop.address ? <div className=\"text-xs text-text-secondary\">{stop.address}</div> : null}\n <div className=\"mt-1 flex flex-wrap items-center gap-2\">\n <StatusBadge variant={stopStatusVariant(stop.status)} label={stop.status} dot />\n <span className=\"text-xs text-text-secondary\">\n {stop.notificationSentAt\n ? t('healthybowl.distribution.routeDetail.notified', 'Notified {{when}}', {\n when: formatDateTime(stop.notificationSentAt),\n })\n : t('healthybowl.distribution.routeDetail.notifyPending', 'Notification pending')}\n </span>\n </div>\n </div>\n </div>\n <div className=\"flex items-center gap-1 sm:justify-end\">\n {next ? (\n <Button\n variant=\"outline\"\n size=\"sm\"\n disabled={busyStopId === stop.id}\n onClick={() => void handleStopStatus(stop, next.value)}\n >\n {next.value === 'DELIVERED' ? (\n <CheckCircle className=\"h-3.5 w-3.5\" />\n ) : (\n <MapPin className=\"h-3.5 w-3.5\" />\n )}\n {next.label}\n </Button>\n ) : null}\n {stop.status !== 'DELIVERED' && stop.status !== 'FAILED' ? (\n <Button\n variant=\"ghost\"\n size=\"sm\"\n disabled={busyStopId === stop.id}\n onClick={() => void handleStopStatus(stop, 'FAILED')}\n className=\"text-text-secondary hover:text-status-error-text\"\n >\n <XCircle className=\"h-3.5 w-3.5\" />\n {t('healthybowl.distribution.routeDetail.actions.markFailed', 'Failed')}\n </Button>\n ) : null}\n </div>\n </li>\n );\n })}\n </ol>\n )}\n </div>\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAmCA,IAAM,KAAkB,MACtB,IAAI,KAAK,CAAG,EAAE,eAAe,SAAS;CACpC,OAAO;CACP,KAAK;CACL,MAAM;CACN,QAAQ;AACV,CAAC,GAGG,KAAkB,MAA4D;CAClF,QAAQ,GAAR;EACE,KAAK,WACH,OAAO;GAAE,OAAO;GAAW,OAAO;EAAe;EACnD,KAAK,WACH,OAAO;GAAE,OAAO;GAAa,OAAO;EAAiB;EACvD,SACE,OAAO;CACX;AACF,GAEa,UAAgC;CAC3C,IAAM,EAAE,SAAM,EAAQ,GAChB,EAAE,eAAY,EAA+B,GAC7C,EAAE,iBAAc,EAAY,GAC5B,EAAE,aAAU,EAAS,GAErB,EAAE,YAAS,kBAAe,kBAAe,EAA2B,CAAC,CAAC,GAEtE,IAAa,EAA8E,GAAoB;EACnH,WAAW;GAAE;GAAS,IAAI,KAAW;EAAG;EACxC,MAAM,CAA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AA,GACjC,EAAE,2DAA2D,QAAQ,CAChE;YACN,IACD;QACH;QAnDG,EAAK,EAmDR;IAER,CAAC;GACC,CAAA,CAEH,EAAA,CAAA;EACK;;AAEhB"}
|
|
1
|
+
{"version":3,"file":"DeliveryRouteDetailPage.js","names":[],"sources":["../../../../src/healthybowl/pages/distribution/DeliveryRouteDetailPage.tsx"],"sourcesContent":["/**\n * Delivery route detail (BOFF-2884).\n * Numbered route map + ordered stop list. \"Dispatch & notify members\" flips the\n * route to IN_PROGRESS, marks each stop's CSA delivery DISPATCHED and triggers the\n * FluidGrids notification flow (one run per member). Per-stop status is drivable.\n */\nimport { useMemo, useState } from 'react';\nimport { useParams } from 'react-router';\nimport { useQuery } from '@apollo/client/react';\nimport { BellRing, CheckCircle, MapPin, Send, Truck, XCircle } from 'lucide-react';\nimport { Button } from '@burdenoff/fe-libs/ui';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport {\n PageLayout,\n StatCard,\n StatusBadge,\n EmptyState,\n ErrorState,\n PageLoader,\n Breadcrumbs,\n DeliveryRouteMap,\n type DeliveryRouteMapStop,\n} from '../../components';\nimport { useToast } from '../../hooks/useToast';\nimport { useBasePath } from '../../hooks/useBasePath';\nimport { formatDateOnly } from '../../utils/helpers';\nimport {\n useHealthyBowlDistribution,\n GET_DELIVERY_ROUTE,\n type DeliveryStop,\n type DeliveryRouteData,\n} from '../../hooks/useHealthyBowlDistribution';\nimport { DistributionNav } from './DistributionNav';\nimport { routeStatusVariant, stopStatusVariant } from './labels';\n\nconst formatDateTime = (iso: string): string =>\n new Date(iso).toLocaleString('en-US', {\n month: 'short',\n day: 'numeric',\n hour: '2-digit',\n minute: '2-digit',\n });\n\n/** Next drivable status for a stop, or null when the stop is terminal. */\nconst nextStopAction = (status: string): { value: string; label: string } | null => {\n switch (status) {\n case 'PENDING':\n return { value: 'ARRIVED', label: 'Mark arrived' };\n case 'ARRIVED':\n return { value: 'DELIVERED', label: 'Mark delivered' };\n default:\n return null;\n }\n};\n\nexport const DeliveryRouteDetailPage = () => {\n const { t } = useI18n();\n const { routeId } = useParams<{ routeId: string }>();\n const { buildPath } = useBasePath();\n const { toast } = useToast();\n\n const { context, dispatchRoute, updateStop } = useHealthyBowlDistribution({});\n\n const routeQuery = useQuery<DeliveryRouteData, { context: { workspaceId: string }; id: string }>(GET_DELIVERY_ROUTE, {\n variables: { context, id: routeId ?? '' },\n skip: !routeId,\n fetchPolicy: 'cache-and-network',\n });\n\n const [dispatching, setDispatching] = useState(false);\n const [busyStopId, setBusyStopId] = useState<string | null>(null);\n\n const route = routeQuery.data?.getHealthyBowlDeliveryRoute ?? null;\n\n const orderedStops = useMemo(() => (route ? [...route.stops].sort((a, b) => a.sequence - b.sequence) : []), [route]);\n\n const mapStops = useMemo<DeliveryRouteMapStop[]>(\n () =>\n orderedStops.map((s) => ({\n id: s.id,\n sequence: s.sequence,\n lat: s.lat,\n lng: s.lng,\n label: s.label,\n status: s.status,\n })),\n [orderedStops]\n );\n\n const handleDispatch = async () => {\n if (!route) return;\n setDispatching(true);\n try {\n const updated = await dispatchRoute(route.id);\n await routeQuery.refetch().catch(() => undefined);\n toast({\n title: t('healthybowl.distribution.routeDetail.toast.dispatched', 'Route dispatched'),\n description: t(\n 'healthybowl.distribution.routeDetail.toast.dispatchedDesc',\n 'Members are being notified for {{count}} stop(s).',\n { count: updated?.stopCount ?? route.stopCount }\n ),\n variant: 'success',\n });\n } catch (err) {\n toast({\n title: t('healthybowl.distribution.routeDetail.toast.dispatchFailed', 'Dispatch failed'),\n description: err instanceof Error ? err.message : String(err),\n variant: 'error',\n });\n } finally {\n setDispatching(false);\n }\n };\n\n const handleStopStatus = async (stop: DeliveryStop, status: string) => {\n setBusyStopId(stop.id);\n try {\n await updateStop({ id: stop.id, status });\n await routeQuery.refetch().catch(() => undefined);\n toast({\n title: t('healthybowl.distribution.routeDetail.toast.stopUpdated', 'Stop updated'),\n description: t('healthybowl.distribution.routeDetail.toast.stopUpdatedDesc', '{{label}} is now {{status}}.', {\n label: stop.label,\n status,\n }),\n variant: 'success',\n });\n } catch (err) {\n toast({\n title: t('healthybowl.distribution.routeDetail.toast.stopFailed', 'Could not update stop'),\n description: err instanceof Error ? err.message : String(err),\n variant: 'error',\n });\n } finally {\n setBusyStopId(null);\n }\n };\n\n if (routeQuery.loading && !route) {\n return <PageLoader />;\n }\n\n if (routeQuery.error && !route) {\n return (\n <PageLayout title={t('healthybowl.distribution.routeDetail.title', 'Delivery route')}>\n <DistributionNav />\n <ErrorState description={routeQuery.error.message} onRetry={() => void routeQuery.refetch()} />\n </PageLayout>\n );\n }\n\n if (!route) {\n return (\n <PageLayout title={t('healthybowl.distribution.routeDetail.title', 'Delivery route')}>\n <DistributionNav />\n <EmptyState\n title={t('healthybowl.distribution.routeDetail.notFound.title', 'Route not found')}\n description={t('healthybowl.distribution.routeDetail.notFound.description', 'This route no longer exists.')}\n />\n </PageLayout>\n );\n }\n\n const canDispatch = route.status === 'PLANNED';\n\n return (\n <PageLayout\n title={route.name}\n description={t('healthybowl.distribution.routeDetail.subtitle', '{{count}} stops · {{date}}', {\n count: route.stopCount,\n date: formatDateOnly(route.routeDate),\n })}\n actions={\n <Button onClick={handleDispatch} disabled={!canDispatch || dispatching || route.stopCount === 0}>\n <Send className={dispatching ? 'h-4 w-4 animate-pulse' : 'h-4 w-4'} />\n {dispatching\n ? t('healthybowl.distribution.routeDetail.actions.dispatching', 'Dispatching…')\n : route.status === 'PLANNED'\n ? t('healthybowl.distribution.routeDetail.actions.dispatch', 'Dispatch & notify members')\n : t('healthybowl.distribution.routeDetail.actions.dispatched', 'Dispatched')}\n </Button>\n }\n >\n <Breadcrumbs\n items={[\n { label: t('healthybowl.distribution.nav.routes', 'Routes'), href: buildPath('distribution/routes') },\n { label: route.name },\n ]}\n />\n\n <div className=\"flex flex-wrap items-center gap-2\">\n <StatusBadge variant={routeStatusVariant(route.status)} label={route.status} dot />\n <StatusBadge\n variant=\"info\"\n label={t('healthybowl.distribution.routeDetail.stopCount', '{{count}} stops', { count: route.stopCount })}\n />\n {route.dispatchedAt ? (\n <span className=\"inline-flex items-center gap-1.5 rounded-full border border-border-subtle bg-bg-sunken/60 px-3 py-1 text-xs text-text-secondary\">\n <BellRing className=\"h-3.5 w-3.5\" />\n {t('healthybowl.distribution.routeDetail.dispatchedAt', 'Dispatched {{when}}', {\n when: formatDateTime(route.dispatchedAt),\n })}\n </span>\n ) : null}\n </div>\n\n <div className=\"grid grid-cols-1 gap-3 sm:grid-cols-3\">\n <StatCard\n label={t('healthybowl.distribution.routeDetail.stats.stops', 'Stops')}\n value={route.stopCount}\n icon={<MapPin className=\"h-5 w-5\" />}\n hero\n />\n <StatCard\n label={t('healthybowl.distribution.routeDetail.stats.distance', 'Distance')}\n value={route.totalDistanceKm !== null ? `${route.totalDistanceKm.toFixed(1)} km` : '—'}\n />\n <StatCard\n label={t('healthybowl.distribution.routeDetail.stats.driver', 'Driver')}\n value={route.driverName ?? t('healthybowl.distribution.routeDetail.stats.unassigned', 'Unassigned')}\n />\n </div>\n\n {mapStops.length > 0 ? (\n <DeliveryRouteMap stops={mapStops} startLat={route.startLat} startLng={route.startLng} />\n ) : null}\n\n <div>\n <h2 className=\"mb-3 text-lg font-semibold text-text-primary\">\n {t('healthybowl.distribution.routeDetail.stopsTitle', 'Stops in order')}\n </h2>\n {orderedStops.length === 0 ? (\n <EmptyState\n icon={<Truck className=\"h-8 w-8 text-text-secondary\" />}\n title={t('healthybowl.distribution.routeDetail.empty.title', 'No stops on this route')}\n description={t(\n 'healthybowl.distribution.routeDetail.empty.description',\n 'This route has no scheduled delivery stops.'\n )}\n />\n ) : (\n <ol className=\"space-y-3\">\n {orderedStops.map((stop) => {\n const next = nextStopAction(stop.status);\n return (\n <li\n key={stop.id}\n // BOFF-6065 — the journey asserts the stops render in `sequence` order and that\n // a member enrolled with coordinates became a numbered stop. Both are read off\n // these attributes; `data-sequence` is the raw number, not the rendered glyph.\n data-testid=\"route-stop\"\n data-sequence={stop.sequence}\n data-status={stop.status}\n className=\"flex flex-col gap-3 rounded-lg border border-border-subtle bg-bg-surface p-4 sm:flex-row sm:items-center sm:justify-between\"\n >\n <div className=\"flex items-start gap-3\">\n <span className=\"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-bg-sunken text-sm font-semibold tabular-nums text-text-primary\">\n {stop.sequence}\n </span>\n <div className=\"min-w-0\">\n <div className=\"font-medium text-text-primary\">{stop.memberName ?? stop.label}</div>\n {stop.address ? <div className=\"text-xs text-text-secondary\">{stop.address}</div> : null}\n <div className=\"mt-1 flex flex-wrap items-center gap-2\">\n <StatusBadge variant={stopStatusVariant(stop.status)} label={stop.status} dot />\n <span className=\"text-xs text-text-secondary\">\n {stop.notificationSentAt\n ? t('healthybowl.distribution.routeDetail.notified', 'Notified {{when}}', {\n when: formatDateTime(stop.notificationSentAt),\n })\n : t('healthybowl.distribution.routeDetail.notifyPending', 'Notification pending')}\n </span>\n </div>\n </div>\n </div>\n <div className=\"flex items-center gap-1 sm:justify-end\">\n {next ? (\n <Button\n variant=\"outline\"\n size=\"sm\"\n disabled={busyStopId === stop.id}\n onClick={() => void handleStopStatus(stop, next.value)}\n >\n {next.value === 'DELIVERED' ? (\n <CheckCircle className=\"h-3.5 w-3.5\" />\n ) : (\n <MapPin className=\"h-3.5 w-3.5\" />\n )}\n {next.label}\n </Button>\n ) : null}\n {stop.status !== 'DELIVERED' && stop.status !== 'FAILED' ? (\n <Button\n variant=\"ghost\"\n size=\"sm\"\n disabled={busyStopId === stop.id}\n onClick={() => void handleStopStatus(stop, 'FAILED')}\n className=\"text-text-secondary hover:text-status-error-text\"\n >\n <XCircle className=\"h-3.5 w-3.5\" />\n {t('healthybowl.distribution.routeDetail.actions.markFailed', 'Failed')}\n </Button>\n ) : null}\n </div>\n </li>\n );\n })}\n </ol>\n )}\n </div>\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAmCA,IAAM,KAAkB,MACtB,IAAI,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K,kBAAkB,EAC9C,CAAC,IACD,EAAE,sDAAsD,sBAAsB;UAC9E,CAAA,CACH;;QACF;SACF;UACL,kBAAC,OAAD;OAAK,WAAU;iBAAf,CACG,IACC,kBAAC,GAAD;QACE,SAAQ;QACR,MAAK;QACL,UAAU,MAAe,EAAK;QAC9B,eAAe,KAAK,EAAiB,GAAM,EAAK,KAAK;kBAJvD,CAMG,EAAK,UAAU,cACd,kBAAC,GAAD,EAAa,WAAU,cAAe,CAAA,IAEtC,kBAAC,GAAD,EAAQ,WAAU,cAAe,CAAA,GAElC,EAAK,KACA;YACN,MACH,EAAK,WAAW,eAAe,EAAK,WAAW,WAC9C,kBAAC,GAAD;QACE,SAAQ;QACR,MAAK;QACL,UAAU,MAAe,EAAK;QAC9B,eAAe,KAAK,EAAiB,GAAM,QAAQ;QACnD,WAAU;kBALZ,CAOE,kBAAC,GAAD,EAAS,WAAU,cAAe,CAAA,GACjC,EAAE,2DAA2D,QAAQ,CAChE;YACN,IACD;QACH;QAzDG,EAAK,EAyDR;IAER,CAAC;GACC,CAAA,CAEH,EAAA,CAAA;EACK;;AAEhB"}
|
|
@@ -10,31 +10,37 @@ var o = () => {
|
|
|
10
10
|
className: "inline-flex flex-wrap gap-1 rounded-lg border border-border-subtle bg-bg-surface p-1",
|
|
11
11
|
children: [
|
|
12
12
|
{
|
|
13
|
+
id: "overview",
|
|
13
14
|
to: l,
|
|
14
15
|
label: o("healthybowl.distribution.nav.overview", "Overview"),
|
|
15
16
|
exact: !0
|
|
16
17
|
},
|
|
17
18
|
{
|
|
19
|
+
id: "csa",
|
|
18
20
|
to: `${l}/csa`,
|
|
19
21
|
label: o("healthybowl.distribution.nav.csa", "CSA Boxes"),
|
|
20
22
|
exact: !1
|
|
21
23
|
},
|
|
22
24
|
{
|
|
25
|
+
id: "wholesale",
|
|
23
26
|
to: `${l}/wholesale`,
|
|
24
27
|
label: o("healthybowl.distribution.nav.wholesale", "Wholesale"),
|
|
25
28
|
exact: !1
|
|
26
29
|
},
|
|
27
30
|
{
|
|
31
|
+
id: "routes",
|
|
28
32
|
to: `${l}/routes`,
|
|
29
33
|
label: o("healthybowl.distribution.nav.routes", "Routes"),
|
|
30
34
|
exact: !1
|
|
31
35
|
},
|
|
32
36
|
{
|
|
37
|
+
id: "pickup",
|
|
33
38
|
to: `${l}/pickup`,
|
|
34
39
|
label: o("healthybowl.distribution.nav.pickup", "Collection Points"),
|
|
35
40
|
exact: !1
|
|
36
41
|
},
|
|
37
42
|
{
|
|
43
|
+
id: "manifest",
|
|
38
44
|
to: `${l}/manifest`,
|
|
39
45
|
label: o("healthybowl.distribution.nav.manifest", "Manifest"),
|
|
40
46
|
exact: !1
|
|
@@ -43,6 +49,8 @@ var o = () => {
|
|
|
43
49
|
let n = t.exact ? c === t.to : c.startsWith(t.to);
|
|
44
50
|
return /* @__PURE__ */ a(r, {
|
|
45
51
|
to: t.to,
|
|
52
|
+
"data-testid": `distribution-tab-${t.id}`,
|
|
53
|
+
"data-active": n,
|
|
46
54
|
className: e("rounded-md px-3 py-1.5 text-sm transition-colors", n ? "bg-bg-sunken font-medium text-text-primary" : "text-text-secondary hover:text-text-primary"),
|
|
47
55
|
children: t.label
|
|
48
56
|
}, t.to);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DistributionNav.js","names":[],"sources":["../../../../src/healthybowl/pages/distribution/DistributionNav.tsx"],"sourcesContent":["/** Sub-navigation tabs shared by the distribution views (BOFF-2884). */\nimport { Link, useLocation } from 'react-router';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { useBasePath } from '../../hooks/useBasePath';\nimport { cn } from '../../utils/helpers';\n\nexport const DistributionNav = () => {\n const { t } = useI18n();\n const { buildPath } = useBasePath();\n const { pathname } = useLocation();\n const root = buildPath('distribution');\n\n const tabs = [\n { to: root, label: t('healthybowl.distribution.nav.overview', 'Overview'), exact: true },\n { to: `${root}/csa`, label: t('healthybowl.distribution.nav.csa', 'CSA Boxes'), exact: false },\n { to: `${root}/wholesale
|
|
1
|
+
{"version":3,"file":"DistributionNav.js","names":[],"sources":["../../../../src/healthybowl/pages/distribution/DistributionNav.tsx"],"sourcesContent":["/** Sub-navigation tabs shared by the distribution views (BOFF-2884). */\nimport { Link, useLocation } from 'react-router';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { useBasePath } from '../../hooks/useBasePath';\nimport { cn } from '../../utils/helpers';\n\nexport const DistributionNav = () => {\n const { t } = useI18n();\n const { buildPath } = useBasePath();\n const { pathname } = useLocation();\n const root = buildPath('distribution');\n\n const tabs = [\n { id: 'overview', to: root, label: t('healthybowl.distribution.nav.overview', 'Overview'), exact: true },\n { id: 'csa', to: `${root}/csa`, label: t('healthybowl.distribution.nav.csa', 'CSA Boxes'), exact: false },\n {\n id: 'wholesale',\n to: `${root}/wholesale`,\n label: t('healthybowl.distribution.nav.wholesale', 'Wholesale'),\n exact: false,\n },\n { id: 'routes', to: `${root}/routes`, label: t('healthybowl.distribution.nav.routes', 'Routes'), exact: false },\n // BOFF-6021 — the collection model shipped server-side with no way in.\n {\n id: 'pickup',\n to: `${root}/pickup`,\n label: t('healthybowl.distribution.nav.pickup', 'Collection Points'),\n exact: false,\n },\n {\n id: 'manifest',\n to: `${root}/manifest`,\n label: t('healthybowl.distribution.nav.manifest', 'Manifest'),\n exact: false,\n },\n ];\n\n return (\n <div className=\"inline-flex flex-wrap gap-1 rounded-lg border border-border-subtle bg-bg-surface p-1\">\n {tabs.map((tab) => {\n const active = tab.exact ? pathname === tab.to : pathname.startsWith(tab.to);\n return (\n <Link\n key={tab.to}\n to={tab.to}\n // BOFF-6065 — the journeys tab through these six. Selecting by visible label would\n // pass only in `en`; HB ships six languages.\n data-testid={`distribution-tab-${tab.id}`}\n data-active={active}\n className={cn(\n 'rounded-md px-3 py-1.5 text-sm transition-colors',\n active ? 'bg-bg-sunken font-medium text-text-primary' : 'text-text-secondary hover:text-text-primary'\n )}\n >\n {tab.label}\n </Link>\n );\n })}\n </div>\n );\n};\n"],"mappings":";;;;;;AAMA,IAAa,UAAwB;CACnC,IAAM,EAAE,SAAM,EAAQ,GAChB,EAAE,iBAAc,EAAY,GAC5B,EAAE,gBAAa,EAAY,GAC3B,IAAO,EAAU,cAAc;CA2BrC,OACE,kBAAC,OAAD;EAAK,WAAU;YACZ;GA1BH;IAAE,IAAI;IAAY,IAAI;IAAM,OAAO,EAAE,yCAAyC,UAAU;IAAG,OAAO;GAAK;GACvG;IAAE,IAAI;IAAO,IAAI,GAAG,EAAK;IAAO,OAAO,EAAE,oCAAoC,WAAW;IAAG,OAAO;GAAM;GACxG;IACE,IAAI;IACJ,IAAI,GAAG,EAAK;IACZ,OAAO,EAAE,0CAA0C,WAAW;IAC9D,OAAO;GACT;GACA;IAAE,IAAI;IAAU,IAAI,GAAG,EAAK;IAAU,OAAO,EAAE,uCAAuC,QAAQ;IAAG,OAAO;GAAM;GAE9G;IACE,IAAI;IACJ,IAAI,GAAG,EAAK;IACZ,OAAO,EAAE,uCAAuC,mBAAmB;IACnE,OAAO;GACT;GACA;IACE,IAAI;IACJ,IAAI,GAAG,EAAK;IACZ,OAAO,EAAE,yCAAyC,UAAU;IAC5D,OAAO;GACT;EAKG,EAAK,KAAK,MAAQ;GACjB,IAAM,IAAS,EAAI,QAAQ,MAAa,EAAI,KAAK,EAAS,WAAW,EAAI,EAAE;GAC3E,OACE,kBAAC,GAAD;IAEE,IAAI,EAAI;IAGR,eAAa,oBAAoB,EAAI;IACrC,eAAa;IACb,WAAW,EACT,oDACA,IAAS,+CAA+C,6CAC1D;cAEC,EAAI;GACD,GAZC,EAAI,EAYL;EAEV,CAAC;CACE,CAAA;AAET"}
|
|
@@ -24,20 +24,28 @@ var E = () => {
|
|
|
24
24
|
{
|
|
25
25
|
key: "orderNumber",
|
|
26
26
|
header: E("healthybowl.distribution.overview.table.order", "Order"),
|
|
27
|
-
render: (e) => /* @__PURE__ */ T("div", {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
render: (e) => /* @__PURE__ */ T("div", {
|
|
28
|
+
"data-testid": "distribution-order-row",
|
|
29
|
+
"data-order-id": e.id,
|
|
30
|
+
children: [/* @__PURE__ */ w("div", {
|
|
31
|
+
className: "font-medium text-text-primary",
|
|
32
|
+
children: e.orderNumber
|
|
33
|
+
}), /* @__PURE__ */ w("div", {
|
|
34
|
+
className: "text-xs text-text-secondary",
|
|
35
|
+
children: t(e.date)
|
|
36
|
+
})]
|
|
37
|
+
})
|
|
34
38
|
},
|
|
35
39
|
{
|
|
36
40
|
key: "channel",
|
|
37
41
|
header: E("healthybowl.distribution.overview.table.channel", "Channel"),
|
|
38
|
-
render: (e) => /* @__PURE__ */ w(
|
|
39
|
-
|
|
40
|
-
|
|
42
|
+
render: (e) => /* @__PURE__ */ w("span", {
|
|
43
|
+
"data-testid": "distribution-order-channel",
|
|
44
|
+
"data-channel": e.channel,
|
|
45
|
+
children: /* @__PURE__ */ w(a, {
|
|
46
|
+
variant: "info",
|
|
47
|
+
label: f(e.channel)
|
|
48
|
+
})
|
|
41
49
|
})
|
|
42
50
|
},
|
|
43
51
|
{
|
|
@@ -102,22 +110,31 @@ var E = () => {
|
|
|
102
110
|
/* @__PURE__ */ w(r, {
|
|
103
111
|
label: E("healthybowl.distribution.overview.stats.members", "Active CSA Members"),
|
|
104
112
|
value: k?.activeCsaMembers ?? 0,
|
|
113
|
+
"data-testid": "distribution-kpi-members",
|
|
114
|
+
"data-value": k?.activeCsaMembers ?? 0,
|
|
105
115
|
icon: /* @__PURE__ */ w(_, { className: "h-5 w-5" }),
|
|
106
116
|
hero: !0
|
|
107
117
|
}),
|
|
108
118
|
/* @__PURE__ */ w(r, {
|
|
109
119
|
label: E("healthybowl.distribution.overview.stats.weeklyBoxes", "Weekly Boxes"),
|
|
110
120
|
value: k?.weeklyBoxes ?? 0,
|
|
121
|
+
"data-testid": "distribution-kpi-weekly-boxes",
|
|
122
|
+
"data-value": k?.weeklyBoxes ?? 0,
|
|
111
123
|
icon: /* @__PURE__ */ w(y, { className: "h-5 w-5" })
|
|
112
124
|
}),
|
|
113
125
|
/* @__PURE__ */ w(r, {
|
|
114
126
|
label: E("healthybowl.distribution.overview.stats.wholesale", "Wholesale Accounts"),
|
|
115
127
|
value: k?.wholesaleAccounts ?? 0,
|
|
128
|
+
"data-testid": "distribution-kpi-wholesale",
|
|
129
|
+
"data-value": k?.wholesaleAccounts ?? 0,
|
|
116
130
|
icon: /* @__PURE__ */ w(b, { className: "h-5 w-5" })
|
|
117
131
|
}),
|
|
118
132
|
/* @__PURE__ */ w(r, {
|
|
119
133
|
label: E("healthybowl.distribution.overview.stats.deliveries", "Deliveries This Week"),
|
|
120
134
|
value: `${k?.routesThisWeek ?? 0} / ${k?.stopsThisWeek ?? 0}`,
|
|
135
|
+
"data-testid": "distribution-kpi-deliveries",
|
|
136
|
+
"data-routes": k?.routesThisWeek ?? 0,
|
|
137
|
+
"data-stops": k?.stopsThisWeek ?? 0,
|
|
121
138
|
icon: /* @__PURE__ */ w(x, { className: "h-5 w-5" })
|
|
122
139
|
})
|
|
123
140
|
]
|
|
@@ -140,6 +157,8 @@ var E = () => {
|
|
|
140
157
|
className: "inline-flex flex-wrap rounded-lg border border-border-subtle p-0.5",
|
|
141
158
|
children: d.map((e) => /* @__PURE__ */ w("button", {
|
|
142
159
|
type: "button",
|
|
160
|
+
"data-testid": `distribution-channel-tab-${e.key}`,
|
|
161
|
+
"data-active": D === e.key,
|
|
143
162
|
onClick: () => O(e.key),
|
|
144
163
|
className: D === e.key ? "rounded-md bg-bg-sunken px-2.5 py-1 text-xs font-medium text-text-primary transition-colors" : "rounded-md px-2.5 py-1 text-xs text-text-secondary transition-colors hover:text-text-primary",
|
|
145
164
|
children: e.label
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DistributionOverviewPage.js","names":[],"sources":["../../../../src/healthybowl/pages/distribution/DistributionOverviewPage.tsx"],"sourcesContent":["/**\n * Distribution & Sales Channels — overview dashboard.\n * Roadmap 12 · BOFF-2884 · gap H-4.\n *\n * KPI cards + a channel-filtered order list, all from real backend data. Recurring\n * billing is reused from the platform billing service; dispatch notifications are\n * driven by a FluidGrids flow — surfaced as honest \"Automation / Billing\" badges.\n */\nimport { useMemo, useState } from 'react';\nimport { Boxes, PackageCheck, Store, Truck, Workflow, CreditCard } from 'lucide-react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { PageLayout, StatCard, DataTable, StatusBadge, EmptyState, ErrorState, PageLoader } from '../../components';\nimport type { Column } from '../../components';\nimport { formatCurrency, formatDateOnly } from '../../utils/helpers';\nimport { useHealthyBowlDistribution, type DistributionOrder } from '../../hooks/useHealthyBowlDistribution';\nimport { DistributionNav } from './DistributionNav';\nimport { CHANNEL_TABS, channelLabel, orderStatusVariant } from './labels';\n\nexport const DistributionOverviewPage = () => {\n const { t } = useI18n();\n const [channelKey, setChannelKey] = useState('ALL');\n const activeChannel = useMemo(() => CHANNEL_TABS.find((c) => c.key === channelKey) ?? CHANNEL_TABS[0], [channelKey]);\n\n const { summary, channelOrders, loading, errors, refetchChannelOrders, refetchSummary } = useHealthyBowlDistribution({\n summary: true,\n channelOrders: true,\n channel: activeChannel.value,\n });\n\n const columns: Column<DistributionOrder>[] = [\n {\n key: 'orderNumber',\n header: t('healthybowl.distribution.overview.table.order', 'Order'),\n render: (o) => (\n <div>\n <div className=\"font-medium text-text-primary\">{o.orderNumber}</div>\n <div className=\"text-xs text-text-secondary\">{formatDateOnly(o.date)}</div>\n </div>\n ),\n },\n {\n key: 'channel',\n header: t('healthybowl.distribution.overview.table.channel', 'Channel'),\n render: (o) => <StatusBadge variant=\"info\" label={channelLabel(o.channel)} />,\n },\n {\n key: 'items',\n header: t('healthybowl.distribution.overview.table.items', 'Items'),\n render: (o) => <span className=\"tabular-nums\">{o.items.length}</span>,\n },\n {\n key: 'total',\n header: t('healthybowl.distribution.overview.table.total', 'Total'),\n render: (o) => <span className=\"tabular-nums\">{formatCurrency(o.total, 'INR')}</span>,\n },\n {\n key: 'status',\n header: t('healthybowl.distribution.overview.table.status', 'Status'),\n render: (o) => <StatusBadge variant={orderStatusVariant(o.status)} label={o.status} dot />,\n },\n {\n key: 'payment',\n header: t('healthybowl.distribution.overview.table.payment', 'Payment'),\n render: (o) => <StatusBadge variant={o.paymentStatus === 'paid' ? 'success' : 'muted'} label={o.paymentStatus} />,\n },\n ];\n\n if (loading.summary && !summary) {\n return <PageLoader />;\n }\n\n return (\n <PageLayout\n title={t('healthybowl.distribution.overview.title', 'Distribution & Sales Channels')}\n titleAccent={t('healthybowl.distribution.overview.titleAccent', 'Distribution')}\n description={t(\n 'healthybowl.distribution.overview.description',\n 'CSA subscription boxes, wholesale bulk orders and delivery-route planning across every sales channel.'\n )}\n hero\n purpose=\"See every order across your channels — CSA subscriptions, wholesale, farmers-market and direct sales — in one place. CSA recurring billing runs on the platform billing service and delivery-dispatch notifications are automated by a FluidGrids flow.\"\n >\n <DistributionNav />\n\n <div className=\"mt-4 flex flex-wrap items-center gap-2\">\n <span className=\"inline-flex items-center gap-1.5 rounded-full border border-border-subtle bg-bg-sunken/60 px-3 py-1 text-xs text-text-secondary\">\n <Workflow className=\"h-3.5 w-3.5\" />\n {t('healthybowl.distribution.overview.badge.automation', 'Automation: FluidGrids')}\n </span>\n <span className=\"inline-flex items-center gap-1.5 rounded-full border border-border-subtle bg-bg-sunken/60 px-3 py-1 text-xs text-text-secondary\">\n <CreditCard className=\"h-3.5 w-3.5\" />\n {t('healthybowl.distribution.overview.badge.billing', 'Billing: platform')}\n </span>\n </div>\n\n {errors.summary && !summary ? (\n <ErrorState description={errors.summary.message} onRetry={() => void refetchSummary()} />\n ) : (\n <>\n <div className=\"mt-4 grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-4\">\n <StatCard\n label={t('healthybowl.distribution.overview.stats.members', 'Active CSA Members')}\n value={summary?.activeCsaMembers ?? 0}\n icon={<Boxes className=\"h-5 w-5\" />}\n hero\n />\n <StatCard\n label={t('healthybowl.distribution.overview.stats.weeklyBoxes', 'Weekly Boxes')}\n value={summary?.weeklyBoxes ?? 0}\n icon={<PackageCheck className=\"h-5 w-5\" />}\n />\n <StatCard\n label={t('healthybowl.distribution.overview.stats.wholesale', 'Wholesale Accounts')}\n value={summary?.wholesaleAccounts ?? 0}\n icon={<Store className=\"h-5 w-5\" />}\n />\n <StatCard\n label={t('healthybowl.distribution.overview.stats.deliveries', 'Deliveries This Week')}\n value={`${summary?.routesThisWeek ?? 0} / ${summary?.stopsThisWeek ?? 0}`}\n icon={<Truck className=\"h-5 w-5\" />}\n />\n </div>\n <p className=\"mt-1 text-xs text-text-secondary\">\n {t(\n 'healthybowl.distribution.overview.deliveriesHint',\n '{{routes}} route(s) · {{stops}} stop(s) scheduled this week.',\n { routes: summary?.routesThisWeek ?? 0, stops: summary?.stopsThisWeek ?? 0 }\n )}\n </p>\n\n <div className=\"mt-6\">\n <div className=\"mb-3 flex flex-wrap items-center justify-between gap-2\">\n <h2 className=\"text-lg font-semibold text-text-primary\">\n {t('healthybowl.distribution.overview.ordersTitle', 'Orders by channel')}\n </h2>\n <div className=\"inline-flex flex-wrap rounded-lg border border-border-subtle p-0.5\">\n {CHANNEL_TABS.map((tab) => (\n <button\n key={tab.key}\n type=\"button\"\n onClick={() => setChannelKey(tab.key)}\n className={\n channelKey === tab.key\n ? 'rounded-md bg-bg-sunken px-2.5 py-1 text-xs font-medium text-text-primary transition-colors'\n : 'rounded-md px-2.5 py-1 text-xs text-text-secondary transition-colors hover:text-text-primary'\n }\n >\n {tab.label}\n </button>\n ))}\n </div>\n </div>\n\n {loading.channelOrders && channelOrders.length === 0 ? (\n <PageLoader />\n ) : errors.channelOrders ? (\n <ErrorState description={errors.channelOrders.message} onRetry={() => void refetchChannelOrders()} />\n ) : channelOrders.length === 0 ? (\n <EmptyState\n icon={<Boxes className=\"h-8 w-8 text-text-secondary\" />}\n title={t('healthybowl.distribution.overview.empty.title', 'No orders in this channel yet')}\n description={t(\n 'healthybowl.distribution.overview.empty.description',\n 'Orders placed through this sales channel will appear here.'\n )}\n />\n ) : (\n <DataTable columns={columns} data={channelOrders} keyField=\"id\" pageSize={10} />\n )}\n </div>\n </>\n )}\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAkBA,IAAa,UAAiC;CAC5C,IAAM,EAAE,SAAM,EAAQ,GAChB,CAAC,GAAY,KAAiB,EAAS,KAAK,GAG5C,EAAE,YAAS,kBAAe,YAAS,WAAQ,yBAAsB,sBAAmB,EAA2B;EACnH,SAAS;EACT,eAAe;EACf,SALoB,QAAc,EAAa,MAAM,MAAM,EAAE,QAAQ,CAAU,KAAK,EAAa,IAAI,CAAC,CAAU,CAKvG,EAAc;CACzB,CAAC,GAEK,IAAuC;EAC3C;GACE,KAAK;GACL,QAAQ,EAAE,iDAAiD,OAAO;GAClE,SAAS,MACP,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,OAAD;IAAK,WAAU;cAAiC,EAAE;GAAiB,CAAA,GACnE,kBAAC,OAAD;IAAK,WAAU;cAA+B,EAAe,EAAE,IAAI;GAAO,CAAA,CACvE,EAAA,CAAA;EAET;EACA;GACE,KAAK;GACL,QAAQ,EAAE,mDAAmD,SAAS;GACtE,SAAS,MAAM,kBAAC,GAAD;IAAa,SAAQ;IAAO,OAAO,EAAa,EAAE,OAAO;GAAI,CAAA;EAC9E;EACA;GACE,KAAK;GACL,QAAQ,EAAE,iDAAiD,OAAO;GAClE,SAAS,MAAM,kBAAC,QAAD;IAAM,WAAU;cAAgB,EAAE,MAAM;GAAa,CAAA;EACtE;EACA;GACE,KAAK;GACL,QAAQ,EAAE,iDAAiD,OAAO;GAClE,SAAS,MAAM,kBAAC,QAAD;IAAM,WAAU;cAAgB,EAAe,EAAE,OAAO,KAAK;GAAQ,CAAA;EACtF;EACA;GACE,KAAK;GACL,QAAQ,EAAE,kD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AA,CAAA;EAEM;;AAEhB"}
|
|
1
|
+
{"version":3,"file":"DistributionOverviewPage.js","names":[],"sources":["../../../../src/healthybowl/pages/distribution/DistributionOverviewPage.tsx"],"sourcesContent":["/**\n * Distribution & Sales Channels — overview dashboard.\n * Roadmap 12 · BOFF-2884 · gap H-4.\n *\n * KPI cards + a channel-filtered order list, all from real backend data. Recurring\n * billing is reused from the platform billing service; dispatch notifications are\n * driven by a FluidGrids flow — surfaced as honest \"Automation / Billing\" badges.\n */\nimport { useMemo, useState } from 'react';\nimport { Boxes, PackageCheck, Store, Truck, Workflow, CreditCard } from 'lucide-react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { PageLayout, StatCard, DataTable, StatusBadge, EmptyState, ErrorState, PageLoader } from '../../components';\nimport type { Column } from '../../components';\nimport { formatCurrency, formatDateOnly } from '../../utils/helpers';\nimport { useHealthyBowlDistribution, type DistributionOrder } from '../../hooks/useHealthyBowlDistribution';\nimport { DistributionNav } from './DistributionNav';\nimport { CHANNEL_TABS, channelLabel, orderStatusVariant } from './labels';\n\nexport const DistributionOverviewPage = () => {\n const { t } = useI18n();\n const [channelKey, setChannelKey] = useState('ALL');\n const activeChannel = useMemo(() => CHANNEL_TABS.find((c) => c.key === channelKey) ?? CHANNEL_TABS[0], [channelKey]);\n\n const { summary, channelOrders, loading, errors, refetchChannelOrders, refetchSummary } = useHealthyBowlDistribution({\n summary: true,\n channelOrders: true,\n channel: activeChannel.value,\n });\n\n const columns: Column<DistributionOrder>[] = [\n {\n key: 'orderNumber',\n header: t('healthybowl.distribution.overview.table.order', 'Order'),\n render: (o) => (\n <div data-testid=\"distribution-order-row\" data-order-id={o.id}>\n <div className=\"font-medium text-text-primary\">{o.orderNumber}</div>\n <div className=\"text-xs text-text-secondary\">{formatDateOnly(o.date)}</div>\n </div>\n ),\n },\n {\n key: 'channel',\n header: t('healthybowl.distribution.overview.table.channel', 'Channel'),\n // BOFF-6065 — \"every row in this table carries a channel badge\" is a pass criterion, and\n // `ResponsiveTable` (fe-libs) exposes no per-row hook. Marking the channel cell AND the\n // order cell lets the spec compare the two counts: a row missing its badge shows up as a\n // mismatch. Cheaper than reaching into a shared component every product depends on.\n render: (o) => (\n <span data-testid=\"distribution-order-channel\" data-channel={o.channel}>\n <StatusBadge variant=\"info\" label={channelLabel(o.channel)} />\n </span>\n ),\n },\n {\n key: 'items',\n header: t('healthybowl.distribution.overview.table.items', 'Items'),\n render: (o) => <span className=\"tabular-nums\">{o.items.length}</span>,\n },\n {\n key: 'total',\n header: t('healthybowl.distribution.overview.table.total', 'Total'),\n render: (o) => <span className=\"tabular-nums\">{formatCurrency(o.total, 'INR')}</span>,\n },\n {\n key: 'status',\n header: t('healthybowl.distribution.overview.table.status', 'Status'),\n render: (o) => <StatusBadge variant={orderStatusVariant(o.status)} label={o.status} dot />,\n },\n {\n key: 'payment',\n header: t('healthybowl.distribution.overview.table.payment', 'Payment'),\n render: (o) => <StatusBadge variant={o.paymentStatus === 'paid' ? 'success' : 'muted'} label={o.paymentStatus} />,\n },\n ];\n\n if (loading.summary && !summary) {\n return <PageLoader />;\n }\n\n return (\n <PageLayout\n title={t('healthybowl.distribution.overview.title', 'Distribution & Sales Channels')}\n titleAccent={t('healthybowl.distribution.overview.titleAccent', 'Distribution')}\n description={t(\n 'healthybowl.distribution.overview.description',\n 'CSA subscription boxes, wholesale bulk orders and delivery-route planning across every sales channel.'\n )}\n hero\n purpose=\"See every order across your channels — CSA subscriptions, wholesale, farmers-market and direct sales — in one place. CSA recurring billing runs on the platform billing service and delivery-dispatch notifications are automated by a FluidGrids flow.\"\n >\n <DistributionNav />\n\n <div className=\"mt-4 flex flex-wrap items-center gap-2\">\n <span className=\"inline-flex items-center gap-1.5 rounded-full border border-border-subtle bg-bg-sunken/60 px-3 py-1 text-xs text-text-secondary\">\n <Workflow className=\"h-3.5 w-3.5\" />\n {t('healthybowl.distribution.overview.badge.automation', 'Automation: FluidGrids')}\n </span>\n <span className=\"inline-flex items-center gap-1.5 rounded-full border border-border-subtle bg-bg-sunken/60 px-3 py-1 text-xs text-text-secondary\">\n <CreditCard className=\"h-3.5 w-3.5\" />\n {t('healthybowl.distribution.overview.badge.billing', 'Billing: platform')}\n </span>\n </div>\n\n {errors.summary && !summary ? (\n <ErrorState description={errors.summary.message} onRetry={() => void refetchSummary()} />\n ) : (\n <>\n <div className=\"mt-4 grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-4\">\n <StatCard\n label={t('healthybowl.distribution.overview.stats.members', 'Active CSA Members')}\n value={summary?.activeCsaMembers ?? 0}\n data-testid=\"distribution-kpi-members\"\n data-value={summary?.activeCsaMembers ?? 0}\n icon={<Boxes className=\"h-5 w-5\" />}\n hero\n />\n <StatCard\n label={t('healthybowl.distribution.overview.stats.weeklyBoxes', 'Weekly Boxes')}\n value={summary?.weeklyBoxes ?? 0}\n data-testid=\"distribution-kpi-weekly-boxes\"\n data-value={summary?.weeklyBoxes ?? 0}\n icon={<PackageCheck className=\"h-5 w-5\" />}\n />\n <StatCard\n label={t('healthybowl.distribution.overview.stats.wholesale', 'Wholesale Accounts')}\n value={summary?.wholesaleAccounts ?? 0}\n data-testid=\"distribution-kpi-wholesale\"\n data-value={summary?.wholesaleAccounts ?? 0}\n icon={<Store className=\"h-5 w-5\" />}\n />\n <StatCard\n label={t('healthybowl.distribution.overview.stats.deliveries', 'Deliveries This Week')}\n value={`${summary?.routesThisWeek ?? 0} / ${summary?.stopsThisWeek ?? 0}`}\n data-testid=\"distribution-kpi-deliveries\"\n data-routes={summary?.routesThisWeek ?? 0}\n data-stops={summary?.stopsThisWeek ?? 0}\n icon={<Truck className=\"h-5 w-5\" />}\n />\n </div>\n <p className=\"mt-1 text-xs text-text-secondary\">\n {t(\n 'healthybowl.distribution.overview.deliveriesHint',\n '{{routes}} route(s) · {{stops}} stop(s) scheduled this week.',\n { routes: summary?.routesThisWeek ?? 0, stops: summary?.stopsThisWeek ?? 0 }\n )}\n </p>\n\n <div className=\"mt-6\">\n <div className=\"mb-3 flex flex-wrap items-center justify-between gap-2\">\n <h2 className=\"text-lg font-semibold text-text-primary\">\n {t('healthybowl.distribution.overview.ordersTitle', 'Orders by channel')}\n </h2>\n <div className=\"inline-flex flex-wrap rounded-lg border border-border-subtle p-0.5\">\n {CHANNEL_TABS.map((tab) => (\n <button\n key={tab.key}\n type=\"button\"\n // BOFF-6065 — the journey asserts that switching channel tabs changes the row\n // set, so it needs to click each one by key rather than by translated label.\n data-testid={`distribution-channel-tab-${tab.key}`}\n data-active={channelKey === tab.key}\n onClick={() => setChannelKey(tab.key)}\n className={\n channelKey === tab.key\n ? 'rounded-md bg-bg-sunken px-2.5 py-1 text-xs font-medium text-text-primary transition-colors'\n : 'rounded-md px-2.5 py-1 text-xs text-text-secondary transition-colors hover:text-text-primary'\n }\n >\n {tab.label}\n </button>\n ))}\n </div>\n </div>\n\n {loading.channelOrders && channelOrders.length === 0 ? (\n <PageLoader />\n ) : errors.channelOrders ? (\n <ErrorState description={errors.channelOrders.message} onRetry={() => void refetchChannelOrders()} />\n ) : channelOrders.length === 0 ? (\n <EmptyState\n icon={<Boxes className=\"h-8 w-8 text-text-secondary\" />}\n title={t('healthybowl.distribution.overview.empty.title', 'No orders in this channel yet')}\n description={t(\n 'healthybowl.distribution.overview.empty.description',\n 'Orders placed through this sales channel will appear here.'\n )}\n />\n ) : (\n <DataTable columns={columns} data={channelOrders} keyField=\"id\" pageSize={10} />\n )}\n </div>\n </>\n )}\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAkBA,IAAa,UAAiC;CAC5C,IAAM,EAAE,SAAM,EAAQ,GAChB,CAAC,GAAY,KAAiB,EAAS,KAAK,GAG5C,EAAE,YAAS,kBAAe,YAAS,WAAQ,yBAAsB,sBAAmB,EAA2B;EACnH,SAAS;EACT,eAAe;EACf,SALoB,QAAc,EAAa,MAAM,MAAM,EAAE,QAAQ,CAAU,KAAK,EAAa,IAAI,CAAC,CAAU,CA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AkB;OACxC,cAAY,GAAS,iBAAiB;OACtC,MAAM,kBAAC,GAAD,EAAO,WAAU,UAAW,CAAA;MACnC,CAAA;KACE;;IACL,kBAAC,KAAD;KAAG,WAAU;eACV,EACC,oDACA,gEACA;MAAE,QAAQ,GAAS,kBAAkB;MAAG,OAAO,GAAS,iBAAiB;KAAE,CAC7E;IACC,CAAA;IAEH,kBAAC,OAAD;KAAK,WAAU;eAAf,CACE,kBAAC,OAAD;MAAK,WAAU;gBAAf,CACE,kBAAC,MAAD;OAAI,WAAU;iBACX,EAAE,iDAAiD,mBAAmB;MACrE,CAAA,GACJ,kBAAC,OAAD;OAAK,WAAU;iBACZ,EAAa,KAAK,MACjB,kBAAC,UAAD;QAEE,MAAK;QAGL,eAAa,4BAA4B,EAAI;QAC7C,eAAa,MAAe,EAAI;QAChC,eAAe,EAAc,EAAI,GAAG;QACpC,WACE,MAAe,EAAI,MACf,gGACA;kBAGL,EAAI;OACC,GAdD,EAAI,GAcH,CACT;MACE,CAAA,CACF;SAEJ,EAAQ,iBAAiB,EAAc,WAAW,IACjD,kBAAC,GAAD,CAAa,CAAA,IACX,EAAO,gBACT,kBAAC,GAAD;MAAY,aAAa,EAAO,cAAc;MAAS,eAAe,KAAK,EAAqB;KAAI,CAAA,IAClG,EAAc,WAAW,IAC3B,kBAAC,GAAD;MACE,MAAM,kBAAC,GAAD,EAAO,WAAU,8BAA+B,CAAA;MACtD,OAAO,EAAE,iDAAiD,+BAA+B;MACzF,aAAa,EACX,uDACA,4DACF;KACD,CAAA,IAED,kBAAC,GAAD;MAAoB;MAAS,MAAM;MAAe,UAAS;MAAK,UAAU;KAAK,CAAA,CAE9E;;GACL,EAAA,CAAA;EAEM;;AAEhB"}
|
|
@@ -204,6 +204,7 @@ function E() {
|
|
|
204
204
|
actions: vt,
|
|
205
205
|
children: z && N.length === 0 ? /* @__PURE__ */ v(ne, {}) : Ve && N.length === 0 ? /* @__PURE__ */ v(r, { onRetry: He }) : bt ? /* @__PURE__ */ y("div", {
|
|
206
206
|
className: "mx-auto max-w-xl py-10 text-center",
|
|
207
|
+
"data-testid": "mandi-empty-state",
|
|
207
208
|
children: [
|
|
208
209
|
/* @__PURE__ */ v("div", {
|
|
209
210
|
className: "mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-2xl bg-[var(--color-accent-soft)]",
|
|
@@ -252,11 +253,15 @@ function E() {
|
|
|
252
253
|
icon: /* @__PURE__ */ v(Ae, { className: "h-4 w-4" })
|
|
253
254
|
}),
|
|
254
255
|
/* @__PURE__ */ v(n, {
|
|
256
|
+
"data-testid": "mandi-kpi-watchlist",
|
|
257
|
+
"data-value": I.length,
|
|
255
258
|
label: o("healthybowl.mandi.kpi.watchlist", "On watchlist"),
|
|
256
259
|
value: I.length,
|
|
257
260
|
icon: /* @__PURE__ */ v(h, { className: "h-4 w-4" })
|
|
258
261
|
}),
|
|
259
262
|
/* @__PURE__ */ v(n, {
|
|
263
|
+
"data-testid": "mandi-kpi-alerts",
|
|
264
|
+
"data-value": _t,
|
|
260
265
|
label: o("healthybowl.mandi.kpi.alerts", "Active alerts"),
|
|
261
266
|
value: _t,
|
|
262
267
|
icon: /* @__PURE__ */ v(Ee, { className: "h-4 w-4" })
|
|
@@ -529,6 +534,8 @@ function E() {
|
|
|
529
534
|
}) : /* @__PURE__ */ v("ul", {
|
|
530
535
|
className: "space-y-2",
|
|
531
536
|
children: $.slice(0, 5).map((t) => /* @__PURE__ */ y("li", {
|
|
537
|
+
"data-testid": "mandi-alert-row",
|
|
538
|
+
"data-alert-id": t.id,
|
|
532
539
|
className: "flex gap-2 rounded-lg border border-border-subtle bg-bg-surface p-2.5",
|
|
533
540
|
children: [/* @__PURE__ */ v("span", { className: e("mt-0.5 w-1 shrink-0 rounded-full", ve(t.severity)) }), /* @__PURE__ */ y("div", {
|
|
534
541
|
className: "min-w-0 flex-1",
|
|
@@ -547,6 +554,7 @@ function E() {
|
|
|
547
554
|
variant: "ghost",
|
|
548
555
|
size: "sm",
|
|
549
556
|
className: "h-6 px-1.5",
|
|
557
|
+
"data-testid": "mandi-alert-acknowledge",
|
|
550
558
|
onClick: () => ht(t),
|
|
551
559
|
"aria-label": o("healthybowl.mandi.alerts.acknowledge", "Acknowledge alert"),
|
|
552
560
|
title: o("healthybowl.mandi.alerts.acknowledge", "Acknowledge alert"),
|