@burdenoff/microfe-healthybowl 2026.814.2 → 2026.814.4

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.
@@ -3,7 +3,7 @@ import { useCallback as t, useMemo as ee } from "react";
3
3
  import { gql as n } from "@apollo/client";
4
4
  import { useMutation as r, useQuery as i } from "@apollo/client/react";
5
5
  //#region src/healthybowl/hooks/useHealthyBowlDistribution.ts
6
- var te = "00000000-0000-0000-0000-000000000001", a = "\n id\n name\n description\n frequency\n price\n currency\n boxSize\n contents { \n productId\n productName\n quantity\n unit\n }\n deliveryDayOfWeek\n startDate\n endDate\n capacity\n status\n recurringBillingPlanId\n billingSyncStatus\n billingSyncError\n activeMemberCount\n createdAt\n", o = "\n id\n csaPlanId\n csaPlanName\n memberUserId\n memberName\n memberEmail\n memberPhone\n deliveryAddress\n lat\n lng\n fulfilmentMode\n pickupLocationId\n pickupLocationName\n status\n startDate\n nextDeliveryDate\n pausedUntil\n cycleCount\n billingAccountId\n billingSyncStatus\n billingSyncError\n createdAt\n", s = "\n id\n csaMembershipId\n csaPlanId\n memberName\n cycleNumber\n scheduledDate\n status\n orderId\n billingOrderId\n billingSyncStatus\n billingSyncError\n workflowRunId\n notificationSentAt\n deliveredAt\n lat\n lng\n deliveryAddress\n notes\n", c = "\n id\n orderId\n orderNumber\n buyerName\n buyerContact\n buyerUserId\n productId\n productName\n quantityKg\n pricePerKg\n appliedTierId\n priceSource\n totalAmount\n fulfilmentStatus\n expectedDeliveryDate\n orderDate\n notes\n", l = "\n id\n productName\n productId\n minQuantityKg\n pricePerKg\n createdAt\n", u = "\n id\n sequence\n csaDeliveryId\n label\n address\n lat\n lng\n status\n memberName\n notificationSentAt\n arrivedAt\n notes\n", d = `
6
+ var te = "00000000-0000-0000-0000-000000000001", a = "\n id\n name\n description\n frequency\n price\n currency\n boxSize\n contents { \n productId\n productName\n quantity\n unit\n }\n deliveryDayOfWeek\n startDate\n endDate\n capacity\n status\n recurringBillingPlanId\n billingSyncStatus\n billingSyncError\n activeMemberCount\n pausedMemberCount\n assignedMemberCount\n capacityRemaining\n capacityUtilisationPct\n atCapacity\n capacityReason\n createdAt\n", o = "\n id\n csaPlanId\n csaPlanName\n memberUserId\n memberName\n memberEmail\n memberPhone\n deliveryAddress\n lat\n lng\n fulfilmentMode\n pickupLocationId\n pickupLocationName\n status\n startDate\n nextDeliveryDate\n pausedUntil\n cycleCount\n billingAccountId\n billingSyncStatus\n billingSyncError\n createdAt\n", s = "\n id\n csaMembershipId\n csaPlanId\n memberName\n cycleNumber\n scheduledDate\n status\n orderId\n billingOrderId\n billingSyncStatus\n billingSyncError\n workflowRunId\n notificationSentAt\n deliveredAt\n lat\n lng\n deliveryAddress\n notes\n", c = "\n id\n orderId\n orderNumber\n buyerName\n buyerContact\n buyerUserId\n productId\n productName\n quantityKg\n pricePerKg\n appliedTierId\n priceSource\n totalAmount\n fulfilmentStatus\n expectedDeliveryDate\n orderDate\n notes\n", l = "\n id\n productName\n productId\n minQuantityKg\n pricePerKg\n createdAt\n", u = "\n id\n sequence\n csaDeliveryId\n label\n address\n lat\n lng\n status\n memberName\n notificationSentAt\n arrivedAt\n notes\n", d = `
7
7
  id
8
8
  name
9
9
  routeDate
