@burdenoff/microfe-healthybowl 2026.811.4 → 2026.811.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/healthybowl/hooks/useLivestockImport.js +45 -0
- package/dist/healthybowl/hooks/useLivestockImport.js.map +1 -0
- package/dist/healthybowl/pages/livestock/HealthRecordsPage.js +394 -387
- package/dist/healthybowl/pages/livestock/HealthRecordsPage.js.map +1 -1
- package/dist/healthybowl/pages/livestock/LivestockImportModal.js +158 -0
- package/dist/healthybowl/pages/livestock/LivestockImportModal.js.map +1 -0
- package/dist/healthybowl/pages/livestock/VaccinationSchedulePage.js +77 -70
- package/dist/healthybowl/pages/livestock/VaccinationSchedulePage.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { useHealthyBowl as e } from "../context/HealthyBowlContext.js";
|
|
2
|
+
import { useCallback as t } from "react";
|
|
3
|
+
import { gql as n } from "@apollo/client";
|
|
4
|
+
import { useMutation as r } from "@apollo/client/react";
|
|
5
|
+
//#region src/healthybowl/hooks/useLivestockImport.ts
|
|
6
|
+
var i = "dryRun imported duplicates skipped errors unknownTags", a = n`
|
|
7
|
+
mutation ImportHealthyBowlHealthRecords($input: ImportHealthyBowlLivestockInput!) {
|
|
8
|
+
importHealthyBowlHealthRecords(input: $input) { ${i} }
|
|
9
|
+
}
|
|
10
|
+
`, o = n`
|
|
11
|
+
mutation ImportHealthyBowlVaccinations($input: ImportHealthyBowlLivestockInput!) {
|
|
12
|
+
importHealthyBowlVaccinations(input: $input) { ${i} }
|
|
13
|
+
}
|
|
14
|
+
`;
|
|
15
|
+
function s() {
|
|
16
|
+
let { workspaceId: n } = e(), i = { workspaceId: n }, [s] = r(a), [c] = r(o);
|
|
17
|
+
return {
|
|
18
|
+
importHealthRecords: t(async (e, t) => {
|
|
19
|
+
let n = await s({ variables: { input: {
|
|
20
|
+
csv: e,
|
|
21
|
+
dryRun: t,
|
|
22
|
+
context: i
|
|
23
|
+
} } });
|
|
24
|
+
if (n.error) throw n.error;
|
|
25
|
+
let r = n.data?.importHealthyBowlHealthRecords;
|
|
26
|
+
if (!r) throw Error("The import did not return a result");
|
|
27
|
+
return r;
|
|
28
|
+
}, [s, n]),
|
|
29
|
+
importVaccinations: t(async (e, t) => {
|
|
30
|
+
let n = await c({ variables: { input: {
|
|
31
|
+
csv: e,
|
|
32
|
+
dryRun: t,
|
|
33
|
+
context: i
|
|
34
|
+
} } });
|
|
35
|
+
if (n.error) throw n.error;
|
|
36
|
+
let r = n.data?.importHealthyBowlVaccinations;
|
|
37
|
+
if (!r) throw Error("The import did not return a result");
|
|
38
|
+
return r;
|
|
39
|
+
}, [c, n])
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
export { s as useLivestockImport };
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=useLivestockImport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLivestockImport.js","names":[],"sources":["../../../src/healthybowl/hooks/useLivestockImport.ts"],"sourcesContent":["/**\n * Livestock health & vaccination CSV import (BOFF-6028).\n *\n * Inline `gql` because these mutations post-date the committed SDL snapshot codegen validates\n * against — the same escape hatch `useHealthyBowlDistribution` and `useHealthyBowlCsaPickup` use.\n *\n * `dryRun` is the point of the API, not a nicety: it validates and resolves every row and writes\n * nothing, so the farmer sees what would land before any of a 500-row migration is committed.\n * @module healthybowl\n */\nimport { useCallback } from 'react';\nimport { gql } from '@apollo/client';\nimport { useMutation } from '@apollo/client/react';\nimport { useHealthyBowl } from '../context/HealthyBowlContext';\nimport type { LivestockImportResult } from '../pages/livestock/LivestockImportModal';\n\nconst IMPORT_RESULT_FIELDS = `dryRun imported duplicates skipped errors unknownTags`;\n\nconst IMPORT_HEALTH_RECORDS = gql`\n mutation ImportHealthyBowlHealthRecords($input: ImportHealthyBowlLivestockInput!) {\n importHealthyBowlHealthRecords(input: $input) { ${IMPORT_RESULT_FIELDS} }\n }\n`;\n\nconst IMPORT_VACCINATIONS = gql`\n mutation ImportHealthyBowlVaccinations($input: ImportHealthyBowlLivestockInput!) {\n importHealthyBowlVaccinations(input: $input) { ${IMPORT_RESULT_FIELDS} }\n }\n`;\n\nexport function useLivestockImport() {\n const { workspaceId } = useHealthyBowl();\n const context = { workspaceId };\n\n const [importHealthMutation] = useMutation<{ importHealthyBowlHealthRecords: LivestockImportResult }>(\n IMPORT_HEALTH_RECORDS\n );\n const [importVaccinationsMutation] = useMutation<{ importHealthyBowlVaccinations: LivestockImportResult }>(\n IMPORT_VACCINATIONS\n );\n\n const importHealthRecords = useCallback(\n async (csv: string, dryRun: boolean): Promise<LivestockImportResult> => {\n const res = await importHealthMutation({ variables: { input: { csv, dryRun, context } } });\n if (res.error) throw res.error;\n const data = res.data?.importHealthyBowlHealthRecords;\n if (!data) throw new Error('The import did not return a result');\n return data;\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [importHealthMutation, workspaceId]\n );\n\n const importVaccinations = useCallback(\n async (csv: string, dryRun: boolean): Promise<LivestockImportResult> => {\n const res = await importVaccinationsMutation({ variables: { input: { csv, dryRun, context } } });\n if (res.error) throw res.error;\n const data = res.data?.importHealthyBowlVaccinations;\n if (!data) throw new Error('The import did not return a result');\n return data;\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [importVaccinationsMutation, workspaceId]\n );\n\n return { importHealthRecords, importVaccinations };\n}\n"],"mappings":";;;;;AAgBA,IAAM,IAAuB,yDAEvB,IAAwB,CAAG;;sDAEqB,EAAqB;;GAIrE,IAAsB,CAAG;;qDAEsB,EAAqB;;;AAI1E,SAAgB,IAAqB;CACnC,IAAM,EAAE,mBAAgB,GAAgB,EAClC,IAAU,EAAE,gBAAa,EAEzB,CAAC,KAAwB,EAC7B,EACD,EACK,CAAC,KAA8B,EACnC,EACD;AA0BD,QAAO;EAAE,qBAxBmB,EAC1B,OAAO,GAAa,MAAoD;GACtE,IAAM,IAAM,MAAM,EAAqB,EAAE,WAAW,EAAE,OAAO;IAAE;IAAK;IAAQ;IAAS,EAAE,EAAE,CAAC;AAC1F,OAAI,EAAI,MAAO,OAAM,EAAI;GACzB,IAAM,IAAO,EAAI,MAAM;AACvB,OAAI,CAAC,EAAM,OAAU,MAAM,qCAAqC;AAChE,UAAO;KAGT,CAAC,GAAsB,EAAY,CACpC;EAc6B,oBAZH,EACzB,OAAO,GAAa,MAAoD;GACtE,IAAM,IAAM,MAAM,EAA2B,EAAE,WAAW,EAAE,OAAO;IAAE;IAAK;IAAQ;IAAS,EAAE,EAAE,CAAC;AAChG,OAAI,EAAI,MAAO,OAAM,EAAI;GACzB,IAAM,IAAO,EAAI,MAAM;AACvB,OAAI,CAAC,EAAM,OAAU,MAAM,qCAAqC;AAChE,UAAO;KAGT,CAAC,GAA4B,EAAY,CAC1C;EAEiD"}
|