diff --git a/src/App.tsx b/src/App.tsx index a9ebbee9..7e32dd2d 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -8,11 +8,9 @@ import { FIRESTORE_FIELDS } from "./constants/firebase"; import { useCurrentRecipeData, useJobId, - useJobLogs, useOutputsDirectory, useRunTime, useSetJobId, - useSetJobLogs, useSetPackingResults, } from "./state/store"; import PackingInput from "./components/PackingInput"; @@ -26,9 +24,8 @@ const { Link } = Typography; function App() { const [jobStatus, setJobStatus] = useState(""); + const [jobLogs, setJobLogs] = useState(""); - const setJobLogs = useSetJobLogs(); - const jobLogs = useJobLogs(); const setJobId = useSetJobId(); const jobId = useJobId(); const setPackingResults = useSetPackingResults(); @@ -100,6 +97,7 @@ function App() { start = Date.now(); const response = await fetch(request); setJobStatus(JOB_STATUS.SUBMITTED); + setJobLogs(""); const data = await response.json(); if (response.ok) { setJobId(data.jobId); @@ -142,16 +140,15 @@ function App() { if (localJobStatus.status == JOB_STATUS.DONE) { setPackingResults({ jobId: id, - jobLogs: "", resultUrl: localJobStatus.result_path, runTime: range, outputDir: localJobStatus.outputs_directory, edits: edits, }); } else if (localJobStatus.status == JOB_STATUS.FAILED) { + setJobLogs(`Packing job failed: ${localJobStatus.error_message}`); setPackingResults({ jobId: id, - jobLogs: `Packing job failed: ${localJobStatus.error_message}`, resultUrl: "", runTime: range, outputDir: "", diff --git a/src/state/constants.ts b/src/state/constants.ts index 9bb1fec3..ce3affd0 100644 --- a/src/state/constants.ts +++ b/src/state/constants.ts @@ -4,7 +4,6 @@ import { EditableField, PackingResult } from "../types"; export const EMPTY_FIELDS: readonly EditableField[] = Object.freeze([]); export const EMPTY_PACKING_RESULT: PackingResult = Object.freeze({ jobId: "", - jobLogs: "", resultUrl: "", runTime: 0, outputDir: "", diff --git a/src/state/store.ts b/src/state/store.ts index 2eba5b34..09fdb074 100644 --- a/src/state/store.ts +++ b/src/state/store.ts @@ -42,7 +42,6 @@ type Actions = { ) => Promise ) => Promise; setPackingResults: (results: PackingResult) => void; - setJobLogs: (logs: string) => void; setJobId: (jobId: string) => void; }; @@ -137,19 +136,6 @@ export const useRecipeStore = create()( }); }, - setJobLogs: (logs: string) => { - const currentRecipeId = get().selectedRecipeId; - set({ - packingResults: { - ...get().packingResults, - [currentRecipeId]: { - ...get().packingResults[currentRecipeId], - jobLogs: logs, - }, - }, - }); - }, - setJobId: (jobId: string) => { const currentRecipeId = get().selectedRecipeId; set({ @@ -327,11 +313,6 @@ export const useRunTime = () => { return results.runTime; }; -export const useJobLogs = () => { - const results = useCurrentPackingResult(); - return results.jobLogs; -}; - export const useJobId = () => { const results = useCurrentPackingResult(); return results.jobId; @@ -376,5 +357,4 @@ export const useGetOriginalValue = () => useRecipeStore((s) => s.getOriginalValue); export const useSetPackingResults = () => useRecipeStore((s) => s.setPackingResults); -export const useSetJobLogs = () => useRecipeStore((s) => s.setJobLogs); export const useSetJobId = () => useRecipeStore((s) => s.setJobId); diff --git a/src/test/store.test.ts b/src/test/store.test.ts index 24de1040..dd31ad25 100644 --- a/src/test/store.test.ts +++ b/src/test/store.test.ts @@ -109,28 +109,6 @@ test("editing one recipe does not affect others", async () => { expect(result.current.getCurrentValue(path)).toBe(newValue1); }); -test("setJobLogs updates job logs for current recipe", async () => { - const { result } = renderHook(() => useRecipeStore()); - - const recipeId = INITIAL_RECIPE_ID; - await result.current.selectRecipe(recipeId); - - const logs = "Some Error Message"; - - act(() => { - result.current.setJobLogs(logs); - }); - - expect(result.current.packingResults[recipeId].jobLogs).toBe(logs); - - for (const recipeId of Object.keys(result.current.inputOptions)) { - if (recipeId !== INITIAL_RECIPE_ID) { - // No other job logs should have been updated to `logs` - expect(result.current.packingResults[recipeId]?.jobLogs).not.toBe(logs); - } - } -}); - test("setJobId updates job ID for current recipe", async () => { const { result } = renderHook(() => useRecipeStore()); diff --git a/src/types/index.ts b/src/types/index.ts index 1d427d8f..ea474830 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -42,7 +42,6 @@ export type JobStatusObject = { export type PackingResult = { jobId: string; - jobLogs: string; resultUrl: string; runTime: number; outputDir: string;