@@ -1 +1 @@
1
- {"version":3,"file":"useHealthyBowlDistribution.js","names":[],"sources":["../../../src/healthybowl/hooks/useHealthyBowlDistribution.ts"],"sourcesContent":["/**\n * Distribution & Sales Channels — data hook.\n * Roadmap 12 · BOFF-2884 · gap H-4.\n *\n * CSA subscription boxes, wholesale bulk orders, and delivery-route planning, plus a\n * per-Order `channel` tag. Documents are declared inline with `gql` (not as\n * `src/operations/wspace/*.graphql`) because codegen validates operations against the\n * committed `graphql/wspace.graphql` snapshot, which can't know about these fields until\n * the subgraph is live in the supergraph — the same escape hatch `useHealthyBowlWithdrawal`\n * uses. Types mirror `wspace-healthybowl-svc/src/modules/healthybowl/schema/distribution.gql`.\n *\n * Reads use `cache-and-network`; every write throws on error then refetches the reads it\n * invalidates. Pages opt into only the reads they render (all default off) so a page never\n * fires a query it doesn't use.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport { gql } from '@apollo/client';\nimport { useMutation, useQuery } from '@apollo/client/react';\nimport { useHealthyBowl } from '../context/HealthyBowlContext';\n\nconst FALLBACK_WORKSPACE_ID = '00000000-0000-0000-0000-000000000001';\n\n// ── types (mirror distribution.gql) ───────────────────────────────────────────\n\nexport type CsaFrequency = 'WEEKLY' | 'BIWEEKLY' | 'MONTHLY';\nexport type CsaBoxSize = 'SMALL' | 'MEDIUM' | 'LARGE';\nexport type CsaPlanStatus = 'ACTIVE' | 'PAUSED' | 'ARCHIVED';\nexport type CsaMembershipStatus = 'ACTIVE' | 'PAUSED' | 'CANCELLED';\nexport type CsaDeliveryStatus = 'SCHEDULED' | 'PACKED' | 'DISPATCHED' | 'DELIVERED' | 'SKIPPED';\nexport type WholesaleFulfilmentStatus = 'CONFIRMED' | 'PACKING' | 'FULFILLED' | 'CANCELLED';\nexport type DeliveryRouteStatus = 'PLANNED' | 'IN_PROGRESS' | 'COMPLETED' | 'CANCELLED';\nexport type DeliveryStopStatus = 'PENDING' | 'ARRIVED' | 'DELIVERED' | 'FAILED';\nexport type BillingSyncStatus = 'PENDING' | 'SYNCED' | 'FAILED';\n\n/** JSON scalar (delivery address). The backend stores a structured object but a string is possible. */\nexport type DeliveryAddress = Record<string, unknown> | string | null;\n\nexport interface CsaBoxItem {\n productId: string | null;\n productName: string;\n quantity: number;\n unit: string;\n}\n\nexport interface CsaPlan {\n id: string;\n name: string;\n description: string | null;\n frequency: string;\n price: number;\n currency: string;\n boxSize: string;\n contents: CsaBoxItem[];\n deliveryDayOfWeek: number;\n startDate: string;\n endDate: string | null;\n capacity: number | null;\n status: string;\n recurringBillingPlanId: string | null;\n billingSyncStatus: string;\n billingSyncError: string | null;\n activeMemberCount: number;\n createdAt: string;\n}\n\nexport interface CsaMembership {\n id: string;\n csaPlanId: string;\n csaPlanName: string;\n memberUserId: string | null;\n memberName: string;\n memberEmail: string | null;\n memberPhone: string | null;\n deliveryAddress: DeliveryAddress;\n lat: number | null;\n lng: number | null;\n /** HOME_DELIVERY | PICKUP — derived from whether pickupLocationId is set (BOFF-5978). */\n fulfilmentMode?: string;\n /** The stand this member collects from. Null = home delivery. */\n pickupLocationId?: string | null;\n /** Read live off the location, so correcting the stand's name corrects it everywhere at once. */\n pickupLocationName?: string | null;\n status: string;\n startDate: string;\n nextDeliveryDate: string | null;\n pausedUntil: string | null;\n cycleCount: number;\n billingAccountId: string | null;\n billingSyncStatus: string;\n billingSyncError: string | null;\n createdAt: string;\n}\n\nexport interface CsaDelivery {\n id: string;\n csaMembershipId: string;\n csaPlanId: string;\n memberName: string;\n cycleNumber: number;\n scheduledDate: string;\n status: string;\n orderId: string | null;\n billingOrderId: string | null;\n billingSyncStatus: string;\n billingSyncError: string | null;\n workflowRunId: string | null;\n notificationSentAt: string | null;\n deliveredAt: string | null;\n lat: number | null;\n lng: number | null;\n deliveryAddress: DeliveryAddress;\n notes: string | null;\n}\n\nexport interface WholesaleOrder {\n id: string;\n orderId: string;\n orderNumber: string;\n buyerName: string;\n buyerContact: string | null;\n buyerUserId: string | null;\n productId: string | null;\n productName: string;\n quantityKg: number;\n pricePerKg: number;\n appliedTierId: string | null;\n priceSource: string;\n totalAmount: number;\n fulfilmentStatus: string;\n expectedDeliveryDate: string | null;\n orderDate: string;\n notes: string | null;\n}\n\nexport interface WholesalePriceTier {\n id: string;\n productName: string;\n productId: string | null;\n minQuantityKg: number;\n pricePerKg: number;\n createdAt: string;\n}\n\nexport interface DeliveryStop {\n id: string;\n sequence: number;\n csaDeliveryId: string | null;\n label: string;\n address: string | null;\n lat: number;\n lng: number;\n status: string;\n memberName: string | null;\n notificationSentAt: string | null;\n arrivedAt: string | null;\n notes: string | null;\n}\n\nexport interface DeliveryRoute {\n id: string;\n name: string;\n routeDate: string;\n status: string;\n driverName: string | null;\n startLat: number | null;\n startLng: number | null;\n stopCount: number;\n totalDistanceKm: number | null;\n dispatchedAt: string | null;\n stops: DeliveryStop[];\n}\n\nexport interface ChannelBreakdown {\n channel: string;\n orderCount: number;\n revenue: number;\n}\n\nexport interface DistributionSummary {\n channels: ChannelBreakdown[];\n activeCsaPlans: number;\n activeCsaMembers: number;\n weeklyBoxes: number;\n upcomingDeliveries: number;\n wholesaleAccounts: number;\n openWholesaleOrders: number;\n routesThisWeek: number;\n stopsThisWeek: number;\n}\n\nexport interface DistributionOrderItem {\n id: string;\n productId: string;\n productName: string;\n quantity: number;\n price: number;\n unit: string;\n seller: string;\n}\n\nexport interface DistributionOrder {\n id: string;\n orderNumber: string;\n date: string;\n items: DistributionOrderItem[];\n subtotal: number;\n tax: number;\n shipping: number;\n total: number;\n status: string;\n paymentStatus: string;\n deliveryDate: string | null;\n channel: string;\n}\n\ninterface HbContext {\n workspaceId: string;\n}\n\n// ── field fragments ───────────────────────────────────────────────────────────\n\nconst CSA_BOX_ITEM_FIELDS = `\n productId\n productName\n quantity\n unit\n`;\n\nconst CSA_PLAN_FIELDS = `\n id\n name\n description\n frequency\n price\n currency\n boxSize\n contents { ${CSA_BOX_ITEM_FIELDS} }\n deliveryDayOfWeek\n startDate\n endDate\n capacity\n status\n recurringBillingPlanId\n billingSyncStatus\n billingSyncError\n activeMemberCount\n createdAt\n`;\n\nconst CSA_MEMBERSHIP_FIELDS = `\n id\n csaPlanId\n csaPlanName\n memberUserId\n memberName\n memberEmail\n memberPhone\n deliveryAddress\n lat\n lng\n fulfilmentMode\n pickupLocationId\n pickupLocationName\n status\n startDate\n nextDeliveryDate\n pausedUntil\n cycleCount\n billingAccountId\n billingSyncStatus\n billingSyncError\n createdAt\n`;\n\nconst CSA_DELIVERY_FIELDS = `\n id\n csaMembershipId\n csaPlanId\n memberName\n cycleNumber\n scheduledDate\n status\n orderId\n billingOrderId\n billingSyncStatus\n billingSyncError\n workflowRunId\n notificationSentAt\n deliveredAt\n lat\n lng\n deliveryAddress\n notes\n`;\n\nconst WHOLESALE_FIELDS = `\n id\n orderId\n orderNumber\n buyerName\n buyerContact\n buyerUserId\n productId\n productName\n quantityKg\n pricePerKg\n appliedTierId\n priceSource\n totalAmount\n fulfilmentStatus\n expectedDeliveryDate\n orderDate\n notes\n`;\n\nconst WHOLESALE_TIER_FIELDS = `\n id\n productName\n productId\n minQuantityKg\n pricePerKg\n createdAt\n`;\n\nconst STOP_FIELDS = `\n id\n sequence\n csaDeliveryId\n label\n address\n lat\n lng\n status\n memberName\n notificationSentAt\n arrivedAt\n notes\n`;\n\nconst ROUTE_FIELDS = `\n id\n name\n routeDate\n status\n driverName\n startLat\n startLng\n stopCount\n totalDistanceKm\n dispatchedAt\n stops { ${STOP_FIELDS} }\n`;\n\nconst ORDER_FIELDS = `\n id\n orderNumber\n date\n items { id productId productName quantity price unit seller }\n subtotal\n tax\n shipping\n total\n status\n paymentStatus\n deliveryDate\n channel\n`;\n\nconst SUMMARY_FIELDS = `\n channels { channel orderCount revenue }\n activeCsaPlans\n activeCsaMembers\n weeklyBoxes\n upcomingDeliveries\n wholesaleAccounts\n openWholesaleOrders\n routesThisWeek\n stopsThisWeek\n`;\n\n// ── documents ───────────────────────────────────────────────────────────────\n\nconst GET_SUMMARY = gql`\n query GetHealthyBowlDistributionSummary($context: ContextInput!) {\n getHealthyBowlDistributionSummary(context: $context) { ${SUMMARY_FIELDS} }\n }\n`;\n\nconst GET_CHANNEL_ORDERS = gql`\n query GetHealthyBowlChannelOrders($context: ContextInput!, $channel: String, $limit: Int, $offset: Int) {\n getHealthyBowlChannelOrders(context: $context, channel: $channel, limit: $limit, offset: $offset) { ${ORDER_FIELDS} }\n }\n`;\n\nconst GET_CSA_PLANS = gql`\n query GetHealthyBowlCsaPlans($context: ContextInput!, $status: String) {\n getHealthyBowlCsaPlans(context: $context, status: $status) { ${CSA_PLAN_FIELDS} }\n }\n`;\n\nconst GET_CSA_PLAN = gql`\n query GetHealthyBowlCsaPlan($context: ContextInput!, $id: ID!) {\n getHealthyBowlCsaPlan(context: $context, id: $id) { ${CSA_PLAN_FIELDS} }\n }\n`;\n\nconst GET_CSA_MEMBERSHIPS = gql`\n query GetHealthyBowlCsaMemberships(\n $context: ContextInput!\n $csaPlanId: ID\n $status: String\n $limit: Int\n $offset: Int\n ) {\n getHealthyBowlCsaMemberships(\n context: $context\n csaPlanId: $csaPlanId\n status: $status\n limit: $limit\n offset: $offset\n ) { ${CSA_MEMBERSHIP_FIELDS} }\n }\n`;\n\nconst GET_WHOLESALE_ORDERS = gql`\n query GetHealthyBowlWholesaleOrders($context: ContextInput!, $fulfilmentStatus: String, $limit: Int, $offset: Int) {\n getHealthyBowlWholesaleOrders(\n context: $context\n fulfilmentStatus: $fulfilmentStatus\n limit: $limit\n offset: $offset\n ) { ${WHOLESALE_FIELDS} }\n }\n`;\n\nconst GET_DELIVERY_ROUTES = gql`\n query GetHealthyBowlDeliveryRoutes($context: ContextInput!, $fromDate: String, $toDate: String) {\n getHealthyBowlDeliveryRoutes(context: $context, fromDate: $fromDate, toDate: $toDate) { ${ROUTE_FIELDS} }\n }\n`;\n\nconst GET_DELIVERY_ROUTE = gql`\n query GetHealthyBowlDeliveryRoute($context: ContextInput!, $id: ID!) {\n getHealthyBowlDeliveryRoute(context: $context, id: $id) { ${ROUTE_FIELDS} }\n }\n`;\n\nconst CREATE_CSA_PLAN = gql`\n mutation CreateHealthyBowlCsaPlan($input: CreateHealthyBowlCsaPlanInput!) {\n createHealthyBowlCsaPlan(input: $input) { ${CSA_PLAN_FIELDS} }\n }\n`;\nconst UPDATE_CSA_PLAN = gql`\n mutation UpdateHealthyBowlCsaPlan($input: UpdateHealthyBowlCsaPlanInput!) {\n updateHealthyBowlCsaPlan(input: $input) { ${CSA_PLAN_FIELDS} }\n }\n`;\nconst DELETE_CSA_PLAN = gql`\n mutation DeleteHealthyBowlCsaPlan($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlCsaPlan(id: $id, context: $context)\n }\n`;\nconst ENROLL_CSA_MEMBER = gql`\n mutation EnrollHealthyBowlCsaMember($input: EnrollHealthyBowlCsaMemberInput!) {\n enrollHealthyBowlCsaMember(input: $input) { ${CSA_MEMBERSHIP_FIELDS} }\n }\n`;\nconst UPDATE_CSA_MEMBERSHIP = gql`\n mutation UpdateHealthyBowlCsaMembership($input: UpdateHealthyBowlCsaMembershipInput!) {\n updateHealthyBowlCsaMembership(input: $input) { ${CSA_MEMBERSHIP_FIELDS} }\n }\n`;\nconst CANCEL_CSA_MEMBERSHIP = gql`\n mutation CancelHealthyBowlCsaMembership($id: ID!, $context: ContextInput!) {\n cancelHealthyBowlCsaMembership(id: $id, context: $context) { ${CSA_MEMBERSHIP_FIELDS} }\n }\n`;\nconst RENEW_CSA_MEMBERSHIP = gql`\n mutation RenewHealthyBowlCsaMembership($input: RenewHealthyBowlCsaMembershipInput!) {\n renewHealthyBowlCsaMembership(input: $input) { ${CSA_MEMBERSHIP_FIELDS} }\n }\n`;\nconst RETRY_CSA_BILLING = gql`\n mutation RetryHealthyBowlCsaBilling($csaDeliveryId: ID!, $context: ContextInput!) {\n retryHealthyBowlCsaBilling(csaDeliveryId: $csaDeliveryId, context: $context) { ${CSA_DELIVERY_FIELDS} }\n }\n`;\nconst UPDATE_CSA_DELIVERY = gql`\n mutation UpdateHealthyBowlCsaDelivery($input: UpdateHealthyBowlCsaDeliveryInput!) {\n updateHealthyBowlCsaDelivery(input: $input) { ${CSA_DELIVERY_FIELDS} }\n }\n`;\nconst CREATE_WHOLESALE_ORDER = gql`\n mutation CreateHealthyBowlWholesaleOrder($input: CreateHealthyBowlWholesaleOrderInput!) {\n createHealthyBowlWholesaleOrder(input: $input) { ${WHOLESALE_FIELDS} }\n }\n`;\nconst UPDATE_WHOLESALE_ORDER = gql`\n mutation UpdateHealthyBowlWholesaleOrder($input: UpdateHealthyBowlWholesaleOrderInput!) {\n updateHealthyBowlWholesaleOrder(input: $input) { ${WHOLESALE_FIELDS} }\n }\n`;\nconst DELETE_WHOLESALE_ORDER = gql`\n mutation DeleteHealthyBowlWholesaleOrder($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlWholesaleOrder(id: $id, context: $context)\n }\n`;\nconst GET_WHOLESALE_PRICE_TIERS = gql`\n query GetHealthyBowlWholesalePriceTiers($context: ContextInput!, $productName: String!) {\n getHealthyBowlWholesalePriceTiers(context: $context, productName: $productName) { ${WHOLESALE_TIER_FIELDS} }\n }\n`;\nconst SET_WHOLESALE_PRICE_TIERS = gql`\n mutation SetHealthyBowlWholesalePriceTiers($input: SetHealthyBowlWholesalePriceTiersInput!) {\n setHealthyBowlWholesalePriceTiers(input: $input) { ${WHOLESALE_TIER_FIELDS} }\n }\n`;\nconst GENERATE_DELIVERY_ROUTE = gql`\n mutation GenerateHealthyBowlDeliveryRoute($input: GenerateHealthyBowlDeliveryRouteInput!) {\n generateHealthyBowlDeliveryRoute(input: $input) { ${ROUTE_FIELDS} }\n }\n`;\nconst UPDATE_DELIVERY_STOP = gql`\n mutation UpdateHealthyBowlDeliveryStop($input: UpdateHealthyBowlDeliveryStopInput!) {\n updateHealthyBowlDeliveryStop(input: $input) { ${STOP_FIELDS} }\n }\n`;\nconst DELETE_DELIVERY_ROUTE = gql`\n mutation DeleteHealthyBowlDeliveryRoute($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlDeliveryRoute(id: $id, context: $context)\n }\n`;\nconst DISPATCH_DELIVERY_ROUTE = gql`\n mutation DispatchHealthyBowlDeliveryRoute($id: ID!, $context: ContextInput!) {\n dispatchHealthyBowlDeliveryRoute(id: $id, context: $context) { ${ROUTE_FIELDS} }\n }\n`;\n\n// ── hook ───────────────────────────────────────────────────────────────────\n\nexport interface UseDistributionOptions {\n /** Fetch the dashboard summary (KPI cards + per-channel breakdown). */\n summary?: boolean;\n /** Fetch the channel-filtered order list. */\n channelOrders?: boolean;\n /** Channel filter for the order list: null/undefined = all channels. */\n channel?: string | null;\n /** Fetch the CSA subscription plans list. */\n plans?: boolean;\n /** Optional status filter for the CSA plans list (ACTIVE | PAUSED | ARCHIVED). */\n plansStatus?: string | null;\n /** Fetch the wholesale orders list. */\n wholesale?: boolean;\n /** Optional fulfilment-status filter for the wholesale list. */\n wholesaleStatus?: string | null;\n /** Fetch the price-tier ladder for one product (requires wholesaleTiersProduct). */\n wholesaleTiers?: boolean;\n /** Product whose ladder `wholesaleTiers` fetches. */\n wholesaleTiersProduct?: string | null;\n /** Fetch the delivery-routes list. */\n routes?: boolean;\n /** Optional inclusive ISO date range for the routes list. */\n routesRange?: { fromDate: string; toDate: string } | null;\n}\n\nexport function useHealthyBowlDistribution(options: UseDistributionOptions = {}) {\n const { workspaceId } = useHealthyBowl();\n const effectiveWorkspaceId = workspaceId || FALLBACK_WORKSPACE_ID;\n const ctx = useMemo<HbContext>(() => ({ workspaceId: effectiveWorkspaceId }), [effectiveWorkspaceId]);\n\n const enableSummary = options.summary === true;\n const enableChannelOrders = options.channelOrders === true;\n const enablePlans = options.plans === true;\n const enableWholesale = options.wholesale === true;\n const enableWholesaleTiers = options.wholesaleTiers === true && !!options.wholesaleTiersProduct;\n const enableRoutes = options.routes === true;\n\n const channel = options.channel ?? null;\n const plansStatus = options.plansStatus ?? null;\n const wholesaleStatus = options.wholesaleStatus ?? null;\n const wholesaleTiersProduct = options.wholesaleTiersProduct ?? null;\n const routesFromDate = options.routesRange?.fromDate ?? null;\n const routesToDate = options.routesRange?.toDate ?? null;\n\n const summaryQuery = useQuery<{ getHealthyBowlDistributionSummary: DistributionSummary }, { context: HbContext }>(\n GET_SUMMARY,\n { variables: { context: ctx }, fetchPolicy: 'cache-and-network', skip: !enableSummary }\n );\n\n const channelOrdersQuery = useQuery<\n { getHealthyBowlChannelOrders: DistributionOrder[] },\n { context: HbContext; channel: string | null; limit: number; offset: number }\n >(GET_CHANNEL_ORDERS, {\n variables: { context: ctx, channel, limit: 100, offset: 0 },\n fetchPolicy: 'cache-and-network',\n skip: !enableChannelOrders,\n });\n\n const plansQuery = useQuery<{ getHealthyBowlCsaPlans: CsaPlan[] }, { context: HbContext; status: string | null }>(\n GET_CSA_PLANS,\n {\n variables: { context: ctx, status: plansStatus },\n fetchPolicy: 'cache-and-network',\n skip: !enablePlans,\n }\n );\n\n const wholesaleQuery = useQuery<\n { getHealthyBowlWholesaleOrders: WholesaleOrder[] },\n { context: HbContext; fulfilmentStatus: string | null; limit: number; offset: number }\n >(GET_WHOLESALE_ORDERS, {\n variables: { context: ctx, fulfilmentStatus: wholesaleStatus, limit: 100, offset: 0 },\n fetchPolicy: 'cache-and-network',\n skip: !enableWholesale,\n });\n\n const routesQuery = useQuery<\n { getHealthyBowlDeliveryRoutes: DeliveryRoute[] },\n { context: HbContext; fromDate: string | null; toDate: string | null }\n >(GET_DELIVERY_ROUTES, {\n variables: { context: ctx, fromDate: routesFromDate, toDate: routesToDate },\n fetchPolicy: 'cache-and-network',\n skip: !enableRoutes,\n });\n\n const wholesaleTiersQuery = useQuery<\n { getHealthyBowlWholesalePriceTiers: WholesalePriceTier[] },\n { context: HbContext; productName: string }\n >(GET_WHOLESALE_PRICE_TIERS, {\n variables: { context: ctx, productName: wholesaleTiersProduct ?? '' },\n fetchPolicy: 'cache-and-network',\n skip: !enableWholesaleTiers,\n });\n\n const refetchSummary = summaryQuery.refetch;\n const refetchChannelOrders = channelOrdersQuery.refetch;\n const refetchPlans = plansQuery.refetch;\n const refetchWholesale = wholesaleQuery.refetch;\n const refetchWholesaleTiers = wholesaleTiersQuery.refetch;\n const refetchRoutes = routesQuery.refetch;\n\n /** Refetch only the reads this page enabled, so a write never fires a skipped query. */\n const reconcileReads = useCallback(async () => {\n const runners: Array<Promise<unknown>> = [];\n if (enableSummary) runners.push(refetchSummary().catch(() => undefined));\n if (enableChannelOrders) runners.push(refetchChannelOrders().catch(() => undefined));\n if (enablePlans) runners.push(refetchPlans().catch(() => undefined));\n if (enableWholesale) runners.push(refetchWholesale().catch(() => undefined));\n if (enableWholesaleTiers) runners.push(refetchWholesaleTiers().catch(() => undefined));\n if (enableRoutes) runners.push(refetchRoutes().catch(() => undefined));\n await Promise.all(runners);\n }, [\n enableSummary,\n enableChannelOrders,\n enablePlans,\n enableWholesale,\n enableWholesaleTiers,\n enableRoutes,\n refetchSummary,\n refetchChannelOrders,\n refetchPlans,\n refetchWholesale,\n refetchWholesaleTiers,\n refetchRoutes,\n ]);\n\n const [createPlanMutation] = useMutation<{ createHealthyBowlCsaPlan: CsaPlan }, { input: Record<string, unknown> }>(\n CREATE_CSA_PLAN\n );\n const [updatePlanMutation] = useMutation<{ updateHealthyBowlCsaPlan: CsaPlan }, { input: Record<string, unknown> }>(\n UPDATE_CSA_PLAN\n );\n const [deletePlanMutation] = useMutation<{ deleteHealthyBowlCsaPlan: boolean }, { id: string; context: HbContext }>(\n DELETE_CSA_PLAN\n );\n const [enrollMemberMutation] = useMutation<\n { enrollHealthyBowlCsaMember: CsaMembership },\n { input: Record<string, unknown> }\n >(ENROLL_CSA_MEMBER);\n const [updateMembershipMutation] = useMutation<\n { updateHealthyBowlCsaMembership: CsaMembership },\n { input: Record<string, unknown> }\n >(UPDATE_CSA_MEMBERSHIP);\n const [cancelMembershipMutation] = useMutation<\n { cancelHealthyBowlCsaMembership: CsaMembership },\n { id: string; context: HbContext }\n >(CANCEL_CSA_MEMBERSHIP);\n const [renewMembershipMutation] = useMutation<\n { renewHealthyBowlCsaMembership: CsaMembership },\n { input: Record<string, unknown> }\n >(RENEW_CSA_MEMBERSHIP);\n const [retryBillingMutation] = useMutation<\n { retryHealthyBowlCsaBilling: CsaDelivery },\n { csaDeliveryId: string; context: HbContext }\n >(RETRY_CSA_BILLING);\n const [updateDeliveryMutation] = useMutation<\n { updateHealthyBowlCsaDelivery: CsaDelivery },\n { input: Record<string, unknown> }\n >(UPDATE_CSA_DELIVERY);\n const [createWholesaleMutation] = useMutation<\n { createHealthyBowlWholesaleOrder: WholesaleOrder },\n { input: Record<string, unknown> }\n >(CREATE_WHOLESALE_ORDER);\n const [updateWholesaleMutation] = useMutation<\n { updateHealthyBowlWholesaleOrder: WholesaleOrder },\n { input: Record<string, unknown> }\n >(UPDATE_WHOLESALE_ORDER);\n const [deleteWholesaleMutation] = useMutation<\n { deleteHealthyBowlWholesaleOrder: boolean },\n { id: string; context: HbContext }\n >(DELETE_WHOLESALE_ORDER);\n const [setWholesaleTiersMutation] = useMutation<\n { setHealthyBowlWholesalePriceTiers: WholesalePriceTier[] },\n { input: Record<string, unknown> }\n >(SET_WHOLESALE_PRICE_TIERS);\n const [generateRouteMutation] = useMutation<\n { generateHealthyBowlDeliveryRoute: DeliveryRoute },\n { input: Record<string, unknown> }\n >(GENERATE_DELIVERY_ROUTE);\n const [updateStopMutation] = useMutation<\n { updateHealthyBowlDeliveryStop: DeliveryStop },\n { input: Record<string, unknown> }\n >(UPDATE_DELIVERY_STOP);\n const [deleteRouteMutation] = useMutation<\n { deleteHealthyBowlDeliveryRoute: boolean },\n { id: string; context: HbContext }\n >(DELETE_DELIVERY_ROUTE);\n const [dispatchRouteMutation] = useMutation<\n { dispatchHealthyBowlDeliveryRoute: DeliveryRoute },\n { id: string; context: HbContext }\n >(DISPATCH_DELIVERY_ROUTE);\n\n const withCtx = useCallback((input: Record<string, unknown>) => ({ ...input, context: ctx }), [ctx]);\n\n return {\n summary: summaryQuery.data?.getHealthyBowlDistributionSummary ?? null,\n channelOrders: channelOrdersQuery.data?.getHealthyBowlChannelOrders ?? [],\n plans: plansQuery.data?.getHealthyBowlCsaPlans ?? [],\n wholesaleOrders: wholesaleQuery.data?.getHealthyBowlWholesaleOrders ?? [],\n wholesaleTiers: wholesaleTiersQuery.data?.getHealthyBowlWholesalePriceTiers ?? [],\n routes: routesQuery.data?.getHealthyBowlDeliveryRoutes ?? [],\n\n loading: {\n summary: summaryQuery.loading,\n channelOrders: channelOrdersQuery.loading,\n plans: plansQuery.loading,\n wholesale: wholesaleQuery.loading,\n wholesaleTiers: wholesaleTiersQuery.loading,\n routes: routesQuery.loading,\n },\n errors: {\n summary: summaryQuery.error,\n channelOrders: channelOrdersQuery.error,\n plans: plansQuery.error,\n wholesale: wholesaleQuery.error,\n wholesaleTiers: wholesaleTiersQuery.error,\n routes: routesQuery.error,\n },\n\n refetchSummary,\n refetchChannelOrders,\n refetchPlans,\n refetchWholesale,\n refetchWholesaleTiers,\n refetchRoutes,\n refetchAll: reconcileReads,\n\n // ── CSA plans ────────────────────────────────────────────────────────────\n createPlan: useCallback(\n async (input: Record<string, unknown>): Promise<CsaPlan | null> => {\n const res = await createPlanMutation({ variables: { input: withCtx(input) } });\n if (res.error) throw res.error;\n await reconcileReads();\n return res.data?.createHealthyBowlCsaPlan ?? null;\n },\n [createPlanMutation, withCtx, reconcileReads]\n ),\n updatePlan: useCallback(\n async (input: Record<string, unknown>): Promise<CsaPlan | null> => {\n const res = await updatePlanMutation({ variables: { input: withCtx(input) } });\n if (res.error) throw res.error;\n await reconcileReads();\n return res.data?.updateHealthyBowlCsaPlan ?? null;\n },\n [updatePlanMutation, withCtx, reconcileReads]\n ),\n deletePlan: useCallback(\n async (id: string): Promise<void> => {\n const res = await deletePlanMutation({ variables: { id, context: ctx } });\n if (res.error) throw res.error;\n await reconcileReads();\n },\n [deletePlanMutation, ctx, reconcileReads]\n ),\n\n // ── CSA memberships ──────────────────────────────────────────────────────\n enrollMember: useCallback(\n async (input: Record<string, unknown>): Promise<CsaMembership | null> => {\n const res = await enrollMemberMutation({ variables: { input: withCtx(input) } });\n if (res.error) throw res.error;\n await reconcileReads();\n return res.data?.enrollHealthyBowlCsaMember ?? null;\n },\n [enrollMemberMutation, withCtx, reconcileReads]\n ),\n updateMembership: useCallback(\n async (input: Record<string, unknown>): Promise<CsaMembership | null> => {\n const res = await updateMembershipMutation({ variables: { input: withCtx(input) } });\n if (res.error) throw res.error;\n await reconcileReads();\n return res.data?.updateHealthyBowlCsaMembership ?? null;\n },\n [updateMembershipMutation, withCtx, reconcileReads]\n ),\n cancelMembership: useCallback(\n async (id: string): Promise<CsaMembership | null> => {\n const res = await cancelMembershipMutation({ variables: { id, context: ctx } });\n if (res.error) throw res.error;\n await reconcileReads();\n return res.data?.cancelHealthyBowlCsaMembership ?? null;\n },\n [cancelMembershipMutation, ctx, reconcileReads]\n ),\n renewMembership: useCallback(\n async (id: string): Promise<CsaMembership | null> => {\n const res = await renewMembershipMutation({ variables: { input: { id, context: ctx } } });\n if (res.error) throw res.error;\n await reconcileReads();\n return res.data?.renewHealthyBowlCsaMembership ?? null;\n },\n [renewMembershipMutation, ctx, reconcileReads]\n ),\n\n // ── CSA deliveries ───────────────────────────────────────────────────────\n retryBilling: useCallback(\n async (csaDeliveryId: string): Promise<CsaDelivery | null> => {\n const res = await retryBillingMutation({ variables: { csaDeliveryId, context: ctx } });\n if (res.error) throw res.error;\n await reconcileReads();\n return res.data?.retryHealthyBowlCsaBilling ?? null;\n },\n [retryBillingMutation, ctx, reconcileReads]\n ),\n updateDelivery: useCallback(\n async (input: Record<string, unknown>): Promise<CsaDelivery | null> => {\n const res = await updateDeliveryMutation({ variables: { input: withCtx(input) } });\n if (res.error) throw res.error;\n await reconcileReads();\n return res.data?.updateHealthyBowlCsaDelivery ?? null;\n },\n [updateDeliveryMutation, withCtx, reconcileReads]\n ),\n\n // ── Wholesale orders ─────────────────────────────────────────────────────\n createWholesaleOrder: useCallback(\n async (input: Record<string, unknown>): Promise<WholesaleOrder | null> => {\n const res = await createWholesaleMutation({ variables: { input: withCtx(input) } });\n if (res.error) throw res.error;\n await reconcileReads();\n return res.data?.createHealthyBowlWholesaleOrder ?? null;\n },\n [createWholesaleMutation, withCtx, reconcileReads]\n ),\n updateWholesaleOrder: useCallback(\n async (input: Record<string, unknown>): Promise<WholesaleOrder | null> => {\n const res = await updateWholesaleMutation({ variables: { input: withCtx(input) } });\n if (res.error) throw res.error;\n await reconcileReads();\n return res.data?.updateHealthyBowlWholesaleOrder ?? null;\n },\n [updateWholesaleMutation, withCtx, reconcileReads]\n ),\n deleteWholesaleOrder: useCallback(\n async (id: string): Promise<void> => {\n const res = await deleteWholesaleMutation({ variables: { id, context: ctx } });\n if (res.error) throw res.error;\n await reconcileReads();\n },\n [deleteWholesaleMutation, ctx, reconcileReads]\n ),\n setWholesalePriceTiers: useCallback(\n async (input: Record<string, unknown>): Promise<WholesalePriceTier[]> => {\n const res = await setWholesaleTiersMutation({ variables: { input: withCtx(input) } });\n if (res.error) throw res.error;\n await reconcileReads();\n return res.data?.setHealthyBowlWholesalePriceTiers ?? [];\n },\n [setWholesaleTiersMutation, withCtx, reconcileReads]\n ),\n\n // ── Delivery routes ──────────────────────────────────────────────────────\n generateRoute: useCallback(\n async (input: Record<string, unknown>): Promise<DeliveryRoute | null> => {\n const res = await generateRouteMutation({ variables: { input: withCtx(input) } });\n if (res.error) throw res.error;\n await reconcileReads();\n return res.data?.generateHealthyBowlDeliveryRoute ?? null;\n },\n [generateRouteMutation, withCtx, reconcileReads]\n ),\n updateStop: useCallback(\n async (input: Record<string, unknown>): Promise<DeliveryStop | null> => {\n const res = await updateStopMutation({ variables: { input: withCtx(input) } });\n if (res.error) throw res.error;\n await reconcileReads();\n return res.data?.updateHealthyBowlDeliveryStop ?? null;\n },\n [updateStopMutation, withCtx, reconcileReads]\n ),\n deleteRoute: useCallback(\n async (id: string): Promise<void> => {\n const res = await deleteRouteMutation({ variables: { id, context: ctx } });\n if (res.error) throw res.error;\n await reconcileReads();\n },\n [deleteRouteMutation, ctx, reconcileReads]\n ),\n dispatchRoute: useCallback(\n async (id: string): Promise<DeliveryRoute | null> => {\n const res = await dispatchRouteMutation({ variables: { id, context: ctx } });\n if (res.error) throw res.error;\n await reconcileReads();\n return res.data?.dispatchHealthyBowlDeliveryRoute ?? null;\n },\n [dispatchRouteMutation, ctx, reconcileReads]\n ),\n\n documents: { GET_CSA_PLAN, GET_CSA_MEMBERSHIPS, GET_DELIVERY_ROUTE, GET_WHOLESALE_PRICE_TIERS },\n context: ctx,\n };\n}\n\nexport { GET_CSA_PLAN, GET_CSA_MEMBERSHIPS, GET_DELIVERY_ROUTE, GET_WHOLESALE_PRICE_TIERS };\n\nexport interface CsaPlanData {\n getHealthyBowlCsaPlan: CsaPlan;\n}\nexport interface CsaMembershipsData {\n getHealthyBowlCsaMemberships: CsaMembership[];\n}\nexport interface DeliveryRouteData {\n getHealthyBowlDeliveryRoute: DeliveryRoute;\n}\n"],"mappings":";;;;;AAqBA,IAAM,KAAwB,wCAgNxB,IAAkB,2TAqBlB,IAAwB,mVAyBxB,IAAsB,0QAqBtB,IAAmB,2PAoBnB,IAAwB,oFASxB,IAAc,+IAed,IAAe;;;;;;;;;;;YAWT,EAAY;GAGlB,IAAe,kMA6Bf,KAAc,CAAG;;6DAdA,0MAgBqD;;GAItE,KAAqB,CAAG;;0GAE4E,EAAa;;GAIjH,KAAgB,CAAG;;mEAE0C,EAAgB;;GAI7E,IAAe,CAAG;;0DAEkC,EAAgB;;GAIpE,IAAsB,CAAG;;;;;;;;;;;;;;UAcrB,EAAsB;;GAI1B,IAAuB,CAAG;;;;;;;UAOtB,EAAiB;;GAIrB,IAAsB,CAAG;;8FAE+D,EAAa;;GAIrG,IAAqB,CAAG;;gEAEkC,EAAa;;GAIvE,KAAkB,CAAG;;gDAEqB,EAAgB;;GAG1D,KAAkB,CAAG;;gDAEqB,EAAgB;;GAG1D,KAAkB,CAAG;;;;GAKrB,KAAoB,CAAG;;kDAEqB,EAAsB;;GAGlE,KAAwB,CAAG;;sDAEqB,EAAsB;;GAGtE,KAAwB,CAAG;;mEAEkC,EAAsB;;GAGnF,KAAuB,CAAG;;qDAEqB,EAAsB;;GAGrE,KAAoB,CAAG;;qFAEwD,EAAoB;;GAGnG,IAAsB,CAAG;;oDAEqB,EAAoB;;GAGlE,IAAyB,CAAG;;uDAEqB,EAAiB;;GAGlE,IAAyB,CAAG;;uDAEqB,EAAiB;;GAGlE,KAAyB,CAAG;;;;GAK5B,IAA4B,CAAG;;wFAEmD,EAAsB;;GAGxG,KAA4B,CAAG;;yDAEoB,EAAsB;;GAGzE,KAA0B,CAAG;;wDAEqB,EAAa;;GAG/D,KAAuB,CAAG;;qDAEqB,EAAY;;G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,UADA,MAAM,GAAgB,EACf,EAAI,MAAM,qCAAqC,EAAE;KAE1D;GAAC;GAA2B;GAAS;GAAe,CACrD;EAGD,eAAe,EACb,OAAO,MAAkE;GACvE,IAAM,IAAM,MAAM,EAAsB,EAAE,WAAW,EAAE,OAAO,EAAQ,EAAM,EAAE,EAAE,CAAC;AACjF,OAAI,EAAI,MAAO,OAAM,EAAI;AAEzB,UADA,MAAM,GAAgB,EACf,EAAI,MAAM,oCAAoC;KAEvD;GAAC;GAAuB;GAAS;GAAe,CACjD;EACD,YAAY,EACV,OAAO,MAAiE;GACtE,IAAM,IAAM,MAAM,EAAmB,EAAE,WAAW,EAAE,OAAO,EAAQ,EAAM,EAAE,EAAE,CAAC;AAC9E,OAAI,EAAI,MAAO,OAAM,EAAI;AAEzB,UADA,MAAM,GAAgB,EACf,EAAI,MAAM,iCAAiC;KAEpD;GAAC;GAAoB;GAAS;GAAe,CAC9C;EACD,aAAa,EACX,OAAO,MAA8B;GACnC,IAAM,IAAM,MAAM,EAAoB,EAAE,WAAW;IAAE;IAAI,SAAS;IAAK,EAAE,CAAC;AAC1E,OAAI,EAAI,MAAO,OAAM,EAAI;AACzB,SAAM,GAAgB;KAExB;GAAC;GAAqB;GAAK;GAAe,CAC3C;EACD,eAAe,EACb,OAAO,MAA8C;GACnD,IAAM,IAAM,MAAM,EAAsB,EAAE,WAAW;IAAE;IAAI,SAAS;IAAK,EAAE,CAAC;AAC5E,OAAI,EAAI,MAAO,OAAM,EAAI;AAEzB,UADA,MAAM,GAAgB,EACf,EAAI,MAAM,oCAAoC;KAEvD;GAAC;GAAuB;GAAK;GAAe,CAC7C;EAED,WAAW;GAAE;GAAc;GAAqB;GAAoB;GAA2B;EAC/F,SAAS;EACV"}
1
+ {"version":3,"file":"useHealthyBowlDistribution.js","names":[],"sources":["../../../src/healthybowl/hooks/useHealthyBowlDistribution.ts"],"sourcesContent":["/**\n * Distribution & Sales Channels — data hook.\n * Roadmap 12 · BOFF-2884 · gap H-4.\n *\n * CSA subscription boxes, wholesale bulk orders, and delivery-route planning, plus a\n * per-Order `channel` tag. Documents are declared inline with `gql` (not as\n * `src/operations/wspace/*.graphql`) because codegen validates operations against the\n * committed `graphql/wspace.graphql` snapshot, which can't know about these fields until\n * the subgraph is live in the supergraph — the same escape hatch `useHealthyBowlWithdrawal`\n * uses. Types mirror `wspace-healthybowl-svc/src/modules/healthybowl/schema/distribution.gql`.\n *\n * Reads use `cache-and-network`; every write throws on error then refetches the reads it\n * invalidates. Pages opt into only the reads they render (all default off) so a page never\n * fires a query it doesn't use.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport { gql } from '@apollo/client';\nimport { useMutation, useQuery } from '@apollo/client/react';\nimport { useHealthyBowl } from '../context/HealthyBowlContext';\n\nconst FALLBACK_WORKSPACE_ID = '00000000-0000-0000-0000-000000000001';\n\n// ── types (mirror distribution.gql) ───────────────────────────────────────────\n\nexport type CsaFrequency = 'WEEKLY' | 'BIWEEKLY' | 'MONTHLY';\nexport type CsaBoxSize = 'SMALL' | 'MEDIUM' | 'LARGE';\nexport type CsaPlanStatus = 'ACTIVE' | 'PAUSED' | 'ARCHIVED';\nexport type CsaMembershipStatus = 'ACTIVE' | 'PAUSED' | 'CANCELLED';\nexport type CsaDeliveryStatus = 'SCHEDULED' | 'PACKED' | 'DISPATCHED' | 'DELIVERED' | 'SKIPPED';\nexport type WholesaleFulfilmentStatus = 'CONFIRMED' | 'PACKING' | 'FULFILLED' | 'CANCELLED';\nexport type DeliveryRouteStatus = 'PLANNED' | 'IN_PROGRESS' | 'COMPLETED' | 'CANCELLED';\nexport type DeliveryStopStatus = 'PENDING' | 'ARRIVED' | 'DELIVERED' | 'FAILED';\nexport type BillingSyncStatus = 'PENDING' | 'SYNCED' | 'FAILED';\n\n/** JSON scalar (delivery address). The backend stores a structured object but a string is possible. */\nexport type DeliveryAddress = Record<string, unknown> | string | null;\n\nexport interface CsaBoxItem {\n productId: string | null;\n productName: string;\n quantity: number;\n unit: string;\n}\n\n/** Why capacityRemaining / capacityUtilisationPct are null. Null when they are not. */\nexport type CsaCapacityReason = 'NO_CAPACITY_SET' | 'CAPACITY_ZERO';\n\nexport interface CsaPlan {\n id: string;\n name: string;\n description: string | null;\n frequency: string;\n price: number;\n currency: string;\n boxSize: string;\n contents: CsaBoxItem[];\n deliveryDayOfWeek: number;\n startDate: string;\n endDate: string | null;\n /** Null = uncapped. */\n capacity: number | null;\n status: string;\n recurringBillingPlanId: string | null;\n billingSyncStatus: string;\n billingSyncError: string | null;\n /** Members with status ACTIVE — who is collecting this cycle. */\n activeMemberCount: number;\n /** Members with status PAUSED — still holding their place on the plan (BOFF-6088). */\n pausedMemberCount: number;\n /** ACTIVE + PAUSED — the figure `capacity` is enforced against at enrolment. */\n assignedMemberCount: number;\n /** Null = uncapped (NOT zero). Negative = genuinely over-subscribed; do not clamp. */\n capacityRemaining: number | null;\n capacityUtilisationPct: number | null;\n atCapacity: boolean;\n capacityReason: CsaCapacityReason | null;\n createdAt: string;\n}\n\nexport interface CsaMembership {\n id: string;\n csaPlanId: string;\n csaPlanName: string;\n memberUserId: string | null;\n memberName: string;\n memberEmail: string | null;\n memberPhone: string | null;\n deliveryAddress: DeliveryAddress;\n lat: number | null;\n lng: number | null;\n /** HOME_DELIVERY | PICKUP — derived from whether pickupLocationId is set (BOFF-5978). */\n fulfilmentMode?: string;\n /** The stand this member collects from. Null = home delivery. */\n pickupLocationId?: string | null;\n /** Read live off the location, so correcting the stand's name corrects it everywhere at once. */\n pickupLocationName?: string | null;\n status: string;\n startDate: string;\n nextDeliveryDate: string | null;\n pausedUntil: string | null;\n cycleCount: number;\n billingAccountId: string | null;\n billingSyncStatus: string;\n billingSyncError: string | null;\n createdAt: string;\n}\n\nexport interface CsaDelivery {\n id: string;\n csaMembershipId: string;\n csaPlanId: string;\n memberName: string;\n cycleNumber: number;\n scheduledDate: string;\n status: string;\n orderId: string | null;\n billingOrderId: string | null;\n billingSyncStatus: string;\n billingSyncError: string | null;\n workflowRunId: string | null;\n notificationSentAt: string | null;\n deliveredAt: string | null;\n lat: number | null;\n lng: number | null;\n deliveryAddress: DeliveryAddress;\n notes: string | null;\n}\n\nexport interface WholesaleOrder {\n id: string;\n orderId: string;\n orderNumber: string;\n buyerName: string;\n buyerContact: string | null;\n buyerUserId: string | null;\n productId: string | null;\n productName: string;\n quantityKg: number;\n pricePerKg: number;\n appliedTierId: string | null;\n priceSource: string;\n totalAmount: number;\n fulfilmentStatus: string;\n expectedDeliveryDate: string | null;\n orderDate: string;\n notes: string | null;\n}\n\nexport interface WholesalePriceTier {\n id: string;\n productName: string;\n productId: string | null;\n minQuantityKg: number;\n pricePerKg: number;\n createdAt: string;\n}\n\nexport interface DeliveryStop {\n id: string;\n sequence: number;\n csaDeliveryId: string | null;\n label: string;\n address: string | null;\n lat: number;\n lng: number;\n status: string;\n memberName: string | null;\n notificationSentAt: string | null;\n arrivedAt: string | null;\n notes: string | null;\n}\n\nexport interface DeliveryRoute {\n id: string;\n name: string;\n routeDate: string;\n status: string;\n driverName: string | null;\n startLat: number | null;\n startLng: number | null;\n stopCount: number;\n totalDistanceKm: number | null;\n dispatchedAt: string | null;\n stops: DeliveryStop[];\n}\n\nexport interface ChannelBreakdown {\n channel: string;\n orderCount: number;\n revenue: number;\n}\n\nexport interface DistributionSummary {\n channels: ChannelBreakdown[];\n activeCsaPlans: number;\n activeCsaMembers: number;\n weeklyBoxes: number;\n upcomingDeliveries: number;\n wholesaleAccounts: number;\n openWholesaleOrders: number;\n routesThisWeek: number;\n stopsThisWeek: number;\n}\n\nexport interface DistributionOrderItem {\n id: string;\n productId: string;\n productName: string;\n quantity: number;\n price: number;\n unit: string;\n seller: string;\n}\n\nexport interface DistributionOrder {\n id: string;\n orderNumber: string;\n date: string;\n items: DistributionOrderItem[];\n subtotal: number;\n tax: number;\n shipping: number;\n total: number;\n status: string;\n paymentStatus: string;\n deliveryDate: string | null;\n channel: string;\n}\n\ninterface HbContext {\n workspaceId: string;\n}\n\n// ── field fragments ───────────────────────────────────────────────────────────\n\nconst CSA_BOX_ITEM_FIELDS = `\n productId\n productName\n quantity\n unit\n`;\n\nconst CSA_PLAN_FIELDS = `\n id\n name\n description\n frequency\n price\n currency\n boxSize\n contents { ${CSA_BOX_ITEM_FIELDS} }\n deliveryDayOfWeek\n startDate\n endDate\n capacity\n status\n recurringBillingPlanId\n billingSyncStatus\n billingSyncError\n activeMemberCount\n pausedMemberCount\n assignedMemberCount\n capacityRemaining\n capacityUtilisationPct\n atCapacity\n capacityReason\n createdAt\n`;\n\nconst CSA_MEMBERSHIP_FIELDS = `\n id\n csaPlanId\n csaPlanName\n memberUserId\n memberName\n memberEmail\n memberPhone\n deliveryAddress\n lat\n lng\n fulfilmentMode\n pickupLocationId\n pickupLocationName\n status\n startDate\n nextDeliveryDate\n pausedUntil\n cycleCount\n billingAccountId\n billingSyncStatus\n billingSyncError\n createdAt\n`;\n\nconst CSA_DELIVERY_FIELDS = `\n id\n csaMembershipId\n csaPlanId\n memberName\n cycleNumber\n scheduledDate\n status\n orderId\n billingOrderId\n billingSyncStatus\n billingSyncError\n workflowRunId\n notificationSentAt\n deliveredAt\n lat\n lng\n deliveryAddress\n notes\n`;\n\nconst WHOLESALE_FIELDS = `\n id\n orderId\n orderNumber\n buyerName\n buyerContact\n buyerUserId\n productId\n productName\n quantityKg\n pricePerKg\n appliedTierId\n priceSource\n totalAmount\n fulfilmentStatus\n expectedDeliveryDate\n orderDate\n notes\n`;\n\nconst WHOLESALE_TIER_FIELDS = `\n id\n productName\n productId\n minQuantityKg\n pricePerKg\n createdAt\n`;\n\nconst STOP_FIELDS = `\n id\n sequence\n csaDeliveryId\n label\n address\n lat\n lng\n status\n memberName\n notificationSentAt\n arrivedAt\n notes\n`;\n\nconst ROUTE_FIELDS = `\n id\n name\n routeDate\n status\n driverName\n startLat\n startLng\n stopCount\n totalDistanceKm\n dispatchedAt\n stops { ${STOP_FIELDS} }\n`;\n\nconst ORDER_FIELDS = `\n id\n orderNumber\n date\n items { id productId productName quantity price unit seller }\n subtotal\n tax\n shipping\n total\n status\n paymentStatus\n deliveryDate\n channel\n`;\n\nconst SUMMARY_FIELDS = `\n channels { channel orderCount revenue }\n activeCsaPlans\n activeCsaMembers\n weeklyBoxes\n upcomingDeliveries\n wholesaleAccounts\n openWholesaleOrders\n routesThisWeek\n stopsThisWeek\n`;\n\n// ── documents ───────────────────────────────────────────────────────────────\n\nconst GET_SUMMARY = gql`\n query GetHealthyBowlDistributionSummary($context: ContextInput!) {\n getHealthyBowlDistributionSummary(context: $context) { ${SUMMARY_FIELDS} }\n }\n`;\n\nconst GET_CHANNEL_ORDERS = gql`\n query GetHealthyBowlChannelOrders($context: ContextInput!, $channel: String, $limit: Int, $offset: Int) {\n getHealthyBowlChannelOrders(context: $context, channel: $channel, limit: $limit, offset: $offset) { ${ORDER_FIELDS} }\n }\n`;\n\nconst GET_CSA_PLANS = gql`\n query GetHealthyBowlCsaPlans($context: ContextInput!, $status: String) {\n getHealthyBowlCsaPlans(context: $context, status: $status) { ${CSA_PLAN_FIELDS} }\n }\n`;\n\nconst GET_CSA_PLAN = gql`\n query GetHealthyBowlCsaPlan($context: ContextInput!, $id: ID!) {\n getHealthyBowlCsaPlan(context: $context, id: $id) { ${CSA_PLAN_FIELDS} }\n }\n`;\n\nconst GET_CSA_MEMBERSHIPS = gql`\n query GetHealthyBowlCsaMemberships(\n $context: ContextInput!\n $csaPlanId: ID\n $status: String\n $limit: Int\n $offset: Int\n ) {\n getHealthyBowlCsaMemberships(\n context: $context\n csaPlanId: $csaPlanId\n status: $status\n limit: $limit\n offset: $offset\n ) { ${CSA_MEMBERSHIP_FIELDS} }\n }\n`;\n\nconst GET_WHOLESALE_ORDERS = gql`\n query GetHealthyBowlWholesaleOrders($context: ContextInput!, $fulfilmentStatus: String, $limit: Int, $offset: Int) {\n getHealthyBowlWholesaleOrders(\n context: $context\n fulfilmentStatus: $fulfilmentStatus\n limit: $limit\n offset: $offset\n ) { ${WHOLESALE_FIELDS} }\n }\n`;\n\nconst GET_DELIVERY_ROUTES = gql`\n query GetHealthyBowlDeliveryRoutes($context: ContextInput!, $fromDate: String, $toDate: String) {\n getHealthyBowlDeliveryRoutes(context: $context, fromDate: $fromDate, toDate: $toDate) { ${ROUTE_FIELDS} }\n }\n`;\n\nconst GET_DELIVERY_ROUTE = gql`\n query GetHealthyBowlDeliveryRoute($context: ContextInput!, $id: ID!) {\n getHealthyBowlDeliveryRoute(context: $context, id: $id) { ${ROUTE_FIELDS} }\n }\n`;\n\nconst CREATE_CSA_PLAN = gql`\n mutation CreateHealthyBowlCsaPlan($input: CreateHealthyBowlCsaPlanInput!) {\n createHealthyBowlCsaPlan(input: $input) { ${CSA_PLAN_FIELDS} }\n }\n`;\nconst UPDATE_CSA_PLAN = gql`\n mutation UpdateHealthyBowlCsaPlan($input: UpdateHealthyBowlCsaPlanInput!) {\n updateHealthyBowlCsaPlan(input: $input) { ${CSA_PLAN_FIELDS} }\n }\n`;\nconst DELETE_CSA_PLAN = gql`\n mutation DeleteHealthyBowlCsaPlan($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlCsaPlan(id: $id, context: $context)\n }\n`;\nconst ENROLL_CSA_MEMBER = gql`\n mutation EnrollHealthyBowlCsaMember($input: EnrollHealthyBowlCsaMemberInput!) {\n enrollHealthyBowlCsaMember(input: $input) { ${CSA_MEMBERSHIP_FIELDS} }\n }\n`;\nconst UPDATE_CSA_MEMBERSHIP = gql`\n mutation UpdateHealthyBowlCsaMembership($input: UpdateHealthyBowlCsaMembershipInput!) {\n updateHealthyBowlCsaMembership(input: $input) { ${CSA_MEMBERSHIP_FIELDS} }\n }\n`;\nconst CANCEL_CSA_MEMBERSHIP = gql`\n mutation CancelHealthyBowlCsaMembership($id: ID!, $context: ContextInput!) {\n cancelHealthyBowlCsaMembership(id: $id, context: $context) { ${CSA_MEMBERSHIP_FIELDS} }\n }\n`;\nconst RENEW_CSA_MEMBERSHIP = gql`\n mutation RenewHealthyBowlCsaMembership($input: RenewHealthyBowlCsaMembershipInput!) {\n renewHealthyBowlCsaMembership(input: $input) { ${CSA_MEMBERSHIP_FIELDS} }\n }\n`;\nconst RETRY_CSA_BILLING = gql`\n mutation RetryHealthyBowlCsaBilling($csaDeliveryId: ID!, $context: ContextInput!) {\n retryHealthyBowlCsaBilling(csaDeliveryId: $csaDeliveryId, context: $context) { ${CSA_DELIVERY_FIELDS} }\n }\n`;\nconst UPDATE_CSA_DELIVERY = gql`\n mutation UpdateHealthyBowlCsaDelivery($input: UpdateHealthyBowlCsaDeliveryInput!) {\n updateHealthyBowlCsaDelivery(input: $input) { ${CSA_DELIVERY_FIELDS} }\n }\n`;\nconst CREATE_WHOLESALE_ORDER = gql`\n mutation CreateHealthyBowlWholesaleOrder($input: CreateHealthyBowlWholesaleOrderInput!) {\n createHealthyBowlWholesaleOrder(input: $input) { ${WHOLESALE_FIELDS} }\n }\n`;\nconst UPDATE_WHOLESALE_ORDER = gql`\n mutation UpdateHealthyBowlWholesaleOrder($input: UpdateHealthyBowlWholesaleOrderInput!) {\n updateHealthyBowlWholesaleOrder(input: $input) { ${WHOLESALE_FIELDS} }\n }\n`;\nconst DELETE_WHOLESALE_ORDER = gql`\n mutation DeleteHealthyBowlWholesaleOrder($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlWholesaleOrder(id: $id, context: $context)\n }\n`;\nconst GET_WHOLESALE_PRICE_TIERS = gql`\n query GetHealthyBowlWholesalePriceTiers($context: ContextInput!, $productName: String!) {\n getHealthyBowlWholesalePriceTiers(context: $context, productName: $productName) { ${WHOLESALE_TIER_FIELDS} }\n }\n`;\nconst SET_WHOLESALE_PRICE_TIERS = gql`\n mutation SetHealthyBowlWholesalePriceTiers($input: SetHealthyBowlWholesalePriceTiersInput!) {\n setHealthyBowlWholesalePriceTiers(input: $input) { ${WHOLESALE_TIER_FIELDS} }\n }\n`;\nconst GENERATE_DELIVERY_ROUTE = gql`\n mutation GenerateHealthyBowlDeliveryRoute($input: GenerateHealthyBowlDeliveryRouteInput!) {\n generateHealthyBowlDeliveryRoute(input: $input) { ${ROUTE_FIELDS} }\n }\n`;\nconst UPDATE_DELIVERY_STOP = gql`\n mutation UpdateHealthyBowlDeliveryStop($input: UpdateHealthyBowlDeliveryStopInput!) {\n updateHealthyBowlDeliveryStop(input: $input) { ${STOP_FIELDS} }\n }\n`;\nconst DELETE_DELIVERY_ROUTE = gql`\n mutation DeleteHealthyBowlDeliveryRoute($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlDeliveryRoute(id: $id, context: $context)\n }\n`;\nconst DISPATCH_DELIVERY_ROUTE = gql`\n mutation DispatchHealthyBowlDeliveryRoute($id: ID!, $context: ContextInput!) {\n dispatchHealthyBowlDeliveryRoute(id: $id, context: $context) { ${ROUTE_FIELDS} }\n }\n`;\n\n// ── hook ───────────────────────────────────────────────────────────────────\n\nexport interface UseDistributionOptions {\n /** Fetch the dashboard summary (KPI cards + per-channel breakdown). */\n summary?: boolean;\n /** Fetch the channel-filtered order list. */\n channelOrders?: boolean;\n /** Channel filter for the order list: null/undefined = all channels. */\n channel?: string | null;\n /** Fetch the CSA subscription plans list. */\n plans?: boolean;\n /** Optional status filter for the CSA plans list (ACTIVE | PAUSED | ARCHIVED). */\n plansStatus?: string | null;\n /** Fetch the wholesale orders list. */\n wholesale?: boolean;\n /** Optional fulfilment-status filter for the wholesale list. */\n wholesaleStatus?: string | null;\n /** Fetch the price-tier ladder for one product (requires wholesaleTiersProduct). */\n wholesaleTiers?: boolean;\n /** Product whose ladder `wholesaleTiers` fetches. */\n wholesaleTiersProduct?: string | null;\n /** Fetch the delivery-routes list. */\n routes?: boolean;\n /** Optional inclusive ISO date range for the routes list. */\n routesRange?: { fromDate: string; toDate: string } | null;\n}\n\nexport function useHealthyBowlDistribution(options: UseDistributionOptions = {}) {\n const { workspaceId } = useHealthyBowl();\n const effectiveWorkspaceId = workspaceId || FALLBACK_WORKSPACE_ID;\n const ctx = useMemo<HbContext>(() => ({ workspaceId: effectiveWorkspaceId }), [effectiveWorkspaceId]);\n\n const enableSummary = options.summary === true;\n const enableChannelOrders = options.channelOrders === true;\n const enablePlans = options.plans === true;\n const enableWholesale = options.wholesale === true;\n const enableWholesaleTiers = options.wholesaleTiers === true && !!options.wholesaleTiersProduct;\n const enableRoutes = options.routes === true;\n\n const channel = options.channel ?? null;\n const plansStatus = options.plansStatus ?? null;\n const wholesaleStatus = options.wholesaleStatus ?? null;\n const wholesaleTiersProduct = options.wholesaleTiersProduct ?? null;\n const routesFromDate = options.routesRange?.fromDate ?? null;\n const routesToDate = options.routesRange?.toDate ?? null;\n\n const summaryQuery = useQuery<{ getHealthyBowlDistributionSummary: DistributionSummary }, { context: HbContext }>(\n GET_SUMMARY,\n { variables: { context: ctx }, fetchPolicy: 'cache-and-network', skip: !enableSummary }\n );\n\n const channelOrdersQuery = useQuery<\n { getHealthyBowlChannelOrders: DistributionOrder[] },\n { context: HbContext; channel: string | null; limit: number; offset: number }\n >(GET_CHANNEL_ORDERS, {\n variables: { context: ctx, channel, limit: 100, offset: 0 },\n fetchPolicy: 'cache-and-network',\n skip: !enableChannelOrders,\n });\n\n const plansQuery = useQuery<{ getHealthyBowlCsaPlans: CsaPlan[] }, { context: HbContext; status: string | null }>(\n GET_CSA_PLANS,\n {\n variables: { context: ctx, status: plansStatus },\n fetchPolicy: 'cache-and-network',\n skip: !enablePlans,\n }\n );\n\n const wholesaleQuery = useQuery<\n { getHealthyBowlWholesaleOrders: WholesaleOrder[] },\n { context: HbContext; fulfilmentStatus: string | null; limit: number; offset: number }\n >(GET_WHOLESALE_ORDERS, {\n variables: { context: ctx, fulfilmentStatus: wholesaleStatus, limit: 100, offset: 0 },\n fetchPolicy: 'cache-and-network',\n skip: !enableWholesale,\n });\n\n const routesQuery = useQuery<\n { getHealthyBowlDeliveryRoutes: DeliveryRoute[] },\n { context: HbContext; fromDate: string | null; toDate: string | null }\n >(GET_DELIVERY_ROUTES, {\n variables: { context: ctx, fromDate: routesFromDate, toDate: routesToDate },\n fetchPolicy: 'cache-and-network',\n skip: !enableRoutes,\n });\n\n const wholesaleTiersQuery = useQuery<\n { getHealthyBowlWholesalePriceTiers: WholesalePriceTier[] },\n { context: HbContext; productName: string }\n >(GET_WHOLESALE_PRICE_TIERS, {\n variables: { context: ctx, productName: wholesaleTiersProduct ?? '' },\n fetchPolicy: 'cache-and-network',\n skip: !enableWholesaleTiers,\n });\n\n const refetchSummary = summaryQuery.refetch;\n const refetchChannelOrders = channelOrdersQuery.refetch;\n const refetchPlans = plansQuery.refetch;\n const refetchWholesale = wholesaleQuery.refetch;\n const refetchWholesaleTiers = wholesaleTiersQuery.refetch;\n const refetchRoutes = routesQuery.refetch;\n\n /** Refetch only the reads this page enabled, so a write never fires a skipped query. */\n const reconcileReads = useCallback(async () => {\n const runners: Array<Promise<unknown>> = [];\n if (enableSummary) runners.push(refetchSummary().catch(() => undefined));\n if (enableChannelOrders) runners.push(refetchChannelOrders().catch(() => undefined));\n if (enablePlans) runners.push(refetchPlans().catch(() => undefined));\n if (enableWholesale) runners.push(refetchWholesale().catch(() => undefined));\n if (enableWholesaleTiers) runners.push(refetchWholesaleTiers().catch(() => undefined));\n if (enableRoutes) runners.push(refetchRoutes().catch(() => undefined));\n await Promise.all(runners);\n }, [\n enableSummary,\n enableChannelOrders,\n enablePlans,\n enableWholesale,\n enableWholesaleTiers,\n enableRoutes,\n refetchSummary,\n refetchChannelOrders,\n refetchPlans,\n refetchWholesale,\n refetchWholesaleTiers,\n refetchRoutes,\n ]);\n\n const [createPlanMutation] = useMutation<{ createHealthyBowlCsaPlan: CsaPlan }, { input: Record<string, unknown> }>(\n CREATE_CSA_PLAN\n );\n const [updatePlanMutation] = useMutation<{ updateHealthyBowlCsaPlan: CsaPlan }, { input: Record<string, unknown> }>(\n UPDATE_CSA_PLAN\n );\n const [deletePlanMutation] = useMutation<{ deleteHealthyBowlCsaPlan: boolean }, { id: string; context: HbContext }>(\n DELETE_CSA_PLAN\n );\n const [enrollMemberMutation] = useMutation<\n { enrollHealthyBowlCsaMember: CsaMembership },\n { input: Record<string, unknown> }\n >(ENROLL_CSA_MEMBER);\n const [updateMembershipMutation] = useMutation<\n { updateHealthyBowlCsaMembership: CsaMembership },\n { input: Record<string, unknown> }\n >(UPDATE_CSA_MEMBERSHIP);\n const [cancelMembershipMutation] = useMutation<\n { cancelHealthyBowlCsaMembership: CsaMembership },\n { id: string; context: HbContext }\n >(CANCEL_CSA_MEMBERSHIP);\n const [renewMembershipMutation] = useMutation<\n { renewHealthyBowlCsaMembership: CsaMembership },\n { input: Record<string, unknown> }\n >(RENEW_CSA_MEMBERSHIP);\n const [retryBillingMutation] = useMutation<\n { retryHealthyBowlCsaBilling: CsaDelivery },\n { csaDeliveryId: string; context: HbContext }\n >(RETRY_CSA_BILLING);\n const [updateDeliveryMutation] = useMutation<\n { updateHealthyBowlCsaDelivery: CsaDelivery },\n { input: Record<string, unknown> }\n >(UPDATE_CSA_DELIVERY);\n const [createWholesaleMutation] = useMutation<\n { createHealthyBowlWholesaleOrder: WholesaleOrder },\n { input: Record<string, unknown> }\n >(CREATE_WHOLESALE_ORDER);\n const [updateWholesaleMutation] = useMutation<\n { updateHealthyBowlWholesaleOrder: WholesaleOrder },\n { input: Record<string, unknown> }\n >(UPDATE_WHOLESALE_ORDER);\n const [deleteWholesaleMutation] = useMutation<\n { deleteHealthyBowlWholesaleOrder: boolean },\n { id: string; context: HbContext }\n >(DELETE_WHOLESALE_ORDER);\n const [setWholesaleTiersMutation] = useMutation<\n { setHealthyBowlWholesalePriceTiers: WholesalePriceTier[] },\n { input: Record<string, unknown> }\n >(SET_WHOLESALE_PRICE_TIERS);\n const [generateRouteMutation] = useMutation<\n { generateHealthyBowlDeliveryRoute: DeliveryRoute },\n { input: Record<string, unknown> }\n >(GENERATE_DELIVERY_ROUTE);\n const [updateStopMutation] = useMutation<\n { updateHealthyBowlDeliveryStop: DeliveryStop },\n { input: Record<string, unknown> }\n >(UPDATE_DELIVERY_STOP);\n const [deleteRouteMutation] = useMutation<\n { deleteHealthyBowlDeliveryRoute: boolean },\n { id: string; context: HbContext }\n >(DELETE_DELIVERY_ROUTE);\n const [dispatchRouteMutation] = useMutation<\n { dispatchHealthyBowlDeliveryRoute: DeliveryRoute },\n { id: string; context: HbContext }\n >(DISPATCH_DELIVERY_ROUTE);\n\n const withCtx = useCallback((input: Record<string, unknown>) => ({ ...input, context: ctx }), [ctx]);\n\n return {\n summary: summaryQuery.data?.getHealthyBowlDistributionSummary ?? null,\n channelOrders: channelOrdersQuery.data?.getHealthyBowlChannelOrders ?? [],\n plans: plansQuery.data?.getHealthyBowlCsaPlans ?? [],\n wholesaleOrders: wholesaleQuery.data?.getHealthyBowlWholesaleOrders ?? [],\n wholesaleTiers: wholesaleTiersQuery.data?.getHealthyBowlWholesalePriceTiers ?? [],\n routes: routesQuery.data?.getHealthyBowlDeliveryRoutes ?? [],\n\n loading: {\n summary: summaryQuery.loading,\n channelOrders: channelOrdersQuery.loading,\n plans: plansQuery.loading,\n wholesale: wholesaleQuery.loading,\n wholesaleTiers: wholesaleTiersQuery.loading,\n routes: routesQuery.loading,\n },\n errors: {\n summary: summaryQuery.error,\n channelOrders: channelOrdersQuery.error,\n plans: plansQuery.error,\n wholesale: wholesaleQuery.error,\n wholesaleTiers: wholesaleTiersQuery.error,\n routes: routesQuery.error,\n },\n\n refetchSummary,\n refetchChannelOrders,\n refetchPlans,\n refetchWholesale,\n refetchWholesaleTiers,\n refetchRoutes,\n refetchAll: reconcileReads,\n\n // ── CSA plans ────────────────────────────────────────────────────────────\n createPlan: useCallback(\n async (input: Record<string, unknown>): Promise<CsaPlan | null> => {\n const res = await createPlanMutation({ variables: { input: withCtx(input) } });\n if (res.error) throw res.error;\n await reconcileReads();\n return res.data?.createHealthyBowlCsaPlan ?? null;\n },\n [createPlanMutation, withCtx, reconcileReads]\n ),\n updatePlan: useCallback(\n async (input: Record<string, unknown>): Promise<CsaPlan | null> => {\n const res = await updatePlanMutation({ variables: { input: withCtx(input) } });\n if (res.error) throw res.error;\n await reconcileReads();\n return res.data?.updateHealthyBowlCsaPlan ?? null;\n },\n [updatePlanMutation, withCtx, reconcileReads]\n ),\n deletePlan: useCallback(\n async (id: string): Promise<void> => {\n const res = await deletePlanMutation({ variables: { id, context: ctx } });\n if (res.error) throw res.error;\n await reconcileReads();\n },\n [deletePlanMutation, ctx, reconcileReads]\n ),\n\n // ── CSA memberships ──────────────────────────────────────────────────────\n enrollMember: useCallback(\n async (input: Record<string, unknown>): Promise<CsaMembership | null> => {\n const res = await enrollMemberMutation({ variables: { input: withCtx(input) } });\n if (res.error) throw res.error;\n await reconcileReads();\n return res.data?.enrollHealthyBowlCsaMember ?? null;\n },\n [enrollMemberMutation, withCtx, reconcileReads]\n ),\n updateMembership: useCallback(\n async (input: Record<string, unknown>): Promise<CsaMembership | null> => {\n const res = await updateMembershipMutation({ variables: { input: withCtx(input) } });\n if (res.error) throw res.error;\n await reconcileReads();\n return res.data?.updateHealthyBowlCsaMembership ?? null;\n },\n [updateMembershipMutation, withCtx, reconcileReads]\n ),\n cancelMembership: useCallback(\n async (id: string): Promise<CsaMembership | null> => {\n const res = await cancelMembershipMutation({ variables: { id, context: ctx } });\n if (res.error) throw res.error;\n await reconcileReads();\n return res.data?.cancelHealthyBowlCsaMembership ?? null;\n },\n [cancelMembershipMutation, ctx, reconcileReads]\n ),\n renewMembership: useCallback(\n async (id: string): Promise<CsaMembership | null> => {\n const res = await renewMembershipMutation({ variables: { input: { id, context: ctx } } });\n if (res.error) throw res.error;\n await reconcileReads();\n return res.data?.renewHealthyBowlCsaMembership ?? null;\n },\n [renewMembershipMutation, ctx, reconcileReads]\n ),\n\n // ── CSA deliveries ───────────────────────────────────────────────────────\n retryBilling: useCallback(\n async (csaDeliveryId: string): Promise<CsaDelivery | null> => {\n const res = await retryBillingMutation({ variables: { csaDeliveryId, context: ctx } });\n if (res.error) throw res.error;\n await reconcileReads();\n return res.data?.retryHealthyBowlCsaBilling ?? null;\n },\n [retryBillingMutation, ctx, reconcileReads]\n ),\n updateDelivery: useCallback(\n async (input: Record<string, unknown>): Promise<CsaDelivery | null> => {\n const res = await updateDeliveryMutation({ variables: { input: withCtx(input) } });\n if (res.error) throw res.error;\n await reconcileReads();\n return res.data?.updateHealthyBowlCsaDelivery ?? null;\n },\n [updateDeliveryMutation, withCtx, reconcileReads]\n ),\n\n // ── Wholesale orders ─────────────────────────────────────────────────────\n createWholesaleOrder: useCallback(\n async (input: Record<string, unknown>): Promise<WholesaleOrder | null> => {\n const res = await createWholesaleMutation({ variables: { input: withCtx(input) } });\n if (res.error) throw res.error;\n await reconcileReads();\n return res.data?.createHealthyBowlWholesaleOrder ?? null;\n },\n [createWholesaleMutation, withCtx, reconcileReads]\n ),\n updateWholesaleOrder: useCallback(\n async (input: Record<string, unknown>): Promise<WholesaleOrder | null> => {\n const res = await updateWholesaleMutation({ variables: { input: withCtx(input) } });\n if (res.error) throw res.error;\n await reconcileReads();\n return res.data?.updateHealthyBowlWholesaleOrder ?? null;\n },\n [updateWholesaleMutation, withCtx, reconcileReads]\n ),\n deleteWholesaleOrder: useCallback(\n async (id: string): Promise<void> => {\n const res = await deleteWholesaleMutation({ variables: { id, context: ctx } });\n if (res.error) throw res.error;\n await reconcileReads();\n },\n [deleteWholesaleMutation, ctx, reconcileReads]\n ),\n setWholesalePriceTiers: useCallback(\n async (input: Record<string, unknown>): Promise<WholesalePriceTier[]> => {\n const res = await setWholesaleTiersMutation({ variables: { input: withCtx(input) } });\n if (res.error) throw res.error;\n await reconcileReads();\n return res.data?.setHealthyBowlWholesalePriceTiers ?? [];\n },\n [setWholesaleTiersMutation, withCtx, reconcileReads]\n ),\n\n // ── Delivery routes ──────────────────────────────────────────────────────\n generateRoute: useCallback(\n async (input: Record<string, unknown>): Promise<DeliveryRoute | null> => {\n const res = await generateRouteMutation({ variables: { input: withCtx(input) } });\n if (res.error) throw res.error;\n await reconcileReads();\n return res.data?.generateHealthyBowlDeliveryRoute ?? null;\n },\n [generateRouteMutation, withCtx, reconcileReads]\n ),\n updateStop: useCallback(\n async (input: Record<string, unknown>): Promise<DeliveryStop | null> => {\n const res = await updateStopMutation({ variables: { input: withCtx(input) } });\n if (res.error) throw res.error;\n await reconcileReads();\n return res.data?.updateHealthyBowlDeliveryStop ?? null;\n },\n [updateStopMutation, withCtx, reconcileReads]\n ),\n deleteRoute: useCallback(\n async (id: string): Promise<void> => {\n const res = await deleteRouteMutation({ variables: { id, context: ctx } });\n if (res.error) throw res.error;\n await reconcileReads();\n },\n [deleteRouteMutation, ctx, reconcileReads]\n ),\n dispatchRoute: useCallback(\n async (id: string): Promise<DeliveryRoute | null> => {\n const res = await dispatchRouteMutation({ variables: { id, context: ctx } });\n if (res.error) throw res.error;\n await reconcileReads();\n return res.data?.dispatchHealthyBowlDeliveryRoute ?? null;\n },\n [dispatchRouteMutation, ctx, reconcileReads]\n ),\n\n documents: { GET_CSA_PLAN, GET_CSA_MEMBERSHIPS, GET_DELIVERY_ROUTE, GET_WHOLESALE_PRICE_TIERS },\n context: ctx,\n };\n}\n\nexport { GET_CSA_PLAN, GET_CSA_MEMBERSHIPS, GET_DELIVERY_ROUTE, GET_WHOLESALE_PRICE_TIERS };\n\nexport interface CsaPlanData {\n getHealthyBowlCsaPlan: CsaPlan;\n}\nexport interface CsaMembershipsData {\n getHealthyBowlCsaMemberships: CsaMembership[];\n}\nexport interface DeliveryRouteData {\n getHealthyBowlDeliveryRoute: DeliveryRoute;\n}\n"],"mappings":";;;;;AAqBA,IAAM,KAAwB,wCA8NxB,IAAkB,sbA2BlB,IAAwB,mVAyBxB,IAAsB,0QAqBtB,IAAmB,2PAoBnB,IAAwB,oFASxB,IAAc,+IAed,IAAe;;;;;;;;;;;YAWT,EAAY;GAGlB,IAAe,kMA6Bf,KAAc,CAAG;;6DAdA,0MAgBqD;;GAItE,KAAqB,CAAG;;0GAE4E,EAAa;;GAIjH,KAAgB,CAAG;;mEAE0C,EAAgB;;GAI7E,IAAe,CAAG;;0DAEkC,EAAgB;;GAIpE,IAAsB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,UADA,MAAM,GAAgB,EACf,EAAI,MAAM,iCAAiC;KAEpD;GAAC;GAAoB;GAAS;GAAe,CAC9C;EACD,aAAa,EACX,OAAO,MAA8B;GACnC,IAAM,IAAM,MAAM,EAAoB,EAAE,WAAW;IAAE;IAAI,SAAS;IAAK,EAAE,CAAC;AAC1E,OAAI,EAAI,MAAO,OAAM,EAAI;AACzB,SAAM,GAAgB;KAExB;GAAC;GAAqB;GAAK;GAAe,CAC3C;EACD,eAAe,EACb,OAAO,MAA8C;GACnD,IAAM,IAAM,MAAM,EAAsB,EAAE,WAAW;IAAE;IAAI,SAAS;IAAK,EAAE,CAAC;AAC5E,OAAI,EAAI,MAAO,OAAM,EAAI;AAEzB,UADA,MAAM,GAAgB,EACf,EAAI,MAAM,oCAAoC;KAEvD;GAAC;GAAuB;GAAK;GAAe,CAC7C;EAED,WAAW;GAAE;GAAc;GAAqB;GAAoB;GAA2B;EAC/F,SAAS;EACV"}
@@ -11,6 +11,7 @@ var r = t`
11
11
  limit
12
12
  remaining
13
13
  noLimit
14
+ provisioned
14
15
  exhausted
15
16
  }
16
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useHealthyBowlQuota.js","names":[],"sources":["../../../src/healthybowl/hooks/useHealthyBowlQuota.ts"],"sourcesContent":["import { gql } from '@apollo/client';\nimport { useQuery } from '@apollo/client/react';\nimport { useHealthyBowl } from '../context/HealthyBowlContext';\n\nconst QUOTA_STATUS_QUERY = gql`\n query GetHealthyBowlQuotaStatus($context: ContextInput!) {\n getHealthyBowlQuotaStatus(context: $context) {\n quotaName\n label\n used\n limit\n remaining\n noLimit\n exhausted\n }\n }\n`;\n\nexport interface HealthyBowlQuotaStatus {\n quotaName: string;\n label: string;\n used: number;\n limit: number | null;\n remaining: number | null;\n noLimit: boolean;\n exhausted: boolean;\n}\n\ninterface QuotaData {\n getHealthyBowlQuotaStatus: HealthyBowlQuotaStatus[];\n}\n\nexport function useHealthyBowlQuota() {\n const { workspaceId } = useHealthyBowl();\n const query = useQuery<QuotaData>(QUOTA_STATUS_QUERY, {\n variables: { context: { workspaceId } },\n skip: !workspaceId,\n fetchPolicy: 'cache-and-network',\n });\n return { ...query, quotas: query.data?.getHealthyBowlQuotaStatus ?? [] };\n}\n"],"mappings":";;;;AAIA,IAAM,IAAqB,CAAG;;;;;;;;;;;;;AA4B9B,SAAgB,IAAsB;CACpC,IAAM,EAAE,mBAAgB,GAAgB,EAClC,IAAQ,EAAoB,GAAoB;EACpD,WAAW,EAAE,SAAS,EAAE,gBAAa,EAAE;EACvC,MAAM,CAAC;EACP,aAAa;EACd,CAAC;AACF,QAAO;EAAE,GAAG;EAAO,QAAQ,EAAM,MAAM,6BAA6B,EAAE;EAAE"}
1
+ {"version":3,"file":"useHealthyBowlQuota.js","names":[],"sources":["../../../src/healthybowl/hooks/useHealthyBowlQuota.ts"],"sourcesContent":["import { gql } from '@apollo/client';\nimport { useQuery } from '@apollo/client/react';\nimport { useHealthyBowl } from '../context/HealthyBowlContext';\n\nconst QUOTA_STATUS_QUERY = gql`\n query GetHealthyBowlQuotaStatus($context: ContextInput!) {\n getHealthyBowlQuotaStatus(context: $context) {\n quotaName\n label\n used\n limit\n remaining\n noLimit\n provisioned\n exhausted\n }\n }\n`;\n\nexport interface HealthyBowlQuotaStatus {\n quotaName: string;\n label: string;\n used: number;\n limit: number | null;\n remaining: number | null;\n noLimit: boolean;\n /**\n * Whether a limit could actually be established. False means unknown — no billing\n * account, no assignment for this workspace, or a failed lookup — and is NOT a claim\n * that the quota is zero or unlimited (BOFF-6302).\n */\n provisioned: boolean;\n exhausted: boolean;\n}\n\ninterface QuotaData {\n getHealthyBowlQuotaStatus: HealthyBowlQuotaStatus[];\n}\n\nexport function useHealthyBowlQuota() {\n const { workspaceId } = useHealthyBowl();\n const query = useQuery<QuotaData>(QUOTA_STATUS_QUERY, {\n variables: { context: { workspaceId } },\n skip: !workspaceId,\n fetchPolicy: 'cache-and-network',\n });\n return { ...query, quotas: query.data?.getHealthyBowlQuotaStatus ?? [] };\n}\n"],"mappings":";;;;AAIA,IAAM,IAAqB,CAAG;;;;;;;;;;;;;;AAmC9B,SAAgB,IAAsB;CACpC,IAAM,EAAE,mBAAgB,GAAgB,EAClC,IAAQ,EAAoB,GAAoB;EACpD,WAAW,EAAE,SAAS,EAAE,gBAAa,EAAE;EACvC,MAAM,CAAC;EACP,aAAa;EACd,CAAC;AACF,QAAO;EAAE,GAAG;EAAO,QAAQ,EAAM,MAAM,6BAA6B,EAAE;EAAE"}
@@ -266,7 +266,10 @@ var A = {
266
266
  }), e.noLimit ? /* @__PURE__ */ E("span", {
267
267
  className: "text-xs text-text-secondary",
268
268
  children: U("healthybowl.home.quotas.unlimited", "Unlimited")
269
- }) : null]
269
+ }) : e.provisioned ? null : /* @__PURE__ */ E("span", {
270
+ className: "text-xs text-status-warning-text",
271
+ children: U("healthybowl.home.quotas.unknown", "Not available")
272
+ })]
270
273
  }),
271
274
  /* @__PURE__ */ D("p", {
272
275
  className: "mt-2 text-lg font-semibold text-text-primary",
@@ -280,8 +283,8 @@ var A = {
280
283
  })
281
284
  }),
282
285
  /* @__PURE__ */ E("p", {
283
- className: `mt-1 text-xs ${e.exhausted ? "text-status-error-text" : "text-text-secondary"}`,
284
- children: e.exhausted ? U("healthybowl.home.quotas.exhausted", "Limit reached") : e.remaining === null ? U("healthybowl.home.quotas.noLimitRemaining", "No limit") : U("healthybowl.home.quotas.remaining", "{{count}} remaining", { count: e.remaining })
286
+ className: `mt-1 text-xs ${e.exhausted ? "text-status-error-text" : e.provisioned ? "text-text-secondary" : "text-status-warning-text"}`,
287
+ children: e.exhausted ? U("healthybowl.home.quotas.exhausted", "Limit reached") : e.provisioned ? e.remaining === null ? U("healthybowl.home.quotas.noLimitRemaining", "No limit") : U("healthybowl.home.quotas.remaining", "{{count}} remaining", { count: e.remaining }) : U("healthybowl.home.quotas.notProvisioned", "No plan limit found for this workspace — creating may be refused.")
285
288
  })
286
289
  ]
287
290
  }, e.quotaName);
@@ -1 +1 @@
1
- {"version":3,"file":"HomePage.js","names":[],"sources":["../../../src/healthybowl/pages/HomePage.tsx"],"sourcesContent":["import { useMemo, useCallback, type FC, type ReactNode } from 'react';\nimport { useNavigate } from 'react-router';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport {\n Sprout,\n CalendarClock,\n Wallet,\n AlertTriangle,\n Plus,\n ClipboardList,\n BarChart3,\n MapPin,\n Thermometer,\n ArrowUpRight,\n ChevronRight,\n CheckCircle2,\n Cloud,\n CloudOff,\n Droplets,\n Wind,\n Eye,\n PawPrint,\n ShieldCheck,\n} from 'lucide-react';\nimport { EmphasisPanel, GlassCard } from '@burdenoff/fe-libs/ui';\nimport { PageLayout, StatusBadge, EmptyState, ErrorState, PageLoader } from '../components';\nimport { useHealthyBowlData } from '../hooks/useHealthyBowlData';\nimport { useHealthyBowlQuota } from '../hooks/useHealthyBowlQuota';\nimport { useBasePath } from '../hooks/useBasePath';\nimport { cn, formatCurrency, HB_DEFAULT_CURRENCY, formatDateOnly } from '../utils/helpers';\nimport { hasWeatherObservation } from '../utils/weatherPresence';\nimport type { Alert, Crop } from '../types';\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Semantic maps — colour carries meaning, always paired with a label. Tokens only.\n// ─────────────────────────────────────────────────────────────────────────────\n\ntype Tone = 'neutral' | 'success' | 'warning' | 'danger';\n\nconst toneValueClass: Record<Tone, string> = {\n neutral: 'text-text-primary',\n success: 'text-status-success-text',\n warning: 'text-status-warning-text',\n danger: 'text-status-error-text',\n};\n\nconst toneChipClass: Record<Tone, string> = {\n neutral: 'bg-[var(--color-accent-soft)] text-text-primary',\n success: 'bg-status-success-bg text-status-success-text',\n warning: 'bg-status-warning-bg text-status-warning-text',\n danger: 'bg-status-error-bg text-status-error-text',\n};\n\nconst severityRank: Record<Alert['severity'], number> = { critical: 0, warning: 1, info: 2 };\n\nconst severityDotClass: Record<Alert['severity'], string> = {\n critical: 'bg-status-error-text',\n warning: 'bg-status-warning-text',\n info: 'bg-status-info-text',\n};\n\nconst healthVariant = (status: string) => {\n switch (status) {\n case 'excellent':\n return 'success' as const;\n case 'good':\n return 'info' as const;\n case 'fair':\n return 'warning' as const;\n default:\n return 'error' as const;\n }\n};\n\nconst clampPercent = (n: number) => Math.max(0, Math.min(100, Math.round(n)));\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Presentational sub-components (module-level so they don't remount each render)\n// ─────────────────────────────────────────────────────────────────────────────\n\ninterface KpiTileProps {\n label: string;\n value: string;\n icon: ReactNode;\n tone?: Tone;\n /** Featured accent glow — reserve for the single focal KPI (needs-attention). */\n glow?: boolean;\n drillLabel: string;\n onClick: () => void;\n}\n\n/** Primary KPI card — big real value + tone-coded chip + drill-down. No fabricated trend/sparkline. */\nconst KpiTile: FC<KpiTileProps> = ({ label, value, icon, tone = 'neutral', glow = false, drillLabel, onClick }) => (\n <button type=\"button\" onClick={onClick} className=\"group block text-start focus-visible:outline-none\">\n <GlassCard\n treatment=\"metric\"\n glow={glow}\n className=\"flex h-full flex-col gap-3 border-border-seam p-4 transition-shadow group-hover:shadow-pop group-focus-visible:ring-2 group-focus-visible:ring-border-focus group-focus-visible:ring-offset-2 group-focus-visible:ring-offset-bg-canvas\"\n >\n <div className=\"flex items-center justify-between\">\n <span className=\"text-sm font-medium text-text-secondary\">{label}</span>\n <span className={cn('flex size-8 items-center justify-center rounded-lg [&>svg]:size-4', toneChipClass[tone])}>\n {icon}\n </span>\n </div>\n <span className={cn('text-3xl font-semibold tabular-nums', toneValueClass[tone])}>{value}</span>\n <span className=\"mt-auto inline-flex items-center gap-1 text-xs font-medium text-text-secondary transition-colors group-hover:text-text-primary\">\n {drillLabel}\n <ArrowUpRight className=\"size-3.5\" />\n </span>\n </GlassCard>\n </button>\n);\n\ninterface MiniStatProps {\n label: string;\n value: string;\n hint?: string;\n icon: ReactNode;\n onClick: () => void;\n}\n\n/** Secondary \"at a glance\" tile — quieter than a KPI, honest zero-state hints. */\nconst MiniStat: FC<MiniStatProps> = ({ label, value, hint, icon, onClick }) => (\n <button type=\"button\" onClick={onClick} className=\"group block text-start focus-visible:outline-none\">\n <GlassCard className=\"flex h-full items-center justify-between gap-3 border-border-seam p-3 transition-shadow group-hover:shadow-pop group-focus-visible:ring-2 group-focus-visible:ring-border-focus group-focus-visible:ring-offset-2 group-focus-visible:ring-offset-bg-canvas\">\n <div className=\"min-w-0\">\n <p className=\"text-xs font-medium text-text-secondary\">{label}</p>\n <p className=\"mt-0.5 truncate text-lg font-semibold tabular-nums text-text-primary\">{value}</p>\n {hint && <p className=\"mt-0.5 truncate text-xs text-text-secondary\">{hint}</p>}\n </div>\n <span className=\"flex size-8 shrink-0 items-center justify-center rounded-lg bg-[var(--color-accent-soft)] text-text-secondary [&>svg]:size-4\">\n {icon}\n </span>\n </GlassCard>\n </button>\n);\n\ninterface AlertRowProps {\n alert: Alert;\n ctaLabel: string;\n relTime: string;\n onOpen: () => void;\n}\n\n/** One needs-attention row: severity dot + title + message + relative time + CTA. */\nconst AlertRow: FC<AlertRowProps> = ({ alert, ctaLabel, relTime, onOpen }) => (\n <li className=\"flex items-start gap-3 py-3\">\n <span className={cn('mt-1.5 size-2.5 shrink-0 rounded-full', severityDotClass[alert.severity])} aria-hidden />\n <div className=\"min-w-0 flex-1\">\n <div className=\"flex items-baseline justify-between gap-3\">\n <p className=\"truncate text-sm font-medium text-text-primary\">{alert.title}</p>\n <button\n type=\"button\"\n onClick={onOpen}\n className=\"shrink-0 text-xs font-medium text-action-primary-bg transition-colors hover:underline focus-visible:underline focus-visible:outline-none\"\n >\n {ctaLabel}\n </button>\n </div>\n <p className=\"mt-0.5 truncate text-xs text-text-secondary\">{alert.message}</p>\n <p className=\"mt-0.5 text-xs text-text-muted\">{relTime}</p>\n </div>\n </li>\n);\n\ninterface CropRowProps {\n crop: Crop;\n metaLabel: string;\n healthLabel: string;\n harvestLabel: string;\n openLabel: string;\n onOpen: () => void;\n}\n\n/** Rich crop row — name, field · stage, health, progress bar, expected harvest, open. */\nconst CropRow: FC<CropRowProps> = ({ crop, metaLabel, healthLabel, harvestLabel, openLabel, onOpen }) => (\n <li>\n <button\n type=\"button\"\n onClick={onOpen}\n className=\"group block w-full rounded-lg p-3 text-start transition-colors hover:bg-bg-sunken/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus\"\n >\n <div className=\"flex items-center justify-between gap-2\">\n <div className=\"min-w-0\">\n <p className=\"truncate text-sm font-medium text-text-primary\">{crop.name}</p>\n <p className=\"truncate text-xs text-text-secondary\">{metaLabel}</p>\n </div>\n <StatusBadge label={healthLabel} variant={healthVariant(crop.healthStatus)} dot />\n </div>\n <div className=\"mt-2 flex items-center gap-3\">\n <div className=\"h-1.5 flex-1 overflow-hidden rounded-full bg-bg-sunken\">\n <div\n className=\"h-full rounded-full bg-action-primary-bg\"\n style={{ width: `${clampPercent(crop.progress)}%` }}\n />\n </div>\n <span className=\"w-9 shrink-0 text-end text-xs font-medium tabular-nums text-text-secondary\">\n {clampPercent(crop.progress)}%\n </span>\n </div>\n <div className=\"mt-1.5 flex items-center justify-between text-xs text-text-secondary\">\n <span className=\"truncate\">{harvestLabel}</span>\n <span className=\"inline-flex shrink-0 items-center gap-0.5 font-medium transition-colors group-hover:text-text-primary\">\n {openLabel}\n <ChevronRight className=\"size-3.5\" />\n </span>\n </div>\n </button>\n </li>\n);\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Dashboard\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const HomePage: FC = () => {\n const { dashboardStats, alerts, crops, weatherData, markAlertRead, farm, loadings, errors, refetch } =\n useHealthyBowlData();\n\n const navigate = useNavigate();\n const { t: translate } = useI18n();\n // Local wrapper preserves the (key, fallback) call style used across HB pages\n // while forwarding interpolation params to the shared i18n `t` (for {{count}} etc.).\n const t = useCallback(\n (key: string, fallback: string, params?: Record<string, string | number>): string =>\n translate(key, fallback, params),\n [translate]\n );\n const { buildPath } = useBasePath();\n const { quotas, loading: quotasLoading } = useHealthyBowlQuota();\n const stats = dashboardStats;\n\n const weather = {\n location: weatherData?.location ?? '',\n current: weatherData?.current,\n forecast: weatherData?.forecast ?? [],\n };\n // The data hook substitutes an all-zero EMPTY_WEATHER when there is nothing to\n // show, so presence has to come from a named condition — never from the\n // numbers, because 0 °C / 0 km/h / UV 0 is a real (and frost-relevant) reading.\n const hasWeather = hasWeatherObservation(weather.current);\n\n // Today's date, localised — \"Friday, 25 July\" style.\n const todayLabel = useMemo(\n () => new Date().toLocaleDateString(undefined, { weekday: 'long', day: 'numeric', month: 'long' }),\n []\n );\n\n // Alerts sorted by severity (critical → warning → info); capped for the panel.\n const sortedAlerts = useMemo(\n () => [...alerts].sort((a, b) => severityRank[a.severity] - severityRank[b.severity]),\n [alerts]\n );\n const visibleAlerts = sortedAlerts.slice(0, 5);\n const attentionCount = alerts.length;\n\n // Crops ordered by nearest harvest first; capped so the anchor stays scannable.\n const sortedCrops = useMemo(\n () =>\n [...crops].sort(\n (a, b) => (a.daysToHarvest ?? Number.MAX_SAFE_INTEGER) - (b.daysToHarvest ?? Number.MAX_SAFE_INTEGER)\n ),\n [crops]\n );\n const visibleCrops = sortedCrops.slice(0, 6);\n\n // Expenses as a share of revenue — honest ratio, null when there's no revenue to compare against.\n const expenseRatioPercent = useMemo(() => {\n if (stats.totalRevenue === 0) return null;\n return Math.round((stats.totalExpenses / stats.totalRevenue) * 100 * 10) / 10;\n }, [stats.totalExpenses, stats.totalRevenue]);\n\n // Compact relative-time (minutes/hours/days/weeks), i18n'd.\n const relTime = useCallback(\n (iso: string): string => {\n const then = new Date(iso).getTime();\n if (Number.isNaN(then)) return '';\n const diffMin = Math.max(0, Math.floor((Date.now() - then) / 60000));\n if (diffMin < 1) return t('healthybowl.home.time.now', 'just now');\n if (diffMin < 60) return t('healthybowl.home.time.minutes', '{{n}}m ago', { n: diffMin });\n const diffHr = Math.floor(diffMin / 60);\n if (diffHr < 24) return t('healthybowl.home.time.hours', '{{n}}h ago', { n: diffHr });\n const diffDay = Math.floor(diffHr / 24);\n if (diffDay < 7) return t('healthybowl.home.time.days', '{{n}}d ago', { n: diffDay });\n return t('healthybowl.home.time.weeks', '{{n}}w ago', { n: Math.floor(diffDay / 7) });\n },\n [t]\n );\n\n // Per-alert CTA label by severity — mirrors Review / Open / View in the design.\n const alertCta = useCallback(\n (severity: Alert['severity']): string => {\n if (severity === 'critical') return t('healthybowl.home.needsAttention.review', 'Review');\n if (severity === 'warning') return t('healthybowl.home.needsAttention.open', 'Open');\n return t('healthybowl.home.needsAttention.view', 'View');\n },\n [t]\n );\n\n const openAlert = useCallback(\n (alert: Alert) => {\n void markAlertRead(alert.id, true);\n if (alert.actionUrl) navigate(alert.actionUrl);\n },\n [markAlertRead, navigate]\n );\n\n // ── Real-field-backed KPI derivations ──\n const netProfitTone: Tone = stats.netProfit > 0 ? 'success' : stats.netProfit < 0 ? 'danger' : 'neutral';\n const hasCritical = alerts.some((a) => a.severity === 'critical');\n const hasWarning = alerts.some((a) => a.severity === 'warning');\n const attentionTone: Tone =\n attentionCount === 0 ? 'success' : hasCritical ? 'danger' : hasWarning ? 'warning' : 'neutral';\n\n const quickActions = [\n {\n label: t('healthybowl.home.quickActions.addCrop.label', 'Add crop'),\n icon: Sprout,\n path: buildPath('crops'),\n },\n {\n label: t('healthybowl.home.quickActions.recordHarvest.label', 'Record harvest'),\n icon: ClipboardList,\n path: buildPath('crops/harvest'),\n },\n {\n label: t('healthybowl.home.quickActions.viewFields.label', 'View fields'),\n icon: MapPin,\n path: buildPath('crops/fields'),\n },\n {\n label: t('healthybowl.home.quickActions.viewWeather.label', 'View weather'),\n icon: Thermometer,\n path: buildPath('weather'),\n },\n {\n label: t('healthybowl.home.quickActions.analytics.label', 'Analytics'),\n icon: BarChart3,\n path: buildPath('analytics'),\n },\n ];\n\n // Compact header subline: date · farm + a live needs-attention summary.\n const attentionSummary =\n attentionCount === 0\n ? t('healthybowl.home.header.allClear', \"You're all caught up\")\n : attentionCount === 1\n ? t('healthybowl.home.header.needsAttentionOne', '1 item needs your attention')\n : t('healthybowl.home.header.needsAttentionOther', '{{count}} items need your attention', {\n count: attentionCount,\n });\n\n // PageLayout's `description` is a plain string; the date + farm reads as the subline.\n const headerSubline = farm?.name ? `${todayLabel} · ${farm.name}` : todayLabel;\n\n const headerActions = (\n <button\n type=\"button\"\n onClick={() => navigate(buildPath('crops'))}\n className=\"inline-flex min-h-[40px] items-center gap-2 rounded-md bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text transition-colors hover:bg-action-primary-bg/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus focus-visible:ring-offset-2 focus-visible:ring-offset-bg-canvas\"\n >\n <Plus className=\"h-4 w-4\" />\n {t('healthybowl.home.primaryAction', 'Add')}\n </button>\n );\n\n return (\n <PageLayout\n title={t('healthybowl.home.title', 'Farm Dashboard')}\n description={headerSubline}\n actions={headerActions}\n >\n <section\n aria-labelledby=\"healthy-bowl-quota-heading\"\n className=\"mb-6 rounded-xl border border-border-seam bg-bg-surface p-5\"\n >\n <div className=\"mb-4 flex items-center justify-between gap-3\">\n <div>\n <h2 id=\"healthy-bowl-quota-heading\" className=\"text-base font-semibold text-text-primary\">\n {t('healthybowl.home.quotas.title', 'Plan usage')}\n </h2>\n <p className=\"text-sm text-text-secondary\">\n {t('healthybowl.home.quotas.description', 'See what your farm plan has used and what remains.')}\n </p>\n </div>\n <button\n type=\"button\"\n onClick={() => navigate('/billing')}\n className=\"text-sm font-medium text-action-primary-text hover:underline\"\n >\n {t('healthybowl.home.quotas.billing', 'Manage plan')}\n </button>\n </div>\n {quotasLoading && quotas.length === 0 ? (\n <p className=\"text-sm text-text-secondary\">{t('healthybowl.common.loading', 'Loading…')}</p>\n ) : (\n <div className=\"grid gap-3 sm:grid-cols-2 lg:grid-cols-5\">\n {quotas.map((quota) => {\n const percent =\n quota.noLimit || quota.limit === null || quota.limit === 0\n ? 0\n : Math.min(100, Math.round((quota.used / quota.limit) * 100));\n return (\n <div key={quota.quotaName} className=\"rounded-lg border border-border-seam bg-bg-canvas p-3\">\n <div className=\"flex items-start justify-between gap-2\">\n <span className=\"text-sm font-medium text-text-primary\">{quota.label}</span>\n {quota.noLimit ? (\n <span className=\"text-xs text-text-secondary\">\n {t('healthybowl.home.quotas.unlimited', 'Unlimited')}\n </span>\n ) : null}\n </div>\n <p className=\"mt-2 text-lg font-semibold text-text-primary\">\n {quota.used}\n {quota.limit === null ? '' : ` / ${quota.limit}`}\n </p>\n {quota.limit !== null ? (\n <div className=\"mt-2 h-2 overflow-hidden rounded-full bg-bg-sunken\">\n <div\n className={`h-full ${quota.exhausted ? 'bg-status-error-bg' : 'bg-action-primary-bg'}`}\n style={{ width: `${percent}%` }}\n />\n </div>\n ) : null}\n <p className={`mt-1 text-xs ${quota.exhausted ? 'text-status-error-text' : 'text-text-secondary'}`}>\n {quota.exhausted\n ? t('healthybowl.home.quotas.exhausted', 'Limit reached')\n : quota.remaining === null\n ? t('healthybowl.home.quotas.noLimitRemaining', 'No limit')\n : t('healthybowl.home.quotas.remaining', '{{count}} remaining', { count: quota.remaining })}\n </p>\n </div>\n );\n })}\n </div>\n )}\n </section>\n {loadings.dashboard ? (\n <PageLoader />\n ) : errors.dashboard ? (\n <ErrorState onRetry={refetch} />\n ) : (\n <div className=\"space-y-6\">\n {/* Live needs-attention summary — reads directly under the compact header */}\n <div\n className={cn(\n 'inline-flex items-center gap-1.5 rounded-full px-3 py-1 text-sm font-medium',\n attentionCount === 0\n ? 'bg-status-success-bg text-status-success-text'\n : 'bg-status-warning-bg text-status-warning-text'\n )}\n >\n {attentionCount === 0 ? <CheckCircle2 className=\"size-4\" /> : <AlertTriangle className=\"size-4\" />}\n {attentionSummary}\n </div>\n\n {/* First-run onboarding — only once data has settled and there's no farm yet */}\n {!farm?.id && (\n <EmphasisPanel className=\"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between\">\n <div>\n <p className=\"text-base font-semibold text-text-primary\">\n {t('healthybowl.home.onboarding.title', 'Welcome to HealthyBowl')}\n </p>\n <p className=\"text-sm text-text-secondary\">\n {t(\n 'healthybowl.home.onboarding.description',\n 'Set up your farm to start tracking crops, livestock, finances, and more.'\n )}\n </p>\n </div>\n <button\n type=\"button\"\n onClick={() => navigate(buildPath('getting-started'))}\n className=\"inline-flex min-h-[44px] items-center gap-2 self-start rounded-md bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text transition-colors hover:bg-action-primary-bg/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus focus-visible:ring-offset-2 focus-visible:ring-offset-bg-canvas sm:self-auto\"\n >\n <Plus className=\"h-4 w-4\" />\n {t('healthybowl.home.onboarding.action', 'Set up your farm')}\n </button>\n </EmphasisPanel>\n )}\n\n {/* Quick-action strip — compact row, existing wired targets */}\n <div className=\"flex flex-wrap gap-2\">\n {quickActions.map(({ label, icon: Icon, path }) => (\n <button\n key={label}\n type=\"button\"\n onClick={() => navigate(path)}\n className=\"inline-flex min-h-[40px] items-center gap-2 rounded-full border border-border-subtle bg-bg-surface px-3.5 py-2 text-sm font-medium text-text-secondary transition-colors hover:border-border-default hover:bg-bg-sunken hover:text-text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus focus-visible:ring-offset-2 focus-visible:ring-offset-bg-canvas\"\n >\n <Icon className=\"size-4\" />\n {label}\n </button>\n ))}\n </div>\n\n {/* Primary row — 4 real-field KPIs + needs-attention panel above the fold */}\n <div className=\"grid grid-cols-1 gap-6 lg:grid-cols-3\">\n <div className=\"grid grid-cols-2 gap-4 lg:col-span-2\">\n <KpiTile\n label={t('healthybowl.home.kpi.activeCrops', 'Active crops')}\n value={String(stats.activeCrops)}\n icon={<Sprout />}\n drillLabel={t('healthybowl.home.kpi.viewCrops', 'View crops')}\n onClick={() => navigate(buildPath('crops'))}\n />\n <KpiTile\n label={t('healthybowl.home.kpi.harvestDue', 'Harvest due')}\n value={String(stats.harvestDue)}\n icon={<CalendarClock />}\n drillLabel={t('healthybowl.home.kpi.viewHarvest', 'View harvest')}\n onClick={() => navigate(buildPath('crops/harvest'))}\n />\n <KpiTile\n label={t('healthybowl.home.kpi.netProfit', 'Net profit')}\n value={formatCurrency(stats.netProfit, HB_DEFAULT_CURRENCY)}\n icon={<Wallet />}\n tone={netProfitTone}\n drillLabel={t('healthybowl.home.kpi.viewFinance', 'View finances')}\n onClick={() => navigate(buildPath('financial'))}\n />\n <KpiTile\n label={t('healthybowl.home.kpi.needsAttention', 'Needs attention')}\n value={String(attentionCount)}\n icon={<AlertTriangle />}\n tone={attentionTone}\n glow={attentionTone === 'danger' || attentionTone === 'warning'}\n drillLabel={t('healthybowl.home.kpi.viewAlerts', 'View alerts')}\n onClick={() => navigate(buildPath('weather/alerts'))}\n />\n </div>\n\n {/* Needs attention */}\n <GlassCard className=\"flex h-full flex-col border-border-seam p-0\">\n <div className=\"flex items-center justify-between px-4 pb-1 pt-4\">\n <h3 className=\"text-sm font-semibold text-text-primary\">\n {t('healthybowl.home.needsAttention.title', 'Needs attention')}\n </h3>\n {sortedAlerts.length > 0 && (\n <button\n type=\"button\"\n onClick={() => navigate(buildPath('weather/alerts'))}\n className=\"text-xs font-medium text-text-secondary transition-colors hover:text-text-primary focus-visible:text-text-primary focus-visible:outline-none\"\n >\n {t('healthybowl.home.needsAttention.viewAll', 'View all')}\n </button>\n )}\n </div>\n <div className=\"flex-1 px-4 pb-4\">\n {sortedAlerts.length === 0 ? (\n <EmptyState\n icon={<CheckCircle2 className=\"h-8 w-8 text-status-success-text\" />}\n title={t('healthybowl.home.needsAttention.empty.title', \"You're all caught up\")}\n description={t(\n 'healthybowl.home.needsAttention.empty.description',\n 'No urgent farm alerts right now.'\n )}\n action={\n <button\n type=\"button\"\n onClick={() => navigate(buildPath('weather/alert-rules'))}\n className=\"inline-flex min-h-[40px] items-center gap-2 rounded-md border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary transition-colors hover:bg-bg-sunken focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus\"\n >\n {t('healthybowl.home.needsAttention.empty.action', 'Manage alert rules')}\n </button>\n }\n />\n ) : (\n <ul className=\"divide-y divide-border-subtle\">\n {visibleAlerts.map((alert) => (\n <AlertRow\n key={alert.id}\n alert={alert}\n ctaLabel={alertCta(alert.severity)}\n relTime={relTime(alert.timestamp)}\n onOpen={() => openAlert(alert)}\n />\n ))}\n </ul>\n )}\n </div>\n </GlassCard>\n </div>\n\n {/* Anchor row — crop overview (strongest) + compact weather */}\n <div className=\"grid grid-cols-1 gap-6 lg:grid-cols-3\">\n {/* Crop overview — the farm-specific anchor */}\n <GlassCard glow className=\"flex h-full flex-col border-border-seam p-0 lg:col-span-2\">\n <div className=\"flex items-center justify-between px-5 pb-2 pt-5\">\n <div className=\"flex items-center gap-2\">\n <span className=\"flex size-8 items-center justify-center rounded-lg bg-[var(--color-accent-soft)] text-primary [&>svg]:size-4\">\n <Sprout />\n </span>\n <div>\n <h2 className=\"text-base font-semibold text-text-primary\">\n {t('healthybowl.home.cropsAnchor.title', 'Crop overview')}\n </h2>\n <p className=\"text-xs text-text-secondary\">\n {crops.length === 1\n ? t('healthybowl.home.cropsAnchor.subtitleOne', '1 crop in progress')\n : t('healthybowl.home.cropsAnchor.subtitleOther', '{{count}} crops in progress', {\n count: crops.length,\n })}\n </p>\n </div>\n </div>\n {crops.length > 0 && (\n <button\n type=\"button\"\n onClick={() => navigate(buildPath('crops'))}\n className=\"text-xs font-medium text-text-secondary transition-colors hover:text-text-primary focus-visible:text-text-primary focus-visible:outline-none\"\n >\n {t('healthybowl.home.cropsAnchor.viewAll', 'View all crops')}\n </button>\n )}\n </div>\n <div className=\"flex-1 px-3 pb-3\">\n {crops.length === 0 ? (\n <EmptyState\n icon={<Sprout className=\"h-8 w-8 text-primary\" />}\n title={t('healthybowl.home.cropsAnchor.empty.title', 'No active crops')}\n description={t(\n 'healthybowl.home.cropsAnchor.empty.description',\n 'Register your first crop to track growth, health and harvest here.'\n )}\n action={\n <button\n type=\"button\"\n onClick={() => navigate(buildPath('crops'))}\n className=\"inline-flex min-h-[40px] items-center gap-2 rounded-md bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text transition-colors hover:bg-action-primary-bg/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus\"\n >\n <Plus className=\"h-4 w-4\" />\n {t('healthybowl.home.quickActions.addCrop.label', 'Add crop')}\n </button>\n }\n />\n ) : (\n <ul className=\"divide-y divide-border-subtle\">\n {visibleCrops.map((crop) => {\n const stage = (crop.growthStage || crop.status || '').replace(/_/g, ' ').trim();\n const metaLabel = [crop.fieldName, stage].filter(Boolean).join(' · ');\n return (\n <CropRow\n key={crop.id}\n crop={crop}\n metaLabel={metaLabel || t('healthybowl.home.cropsAnchor.noField', 'Unassigned')}\n healthLabel={(crop.healthStatus || 'unknown').replace(/_/g, ' ')}\n harvestLabel={\n crop.expectedHarvestDate\n ? t('healthybowl.home.cropsAnchor.harvest', 'Harvest {{date}}', {\n date: formatDateOnly(crop.expectedHarvestDate),\n })\n : t('healthybowl.home.cropsAnchor.harvestUnknown', 'Harvest date TBD')\n }\n openLabel={t('healthybowl.home.cropsAnchor.open', 'Open')}\n onOpen={() => navigate(buildPath(`crops/${crop.id}`))}\n />\n );\n })}\n </ul>\n )}\n </div>\n </GlassCard>\n\n {/* Weather — secondary */}\n <GlassCard className=\"flex h-full flex-col border-border-seam p-0\">\n <div className=\"px-4 pb-1 pt-4\">\n <h3 className=\"text-sm font-semibold text-text-primary\">\n {t('healthybowl.home.weatherCard.title', 'Current weather')}\n </h3>\n {weather.location && <p className=\"text-xs text-text-secondary\">{weather.location}</p>}\n </div>\n <div className=\"flex flex-1 flex-col gap-4 px-4 pb-4\">\n {!hasWeather ? (\n // No observation. Say so, rather than printing 0 °C / 0% / 0 hPa\n // — fabricated readings are worse than none on a farm dashboard.\n <EmptyState\n icon={<CloudOff className=\"h-8 w-8 text-text-muted\" />}\n title={\n errors.weather\n ? t('healthybowl.home.weatherCard.error.title', 'Weather unavailable')\n : t('healthybowl.home.weatherCard.empty.title', 'No weather yet')\n }\n description={\n errors.weather\n ? t(\n 'healthybowl.home.weatherCard.error.description',\n \"We couldn't load conditions for your farm just now.\"\n )\n : t(\n 'healthybowl.home.weatherCard.empty.description',\n 'Set your farm location to see local conditions here.'\n )\n }\n action={\n <button\n type=\"button\"\n onClick={() => (errors.weather ? refetch() : navigate(buildPath('farm')))}\n className=\"inline-flex min-h-[40px] items-center gap-2 rounded-md border border-border-default px-4 py-2 text-sm font-medium text-text-primary transition-colors hover:bg-bg-elevated focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus\"\n >\n {errors.weather\n ? t('healthybowl.home.weatherCard.error.retry', 'Try again')\n : t('healthybowl.home.weatherCard.empty.action', 'Set farm location')}\n </button>\n }\n />\n ) : (\n <>\n <div className=\"flex items-center justify-between\">\n <div>\n <p className=\"text-4xl font-bold text-text-primary\">{weather.current.temperature}&deg;C</p>\n <p className=\"text-sm text-text-secondary\">{weather.current.condition}</p>\n <p className=\"mt-1 text-xs text-text-secondary\">\n {t('healthybowl.home.weatherCard.feelsLike', 'Feels like')} {weather.current.feelsLike}&deg;C\n </p>\n </div>\n <div className=\"flex flex-col items-center\">\n <Cloud className=\"h-12 w-12 text-text-secondary\" />\n <span className=\"mt-1 text-xs text-text-secondary\">UV {weather.current.uvIndex}</span>\n </div>\n </div>\n\n <div className=\"grid grid-cols-2 gap-3 border-t border-border-subtle pt-3\">\n <div className=\"flex items-center gap-2 text-sm text-text-secondary\">\n <Droplets className=\"h-4 w-4\" />\n <span>\n {weather.current.humidity}% {t('healthybowl.home.weatherCard.humidity', 'Humidity')}\n </span>\n </div>\n <div className=\"flex items-center gap-2 text-sm text-text-secondary\">\n <Wind className=\"h-4 w-4\" />\n <span>{weather.current.windSpeed} km/h</span>\n </div>\n <div className=\"flex items-center gap-2 text-sm text-text-secondary\">\n <Thermometer className=\"h-4 w-4\" />\n <span>{weather.current.pressure} hPa</span>\n </div>\n <div className=\"flex items-center gap-2 text-sm text-text-secondary\">\n <Eye className=\"h-4 w-4\" />\n <span>{weather.current.visibility} km</span>\n </div>\n </div>\n </>\n )}\n\n {weather.forecast.length > 0 && (\n <div className=\"grid grid-cols-4 gap-2 border-t border-border-subtle pt-3\">\n {weather.forecast.slice(0, 4).map((day) => (\n <div key={day.date} className=\"rounded-md bg-bg-sunken/50 p-2 text-center\">\n <p className=\"text-xs font-medium text-text-secondary\">\n {new Date(day.date).toLocaleDateString('en-US', { weekday: 'short' })}\n </p>\n <p className=\"mt-1 text-sm font-semibold text-text-primary\">{day.high}&deg;</p>\n <p className=\"text-xs text-text-secondary\">{day.low}&deg;</p>\n <p className=\"mt-0.5 text-xs text-text-secondary\">{day.precipitation}%</p>\n </div>\n ))}\n </div>\n )}\n\n <button\n type=\"button\"\n onClick={() => navigate(buildPath('weather'))}\n className=\"mt-auto w-full rounded-md border border-border-subtle py-2 text-sm text-text-primary transition-colors hover:bg-bg-sunken/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus\"\n >\n {t('healthybowl.home.weatherCard.viewForecast', 'View full forecast')}\n </button>\n </div>\n </GlassCard>\n </div>\n\n {/* At a glance — demoted secondary metrics with honest zero-states */}\n <section>\n <h3 className=\"mb-2 text-xs font-medium uppercase tracking-wide text-text-secondary\">\n {t('healthybowl.home.glance.title', 'At a glance')}\n </h3>\n <div className=\"grid grid-cols-2 gap-3 sm:grid-cols-4\">\n <MiniStat\n label={t('healthybowl.home.glance.fields', 'Fields')}\n value={String(stats.totalFields)}\n hint={\n stats.totalFields > 0\n ? t('healthybowl.home.glance.fieldsHint', 'Monitored')\n : t('healthybowl.home.glance.fieldsEmpty', 'No fields yet')\n }\n icon={<MapPin />}\n onClick={() => navigate(buildPath('crops/fields'))}\n />\n <MiniStat\n label={t('healthybowl.home.glance.livestock', 'Livestock')}\n value={String(stats.totalAnimals)}\n hint={\n stats.totalAnimals > 0\n ? t('healthybowl.home.glance.livestockHint', 'Under management')\n : t('healthybowl.home.glance.livestockEmpty', 'No livestock added')\n }\n icon={<PawPrint />}\n onClick={() => navigate(buildPath('livestock'))}\n />\n <MiniStat\n label={t('healthybowl.home.glance.organic', 'Organic score')}\n value={\n stats.organicScore > 0\n ? `${stats.organicScore}%`\n : t('healthybowl.home.glance.organicEmpty', 'Not configured')\n }\n hint={stats.organicScore > 0 ? t('healthybowl.home.glance.organicHint', 'Compliance') : undefined}\n icon={<ShieldCheck />}\n onClick={() => navigate(buildPath('compliance'))}\n />\n <MiniStat\n label={t('healthybowl.home.glance.expenses', 'Expenses')}\n value={formatCurrency(stats.totalExpenses, HB_DEFAULT_CURRENCY)}\n hint={\n expenseRatioPercent != null\n ? t('healthybowl.home.glance.expensesRatio', '{{pct}}% of revenue', { pct: expenseRatioPercent })\n : t('healthybowl.home.glance.noRevenue', 'No revenue yet')\n }\n icon={<Wallet />}\n onClick={() => navigate(buildPath('financial'))}\n />\n </div>\n </section>\n </div>\n )}\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAuCA,IAAM,IAAuC;CAC3C,SAAS;CACT,SAAS;CACT,SAAS;CACT,QAAQ;CACT,EAEK,IAAsC;CAC1C,SAAS;CACT,SAAS;CACT,SAAS;CACT,QAAQ;CACT,EAEK,IAAkD;CAAE,UAAU;CAAG,SAAS;CAAG,MAAM;CAAG,EAEtF,IAAsD;CAC1D,UAAU;CACV,SAAS;CACT,MAAM;CACP,EAEK,KAAiB,MAAmB;AACxC,SAAQ,GAAR;EACE,KAAK,YACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,QACE,QAAO;;GAIP,KAAgB,MAAc,KAAK,IAAI,GAAG,KAAK,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC,CAAC,EAkBvE,KAA6B,EAAE,UAAO,UAAO,SAAM,UAAO,WAAW,UAAO,IAAO,eAAY,iBACnG,kBAAC,UAAD;CAAQ,MAAK;CAAkB;CAAS,WAAU;WAChD,kBAAC,GAAD;E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l/pages/HomePage.tsx"],"sourcesContent":["import { useMemo, useCallback, type FC, type ReactNode } from 'react';\nimport { useNavigate } from 'react-router';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport {\n Sprout,\n CalendarClock,\n Wallet,\n AlertTriangle,\n Plus,\n ClipboardList,\n BarChart3,\n MapPin,\n Thermometer,\n ArrowUpRight,\n ChevronRight,\n CheckCircle2,\n Cloud,\n CloudOff,\n Droplets,\n Wind,\n Eye,\n PawPrint,\n ShieldCheck,\n} from 'lucide-react';\nimport { EmphasisPanel, GlassCard } from '@burdenoff/fe-libs/ui';\nimport { PageLayout, StatusBadge, EmptyState, ErrorState, PageLoader } from '../components';\nimport { useHealthyBowlData } from '../hooks/useHealthyBowlData';\nimport { useHealthyBowlQuota } from '../hooks/useHealthyBowlQuota';\nimport { useBasePath } from '../hooks/useBasePath';\nimport { cn, formatCurrency, HB_DEFAULT_CURRENCY, formatDateOnly } from '../utils/helpers';\nimport { hasWeatherObservation } from '../utils/weatherPresence';\nimport type { Alert, Crop } from '../types';\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Semantic maps — colour carries meaning, always paired with a label. Tokens only.\n// ─────────────────────────────────────────────────────────────────────────────\n\ntype Tone = 'neutral' | 'success' | 'warning' | 'danger';\n\nconst toneValueClass: Record<Tone, string> = {\n neutral: 'text-text-primary',\n success: 'text-status-success-text',\n warning: 'text-status-warning-text',\n danger: 'text-status-error-text',\n};\n\nconst toneChipClass: Record<Tone, string> = {\n neutral: 'bg-[var(--color-accent-soft)] text-text-primary',\n success: 'bg-status-success-bg text-status-success-text',\n warning: 'bg-status-warning-bg text-status-warning-text',\n danger: 'bg-status-error-bg text-status-error-text',\n};\n\nconst severityRank: Record<Alert['severity'], number> = { critical: 0, warning: 1, info: 2 };\n\nconst severityDotClass: Record<Alert['severity'], string> = {\n critical: 'bg-status-error-text',\n warning: 'bg-status-warning-text',\n info: 'bg-status-info-text',\n};\n\nconst healthVariant = (status: string) => {\n switch (status) {\n case 'excellent':\n return 'success' as const;\n case 'good':\n return 'info' as const;\n case 'fair':\n return 'warning' as const;\n default:\n return 'error' as const;\n }\n};\n\nconst clampPercent = (n: number) => Math.max(0, Math.min(100, Math.round(n)));\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Presentational sub-components (module-level so they don't remount each render)\n// ─────────────────────────────────────────────────────────────────────────────\n\ninterface KpiTileProps {\n label: string;\n value: string;\n icon: ReactNode;\n tone?: Tone;\n /** Featured accent glow — reserve for the single focal KPI (needs-attention). */\n glow?: boolean;\n drillLabel: string;\n onClick: () => void;\n}\n\n/** Primary KPI card — big real value + tone-coded chip + drill-down. No fabricated trend/sparkline. */\nconst KpiTile: FC<KpiTileProps> = ({ label, value, icon, tone = 'neutral', glow = false, drillLabel, onClick }) => (\n <button type=\"button\" onClick={onClick} className=\"group block text-start focus-visible:outline-none\">\n <GlassCard\n treatment=\"metric\"\n glow={glow}\n className=\"flex h-full flex-col gap-3 border-border-seam p-4 transition-shadow group-hover:shadow-pop group-focus-visible:ring-2 group-focus-visible:ring-border-focus group-focus-visible:ring-offset-2 group-focus-visible:ring-offset-bg-canvas\"\n >\n <div className=\"flex items-center justify-between\">\n <span className=\"text-sm font-medium text-text-secondary\">{label}</span>\n <span className={cn('flex size-8 items-center justify-center rounded-lg [&>svg]:size-4', toneChipClass[tone])}>\n {icon}\n </span>\n </div>\n <span className={cn('text-3xl font-semibold tabular-nums', toneValueClass[tone])}>{value}</span>\n <span className=\"mt-auto inline-flex items-center gap-1 text-xs font-medium text-text-secondary transition-colors group-hover:text-text-primary\">\n {drillLabel}\n <ArrowUpRight className=\"size-3.5\" />\n </span>\n </GlassCard>\n </button>\n);\n\ninterface MiniStatProps {\n label: string;\n value: string;\n hint?: string;\n icon: ReactNode;\n onClick: () => void;\n}\n\n/** Secondary \"at a glance\" tile — quieter than a KPI, honest zero-state hints. */\nconst MiniStat: FC<MiniStatProps> = ({ label, value, hint, icon, onClick }) => (\n <button type=\"button\" onClick={onClick} className=\"group block text-start focus-visible:outline-none\">\n <GlassCard className=\"flex h-full items-center justify-between gap-3 border-border-seam p-3 transition-shadow group-hover:shadow-pop group-focus-visible:ring-2 group-focus-visible:ring-border-focus group-focus-visible:ring-offset-2 group-focus-visible:ring-offset-bg-canvas\">\n <div className=\"min-w-0\">\n <p className=\"text-xs font-medium text-text-secondary\">{label}</p>\n <p className=\"mt-0.5 truncate text-lg font-semibold tabular-nums text-text-primary\">{value}</p>\n {hint && <p className=\"mt-0.5 truncate text-xs text-text-secondary\">{hint}</p>}\n </div>\n <span className=\"flex size-8 shrink-0 items-center justify-center rounded-lg bg-[var(--color-accent-soft)] text-text-secondary [&>svg]:size-4\">\n {icon}\n </span>\n </GlassCard>\n </button>\n);\n\ninterface AlertRowProps {\n alert: Alert;\n ctaLabel: string;\n relTime: string;\n onOpen: () => void;\n}\n\n/** One needs-attention row: severity dot + title + message + relative time + CTA. */\nconst AlertRow: FC<AlertRowProps> = ({ alert, ctaLabel, relTime, onOpen }) => (\n <li className=\"flex items-start gap-3 py-3\">\n <span className={cn('mt-1.5 size-2.5 shrink-0 rounded-full', severityDotClass[alert.severity])} aria-hidden />\n <div className=\"min-w-0 flex-1\">\n <div className=\"flex items-baseline justify-between gap-3\">\n <p className=\"truncate text-sm font-medium text-text-primary\">{alert.title}</p>\n <button\n type=\"button\"\n onClick={onOpen}\n className=\"shrink-0 text-xs font-medium text-action-primary-bg transition-colors hover:underline focus-visible:underline focus-visible:outline-none\"\n >\n {ctaLabel}\n </button>\n </div>\n <p className=\"mt-0.5 truncate text-xs text-text-secondary\">{alert.message}</p>\n <p className=\"mt-0.5 text-xs text-text-muted\">{relTime}</p>\n </div>\n </li>\n);\n\ninterface CropRowProps {\n crop: Crop;\n metaLabel: string;\n healthLabel: string;\n harvestLabel: string;\n openLabel: string;\n onOpen: () => void;\n}\n\n/** Rich crop row — name, field · stage, health, progress bar, expected harvest, open. */\nconst CropRow: FC<CropRowProps> = ({ crop, metaLabel, healthLabel, harvestLabel, openLabel, onOpen }) => (\n <li>\n <button\n type=\"button\"\n onClick={onOpen}\n className=\"group block w-full rounded-lg p-3 text-start transition-colors hover:bg-bg-sunken/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus\"\n >\n <div className=\"flex items-center justify-between gap-2\">\n <div className=\"min-w-0\">\n <p className=\"truncate text-sm font-medium text-text-primary\">{crop.name}</p>\n <p className=\"truncate text-xs text-text-secondary\">{metaLabel}</p>\n </div>\n <StatusBadge label={healthLabel} variant={healthVariant(crop.healthStatus)} dot />\n </div>\n <div className=\"mt-2 flex items-center gap-3\">\n <div className=\"h-1.5 flex-1 overflow-hidden rounded-full bg-bg-sunken\">\n <div\n className=\"h-full rounded-full bg-action-primary-bg\"\n style={{ width: `${clampPercent(crop.progress)}%` }}\n />\n </div>\n <span className=\"w-9 shrink-0 text-end text-xs font-medium tabular-nums text-text-secondary\">\n {clampPercent(crop.progress)}%\n </span>\n </div>\n <div className=\"mt-1.5 flex items-center justify-between text-xs text-text-secondary\">\n <span className=\"truncate\">{harvestLabel}</span>\n <span className=\"inline-flex shrink-0 items-center gap-0.5 font-medium transition-colors group-hover:text-text-primary\">\n {openLabel}\n <ChevronRight className=\"size-3.5\" />\n </span>\n </div>\n </button>\n </li>\n);\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Dashboard\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const HomePage: FC = () => {\n const { dashboardStats, alerts, crops, weatherData, markAlertRead, farm, loadings, errors, refetch } =\n useHealthyBowlData();\n\n const navigate = useNavigate();\n const { t: translate } = useI18n();\n // Local wrapper preserves the (key, fallback) call style used across HB pages\n // while forwarding interpolation params to the shared i18n `t` (for {{count}} etc.).\n const t = useCallback(\n (key: string, fallback: string, params?: Record<string, string | number>): string =>\n translate(key, fallback, params),\n [translate]\n );\n const { buildPath } = useBasePath();\n const { quotas, loading: quotasLoading } = useHealthyBowlQuota();\n const stats = dashboardStats;\n\n const weather = {\n location: weatherData?.location ?? '',\n current: weatherData?.current,\n forecast: weatherData?.forecast ?? [],\n };\n // The data hook substitutes an all-zero EMPTY_WEATHER when there is nothing to\n // show, so presence has to come from a named condition — never from the\n // numbers, because 0 °C / 0 km/h / UV 0 is a real (and frost-relevant) reading.\n const hasWeather = hasWeatherObservation(weather.current);\n\n // Today's date, localised — \"Friday, 25 July\" style.\n const todayLabel = useMemo(\n () => new Date().toLocaleDateString(undefined, { weekday: 'long', day: 'numeric', month: 'long' }),\n []\n );\n\n // Alerts sorted by severity (critical → warning → info); capped for the panel.\n const sortedAlerts = useMemo(\n () => [...alerts].sort((a, b) => severityRank[a.severity] - severityRank[b.severity]),\n [alerts]\n );\n const visibleAlerts = sortedAlerts.slice(0, 5);\n const attentionCount = alerts.length;\n\n // Crops ordered by nearest harvest first; capped so the anchor stays scannable.\n const sortedCrops = useMemo(\n () =>\n [...crops].sort(\n (a, b) => (a.daysToHarvest ?? Number.MAX_SAFE_INTEGER) - (b.daysToHarvest ?? Number.MAX_SAFE_INTEGER)\n ),\n [crops]\n );\n const visibleCrops = sortedCrops.slice(0, 6);\n\n // Expenses as a share of revenue — honest ratio, null when there's no revenue to compare against.\n const expenseRatioPercent = useMemo(() => {\n if (stats.totalRevenue === 0) return null;\n return Math.round((stats.totalExpenses / stats.totalRevenue) * 100 * 10) / 10;\n }, [stats.totalExpenses, stats.totalRevenue]);\n\n // Compact relative-time (minutes/hours/days/weeks), i18n'd.\n const relTime = useCallback(\n (iso: string): string => {\n const then = new Date(iso).getTime();\n if (Number.isNaN(then)) return '';\n const diffMin = Math.max(0, Math.floor((Date.now() - then) / 60000));\n if (diffMin < 1) return t('healthybowl.home.time.now', 'just now');\n if (diffMin < 60) return t('healthybowl.home.time.minutes', '{{n}}m ago', { n: diffMin });\n const diffHr = Math.floor(diffMin / 60);\n if (diffHr < 24) return t('healthybowl.home.time.hours', '{{n}}h ago', { n: diffHr });\n const diffDay = Math.floor(diffHr / 24);\n if (diffDay < 7) return t('healthybowl.home.time.days', '{{n}}d ago', { n: diffDay });\n return t('healthybowl.home.time.weeks', '{{n}}w ago', { n: Math.floor(diffDay / 7) });\n },\n [t]\n );\n\n // Per-alert CTA label by severity — mirrors Review / Open / View in the design.\n const alertCta = useCallback(\n (severity: Alert['severity']): string => {\n if (severity === 'critical') return t('healthybowl.home.needsAttention.review', 'Review');\n if (severity === 'warning') return t('healthybowl.home.needsAttention.open', 'Open');\n return t('healthybowl.home.needsAttention.view', 'View');\n },\n [t]\n );\n\n const openAlert = useCallback(\n (alert: Alert) => {\n void markAlertRead(alert.id, true);\n if (alert.actionUrl) navigate(alert.actionUrl);\n },\n [markAlertRead, navigate]\n );\n\n // ── Real-field-backed KPI derivations ──\n const netProfitTone: Tone = stats.netProfit > 0 ? 'success' : stats.netProfit < 0 ? 'danger' : 'neutral';\n const hasCritical = alerts.some((a) => a.severity === 'critical');\n const hasWarning = alerts.some((a) => a.severity === 'warning');\n const attentionTone: Tone =\n attentionCount === 0 ? 'success' : hasCritical ? 'danger' : hasWarning ? 'warning' : 'neutral';\n\n const quickActions = [\n {\n label: t('healthybowl.home.quickActions.addCrop.label', 'Add crop'),\n icon: Sprout,\n path: buildPath('crops'),\n },\n {\n label: t('healthybowl.home.quickActions.recordHarvest.label', 'Record harvest'),\n icon: ClipboardList,\n path: buildPath('crops/harvest'),\n },\n {\n label: t('healthybowl.home.quickActions.viewFields.label', 'View fields'),\n icon: MapPin,\n path: buildPath('crops/fields'),\n },\n {\n label: t('healthybowl.home.quickActions.viewWeather.label', 'View weather'),\n icon: Thermometer,\n path: buildPath('weather'),\n },\n {\n label: t('healthybowl.home.quickActions.analytics.label', 'Analytics'),\n icon: BarChart3,\n path: buildPath('analytics'),\n },\n ];\n\n // Compact header subline: date · farm + a live needs-attention summary.\n const attentionSummary =\n attentionCount === 0\n ? t('healthybowl.home.header.allClear', \"You're all caught up\")\n : attentionCount === 1\n ? t('healthybowl.home.header.needsAttentionOne', '1 item needs your attention')\n : t('healthybowl.home.header.needsAttentionOther', '{{count}} items need your attention', {\n count: attentionCount,\n });\n\n // PageLayout's `description` is a plain string; the date + farm reads as the subline.\n const headerSubline = farm?.name ? `${todayLabel} · ${farm.name}` : todayLabel;\n\n const headerActions = (\n <button\n type=\"button\"\n onClick={() => navigate(buildPath('crops'))}\n className=\"inline-flex min-h-[40px] items-center gap-2 rounded-md bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text transition-colors hover:bg-action-primary-bg/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus focus-visible:ring-offset-2 focus-visible:ring-offset-bg-canvas\"\n >\n <Plus className=\"h-4 w-4\" />\n {t('healthybowl.home.primaryAction', 'Add')}\n </button>\n );\n\n return (\n <PageLayout\n title={t('healthybowl.home.title', 'Farm Dashboard')}\n description={headerSubline}\n actions={headerActions}\n >\n <section\n aria-labelledby=\"healthy-bowl-quota-heading\"\n className=\"mb-6 rounded-xl border border-border-seam bg-bg-surface p-5\"\n >\n <div className=\"mb-4 flex items-center justify-between gap-3\">\n <div>\n <h2 id=\"healthy-bowl-quota-heading\" className=\"text-base font-semibold text-text-primary\">\n {t('healthybowl.home.quotas.title', 'Plan usage')}\n </h2>\n <p className=\"text-sm text-text-secondary\">\n {t('healthybowl.home.quotas.description', 'See what your farm plan has used and what remains.')}\n </p>\n </div>\n <button\n type=\"button\"\n onClick={() => navigate('/billing')}\n className=\"text-sm font-medium text-action-primary-text hover:underline\"\n >\n {t('healthybowl.home.quotas.billing', 'Manage plan')}\n </button>\n </div>\n {quotasLoading && quotas.length === 0 ? (\n <p className=\"text-sm text-text-secondary\">{t('healthybowl.common.loading', 'Loading…')}</p>\n ) : (\n <div className=\"grid gap-3 sm:grid-cols-2 lg:grid-cols-5\">\n {quotas.map((quota) => {\n const percent =\n quota.noLimit || quota.limit === null || quota.limit === 0\n ? 0\n : Math.min(100, Math.round((quota.used / quota.limit) * 100));\n return (\n <div key={quota.quotaName} className=\"rounded-lg border border-border-seam bg-bg-canvas p-3\">\n <div className=\"flex items-start justify-between gap-2\">\n <span className=\"text-sm font-medium text-text-primary\">{quota.label}</span>\n {/*\n \"Unlimited\" is only honest when billing actually said so. This tile\n used to render it whenever the limit lookup failed for any reason,\n including \"this workspace has no quota assignment\" — so a farmer\n whose every create was being refused was told they had no limit\n (BOFF-6302).\n */}\n {quota.noLimit ? (\n <span className=\"text-xs text-text-secondary\">\n {t('healthybowl.home.quotas.unlimited', 'Unlimited')}\n </span>\n ) : !quota.provisioned ? (\n <span className=\"text-xs text-status-warning-text\">\n {t('healthybowl.home.quotas.unknown', 'Not available')}\n </span>\n ) : null}\n </div>\n <p className=\"mt-2 text-lg font-semibold text-text-primary\">\n {quota.used}\n {quota.limit === null ? '' : ` / ${quota.limit}`}\n </p>\n {quota.limit !== null ? (\n <div className=\"mt-2 h-2 overflow-hidden rounded-full bg-bg-sunken\">\n <div\n className={`h-full ${quota.exhausted ? 'bg-status-error-bg' : 'bg-action-primary-bg'}`}\n style={{ width: `${percent}%` }}\n />\n </div>\n ) : null}\n <p\n className={`mt-1 text-xs ${\n quota.exhausted\n ? 'text-status-error-text'\n : !quota.provisioned\n ? 'text-status-warning-text'\n : 'text-text-secondary'\n }`}\n >\n {quota.exhausted\n ? t('healthybowl.home.quotas.exhausted', 'Limit reached')\n : !quota.provisioned\n ? t(\n 'healthybowl.home.quotas.notProvisioned',\n 'No plan limit found for this workspace — creating may be refused.'\n )\n : quota.remaining === null\n ? t('healthybowl.home.quotas.noLimitRemaining', 'No limit')\n : t('healthybowl.home.quotas.remaining', '{{count}} remaining', {\n count: quota.remaining,\n })}\n </p>\n </div>\n );\n })}\n </div>\n )}\n </section>\n {loadings.dashboard ? (\n <PageLoader />\n ) : errors.dashboard ? (\n <ErrorState onRetry={refetch} />\n ) : (\n <div className=\"space-y-6\">\n {/* Live needs-attention summary — reads directly under the compact header */}\n <div\n className={cn(\n 'inline-flex items-center gap-1.5 rounded-full px-3 py-1 text-sm font-medium',\n attentionCount === 0\n ? 'bg-status-success-bg text-status-success-text'\n : 'bg-status-warning-bg text-status-warning-text'\n )}\n >\n {attentionCount === 0 ? <CheckCircle2 className=\"size-4\" /> : <AlertTriangle className=\"size-4\" />}\n {attentionSummary}\n </div>\n\n {/* First-run onboarding — only once data has settled and there's no farm yet */}\n {!farm?.id && (\n <EmphasisPanel className=\"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between\">\n <div>\n <p className=\"text-base font-semibold text-text-primary\">\n {t('healthybowl.home.onboarding.title', 'Welcome to HealthyBowl')}\n </p>\n <p className=\"text-sm text-text-secondary\">\n {t(\n 'healthybowl.home.onboarding.description',\n 'Set up your farm to start tracking crops, livestock, finances, and more.'\n )}\n </p>\n </div>\n <button\n type=\"button\"\n onClick={() => navigate(buildPath('getting-started'))}\n className=\"inline-flex min-h-[44px] items-center gap-2 self-start rounded-md bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text transition-colors hover:bg-action-primary-bg/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus focus-visible:ring-offset-2 focus-visible:ring-offset-bg-canvas sm:self-auto\"\n >\n <Plus className=\"h-4 w-4\" />\n {t('healthybowl.home.onboarding.action', 'Set up your farm')}\n </button>\n </EmphasisPanel>\n )}\n\n {/* Quick-action strip — compact row, existing wired targets */}\n <div className=\"flex flex-wrap gap-2\">\n {quickActions.map(({ label, icon: Icon, path }) => (\n <button\n key={label}\n type=\"button\"\n onClick={() => navigate(path)}\n className=\"inline-flex min-h-[40px] items-center gap-2 rounded-full border border-border-subtle bg-bg-surface px-3.5 py-2 text-sm font-medium text-text-secondary transition-colors hover:border-border-default hover:bg-bg-sunken hover:text-text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus focus-visible:ring-offset-2 focus-visible:ring-offset-bg-canvas\"\n >\n <Icon className=\"size-4\" />\n {label}\n </button>\n ))}\n </div>\n\n {/* Primary row — 4 real-field KPIs + needs-attention panel above the fold */}\n <div className=\"grid grid-cols-1 gap-6 lg:grid-cols-3\">\n <div className=\"grid grid-cols-2 gap-4 lg:col-span-2\">\n <KpiTile\n label={t('healthybowl.home.kpi.activeCrops', 'Active crops')}\n value={String(stats.activeCrops)}\n icon={<Sprout />}\n drillLabel={t('healthybowl.home.kpi.viewCrops', 'View crops')}\n onClick={() => navigate(buildPath('crops'))}\n />\n <KpiTile\n label={t('healthybowl.home.kpi.harvestDue', 'Harvest due')}\n value={String(stats.harvestDue)}\n icon={<CalendarClock />}\n drillLabel={t('healthybowl.home.kpi.viewHarvest', 'View harvest')}\n onClick={() => navigate(buildPath('crops/harvest'))}\n />\n <KpiTile\n label={t('healthybowl.home.kpi.netProfit', 'Net profit')}\n value={formatCurrency(stats.netProfit, HB_DEFAULT_CURRENCY)}\n icon={<Wallet />}\n tone={netProfitTone}\n drillLabel={t('healthybowl.home.kpi.viewFinance', 'View finances')}\n onClick={() => navigate(buildPath('financial'))}\n />\n <KpiTile\n label={t('healthybowl.home.kpi.needsAttention', 'Needs attention')}\n value={String(attentionCount)}\n icon={<AlertTriangle />}\n tone={attentionTone}\n glow={attentionTone === 'danger' || attentionTone === 'warning'}\n drillLabel={t('healthybowl.home.kpi.viewAlerts', 'View alerts')}\n onClick={() => navigate(buildPath('weather/alerts'))}\n />\n </div>\n\n {/* Needs attention */}\n <GlassCard className=\"flex h-full flex-col border-border-seam p-0\">\n <div className=\"flex items-center justify-between px-4 pb-1 pt-4\">\n <h3 className=\"text-sm font-semibold text-text-primary\">\n {t('healthybowl.home.needsAttention.title', 'Needs attention')}\n </h3>\n {sortedAlerts.length > 0 && (\n <button\n type=\"button\"\n onClick={() => navigate(buildPath('weather/alerts'))}\n className=\"text-xs font-medium text-text-secondary transition-colors hover:text-text-primary focus-visible:text-text-primary focus-visible:outline-none\"\n >\n {t('healthybowl.home.needsAttention.viewAll', 'View all')}\n </button>\n )}\n </div>\n <div className=\"flex-1 px-4 pb-4\">\n {sortedAlerts.length === 0 ? (\n <EmptyState\n icon={<CheckCircle2 className=\"h-8 w-8 text-status-success-text\" />}\n title={t('healthybowl.home.needsAttention.empty.title', \"You're all caught up\")}\n description={t(\n 'healthybowl.home.needsAttention.empty.description',\n 'No urgent farm alerts right now.'\n )}\n action={\n <button\n type=\"button\"\n onClick={() => navigate(buildPath('weather/alert-rules'))}\n className=\"inline-flex min-h-[40px] items-center gap-2 rounded-md border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary transition-colors hover:bg-bg-sunken focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus\"\n >\n {t('healthybowl.home.needsAttention.empty.action', 'Manage alert rules')}\n </button>\n }\n />\n ) : (\n <ul className=\"divide-y divide-border-subtle\">\n {visibleAlerts.map((alert) => (\n <AlertRow\n key={alert.id}\n alert={alert}\n ctaLabel={alertCta(alert.severity)}\n relTime={relTime(alert.timestamp)}\n onOpen={() => openAlert(alert)}\n />\n ))}\n </ul>\n )}\n </div>\n </GlassCard>\n </div>\n\n {/* Anchor row — crop overview (strongest) + compact weather */}\n <div className=\"grid grid-cols-1 gap-6 lg:grid-cols-3\">\n {/* Crop overview — the farm-specific anchor */}\n <GlassCard glow className=\"flex h-full flex-col border-border-seam p-0 lg:col-span-2\">\n <div className=\"flex items-center justify-between px-5 pb-2 pt-5\">\n <div className=\"flex items-center gap-2\">\n <span className=\"flex size-8 items-center justify-center rounded-lg bg-[var(--color-accent-soft)] text-primary [&>svg]:size-4\">\n <Sprout />\n </span>\n <div>\n <h2 className=\"text-base font-semibold text-text-primary\">\n {t('healthybowl.home.cropsAnchor.title', 'Crop overview')}\n </h2>\n <p className=\"text-xs text-text-secondary\">\n {crops.length === 1\n ? t('healthybowl.home.cropsAnchor.subtitleOne', '1 crop in progress')\n : t('healthybowl.home.cropsAnchor.subtitleOther', '{{count}} crops in progress', {\n count: crops.length,\n })}\n </p>\n </div>\n </div>\n {crops.length > 0 && (\n <button\n type=\"button\"\n onClick={() => navigate(buildPath('crops'))}\n className=\"text-xs font-medium text-text-secondary transition-colors hover:text-text-primary focus-visible:text-text-primary focus-visible:outline-none\"\n >\n {t('healthybowl.home.cropsAnchor.viewAll', 'View all crops')}\n </button>\n )}\n </div>\n <div className=\"flex-1 px-3 pb-3\">\n {crops.length === 0 ? (\n <EmptyState\n icon={<Sprout className=\"h-8 w-8 text-primary\" />}\n title={t('healthybowl.home.cropsAnchor.empty.title', 'No active crops')}\n description={t(\n 'healthybowl.home.cropsAnchor.empty.description',\n 'Register your first crop to track growth, health and harvest here.'\n )}\n action={\n <button\n type=\"button\"\n onClick={() => navigate(buildPath('crops'))}\n className=\"inline-flex min-h-[40px] items-center gap-2 rounded-md bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text transition-colors hover:bg-action-primary-bg/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus\"\n >\n <Plus className=\"h-4 w-4\" />\n {t('healthybowl.home.quickActions.addCrop.label', 'Add crop')}\n </button>\n }\n />\n ) : (\n <ul className=\"divide-y divide-border-subtle\">\n {visibleCrops.map((crop) => {\n const stage = (crop.growthStage || crop.status || '').replace(/_/g, ' ').trim();\n const metaLabel = [crop.fieldName, stage].filter(Boolean).join(' · ');\n return (\n <CropRow\n key={crop.id}\n crop={crop}\n metaLabel={metaLabel || t('healthybowl.home.cropsAnchor.noField', 'Unassigned')}\n healthLabel={(crop.healthStatus || 'unknown').replace(/_/g, ' ')}\n harvestLabel={\n crop.expectedHarvestDate\n ? t('healthybowl.home.cropsAnchor.harvest', 'Harvest {{date}}', {\n date: formatDateOnly(crop.expectedHarvestDate),\n })\n : t('healthybowl.home.cropsAnchor.harvestUnknown', 'Harvest date TBD')\n }\n openLabel={t('healthybowl.home.cropsAnchor.open', 'Open')}\n onOpen={() => navigate(buildPath(`crops/${crop.id}`))}\n />\n );\n })}\n </ul>\n )}\n </div>\n </GlassCard>\n\n {/* Weather — secondary */}\n <GlassCard className=\"flex h-full flex-col border-border-seam p-0\">\n <div className=\"px-4 pb-1 pt-4\">\n <h3 className=\"text-sm font-semibold text-text-primary\">\n {t('healthybowl.home.weatherCard.title', 'Current weather')}\n </h3>\n {weather.location && <p className=\"text-xs text-text-secondary\">{weather.location}</p>}\n </div>\n <div className=\"flex flex-1 flex-col gap-4 px-4 pb-4\">\n {!hasWeather ? (\n // No observation. Say so, rather than printing 0 °C / 0% / 0 hPa\n // — fabricated readings are worse than none on a farm dashboard.\n <EmptyState\n icon={<CloudOff className=\"h-8 w-8 text-text-muted\" />}\n title={\n errors.weather\n ? t('healthybowl.home.weatherCard.error.title', 'Weather unavailable')\n : t('healthybowl.home.weatherCard.empty.title', 'No weather yet')\n }\n description={\n errors.weather\n ? t(\n 'healthybowl.home.weatherCard.error.description',\n \"We couldn't load conditions for your farm just now.\"\n )\n : t(\n 'healthybowl.home.weatherCard.empty.description',\n 'Set your farm location to see local conditions here.'\n )\n }\n action={\n <button\n type=\"button\"\n onClick={() => (errors.weather ? refetch() : navigate(buildPath('farm')))}\n className=\"inline-flex min-h-[40px] items-center gap-2 rounded-md border border-border-default px-4 py-2 text-sm font-medium text-text-primary transition-colors hover:bg-bg-elevated focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus\"\n >\n {errors.weather\n ? t('healthybowl.home.weatherCard.error.retry', 'Try again')\n : t('healthybowl.home.weatherCard.empty.action', 'Set farm location')}\n </button>\n }\n />\n ) : (\n <>\n <div className=\"flex items-center justify-between\">\n <div>\n <p className=\"text-4xl font-bold text-text-primary\">{weather.current.temperature}&deg;C</p>\n <p className=\"text-sm text-text-secondary\">{weather.current.condition}</p>\n <p className=\"mt-1 text-xs text-text-secondary\">\n {t('healthybowl.home.weatherCard.feelsLike', 'Feels like')} {weather.current.feelsLike}&deg;C\n </p>\n </div>\n <div className=\"flex flex-col items-center\">\n <Cloud className=\"h-12 w-12 text-text-secondary\" />\n <span className=\"mt-1 text-xs text-text-secondary\">UV {weather.current.uvIndex}</span>\n </div>\n </div>\n\n <div className=\"grid grid-cols-2 gap-3 border-t border-border-subtle pt-3\">\n <div className=\"flex items-center gap-2 text-sm text-text-secondary\">\n <Droplets className=\"h-4 w-4\" />\n <span>\n {weather.current.humidity}% {t('healthybowl.home.weatherCard.humidity', 'Humidity')}\n </span>\n </div>\n <div className=\"flex items-center gap-2 text-sm text-text-secondary\">\n <Wind className=\"h-4 w-4\" />\n <span>{weather.current.windSpeed} km/h</span>\n </div>\n <div className=\"flex items-center gap-2 text-sm text-text-secondary\">\n <Thermometer className=\"h-4 w-4\" />\n <span>{weather.current.pressure} hPa</span>\n </div>\n <div className=\"flex items-center gap-2 text-sm text-text-secondary\">\n <Eye className=\"h-4 w-4\" />\n <span>{weather.current.visibility} km</span>\n </div>\n </div>\n </>\n )}\n\n {weather.forecast.length > 0 && (\n <div className=\"grid grid-cols-4 gap-2 border-t border-border-subtle pt-3\">\n {weather.forecast.slice(0, 4).map((day) => (\n <div key={day.date} className=\"rounded-md bg-bg-sunken/50 p-2 text-center\">\n <p className=\"text-xs font-medium text-text-secondary\">\n {new Date(day.date).toLocaleDateString('en-US', { weekday: 'short' })}\n </p>\n <p className=\"mt-1 text-sm font-semibold text-text-primary\">{day.high}&deg;</p>\n <p className=\"text-xs text-text-secondary\">{day.low}&deg;</p>\n <p className=\"mt-0.5 text-xs text-text-secondary\">{day.precipitation}%</p>\n </div>\n ))}\n </div>\n )}\n\n <button\n type=\"button\"\n onClick={() => navigate(buildPath('weather'))}\n className=\"mt-auto w-full rounded-md border border-border-subtle py-2 text-sm text-text-primary transition-colors hover:bg-bg-sunken/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus\"\n >\n {t('healthybowl.home.weatherCard.viewForecast', 'View full forecast')}\n </button>\n </div>\n </GlassCard>\n </div>\n\n {/* At a glance — demoted secondary metrics with honest zero-states */}\n <section>\n <h3 className=\"mb-2 text-xs font-medium uppercase tracking-wide text-text-secondary\">\n {t('healthybowl.home.glance.title', 'At a glance')}\n </h3>\n <div className=\"grid grid-cols-2 gap-3 sm:grid-cols-4\">\n <MiniStat\n label={t('healthybowl.home.glance.fields', 'Fields')}\n value={String(stats.totalFields)}\n hint={\n stats.totalFields > 0\n ? t('healthybowl.home.glance.fieldsHint', 'Monitored')\n : t('healthybowl.home.glance.fieldsEmpty', 'No fields yet')\n }\n icon={<MapPin />}\n onClick={() => navigate(buildPath('crops/fields'))}\n />\n <MiniStat\n label={t('healthybowl.home.glance.livestock', 'Livestock')}\n value={String(stats.totalAnimals)}\n hint={\n stats.totalAnimals > 0\n ? t('healthybowl.home.glance.livestockHint', 'Under management')\n : t('healthybowl.home.glance.livestockEmpty', 'No livestock added')\n }\n icon={<PawPrint />}\n onClick={() => navigate(buildPath('livestock'))}\n />\n <MiniStat\n label={t('healthybowl.home.glance.organic', 'Organic score')}\n value={\n stats.organicScore > 0\n ? `${stats.organicScore}%`\n : t('healthybowl.home.glance.organicEmpty', 'Not configured')\n }\n hint={stats.organicScore > 0 ? t('healthybowl.home.glance.organicHint', 'Compliance') : undefined}\n icon={<ShieldCheck />}\n onClick={() => navigate(buildPath('compliance'))}\n />\n <MiniStat\n label={t('healthybowl.home.glance.expenses', 'Expenses')}\n value={formatCurrency(stats.totalExpenses, HB_DEFAULT_CURRENCY)}\n hint={\n expenseRatioPercent != null\n ? t('healthybowl.home.glance.expensesRatio', '{{pct}}% of revenue', { pct: expenseRatioPercent })\n : t('healthybowl.home.glance.noRevenue', 'No revenue yet')\n }\n icon={<Wallet />}\n onClick={() => navigate(buildPath('financial'))}\n />\n </div>\n </section>\n </div>\n )}\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAuCA,IAAM,IAAuC;CAC3C,SAAS;CACT,SAAS;CACT,SAAS;CACT,QAAQ;CACT,EAEK,IAAsC;CAC1C,SAAS;CACT,SAAS;CACT,SAAS;CACT,QAAQ;CACT,EAEK,IAAkD;CAAE,UAAU;CAAG,SAAS;CAAG,MAAM;CAAG,EAEtF,IAAsD;CAC1D,UAAU;CACV,SAAS;CACT,MAAM;CACP,EAEK,KAAiB,MAAmB;AACxC,SAAQ,GAAR;EACE,KAAK,Y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