From f6c15bbe9ff29bf33cd5c1f83b6bb19bf47c18be Mon Sep 17 00:00:00 2001 From: Aja Beckett Date: Mon, 23 Oct 2023 17:51:55 -0700 Subject: [PATCH] chore: add loading state Attaching a loading state to the call that's populating the user's Sites and Projects data, so we can show loading indicators in the mobile app. --- src/soilId/soilIdSlice.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/soilId/soilIdSlice.ts b/src/soilId/soilIdSlice.ts index 58ddc3f8..ee198449 100644 --- a/src/soilId/soilIdSlice.ts +++ b/src/soilId/soilIdSlice.ts @@ -89,6 +89,7 @@ export type ProjectSoilSettings = Omit< const initialState = { soilData: {} as Record, projectSettings: {} as Record, + loading: false, }; export const sameDepth = @@ -151,6 +152,14 @@ const soilIdSlice = createSlice({ builder.addCase(deleteProjectDepthInterval.fulfilled, (state, action) => { state.projectSettings[action.meta.arg.projectId] = action.payload; }); + + builder.addCase(fetchSoilDataForUser.fulfilled, (state, action) => { + state.loading = false; + }); + + builder.addCase(fetchSoilDataForUser.pending, (state, action) => { + state.loading = true; + }); }, });