@burdenoff/microfe-healthybowl 2026.814.5 → 2026.814.6
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,42 +3,59 @@ import { useCallback as t } 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/useSuppliers.ts
|
|
6
|
-
var a = "\n id\n name\n contactPerson\n type\n location\n email\n phone\n address\n certification\n notes\n entityTags {\n id\n key\n label\n color\n vocabularyKey\n }\n comProfileId\n", o = n`
|
|
6
|
+
var a = "\n id\n name\n contactPerson\n type\n location\n email\n phone\n address\n certification\n notes\n entityTags {\n id\n key\n label\n color\n vocabularyKey\n }\n comProfileId\n directoryId\n", o = n`
|
|
7
7
|
query HealthyBowlSuppliers($context: ContextInput!) {
|
|
8
8
|
healthyBowlSuppliers(context: $context) {
|
|
9
9
|
${a}
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
`, s = n`
|
|
13
|
+
query HealthyBowlSupplierDirectory($context: ContextInput!, $filter: HealthyBowlSupplierDirectoryFilter) {
|
|
14
|
+
getHealthyBowlSupplierDirectory(context: $context, filter: $filter) {
|
|
15
|
+
id
|
|
16
|
+
name
|
|
17
|
+
type
|
|
18
|
+
state
|
|
19
|
+
district
|
|
20
|
+
cropsOffered
|
|
21
|
+
organicInputCertified
|
|
22
|
+
contactPerson
|
|
23
|
+
email
|
|
24
|
+
phone
|
|
25
|
+
address
|
|
26
|
+
status
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
`, c = n`
|
|
13
30
|
mutation CreateHealthyBowlSupplier($input: CreateHealthyBowlSupplierInput!) {
|
|
14
31
|
createHealthyBowlSupplier(input: $input) {
|
|
15
32
|
${a}
|
|
16
33
|
}
|
|
17
34
|
}
|
|
18
|
-
`,
|
|
35
|
+
`, l = n`
|
|
19
36
|
mutation UpdateHealthyBowlSupplier($input: UpdateHealthyBowlSupplierInput!) {
|
|
20
37
|
updateHealthyBowlSupplier(input: $input) {
|
|
21
38
|
${a}
|
|
22
39
|
}
|
|
23
40
|
}
|
|
24
|
-
`,
|
|
41
|
+
`, u = n`
|
|
25
42
|
mutation DeleteHealthyBowlSupplier($id: ID!, $context: ContextInput!) {
|
|
26
43
|
deleteHealthyBowlSupplier(id: $id, context: $context)
|
|
27
44
|
}
|
|
28
|
-
`,
|
|
45
|
+
`, d = n`
|
|
29
46
|
mutation ImportHealthyBowlSuppliers($rows: [ImportHealthyBowlSupplierRow!]!, $context: ContextInput!) {
|
|
30
47
|
importHealthyBowlSuppliers(rows: $rows, context: $context) {
|
|
31
48
|
${a}
|
|
32
49
|
}
|
|
33
50
|
}
|
|
34
51
|
`;
|
|
35
|
-
function
|
|
36
|
-
let { workspaceId: n } = e(), a = { workspaceId: n }, { data:
|
|
52
|
+
function f() {
|
|
53
|
+
let { workspaceId: n } = e(), a = { workspaceId: n }, { data: s, loading: f, error: p, refetch: m } = i(o, {
|
|
37
54
|
variables: { context: a },
|
|
38
55
|
skip: !n,
|
|
39
56
|
fetchPolicy: "cache-and-network",
|
|
40
57
|
notifyOnNetworkStatusChange: !0
|
|
41
|
-
}), [h] = r(
|
|
58
|
+
}), [h] = r(c), [g] = r(l), [_] = r(u), [v] = r(d), y = t(async (e) => {
|
|
42
59
|
await h({ variables: { input: {
|
|
43
60
|
...e,
|
|
44
61
|
context: a
|
|
@@ -77,7 +94,7 @@ function d() {
|
|
|
77
94
|
n
|
|
78
95
|
]);
|
|
79
96
|
return {
|
|
80
|
-
suppliers:
|
|
97
|
+
suppliers: s?.healthyBowlSuppliers ?? [],
|
|
81
98
|
loading: f,
|
|
82
99
|
error: p,
|
|
83
100
|
refetch: m,
|
|
@@ -87,7 +104,24 @@ function d() {
|
|
|
87
104
|
importSuppliers: S
|
|
88
105
|
};
|
|
89
106
|
}
|
|
107
|
+
function p(t) {
|
|
108
|
+
let { workspaceId: n } = e(), { data: r, loading: a, error: o, refetch: c } = i(s, {
|
|
109
|
+
variables: {
|
|
110
|
+
context: { workspaceId: n },
|
|
111
|
+
filter: t ?? null
|
|
112
|
+
},
|
|
113
|
+
skip: !n,
|
|
114
|
+
fetchPolicy: "cache-and-network",
|
|
115
|
+
notifyOnNetworkStatusChange: !0
|
|
116
|
+
});
|
|
117
|
+
return {
|
|
118
|
+
directory: r?.getHealthyBowlSupplierDirectory ?? [],
|
|
119
|
+
loading: a,
|
|
120
|
+
error: o,
|
|
121
|
+
refetch: c
|
|
122
|
+
};
|
|
123
|
+
}
|
|
90
124
|
//#endregion
|
|
91
|
-
export {
|
|
125
|
+
export { p as useSupplierDirectory, f as useSuppliers };
|
|
92
126
|
|
|
93
127
|
//# sourceMappingURL=useSuppliers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSuppliers.js","names":[],"sources":["../../../src/healthybowl/hooks/useSuppliers.ts"],"sourcesContent":["/**\n * Suppliers data hook (Nursery / Seed provenance + Suppliers, roadmap #5).\n *\n * The offline codegen doesn't type the Supplier operations, so — mirroring the\n * raw-gql pattern used for the Master Plant List (`usePlantCatalog`) and the\n * Field-Map Bed/MapFeature ops — these are hand-written `gql` documents executed\n * directly against the live gateway. Every op carries the workspace `context`.\n * @module healthybowl\n */\nimport { useCallback } from 'react';\nimport type { HBTagLike } from '../components/HBEntityTags';\nimport { gql } from '@apollo/client';\nimport { useMutation, useQuery } from '@apollo/client/react';\nimport { useHealthyBowl } from '../context/HealthyBowlContext';\n\n/** A supplier of seeds, seedlings, fertilizer, or equipment. */\nexport interface Supplier {\n id: string;\n name: string;\n contactPerson?: string | null;\n /** Free-form supplier type, e.g. Seed / Seedling / Fertilizer / Equipment. */\n type?: string | null;\n location?: string | null;\n email?: string | null;\n phone?: string | null;\n address?: string | null;\n /** Certification held by the supplier, e.g. \"NPOP Certified\". */\n certification?: string | null;\n notes?: string | null;\n /** Universal entity-owned tags, the same set Crop and MarketplaceProduct carry. */\n entityTags?: HBTagLike[] | null;\n /** Optional link to a ComradeCircle ComProfile (loose reference, no FK). */\n comProfileId?: string | null;\n}\n\n/** Editable fields for create/update (context is attached from the hook). */\nexport interface SupplierInput {\n name: string;\n contactPerson?: string | null;\n type?: string | null;\n location?: string | null;\n email?: string | null;\n phone?: string | null;\n address?: string | null;\n certification?: string | null;\n notes?: string | null;\n comProfileId?: string | null;\n}\n\n/** A single supplier row for bulk CSV import (no context; supplied on the parent op). */\nexport interface ImportSupplierRow {\n name: string;\n contactPerson?: string | null;\n type?: string | null;\n location?: string | null;\n email?: string | null;\n phone?: string | null;\n address?: string | null;\n certification?: string | null;\n notes?: string | null;\n comProfileId?: string | null;\n}\n\nconst SUPPLIER_FIELDS = `\n id\n name\n contactPerson\n type\n location\n email\n phone\n address\n certification\n notes\n entityTags {\n id\n key\n label\n color\n vocabularyKey\n }\n comProfileId\n`;\n\nconst SUPPLIERS_QUERY = gql`\n query HealthyBowlSuppliers($context: ContextInput!) {\n healthyBowlSuppliers(context: $context) {\n ${SUPPLIER_FIELDS}\n }\n }\n`;\n\nconst CREATE_SUPPLIER = gql`\n mutation CreateHealthyBowlSupplier($input: CreateHealthyBowlSupplierInput!) {\n createHealthyBowlSupplier(input: $input) {\n ${SUPPLIER_FIELDS}\n }\n }\n`;\n\nconst UPDATE_SUPPLIER = gql`\n mutation UpdateHealthyBowlSupplier($input: UpdateHealthyBowlSupplierInput!) {\n updateHealthyBowlSupplier(input: $input) {\n ${SUPPLIER_FIELDS}\n }\n }\n`;\n\nconst DELETE_SUPPLIER = gql`\n mutation DeleteHealthyBowlSupplier($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlSupplier(id: $id, context: $context)\n }\n`;\n\nconst IMPORT_SUPPLIERS = gql`\n mutation ImportHealthyBowlSuppliers($rows: [ImportHealthyBowlSupplierRow!]!, $context: ContextInput!) {\n importHealthyBowlSuppliers(rows: $rows, context: $context) {\n ${SUPPLIER_FIELDS}\n }\n }\n`;\n\ninterface SuppliersQueryData {\n healthyBowlSuppliers: Supplier[];\n}\n\n/**\n * Loads the supplier list for the active workspace and exposes create / update /\n * delete / bulk-import helpers. Mutations refetch the list so the caller's view\n * stays in sync without hand-managing the cache.\n */\nexport function useSuppliers() {\n const { workspaceId } = useHealthyBowl();\n const context = { workspaceId };\n\n const { data, loading, error, refetch } = useQuery<SuppliersQueryData>(SUPPLIERS_QUERY, {\n variables: { context },\n skip: !workspaceId,\n fetchPolicy: 'cache-and-network',\n notifyOnNetworkStatusChange: true,\n });\n\n const [createMutation] = useMutation(CREATE_SUPPLIER);\n const [updateMutation] = useMutation(UPDATE_SUPPLIER);\n const [deleteMutation] = useMutation(DELETE_SUPPLIER);\n const [importMutation] = useMutation(IMPORT_SUPPLIERS);\n\n const createSupplier = useCallback(\n async (input: SupplierInput) => {\n await createMutation({ variables: { input: { ...input, context } } });\n await refetch();\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [createMutation, refetch, workspaceId]\n );\n\n const updateSupplier = useCallback(\n async (id: string, input: SupplierInput) => {\n await updateMutation({ variables: { input: { id, ...input, context } } });\n await refetch();\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [updateMutation, refetch, workspaceId]\n );\n\n const deleteSupplier = useCallback(\n async (id: string) => {\n await deleteMutation({ variables: { id, context } });\n await refetch();\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [deleteMutation, refetch, workspaceId]\n );\n\n const importSuppliers = useCallback(\n async (rows: ImportSupplierRow[]) => {\n await importMutation({ variables: { rows, context } });\n await refetch();\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [importMutation, refetch, workspaceId]\n );\n\n return {\n suppliers: data?.healthyBowlSuppliers ?? [],\n loading,\n error,\n refetch,\n createSupplier,\n updateSupplier,\n deleteSupplier,\n importSuppliers,\n };\n}\n"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"useSuppliers.js","names":[],"sources":["../../../src/healthybowl/hooks/useSuppliers.ts"],"sourcesContent":["/**\n * Suppliers data hook (Nursery / Seed provenance + Suppliers, roadmap #5).\n *\n * The offline codegen doesn't type the Supplier operations, so — mirroring the\n * raw-gql pattern used for the Master Plant List (`usePlantCatalog`) and the\n * Field-Map Bed/MapFeature ops — these are hand-written `gql` documents executed\n * directly against the live gateway. Every op carries the workspace `context`.\n * @module healthybowl\n */\nimport { useCallback } from 'react';\nimport type { HBTagLike } from '../components/HBEntityTags';\nimport { gql } from '@apollo/client';\nimport { useMutation, useQuery } from '@apollo/client/react';\nimport { useHealthyBowl } from '../context/HealthyBowlContext';\n\n/** A supplier of seeds, seedlings, fertilizer, or equipment. */\nexport interface Supplier {\n id: string;\n name: string;\n contactPerson?: string | null;\n /** Free-form supplier type, e.g. Seed / Seedling / Fertilizer / Equipment. */\n type?: string | null;\n location?: string | null;\n email?: string | null;\n phone?: string | null;\n address?: string | null;\n /** Certification held by the supplier, e.g. \"NPOP Certified\". */\n certification?: string | null;\n notes?: string | null;\n /** Universal entity-owned tags, the same set Crop and MarketplaceProduct carry. */\n entityTags?: HBTagLike[] | null;\n /** Optional link to a ComradeCircle ComProfile (loose reference, no FK). */\n comProfileId?: string | null;\n /** Id of the shared directory row this supplier was saved from, if any (BOFF-6096). */\n directoryId?: string | null;\n}\n\n/** Editable fields for create/update (context is attached from the hook). */\nexport interface SupplierInput {\n name: string;\n contactPerson?: string | null;\n type?: string | null;\n location?: string | null;\n email?: string | null;\n phone?: string | null;\n address?: string | null;\n certification?: string | null;\n notes?: string | null;\n comProfileId?: string | null;\n directoryId?: string | null;\n}\n\n/** A shared, admin-curated seed/nursery/input supplier directory entry (BOFF-6096). */\nexport interface SeedSupplierDirectoryEntry {\n id: string;\n name: string;\n type: string;\n state: string;\n district: string;\n cropsOffered: string[];\n organicInputCertified: boolean;\n contactPerson?: string | null;\n email?: string | null;\n phone?: string | null;\n address?: string | null;\n status: string;\n}\n\n/** Filter for browsing the shared directory. Every field is optional and combines with AND semantics. */\nexport interface SupplierDirectoryFilter {\n crop?: string | null;\n type?: string | null;\n state?: string | null;\n district?: string | null;\n organicInputCertified?: boolean | null;\n}\n\n/** A single supplier row for bulk CSV import (no context; supplied on the parent op). */\nexport interface ImportSupplierRow {\n name: string;\n contactPerson?: string | null;\n type?: string | null;\n location?: string | null;\n email?: string | null;\n phone?: string | null;\n address?: string | null;\n certification?: string | null;\n notes?: string | null;\n comProfileId?: string | null;\n}\n\nconst SUPPLIER_FIELDS = `\n id\n name\n contactPerson\n type\n location\n email\n phone\n address\n certification\n notes\n entityTags {\n id\n key\n label\n color\n vocabularyKey\n }\n comProfileId\n directoryId\n`;\n\nconst SUPPLIERS_QUERY = gql`\n query HealthyBowlSuppliers($context: ContextInput!) {\n healthyBowlSuppliers(context: $context) {\n ${SUPPLIER_FIELDS}\n }\n }\n`;\n\n// Offline codegen doesn't type this op either — raw gql, mirroring SUPPLIERS_QUERY.\n// `context` is an authentication gate only; the same catalog rows render for every\n// workspace (BOFF-6096).\nconst SUPPLIER_DIRECTORY_QUERY = gql`\n query HealthyBowlSupplierDirectory($context: ContextInput!, $filter: HealthyBowlSupplierDirectoryFilter) {\n getHealthyBowlSupplierDirectory(context: $context, filter: $filter) {\n id\n name\n type\n state\n district\n cropsOffered\n organicInputCertified\n contactPerson\n email\n phone\n address\n status\n }\n }\n`;\n\nconst CREATE_SUPPLIER = gql`\n mutation CreateHealthyBowlSupplier($input: CreateHealthyBowlSupplierInput!) {\n createHealthyBowlSupplier(input: $input) {\n ${SUPPLIER_FIELDS}\n }\n }\n`;\n\nconst UPDATE_SUPPLIER = gql`\n mutation UpdateHealthyBowlSupplier($input: UpdateHealthyBowlSupplierInput!) {\n updateHealthyBowlSupplier(input: $input) {\n ${SUPPLIER_FIELDS}\n }\n }\n`;\n\nconst DELETE_SUPPLIER = gql`\n mutation DeleteHealthyBowlSupplier($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlSupplier(id: $id, context: $context)\n }\n`;\n\nconst IMPORT_SUPPLIERS = gql`\n mutation ImportHealthyBowlSuppliers($rows: [ImportHealthyBowlSupplierRow!]!, $context: ContextInput!) {\n importHealthyBowlSuppliers(rows: $rows, context: $context) {\n ${SUPPLIER_FIELDS}\n }\n }\n`;\n\ninterface SuppliersQueryData {\n healthyBowlSuppliers: Supplier[];\n}\n\n/**\n * Loads the supplier list for the active workspace and exposes create / update /\n * delete / bulk-import helpers. Mutations refetch the list so the caller's view\n * stays in sync without hand-managing the cache.\n */\nexport function useSuppliers() {\n const { workspaceId } = useHealthyBowl();\n const context = { workspaceId };\n\n const { data, loading, error, refetch } = useQuery<SuppliersQueryData>(SUPPLIERS_QUERY, {\n variables: { context },\n skip: !workspaceId,\n fetchPolicy: 'cache-and-network',\n notifyOnNetworkStatusChange: true,\n });\n\n const [createMutation] = useMutation(CREATE_SUPPLIER);\n const [updateMutation] = useMutation(UPDATE_SUPPLIER);\n const [deleteMutation] = useMutation(DELETE_SUPPLIER);\n const [importMutation] = useMutation(IMPORT_SUPPLIERS);\n\n const createSupplier = useCallback(\n async (input: SupplierInput) => {\n await createMutation({ variables: { input: { ...input, context } } });\n await refetch();\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [createMutation, refetch, workspaceId]\n );\n\n const updateSupplier = useCallback(\n async (id: string, input: SupplierInput) => {\n await updateMutation({ variables: { input: { id, ...input, context } } });\n await refetch();\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [updateMutation, refetch, workspaceId]\n );\n\n const deleteSupplier = useCallback(\n async (id: string) => {\n await deleteMutation({ variables: { id, context } });\n await refetch();\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [deleteMutation, refetch, workspaceId]\n );\n\n const importSuppliers = useCallback(\n async (rows: ImportSupplierRow[]) => {\n await importMutation({ variables: { rows, context } });\n await refetch();\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [importMutation, refetch, workspaceId]\n );\n\n return {\n suppliers: data?.healthyBowlSuppliers ?? [],\n loading,\n error,\n refetch,\n createSupplier,\n updateSupplier,\n deleteSupplier,\n importSuppliers,\n };\n}\n\ninterface SupplierDirectoryQueryData {\n getHealthyBowlSupplierDirectory: SeedSupplierDirectoryEntry[];\n}\n\n/**\n * Browses the shared, admin-curated seed/nursery supplier directory (BOFF-6096). Reference\n * data — the identical catalog rows render for every workspace, only `context` is required\n * (an authentication gate, not a data scope). Re-queries the server on every filter change\n * rather than filtering client-side, matching the mandi price page's server-filtered pattern.\n */\nexport function useSupplierDirectory(filter?: SupplierDirectoryFilter) {\n const { workspaceId } = useHealthyBowl();\n const context = { workspaceId };\n\n const { data, loading, error, refetch } = useQuery<SupplierDirectoryQueryData>(SUPPLIER_DIRECTORY_QUERY, {\n variables: { context, filter: filter ?? null },\n skip: !workspaceId,\n fetchPolicy: 'cache-and-network',\n notifyOnNetworkStatusChange: true,\n });\n\n return {\n directory: data?.getHealthyBowlSupplierDirectory ?? [],\n loading,\n error,\n refetch,\n };\n}\n"],"mappings":";;;;;AA2FA,IAAM,IAAkB,8NAsBlB,IAAkB,CAAG;;;QAGnB,EAAgB;;;GAQlB,IAA2B,CAAG;;;;;;;;;;;;;;;;;GAmB9B,IAAkB,CAAG;;;QAGnB,EAAgB;;;GAKlB,IAAkB,CAAG;;;QAGnB,EAAgB;;;GAKlB,IAAkB,CAAG;;;;GAMrB,IAAmB,CAAG;;;QAGpB,EAAgB;;;;AAcxB,SAAgB,IAAe;CAC7B,IAAM,EAAE,mBAAgB,GAAgB,EAClC,IAAU,EAAE,gBAAa,EAEzB,EAAE,SAAM,YAAS,UAAO,eAAY,EAA6B,GAAiB;EACtF,WAAW,EAAE,YAAS;EACtB,MAAM,CAAC;EACP,aAAa;EACb,6BAA6B;EAC9B,CAAC,EAEI,CAAC,KAAkB,EAAY,EAAgB,EAC/C,CAAC,KAAkB,EAAY,EAAgB,EAC/C,CAAC,KAAkB,EAAY,EAAgB,EAC/C,CAAC,KAAkB,EAAY,EAAiB,EAEhD,IAAiB,EACrB,OAAO,MAAyB;AAE9B,EADA,MAAM,EAAe,EAAE,WAAW,EAAE,OAAO;GAAE,GAAG;GAAO;GAAS,EAAE,EAAE,CAAC,EACrE,MAAM,GAAS;IAGjB;EAAC;EAAgB;EAAS;EAAY,CACvC,EAEK,IAAiB,EACrB,OAAO,GAAY,MAAyB;AAE1C,EADA,MAAM,EAAe,EAAE,WAAW,EAAE,OAAO;GAAE;GAAI,GAAG;GAAO;GAAS,EAAE,EAAE,CAAC,EACzE,MAAM,GAAS;IAGjB;EAAC;EAAgB;EAAS;EAAY,CACvC,EAEK,IAAiB,EACrB,OAAO,MAAe;AAEpB,EADA,MAAM,EAAe,EAAE,WAAW;GAAE;GAAI;GAAS,EAAE,CAAC,EACpD,MAAM,GAAS;IAGjB;EAAC;EAAgB;EAAS;EAAY,CACvC,EAEK,IAAkB,EACtB,OAAO,MAA8B;AAEnC,EADA,MAAM,EAAe,EAAE,WAAW;GAAE;GAAM;GAAS,EAAE,CAAC,EACtD,MAAM,GAAS;IAGjB;EAAC;EAAgB;EAAS;EAAY,CACvC;AAED,QAAO;EACL,WAAW,GAAM,wBAAwB,EAAE;EAC3C;EACA;EACA;EACA;EACA;EACA;EACA;EACD;;AAaH,SAAgB,EAAqB,GAAkC;CACrE,IAAM,EAAE,mBAAgB,GAAgB,EAGlC,EAAE,SAAM,YAAS,UAAO,eAAY,EAAqC,GAA0B;EACvG,WAAW;GAAE,SAHC,EAAE,gBAAa;GAGP,QAAQ,KAAU;GAAM;EAC9C,MAAM,CAAC;EACP,aAAa;EACb,6BAA6B;EAC9B,CAAC;AAEF,QAAO;EACL,WAAW,GAAM,mCAAmC,EAAE;EACtD;EACA;EACA;EACD"}
|