Skip to content

Commit

Permalink
chore: add loading state
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ajabeckett committed Oct 24, 2023
1 parent fe41d24 commit f6c15bb
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/soilId/soilIdSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export type ProjectSoilSettings = Omit<
const initialState = {
soilData: {} as Record<string, SoilData>,
projectSettings: {} as Record<string, ProjectSoilSettings>,
loading: false,
};

export const sameDepth =
Expand Down Expand Up @@ -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;
});
},
});

Expand Down

0 comments on commit f6c15bb

Please sign in to comment.