@burdenoff/microfe-healthybowl 2026.714.3 → 2026.714.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.
Files changed (45) hide show
  1. package/dist/healthybowl/HealthyBowlRoutes.js +137 -113
  2. package/dist/healthybowl/HealthyBowlRoutes.js.map +1 -1
  3. package/dist/healthybowl/hooks/useHealthyBowlContacts.js +149 -0
  4. package/dist/healthybowl/hooks/useHealthyBowlContacts.js.map +1 -0
  5. package/dist/healthybowl/hooks/useHealthyBowlLivestockDepth.js +200 -0
  6. package/dist/healthybowl/hooks/useHealthyBowlLivestockDepth.js.map +1 -0
  7. package/dist/healthybowl/hooks/useHealthyBowlStorage.js +162 -0
  8. package/dist/healthybowl/hooks/useHealthyBowlStorage.js.map +1 -0
  9. package/dist/healthybowl/pages/contacts/ContactDetailPage.js +224 -0
  10. package/dist/healthybowl/pages/contacts/ContactDetailPage.js.map +1 -0
  11. package/dist/healthybowl/pages/contacts/ContactFormModal.js +147 -0
  12. package/dist/healthybowl/pages/contacts/ContactFormModal.js.map +1 -0
  13. package/dist/healthybowl/pages/contacts/ContactsPage.js +241 -0
  14. package/dist/healthybowl/pages/contacts/ContactsPage.js.map +1 -0
  15. package/dist/healthybowl/pages/contacts/CsvImportModal.js +155 -0
  16. package/dist/healthybowl/pages/contacts/CsvImportModal.js.map +1 -0
  17. package/dist/healthybowl/pages/contacts/RecordOrderModal.js +131 -0
  18. package/dist/healthybowl/pages/contacts/RecordOrderModal.js.map +1 -0
  19. package/dist/healthybowl/pages/contacts/labels.js +46 -0
  20. package/dist/healthybowl/pages/contacts/labels.js.map +1 -0
  21. package/dist/healthybowl/pages/livestock/AnimalDepthFormModal.js +152 -0
  22. package/dist/healthybowl/pages/livestock/AnimalDepthFormModal.js.map +1 -0
  23. package/dist/healthybowl/pages/livestock/AnimalDepthPage.js +245 -0
  24. package/dist/healthybowl/pages/livestock/AnimalDepthPage.js.map +1 -0
  25. package/dist/healthybowl/pages/livestock/AnimalGroupModal.js +210 -0
  26. package/dist/healthybowl/pages/livestock/AnimalGroupModal.js.map +1 -0
  27. package/dist/healthybowl/pages/livestock/HerdDepthPage.js +189 -0
  28. package/dist/healthybowl/pages/livestock/HerdDepthPage.js.map +1 -0
  29. package/dist/healthybowl/pages/livestock/RecordWeightModal.js +100 -0
  30. package/dist/healthybowl/pages/livestock/RecordWeightModal.js.map +1 -0
  31. package/dist/healthybowl/pages/livestock/depthLabels.js +31 -0
  32. package/dist/healthybowl/pages/livestock/depthLabels.js.map +1 -0
  33. package/dist/healthybowl/pages/storage/PlaceLotModal.js +150 -0
  34. package/dist/healthybowl/pages/storage/PlaceLotModal.js.map +1 -0
  35. package/dist/healthybowl/pages/storage/RecordMovementModal.js +140 -0
  36. package/dist/healthybowl/pages/storage/RecordMovementModal.js.map +1 -0
  37. package/dist/healthybowl/pages/storage/StorageLocationFormModal.js +139 -0
  38. package/dist/healthybowl/pages/storage/StorageLocationFormModal.js.map +1 -0
  39. package/dist/healthybowl/pages/storage/StorageLotDetailPage.js +150 -0
  40. package/dist/healthybowl/pages/storage/StorageLotDetailPage.js.map +1 -0
  41. package/dist/healthybowl/pages/storage/StoragePage.js +251 -0
  42. package/dist/healthybowl/pages/storage/StoragePage.js.map +1 -0
  43. package/dist/healthybowl/pages/storage/labels.js +67 -0
  44. package/dist/healthybowl/pages/storage/labels.js.map +1 -0
  45. package/package.json +1 -1
