diff --git a/src/site/siteSlice.ts b/src/site/siteSlice.ts index aae9f284..0a361e59 100644 --- a/src/site/siteSlice.ts +++ b/src/site/siteSlice.ts @@ -19,6 +19,7 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; import { SiteAddMutationInput, SiteTransferMutationInput, + SiteUpdateMutationInput, } from 'terraso-client-shared/graphqlSchema/graphql'; import { addSiteToProject, @@ -72,9 +73,18 @@ export const addSite = createAsyncThunk( }, ); -export const updateSite = createAsyncThunk( +export const updateSite = createAsyncThunk( 'site/updateSite', - siteService.updateSite, + async (input, _currentUser, { dispatch }) => { + const result = await siteService.updateSite(input); + dispatch(removeSiteFromAllProjects(result.id)); + if (result.projectId) { + dispatch( + addSiteToProject({ projectId: result.projectId, siteId: input.id }), + ); + } + return result; + }, ); export const deleteSite = createAsyncThunk(