@@ -0,0 +1,200 @@
1
+ import { useHealthyBowl as e } from "../context/HealthyBowlContext.js";
2
+ import { useCallback as t, useMemo as n } from "react";
3
+ import { gql as r } from "@apollo/client";
4
+ import { useMutation as i, useQuery as a } from "@apollo/client/react";
5
+ //#region src/healthybowl/hooks/useHealthyBowlLivestockDepth.ts
6
+ var o = "00000000-0000-0000-0000-000000000001", s = "\n status\n blocked\n endDate\n daysLeft\n milkClearDate\n meatClearDate\n eggsClearDate\n", c = "\n id\n name\n description\n kind\n smartRule\n color\n animalCount\n createdAt\n updatedAt\n", l = `
7
+ animalId
8
+ tagNumber
9
+ eidTag
10
+ name
11
+ type
12
+ groupId
13
+ groupName
14
+ bodyConditionScore
15
+ adgKgPerDay
16
+ latestWeightKg
17
+ latestWeightAt
18
+ withdrawal { ${s} }
19
+ `, u = "\n id\n animalId\n weightKg\n measuredAt\n method\n notes\n createdAt\n", d = `
20
+ animalId
21
+ tagNumber
22
+ eidTag
23
+ name
24
+ type
25
+ breed
26
+ status
27
+ groupId
28
+ groupName
29
+ bodyConditionScore
30
+ damId
31
+ damTag
32
+ sireId
33
+ sireTag
34
+ grazingPaddock
35
+ rotationDate
36
+ grazingNotes
37
+ adgKgPerDay
38
+ latestWeightKg
39
+ latestWeightAt
40
+ weightHistory { ${u} }
41
+ withdrawal { ${s} }
42
+ `, f = r`
43
+ query HealthyBowlHerdDepth($context: ContextInput!, $groupId: ID, $search: String) {
44
+ healthyBowlHerdDepth(context: $context, groupId: $groupId, search: $search) {
45
+ rows { ${l} }
46
+ summary { totalAnimals animalsInWithdrawal animalsClear complianceMessage }
47
+ groups { ${c} }
48
+ }
49
+ }
50
+ `, p = r`
51
+ query HealthyBowlAnimalDepth($context: ContextInput!, $animalId: ID!) {
52
+ healthyBowlAnimalDepth(context: $context, animalId: $animalId) { ${d} }
53
+ }
54
+ `, m = r`
55
+ query HealthyBowlAnimalGroups($context: ContextInput!) {
56
+ healthyBowlAnimalGroups(context: $context) { ${c} }
57
+ }
58
+ `, h = r`
59
+ mutation UpdateHealthyBowlAnimalDepth($input: UpdateHealthyBowlAnimalDepthInput!) {
60
+ updateHealthyBowlAnimalDepth(input: $input) { ${d} }
61
+ }
62
+ `, g = r`
63
+ mutation CreateHealthyBowlAnimalGroup($input: CreateHealthyBowlAnimalGroupInput!) {
64
+ createHealthyBowlAnimalGroup(input: $input) { ${c} }
65
+ }
66
+ `, _ = r`
67
+ mutation UpdateHealthyBowlAnimalGroup($input: UpdateHealthyBowlAnimalGroupInput!) {
68
+ updateHealthyBowlAnimalGroup(input: $input) { ${c} }
69
+ }
70
+ `, v = r`
71
+ mutation DeleteHealthyBowlAnimalGroup($id: ID!, $context: ContextInput!) {
72
+ deleteHealthyBowlAnimalGroup(id: $id, context: $context)
73
+ }
74
+ `, y = r`
75
+ mutation RecordHealthyBowlAnimalWeight($input: RecordHealthyBowlAnimalWeightInput!) {
76
+ recordHealthyBowlAnimalWeight(input: $input) { ${u} }
77
+ }
78
+ `, b = r`
79
+ mutation DeleteHealthyBowlAnimalWeight($id: ID!, $context: ContextInput!) {
80
+ deleteHealthyBowlAnimalWeight(id: $id, context: $context)
81
+ }
82
+ `;
83
+ function x(r = {}) {
84
+ let { workspaceId: s } = e(), c = s || o, l = n(() => ({ workspaceId: c }), [c]), u = r.herd === !0, d = r.groups === !0, x = r.animalId ?? null, S = a(f, {
85
+ variables: {
86
+ context: l,
87
+ groupId: r.herdGroupId ?? null,
88
+ search: r.herdSearch ?? null
89
+ },
90
+ fetchPolicy: "cache-and-network",
91
+ skip: !u
92
+ }), C = a(m, {
93
+ variables: { context: l },
94
+ fetchPolicy: "cache-and-network",
95
+ skip: !d
96
+ }), w = a(p, {
97
+ variables: {
98
+ context: l,
99
+ animalId: x ?? ""
100
+ },
101
+ fetchPolicy: "cache-and-network",
102
+ skip: !x
103
+ }), [T] = i(h), [E] = i(g), [D] = i(_), [O] = i(v), [k] = i(y), [A] = i(b), j = t(() => S.refetch(), [S]), M = t(() => C.refetch(), [C]), N = t(() => w.refetch(), [w]), P = t(async () => {
104
+ let e = [];
105
+ u && e.push(j().catch(() => void 0)), d && e.push(M().catch(() => void 0)), x && e.push(N().catch(() => void 0)), await Promise.all(e);
106
+ }, [
107
+ u,
108
+ d,
109
+ x,
110
+ j,
111
+ M,
112
+ N
113
+ ]), F = t(async (e) => {
114
+ let t = await T({ variables: { input: {
115
+ ...e,
116
+ context: l
117
+ } } });
118
+ return await P(), t.data?.updateHealthyBowlAnimalDepth;
119
+ }, [
120
+ T,
121
+ l,
122
+ P
123
+ ]), I = t(async (e) => {
124
+ let t = await E({ variables: { input: {
125
+ ...e,
126
+ context: l
127
+ } } });
128
+ return await P(), t.data?.createHealthyBowlAnimalGroup;
129
+ }, [
130
+ E,
131
+ l,
132
+ P
133
+ ]), L = t(async (e) => {
134
+ let t = await D({ variables: { input: {
135
+ ...e,
136
+ context: l
137
+ } } });
138
+ return await P(), t.data?.updateHealthyBowlAnimalGroup;
139
+ }, [
140
+ D,
141
+ l,
142
+ P
143
+ ]), R = t(async (e) => {
144
+ await O({ variables: {
145
+ id: e,
146
+ context: l
147
+ } }), await P();
148
+ }, [
149
+ O,
150
+ l,
151
+ P
152
+ ]), z = t(async (e) => {
153
+ let t = await k({ variables: { input: {
154
+ ...e,
155
+ context: l
156
+ } } });
157
+ return await P(), t.data?.recordHealthyBowlAnimalWeight;
158
+ }, [
159
+ k,
160
+ l,
161
+ P
162
+ ]), B = t(async (e) => {
163
+ await A({ variables: {
164
+ id: e,
165
+ context: l
166
+ } }), await P();
167
+ }, [
168
+ A,
169
+ l,
170
+ P
171
+ ]);
172
+ return {
173
+ herd: S.data?.healthyBowlHerdDepth ?? null,
174
+ groups: C.data?.healthyBowlAnimalGroups ?? S.data?.healthyBowlHerdDepth?.groups ?? [],
175
+ animalDepth: w.data?.healthyBowlAnimalDepth ?? null,
176
+ loading: {
177
+ herd: S.loading,
178
+ groups: C.loading,
179
+ animal: w.loading
180
+ },
181
+ errors: {
182
+ herd: S.error ?? null,
183
+ groups: C.error ?? null,
184
+ animal: w.error ?? null
185
+ },
186
+ refetchHerd: j,
187
+ refetchGroups: M,
188
+ refetchAnimal: N,
189
+ updateAnimalDepth: F,
190
+ createGroup: I,
191
+ updateGroup: L,
192
+ deleteGroup: R,
193
+ recordWeight: z,
194
+ deleteWeight: B
195
+ };
196
+ }
197
+ //#endregion
198
+ export { x as useHealthyBowlLivestockDepth };
199
+
200
+ //# sourceMappingURL=useHealthyBowlLivestockDepth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHealthyBowlLivestockDepth.js","names":[],"sources":["../../../src/healthybowl/hooks/useHealthyBowlLivestockDepth.ts"],"sourcesContent":["/**\n * Deep livestock records — data hook.\n * Roadmap 18 · BOFF-2890 · gap L-1.\n *\n * Broadens the animal record with EID/RFID, body-condition score, manual/smart groups, dam/sire\n * genealogy, grazing/rotation, and a weight history that yields ADG. The medication-withdrawal\n * end-date + \"do not sell\" compliance flag are REUSED from the shipped withdrawal sub-domain\n * (BOFF-2885) and surfaced here on the deep herd view. Documents are declared inline with `gql`\n * (the same escape hatch `useHealthyBowlWithdrawal`/`useHealthyBowlDistribution` use) because\n * codegen validates against the committed `graphql/wspace.graphql` snapshot. Types mirror\n * `wspace-healthybowl-svc/src/modules/healthybowl/schema/livestock-depth.gql`.\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 livestock-depth.gql) ─────────────────────────────────────────\n\nexport interface AnimalWithdrawalBadge {\n status: string;\n blocked: boolean;\n endDate: string | null;\n daysLeft: number;\n milkClearDate: string | null;\n meatClearDate: string | null;\n eggsClearDate: string | null;\n}\n\nexport interface HerdDepthRow {\n animalId: string;\n tagNumber: string;\n eidTag: string | null;\n name: string;\n type: string;\n groupId: string | null;\n groupName: string | null;\n bodyConditionScore: number | null;\n adgKgPerDay: number | null;\n latestWeightKg: number | null;\n latestWeightAt: string | null;\n withdrawal: AnimalWithdrawalBadge;\n}\n\nexport interface AnimalGroup {\n id: string;\n name: string;\n description: string | null;\n kind: string;\n smartRule: Record<string, unknown> | null;\n color: string | null;\n animalCount: number;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface HerdComplianceSummary {\n totalAnimals: number;\n animalsInWithdrawal: number;\n animalsClear: number;\n complianceMessage: string;\n}\n\nexport interface HerdDepthView {\n rows: HerdDepthRow[];\n summary: HerdComplianceSummary;\n groups: AnimalGroup[];\n}\n\nexport interface WeightRecord {\n id: string;\n animalId: string;\n weightKg: number;\n measuredAt: string;\n method: string | null;\n notes: string | null;\n createdAt: string;\n}\n\nexport interface AnimalDepthRecord {\n animalId: string;\n tagNumber: string;\n eidTag: string | null;\n name: string;\n type: string;\n breed: string | null;\n status: string;\n groupId: string | null;\n groupName: string | null;\n bodyConditionScore: number | null;\n damId: string | null;\n damTag: string | null;\n sireId: string | null;\n sireTag: string | null;\n grazingPaddock: string | null;\n rotationDate: string | null;\n grazingNotes: string | null;\n adgKgPerDay: number | null;\n latestWeightKg: number | null;\n latestWeightAt: string | null;\n weightHistory: WeightRecord[];\n withdrawal: AnimalWithdrawalBadge;\n}\n\ninterface HbContext {\n workspaceId: string;\n}\n\n// ── field fragments ─────────────────────────────────────────────────────────\n\nconst WITHDRAWAL_FIELDS = `\n status\n blocked\n endDate\n daysLeft\n milkClearDate\n meatClearDate\n eggsClearDate\n`;\n\nconst GROUP_FIELDS = `\n id\n name\n description\n kind\n smartRule\n color\n animalCount\n createdAt\n updatedAt\n`;\n\nconst HERD_ROW_FIELDS = `\n animalId\n tagNumber\n eidTag\n name\n type\n groupId\n groupName\n bodyConditionScore\n adgKgPerDay\n latestWeightKg\n latestWeightAt\n withdrawal { ${WITHDRAWAL_FIELDS} }\n`;\n\nconst WEIGHT_FIELDS = `\n id\n animalId\n weightKg\n measuredAt\n method\n notes\n createdAt\n`;\n\nconst ANIMAL_DEPTH_FIELDS = `\n animalId\n tagNumber\n eidTag\n name\n type\n breed\n status\n groupId\n groupName\n bodyConditionScore\n damId\n damTag\n sireId\n sireTag\n grazingPaddock\n rotationDate\n grazingNotes\n adgKgPerDay\n latestWeightKg\n latestWeightAt\n weightHistory { ${WEIGHT_FIELDS} }\n withdrawal { ${WITHDRAWAL_FIELDS} }\n`;\n\n// ── documents ─────────────────────────────────────────────────────────────\n\nconst GET_HERD_DEPTH = gql`\n query HealthyBowlHerdDepth($context: ContextInput!, $groupId: ID, $search: String) {\n healthyBowlHerdDepth(context: $context, groupId: $groupId, search: $search) {\n rows { ${HERD_ROW_FIELDS} }\n summary { totalAnimals animalsInWithdrawal animalsClear complianceMessage }\n groups { ${GROUP_FIELDS} }\n }\n }\n`;\n\nconst GET_ANIMAL_DEPTH = gql`\n query HealthyBowlAnimalDepth($context: ContextInput!, $animalId: ID!) {\n healthyBowlAnimalDepth(context: $context, animalId: $animalId) { ${ANIMAL_DEPTH_FIELDS} }\n }\n`;\n\nconst GET_GROUPS = gql`\n query HealthyBowlAnimalGroups($context: ContextInput!) {\n healthyBowlAnimalGroups(context: $context) { ${GROUP_FIELDS} }\n }\n`;\n\nconst UPDATE_ANIMAL_DEPTH = gql`\n mutation UpdateHealthyBowlAnimalDepth($input: UpdateHealthyBowlAnimalDepthInput!) {\n updateHealthyBowlAnimalDepth(input: $input) { ${ANIMAL_DEPTH_FIELDS} }\n }\n`;\n\nconst CREATE_GROUP = gql`\n mutation CreateHealthyBowlAnimalGroup($input: CreateHealthyBowlAnimalGroupInput!) {\n createHealthyBowlAnimalGroup(input: $input) { ${GROUP_FIELDS} }\n }\n`;\n\nconst UPDATE_GROUP = gql`\n mutation UpdateHealthyBowlAnimalGroup($input: UpdateHealthyBowlAnimalGroupInput!) {\n updateHealthyBowlAnimalGroup(input: $input) { ${GROUP_FIELDS} }\n }\n`;\n\nconst DELETE_GROUP = gql`\n mutation DeleteHealthyBowlAnimalGroup($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlAnimalGroup(id: $id, context: $context)\n }\n`;\n\nconst RECORD_WEIGHT = gql`\n mutation RecordHealthyBowlAnimalWeight($input: RecordHealthyBowlAnimalWeightInput!) {\n recordHealthyBowlAnimalWeight(input: $input) { ${WEIGHT_FIELDS} }\n }\n`;\n\nconst DELETE_WEIGHT = gql`\n mutation DeleteHealthyBowlAnimalWeight($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlAnimalWeight(id: $id, context: $context)\n }\n`;\n\n// ── hook ─────────────────────────────────────────────────────────────────────\n\nexport interface UseLivestockDepthOptions {\n /** Fetch the deep herd view (rows + compliance summary + groups). */\n herd?: boolean;\n /** Optional group filter for the herd view. */\n herdGroupId?: string | null;\n /** Optional free-text search (tag / name / EID) for the herd view. */\n herdSearch?: string | null;\n /** Fetch the animal groups list. */\n groups?: boolean;\n /** Fetch a single animal's deep record. */\n animalId?: string | null;\n}\n\nexport function useHealthyBowlLivestockDepth(options: UseLivestockDepthOptions = {}) {\n const { workspaceId } = useHealthyBowl();\n const effectiveWorkspaceId = workspaceId || FALLBACK_WORKSPACE_ID;\n const ctx = useMemo<HbContext>(() => ({ workspaceId: effectiveWorkspaceId }), [effectiveWorkspaceId]);\n\n const enableHerd = options.herd === true;\n const enableGroups = options.groups === true;\n const animalId = options.animalId ?? null;\n const herdGroupId = options.herdGroupId ?? null;\n const herdSearch = options.herdSearch ?? null;\n\n const herdQuery = useQuery<\n { healthyBowlHerdDepth: HerdDepthView },\n { context: HbContext; groupId: string | null; search: string | null }\n >(GET_HERD_DEPTH, {\n variables: { context: ctx, groupId: herdGroupId, search: herdSearch },\n fetchPolicy: 'cache-and-network',\n skip: !enableHerd,\n });\n\n const groupsQuery = useQuery<{ healthyBowlAnimalGroups: AnimalGroup[] }, { context: HbContext }>(GET_GROUPS, {\n variables: { context: ctx },\n fetchPolicy: 'cache-and-network',\n skip: !enableGroups,\n });\n\n const animalQuery = useQuery<{ healthyBowlAnimalDepth: AnimalDepthRecord }, { context: HbContext; animalId: string }>(\n GET_ANIMAL_DEPTH,\n { variables: { context: ctx, animalId: animalId ?? '' }, fetchPolicy: 'cache-and-network', skip: !animalId }\n );\n\n const [updateAnimalDepthMutation] = useMutation(UPDATE_ANIMAL_DEPTH);\n const [createGroupMutation] = useMutation(CREATE_GROUP);\n const [updateGroupMutation] = useMutation(UPDATE_GROUP);\n const [deleteGroupMutation] = useMutation(DELETE_GROUP);\n const [recordWeightMutation] = useMutation(RECORD_WEIGHT);\n const [deleteWeightMutation] = useMutation(DELETE_WEIGHT);\n\n const refetchHerd = useCallback(() => herdQuery.refetch(), [herdQuery]);\n const refetchGroups = useCallback(() => groupsQuery.refetch(), [groupsQuery]);\n const refetchAnimal = useCallback(() => animalQuery.refetch(), [animalQuery]);\n\n const reconcile = useCallback(async () => {\n const runners: Array<Promise<unknown>> = [];\n if (enableHerd) runners.push(refetchHerd().catch(() => undefined));\n if (enableGroups) runners.push(refetchGroups().catch(() => undefined));\n if (animalId) runners.push(refetchAnimal().catch(() => undefined));\n await Promise.all(runners);\n }, [enableHerd, enableGroups, animalId, refetchHerd, refetchGroups, refetchAnimal]);\n\n const updateAnimalDepth = useCallback(\n async (input: Record<string, unknown>): Promise<AnimalDepthRecord | undefined> => {\n const res = await updateAnimalDepthMutation({ variables: { input: { ...input, context: ctx } } });\n await reconcile();\n return (res.data as { updateHealthyBowlAnimalDepth?: AnimalDepthRecord } | null)?.updateHealthyBowlAnimalDepth;\n },\n [updateAnimalDepthMutation, ctx, reconcile]\n );\n\n const createGroup = useCallback(\n async (input: Record<string, unknown>): Promise<AnimalGroup | undefined> => {\n const res = await createGroupMutation({ variables: { input: { ...input, context: ctx } } });\n await reconcile();\n return (res.data as { createHealthyBowlAnimalGroup?: AnimalGroup } | null)?.createHealthyBowlAnimalGroup;\n },\n [createGroupMutation, ctx, reconcile]\n );\n\n const updateGroup = useCallback(\n async (input: Record<string, unknown>): Promise<AnimalGroup | undefined> => {\n const res = await updateGroupMutation({ variables: { input: { ...input, context: ctx } } });\n await reconcile();\n return (res.data as { updateHealthyBowlAnimalGroup?: AnimalGroup } | null)?.updateHealthyBowlAnimalGroup;\n },\n [updateGroupMutation, ctx, reconcile]\n );\n\n const deleteGroup = useCallback(\n async (id: string): Promise<void> => {\n await deleteGroupMutation({ variables: { id, context: ctx } });\n await reconcile();\n },\n [deleteGroupMutation, ctx, reconcile]\n );\n\n const recordWeight = useCallback(\n async (input: Record<string, unknown>): Promise<WeightRecord | undefined> => {\n const res = await recordWeightMutation({ variables: { input: { ...input, context: ctx } } });\n await reconcile();\n return (res.data as { recordHealthyBowlAnimalWeight?: WeightRecord } | null)?.recordHealthyBowlAnimalWeight;\n },\n [recordWeightMutation, ctx, reconcile]\n );\n\n const deleteWeight = useCallback(\n async (id: string): Promise<void> => {\n await deleteWeightMutation({ variables: { id, context: ctx } });\n await reconcile();\n },\n [deleteWeightMutation, ctx, reconcile]\n );\n\n return {\n herd: herdQuery.data?.healthyBowlHerdDepth ?? null,\n groups: groupsQuery.data?.healthyBowlAnimalGroups ?? herdQuery.data?.healthyBowlHerdDepth?.groups ?? [],\n animalDepth: animalQuery.data?.healthyBowlAnimalDepth ?? null,\n loading: {\n herd: herdQuery.loading,\n groups: groupsQuery.loading,\n animal: animalQuery.loading,\n },\n errors: {\n herd: herdQuery.error ?? null,\n groups: groupsQuery.error ?? null,\n animal: animalQuery.error ?? null,\n },\n refetchHerd,\n refetchGroups,\n refetchAnimal,\n updateAnimalDepth,\n createGroup,\n updateGroup,\n deleteGroup,\n recordWeight,\n deleteWeight,\n };\n}\n"],"mappings":";;;;;AAkBA,IAAM,IAAwB,wCA+FxB,IAAoB,qGAUpB,IAAe,0GAYf,IAAkB;;;;;;;;;;;;iBAYP,EAAkB;GAG7B,IAAgB,kFAUhB,IAAsB;;;;;;;;;;;;;;;;;;;;;oBAqBR,EAAc;iBACjB,EAAkB;GAK7B,IAAiB,CAAG;;;eAGX,EAAgB;;iBAEd,EAAa;;;GAKxB,IAAmB,CAAG;;uEAE2C,EAAoB;;GAIrF,IAAa,CAAG;;mDAE6B,EAAa;;GAI1D,IAAsB,CAAG;;oDAEqB,EAAoB;;GAIlE,IAAe,CAAG;;oDAE4B,EAAa;;GAI3D,IAAe,CAAG;;oDAE4B,EAAa;;GAI3D,IAAe,CAAG;;;;GAMlB,IAAgB,CAAG;;qDAE4B,EAAc;;GAI7D,IAAgB,CAAG;;;;;AAqBzB,SAAgB,EAA6B,IAAoC,EAAE,EAAE;CACnF,IAAM,EAAE,mBAA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9C,QAAQ,EAAY,MAAM,2BAA2B,EAAU,MAAM,sBAAsB,UAAU,EAAE;EACvG,aAAa,EAAY,MAAM,0BAA0B;EACzD,SAAS;GACP,MAAM,EAAU;GAChB,QAAQ,EAAY;GACpB,QAAQ,EAAY;GACrB;EACD,QAAQ;GACN,MAAM,EAAU,SAAS;GACzB,QAAQ,EAAY,SAAS;GAC7B,QAAQ,EAAY,SAAS;GAC9B;EACD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD"}
@@ -0,0 +1,162 @@
1
+ import { useHealthyBowl as e } from "../context/HealthyBowlContext.js";
2
+ import { useCallback as t, useMemo as n } from "react";
3
+ import { gql as r } from "@apollo/client";
4
+ import { useMutation as i, useQuery as a } from "@apollo/client/react";
5
+ //#region src/healthybowl/hooks/useHealthyBowlStorage.ts
6
+ var o = "00000000-0000-0000-0000-000000000001", s = "id name kind storageType parentId capacity capacityUnit notes createdAt updatedAt", c = "id locationId locationName warehouseName lotCode produce productId productionBatchId traceBatchId harvestRecordId quantity unit status receivedAt expiryDate notes createdAt updatedAt", l = "id lotId lotCode produce locationId locationName direction quantity unit reason orderId reference occurredAt notes createdAt", u = r`
7
+ query HealthyBowlStorageOverview($context: ContextInput!) {
8
+ healthyBowlStorageOverview(context: $context) {
9
+ warehouses {
10
+ warehouse { ${s} }
11
+ usedCapacity
12
+ capacity
13
+ capacityUnit
14
+ capacityPct
15
+ binCount
16
+ lotCount
17
+ bins { location { ${s} } lots { ${c} } }
18
+ }
19
+ recentMovements { ${l} }
20
+ }
21
+ }
22
+ `, d = r`
23
+ query HealthyBowlStorageLocations($context: ContextInput!, $kind: String) {
24
+ healthyBowlStorageLocations(context: $context, kind: $kind) { ${s} }
25
+ }
26
+ `, f = r`
27
+ query HealthyBowlStorageLot($context: ContextInput!, $id: ID!) {
28
+ healthyBowlStorageLot(id: $id, context: $context) {
29
+ lot { ${c} }
30
+ movements { ${l} }
31
+ }
32
+ }
33
+ `, p = r`
34
+ mutation CreateHealthyBowlStorageLocation($input: CreateHealthyBowlStorageLocationInput!) {
35
+ createHealthyBowlStorageLocation(input: $input) { ${s} }
36
+ }
37
+ `, m = r`
38
+ mutation UpdateHealthyBowlStorageLocation($input: UpdateHealthyBowlStorageLocationInput!) {
39
+ updateHealthyBowlStorageLocation(input: $input) { ${s} }
40
+ }
41
+ `, h = r`
42
+ mutation DeleteHealthyBowlStorageLocation($id: ID!, $context: ContextInput!) {
43
+ deleteHealthyBowlStorageLocation(id: $id, context: $context)
44
+ }
45
+ `, g = r`
46
+ mutation PlaceHealthyBowlStorageLot($input: PlaceHealthyBowlStorageLotInput!) {
47
+ placeHealthyBowlStorageLot(input: $input) { ${c} }
48
+ }
49
+ `, _ = r`
50
+ mutation UpdateHealthyBowlStorageLot($input: UpdateHealthyBowlStorageLotInput!) {
51
+ updateHealthyBowlStorageLot(input: $input) { ${c} }
52
+ }
53
+ `, v = r`
54
+ mutation DeleteHealthyBowlStorageLot($id: ID!, $context: ContextInput!) {
55
+ deleteHealthyBowlStorageLot(id: $id, context: $context)
56
+ }
57
+ `, y = r`
58
+ mutation RecordHealthyBowlStockMovement($input: RecordHealthyBowlStockMovementInput!) {
59
+ recordHealthyBowlStockMovement(input: $input) { ${l} }
60
+ }
61
+ `;
62
+ function b(r = {}) {
63
+ let { workspaceId: s } = e(), c = s || o, l = n(() => ({ workspaceId: c }), [c]), b = r.overview === !0, x = r.locations === !0, S = r.lotId ?? null, C = a(u, {
64
+ variables: { context: l },
65
+ fetchPolicy: "cache-and-network",
66
+ skip: !b
67
+ }), w = a(d, {
68
+ variables: {
69
+ context: l,
70
+ kind: r.locationsKind ?? null
71
+ },
72
+ fetchPolicy: "cache-and-network",
73
+ skip: !x
74
+ }), T = a(f, {
75
+ variables: {
76
+ context: l,
77
+ id: S
78
+ },
79
+ fetchPolicy: "cache-and-network",
80
+ skip: !S
81
+ }), [E] = i(p), [D] = i(m), [O] = i(h), [k] = i(g), [A] = i(_), [j] = i(v), [M] = i(y), N = t(() => b ? C.refetch() : Promise.resolve(), [b, C]), P = t(() => x ? w.refetch() : Promise.resolve(), [x, w]), F = t(() => S ? T.refetch() : Promise.resolve(), [S, T]), I = t(async (e, t) => {
82
+ let n = await e;
83
+ return await Promise.all([N(), F()]), t(n.data);
84
+ }, [N, F]), L = t((e) => I(E({ variables: { input: {
85
+ ...e,
86
+ context: l
87
+ } } }), (e) => e.createHealthyBowlStorageLocation), [
88
+ E,
89
+ l,
90
+ I
91
+ ]), R = t((e) => I(D({ variables: { input: {
92
+ ...e,
93
+ context: l
94
+ } } }), (e) => e.updateHealthyBowlStorageLocation), [
95
+ D,
96
+ l,
97
+ I
98
+ ]), z = t((e) => I(O({ variables: {
99
+ id: e,
100
+ context: l
101
+ } }), (e) => !!e.deleteHealthyBowlStorageLocation), [
102
+ O,
103
+ l,
104
+ I
105
+ ]), B = t((e) => I(k({ variables: { input: {
106
+ ...e,
107
+ context: l
108
+ } } }), (e) => e.placeHealthyBowlStorageLot), [
109
+ k,
110
+ l,
111
+ I
112
+ ]), V = t((e) => I(A({ variables: { input: {
113
+ ...e,
114
+ context: l
115
+ } } }), (e) => e.updateHealthyBowlStorageLot), [
116
+ A,
117
+ l,
118
+ I
119
+ ]), H = t((e) => I(j({ variables: {
120
+ id: e,
121
+ context: l
122
+ } }), (e) => !!e.deleteHealthyBowlStorageLot), [
123
+ j,
124
+ l,
125
+ I
126
+ ]), U = t((e) => I(M({ variables: { input: {
127
+ ...e,
128
+ context: l
129
+ } } }), (e) => e.recordHealthyBowlStockMovement), [
130
+ M,
131
+ l,
132
+ I
133
+ ]);
134
+ return {
135
+ overview: C.data?.healthyBowlStorageOverview ?? null,
136
+ locations: w.data?.healthyBowlStorageLocations ?? [],
137
+ lotDetail: T.data?.healthyBowlStorageLot ?? null,
138
+ loading: {
139
+ overview: C.loading,
140
+ locations: w.loading,
141
+ lot: T.loading
142
+ },
143
+ errors: {
144
+ overview: C.error ?? null,
145
+ lot: T.error ?? null
146
+ },
147
+ refetchOverview: N,
148
+ refetchLocations: P,
149
+ refetchLot: F,
150
+ createLocation: L,
151
+ updateLocation: R,
152
+ deleteLocation: z,
153
+ placeLot: B,
154
+ updateLot: V,
155
+ deleteLot: H,
156
+ recordMovement: U
157
+ };
158
+ }
159
+ //#endregion
160
+ export { b as useHealthyBowlStorage };
161
+
162
+ //# sourceMappingURL=useHealthyBowlStorage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHealthyBowlStorage.js","names":[],"sources":["../../../src/healthybowl/hooks/useHealthyBowlStorage.ts"],"sourcesContent":["/**\n * Warehouse storage — data hook (roadmap 18 · BOFF-2890 · gap K-1).\n *\n * Storage locations (warehouse → bin), lots of produce/milk in a bin, and an IN/OUT\n * stock-movement ledger that keeps each lot's on-hand quantity in sync. Documents are inline\n * `gql` (escape hatch); types mirror `wspace-healthybowl-svc/.../schema/storage.gql`. Reads use\n * `cache-and-network`; writes throw on error then refetch (fe-libs clears the 15s read cache on\n * every successful mutation).\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\nexport interface StorageLocation {\n id: string;\n name: string;\n kind: string;\n storageType: string | null;\n parentId: string | null;\n capacity: number | null;\n capacityUnit: string | null;\n notes: string | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface StorageLot {\n id: string;\n locationId: string;\n locationName: string;\n warehouseName: string;\n lotCode: string;\n produce: string;\n productId: string | null;\n productionBatchId: string | null;\n traceBatchId: string | null;\n harvestRecordId: string | null;\n quantity: number;\n unit: string;\n status: string;\n receivedAt: string | null;\n expiryDate: string | null;\n notes: string | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface StockMovement {\n id: string;\n lotId: string | null;\n lotCode: string | null;\n produce: string | null;\n locationId: string | null;\n locationName: string | null;\n direction: string;\n quantity: number;\n unit: string;\n reason: string | null;\n orderId: string | null;\n reference: string | null;\n occurredAt: string;\n notes: string | null;\n createdAt: string;\n}\n\nexport interface WarehouseBin {\n location: StorageLocation;\n lots: StorageLot[];\n}\n\nexport interface WarehouseSummary {\n warehouse: StorageLocation;\n usedCapacity: number;\n capacity: number | null;\n capacityUnit: string;\n capacityPct: number | null;\n binCount: number;\n lotCount: number;\n bins: WarehouseBin[];\n}\n\nexport interface StorageOverview {\n warehouses: WarehouseSummary[];\n recentMovements: StockMovement[];\n}\n\nexport interface StorageLotDetail {\n lot: StorageLot;\n movements: StockMovement[];\n}\n\ninterface HbContext {\n workspaceId: string;\n}\n\nconst LOCATION_FIELDS = `id name kind storageType parentId capacity capacityUnit notes createdAt updatedAt`;\nconst LOT_FIELDS = `id locationId locationName warehouseName lotCode produce productId productionBatchId traceBatchId harvestRecordId quantity unit status receivedAt expiryDate notes createdAt updatedAt`;\nconst MOVEMENT_FIELDS = `id lotId lotCode produce locationId locationName direction quantity unit reason orderId reference occurredAt notes createdAt`;\n\nconst GET_OVERVIEW = gql`\n query HealthyBowlStorageOverview($context: ContextInput!) {\n healthyBowlStorageOverview(context: $context) {\n warehouses {\n warehouse { ${LOCATION_FIELDS} }\n usedCapacity\n capacity\n capacityUnit\n capacityPct\n binCount\n lotCount\n bins { location { ${LOCATION_FIELDS} } lots { ${LOT_FIELDS} } }\n }\n recentMovements { ${MOVEMENT_FIELDS} }\n }\n }\n`;\n\nconst GET_LOCATIONS = gql`\n query HealthyBowlStorageLocations($context: ContextInput!, $kind: String) {\n healthyBowlStorageLocations(context: $context, kind: $kind) { ${LOCATION_FIELDS} }\n }\n`;\n\nconst GET_LOT = gql`\n query HealthyBowlStorageLot($context: ContextInput!, $id: ID!) {\n healthyBowlStorageLot(id: $id, context: $context) {\n lot { ${LOT_FIELDS} }\n movements { ${MOVEMENT_FIELDS} }\n }\n }\n`;\n\nconst CREATE_LOCATION = gql`\n mutation CreateHealthyBowlStorageLocation($input: CreateHealthyBowlStorageLocationInput!) {\n createHealthyBowlStorageLocation(input: $input) { ${LOCATION_FIELDS} }\n }\n`;\nconst UPDATE_LOCATION = gql`\n mutation UpdateHealthyBowlStorageLocation($input: UpdateHealthyBowlStorageLocationInput!) {\n updateHealthyBowlStorageLocation(input: $input) { ${LOCATION_FIELDS} }\n }\n`;\nconst DELETE_LOCATION = gql`\n mutation DeleteHealthyBowlStorageLocation($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlStorageLocation(id: $id, context: $context)\n }\n`;\nconst PLACE_LOT = gql`\n mutation PlaceHealthyBowlStorageLot($input: PlaceHealthyBowlStorageLotInput!) {\n placeHealthyBowlStorageLot(input: $input) { ${LOT_FIELDS} }\n }\n`;\nconst UPDATE_LOT = gql`\n mutation UpdateHealthyBowlStorageLot($input: UpdateHealthyBowlStorageLotInput!) {\n updateHealthyBowlStorageLot(input: $input) { ${LOT_FIELDS} }\n }\n`;\nconst DELETE_LOT = gql`\n mutation DeleteHealthyBowlStorageLot($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlStorageLot(id: $id, context: $context)\n }\n`;\nconst RECORD_MOVEMENT = gql`\n mutation RecordHealthyBowlStockMovement($input: RecordHealthyBowlStockMovementInput!) {\n recordHealthyBowlStockMovement(input: $input) { ${MOVEMENT_FIELDS} }\n }\n`;\n\nexport interface UseStorageOptions {\n overview?: boolean;\n /** Fetch the flat location list (optionally filtered by kind) — used by the form Selects. */\n locations?: boolean;\n locationsKind?: string | null;\n lotId?: string | null;\n}\n\nexport function useHealthyBowlStorage(options: UseStorageOptions = {}) {\n const { workspaceId } = useHealthyBowl();\n const effectiveWorkspaceId = workspaceId || FALLBACK_WORKSPACE_ID;\n const ctx = useMemo<HbContext>(() => ({ workspaceId: effectiveWorkspaceId }), [effectiveWorkspaceId]);\n\n const enableOverview = options.overview === true;\n const enableLocations = options.locations === true;\n const lotId = options.lotId ?? null;\n\n const overviewQuery = useQuery<{ healthyBowlStorageOverview: StorageOverview }, { context: HbContext }>(\n GET_OVERVIEW,\n {\n variables: { context: ctx },\n fetchPolicy: 'cache-and-network',\n skip: !enableOverview,\n }\n );\n\n const locationsQuery = useQuery<{ healthyBowlStorageLocations: StorageLocation[] }, Record<string, unknown>>(\n GET_LOCATIONS,\n {\n variables: { context: ctx, kind: options.locationsKind ?? null },\n fetchPolicy: 'cache-and-network',\n skip: !enableLocations,\n }\n );\n\n const lotQuery = useQuery<{ healthyBowlStorageLot: StorageLotDetail }, Record<string, unknown>>(GET_LOT, {\n variables: { context: ctx, id: lotId },\n fetchPolicy: 'cache-and-network',\n skip: !lotId,\n });\n\n const [createLocationM] = useMutation(CREATE_LOCATION);\n const [updateLocationM] = useMutation(UPDATE_LOCATION);\n const [deleteLocationM] = useMutation(DELETE_LOCATION);\n const [placeLotM] = useMutation(PLACE_LOT);\n const [updateLotM] = useMutation(UPDATE_LOT);\n const [deleteLotM] = useMutation(DELETE_LOT);\n const [recordMovementM] = useMutation(RECORD_MOVEMENT);\n\n const refetchOverview = useCallback(\n () => (enableOverview ? overviewQuery.refetch() : Promise.resolve()),\n [enableOverview, overviewQuery]\n );\n const refetchLocations = useCallback(\n () => (enableLocations ? locationsQuery.refetch() : Promise.resolve()),\n [enableLocations, locationsQuery]\n );\n const refetchLot = useCallback(() => (lotId ? lotQuery.refetch() : Promise.resolve()), [lotId, lotQuery]);\n\n const run = useCallback(\n async <T>(promise: Promise<{ data?: unknown }>, pick: (d: unknown) => T): Promise<T> => {\n const res = await promise;\n await Promise.all([refetchOverview(), refetchLot()]);\n return pick(res.data);\n },\n [refetchOverview, refetchLot]\n );\n\n const createLocation = useCallback(\n (input: Record<string, unknown>) =>\n run(\n createLocationM({ variables: { input: { ...input, context: ctx } } }),\n (d) => (d as { createHealthyBowlStorageLocation: StorageLocation }).createHealthyBowlStorageLocation\n ),\n [createLocationM, ctx, run]\n );\n const updateLocation = useCallback(\n (input: Record<string, unknown>) =>\n run(\n updateLocationM({ variables: { input: { ...input, context: ctx } } }),\n (d) => (d as { updateHealthyBowlStorageLocation: StorageLocation }).updateHealthyBowlStorageLocation\n ),\n [updateLocationM, ctx, run]\n );\n const deleteLocation = useCallback(\n (id: string) =>\n run(deleteLocationM({ variables: { id, context: ctx } }), (d) =>\n Boolean((d as { deleteHealthyBowlStorageLocation: boolean }).deleteHealthyBowlStorageLocation)\n ),\n [deleteLocationM, ctx, run]\n );\n const placeLot = useCallback(\n (input: Record<string, unknown>) =>\n run(\n placeLotM({ variables: { input: { ...input, context: ctx } } }),\n (d) => (d as { placeHealthyBowlStorageLot: StorageLot }).placeHealthyBowlStorageLot\n ),\n [placeLotM, ctx, run]\n );\n const updateLot = useCallback(\n (input: Record<string, unknown>) =>\n run(\n updateLotM({ variables: { input: { ...input, context: ctx } } }),\n (d) => (d as { updateHealthyBowlStorageLot: StorageLot }).updateHealthyBowlStorageLot\n ),\n [updateLotM, ctx, run]\n );\n const deleteLot = useCallback(\n (id: string) =>\n run(deleteLotM({ variables: { id, context: ctx } }), (d) =>\n Boolean((d as { deleteHealthyBowlStorageLot: boolean }).deleteHealthyBowlStorageLot)\n ),\n [deleteLotM, ctx, run]\n );\n const recordMovement = useCallback(\n (input: Record<string, unknown>) =>\n run(\n recordMovementM({ variables: { input: { ...input, context: ctx } } }),\n (d) => (d as { recordHealthyBowlStockMovement: StockMovement }).recordHealthyBowlStockMovement\n ),\n [recordMovementM, ctx, run]\n );\n\n return {\n overview: overviewQuery.data?.healthyBowlStorageOverview ?? null,\n locations: locationsQuery.data?.healthyBowlStorageLocations ?? [],\n lotDetail: lotQuery.data?.healthyBowlStorageLot ?? null,\n loading: { overview: overviewQuery.loading, locations: locationsQuery.loading, lot: lotQuery.loading },\n errors: { overview: overviewQuery.error ?? null, lot: lotQuery.error ?? null },\n refetchOverview,\n refetchLocations,\n refetchLot,\n createLocation,\n updateLocation,\n deleteLocation,\n placeLot,\n updateLot,\n deleteLot,\n recordMovement,\n };\n}\n"],"mappings":";;;;;AAeA,IAAM,IAAwB,wCAoFxB,IAAkB,qFAClB,I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;EAAC;EAAY;EAAK;EAAI,CACvB,EACK,IAAY,GACf,MACC,EAAI,EAAW,EAAE,WAAW;EAAE;EAAI,SAAS;EAAK,EAAE,CAAC,GAAG,MACpD,EAAS,EAA+C,4BACzD,EACH;EAAC;EAAY;EAAK;EAAI,CACvB,EACK,IAAiB,GACpB,MACC,EACE,EAAgB,EAAE,WAAW,EAAE,OAAO;EAAE,GAAG;EAAO,SAAS;EAAK,EAAE,EAAE,CAAC,GACpE,MAAO,EAAwD,+BACjE,EACH;EAAC;EAAiB;EAAK;EAAI,CAC5B;AAED,QAAO;EACL,UAAU,EAAc,MAAM,8BAA8B;EAC5D,WAAW,EAAe,MAAM,+BAA+B,EAAE;EACjE,WAAW,EAAS,MAAM,yBAAyB;EACnD,SAAS;GAAE,UAAU,EAAc;GAAS,WAAW,EAAe;GAAS,KAAK,EAAS;GAAS;EACtG,QAAQ;GAAE,UAAU,EAAc,SAAS;GAAM,KAAK,EAAS,SAAS;GAAM;EAC9E;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD"}
@@ -0,0 +1,224 @@
1
+ import { formatCurrency as e } from "../../utils/helpers.js";
2
+ import { useBasePath as t } from "../../hooks/useBasePath.js";
3
+ import { PageLayout as n } from "../../components/PageLayout.js";
4
+ import { StatCard as r } from "../../components/StatCard.js";
5
+ import { DataTable as i } from "../../components/DataTable.js";
6
+ import { StatusBadge as a } from "../../components/StatusBadge.js";
7
+ import { ErrorState as o } from "../../components/ErrorState.js";
8
+ import { PageLoader as s } from "../../components/PageLoader.js";
9
+ import { useToast as c } from "../../hooks/useToast.js";
10
+ import "../../components/index.js";
11
+ import { useHealthyBowlContacts as l } from "../../hooks/useHealthyBowlContacts.js";
12
+ import { ContactFormModal as u } from "./ContactFormModal.js";
13
+ import { RecordOrderModal as d } from "./RecordOrderModal.js";
14
+ import { contactInitials as f, contactTypeLabel as p, contactTypeVariant as m, orderStatusVariant as h } from "./labels.js";
15
+ import { useState as g } from "react";
16
+ import { useI18n as _ } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
17
+ import { ArrowLeft as v, Mail as y, MapPin as b, Pencil as x, Phone as S, Plus as C } from "lucide-react";
18
+ import { useNavigate as w, useParams as T } from "react-router-dom";
19
+ import { jsx as E, jsxs as D } from "react/jsx-runtime";
20
+ import { Button as O } from "@burdenoff/fe-libs/ui";
21
+ //#region src/healthybowl/pages/contacts/ContactDetailPage.tsx
22
+ var k = () => {
23
+ let { t: k } = _(), A = w(), { buildPath: j } = t(), { toast: M } = c(), { contactId: N } = T(), { contactDetail: P, loading: F, errors: I, refetchDetail: L, updateContact: R, recordOrder: z } = l({ detailId: N ?? null }), [B, V] = g(!1), [H, U] = g(!1), W = async (e) => {
24
+ await R(e), M({
25
+ title: k("healthybowl.contacts.toast.updated", "Contact updated"),
26
+ variant: "success"
27
+ });
28
+ }, G = async (e) => {
29
+ await z({
30
+ ...e,
31
+ contactId: N
32
+ }), M({
33
+ title: k("healthybowl.contacts.toast.orderRecorded", "Order recorded"),
34
+ variant: "success"
35
+ });
36
+ }, K = [
37
+ {
38
+ key: "orderNumber",
39
+ header: k("healthybowl.contacts.orders.number", "Order #"),
40
+ render: (e) => /* @__PURE__ */ E("span", {
41
+ className: "font-medium text-text-primary",
42
+ children: e.orderNumber
43
+ })
44
+ },
45
+ {
46
+ key: "date",
47
+ header: k("healthybowl.contacts.orders.date", "Date"),
48
+ render: (e) => /* @__PURE__ */ E("span", {
49
+ className: "tabular-nums text-text-secondary",
50
+ children: e.date
51
+ })
52
+ },
53
+ {
54
+ key: "items",
55
+ header: k("healthybowl.contacts.orders.items", "Items"),
56
+ render: (e) => /* @__PURE__ */ E("span", {
57
+ className: "text-text-secondary",
58
+ children: e.itemsSummary
59
+ })
60
+ },
61
+ {
62
+ key: "quantity",
63
+ header: k("healthybowl.contacts.orders.quantity", "Quantity"),
64
+ render: (e) => /* @__PURE__ */ E("span", {
65
+ className: "tabular-nums",
66
+ children: e.quantity || "—"
67
+ })
68
+ },
69
+ {
70
+ key: "amount",
71
+ header: k("healthybowl.contacts.orders.amount", "Amount"),
72
+ render: (t) => /* @__PURE__ */ E("span", {
73
+ className: "tabular-nums",
74
+ children: e(t.amount, "INR")
75
+ })
76
+ },
77
+ {
78
+ key: "status",
79
+ header: k("healthybowl.contacts.orders.status", "Status"),
80
+ render: (e) => /* @__PURE__ */ E(a, {
81
+ variant: h(e.status),
82
+ label: e.status.toLowerCase()
83
+ })
84
+ }
85
+ ];
86
+ if (F.detail && !P) return /* @__PURE__ */ E(s, {});
87
+ if (I.detail && !P || !P) return /* @__PURE__ */ E("div", {
88
+ className: "p-4",
89
+ children: /* @__PURE__ */ E(o, {
90
+ description: I.detail?.message ?? k("healthybowl.contacts.detail.notFound", "Contact not found."),
91
+ onRetry: () => void L()
92
+ })
93
+ });
94
+ let { contact: q, orders: J, summary: Y } = P;
95
+ return /* @__PURE__ */ D(n, {
96
+ title: q.name,
97
+ description: p(q.type),
98
+ hideHelp: !0,
99
+ children: [
100
+ /* @__PURE__ */ D("button", {
101
+ type: "button",
102
+ onClick: () => A(j("contacts")),
103
+ className: "mb-3 inline-flex items-center gap-1 text-sm text-text-secondary hover:text-text-primary",
104
+ children: [/* @__PURE__ */ E(v, { className: "h-4 w-4" }), k("healthybowl.contacts.detail.back", "Contacts")]
105
+ }),
106
+ /* @__PURE__ */ D("div", {
107
+ className: "rounded-xl border border-border-subtle bg-bg-surface p-4",
108
+ children: [/* @__PURE__ */ D("div", {
109
+ className: "flex flex-wrap items-start justify-between gap-4",
110
+ children: [/* @__PURE__ */ D("div", {
111
+ className: "flex items-center gap-3",
112
+ children: [/* @__PURE__ */ E("div", {
113
+ className: "flex h-12 w-12 items-center justify-center rounded-full bg-accent-teal/10 text-lg font-semibold text-accent-teal",
114
+ children: f(q.name)
115
+ }), /* @__PURE__ */ D("div", { children: [/* @__PURE__ */ D("div", {
116
+ className: "flex items-center gap-2",
117
+ children: [/* @__PURE__ */ E("h2", {
118
+ className: "text-lg font-semibold text-text-primary",
119
+ children: q.name
120
+ }), /* @__PURE__ */ E(a, {
121
+ variant: m(q.type),
122
+ label: p(q.type)
123
+ })]
124
+ }), /* @__PURE__ */ D("div", {
125
+ className: "mt-1 flex flex-wrap gap-x-4 gap-y-1 text-sm text-text-secondary",
126
+ children: [
127
+ q.phone ? /* @__PURE__ */ D("span", {
128
+ className: "inline-flex items-center gap-1",
129
+ children: [/* @__PURE__ */ E(S, { className: "h-3.5 w-3.5" }), q.phone]
130
+ }) : null,
131
+ q.email ? /* @__PURE__ */ D("span", {
132
+ className: "inline-flex items-center gap-1",
133
+ children: [/* @__PURE__ */ E(y, { className: "h-3.5 w-3.5" }), q.email]
134
+ }) : null,
135
+ q.address ? /* @__PURE__ */ D("span", {
136
+ className: "inline-flex items-center gap-1",
137
+ children: [/* @__PURE__ */ E(b, { className: "h-3.5 w-3.5" }), q.address]
138
+ }) : null,
139
+ q.gstin ? /* @__PURE__ */ D("span", {
140
+ className: "text-text-tertiary",
141
+ children: ["GSTIN ", q.gstin]
142
+ }) : null
143
+ ]
144
+ })] })]
145
+ }), /* @__PURE__ */ D(O, {
146
+ variant: "outline",
147
+ onClick: () => V(!0),
148
+ children: [/* @__PURE__ */ E(x, { className: "h-4 w-4" }), k("healthybowl.contacts.detail.edit", "Edit")]
149
+ })]
150
+ }), q.notes ? /* @__PURE__ */ D("div", {
151
+ className: "mt-4 border-t border-border-subtle pt-3",
152
+ children: [/* @__PURE__ */ E("div", {
153
+ className: "text-xs font-medium uppercase tracking-wide text-text-tertiary",
154
+ children: k("healthybowl.contacts.detail.notes", "Notes")
155
+ }), /* @__PURE__ */ E("p", {
156
+ className: "mt-1 whitespace-pre-wrap text-sm text-text-secondary",
157
+ children: q.notes
158
+ })]
159
+ }) : null]
160
+ }),
161
+ /* @__PURE__ */ D("div", {
162
+ className: "mt-4 grid grid-cols-1 gap-3 sm:grid-cols-3",
163
+ children: [
164
+ /* @__PURE__ */ E(r, {
165
+ label: k("healthybowl.contacts.detail.totalOrders", "Total Orders"),
166
+ value: Y.totalOrders
167
+ }),
168
+ /* @__PURE__ */ E(r, {
169
+ label: k("healthybowl.contacts.detail.lifetimeValue", "Lifetime Value"),
170
+ value: e(Y.lifetimeValue, "INR")
171
+ }),
172
+ /* @__PURE__ */ E(r, {
173
+ label: k("healthybowl.contacts.detail.lastOrder", "Last Order"),
174
+ value: Y.lastOrderDate ?? "—"
175
+ })
176
+ ]
177
+ }),
178
+ /* @__PURE__ */ D("div", {
179
+ className: "mt-4",
180
+ children: [/* @__PURE__ */ D("div", {
181
+ className: "mb-2 flex items-center justify-between",
182
+ children: [/* @__PURE__ */ D("h3", {
183
+ className: "text-sm font-semibold text-text-primary",
184
+ children: [
185
+ k("healthybowl.contacts.detail.orderHistory", "Order History"),
186
+ " (",
187
+ J.length,
188
+ ")"
189
+ ]
190
+ }), /* @__PURE__ */ D(O, {
191
+ variant: "outline",
192
+ size: "sm",
193
+ onClick: () => U(!0),
194
+ children: [/* @__PURE__ */ E(C, { className: "h-3.5 w-3.5" }), k("healthybowl.contacts.detail.logOrder", "Log Order")]
195
+ })]
196
+ }), J.length === 0 ? /* @__PURE__ */ E("div", {
197
+ className: "rounded-lg border border-border-subtle bg-bg-sunken px-4 py-8 text-center text-sm text-text-secondary",
198
+ children: k("healthybowl.contacts.detail.noOrders", "No orders linked to this contact yet.")
199
+ }) : /* @__PURE__ */ E(i, {
200
+ columns: K,
201
+ data: J,
202
+ keyField: "id",
203
+ pageSize: 10
204
+ })]
205
+ }),
206
+ /* @__PURE__ */ E(u, {
207
+ open: B,
208
+ onClose: () => V(!1),
209
+ contact: q,
210
+ onSubmit: W
211
+ }),
212
+ /* @__PURE__ */ E(d, {
213
+ open: H,
214
+ onClose: () => U(!1),
215
+ contactName: q.name,
216
+ onSubmit: G
217
+ })
218
+ ]
219
+ });
220
+ };
221
+ //#endregion
222
+ export { k as ContactDetailPage };
223
+
224
+ //# sourceMappingURL=ContactDetailPage.js.map