X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/b7a4d46fe2b011cdb6e38ed42e9f886fee8290b8..e8e0182d65a74b1a222127eb8b36f31a906b14c8:/src/store/my-account/my-account-panel-actions.ts diff --git a/src/store/my-account/my-account-panel-actions.ts b/src/store/my-account/my-account-panel-actions.ts index cb1584cb..93c6a3c5 100644 --- a/src/store/my-account/my-account-panel-actions.ts +++ b/src/store/my-account/my-account-panel-actions.ts @@ -4,8 +4,12 @@ import { Dispatch } from "redux"; import { RootState } from "~/store/store"; +import { initialize } from "redux-form"; import { ServiceRepository } from "~/services/services"; import { setBreadcrumbs } from "~/store/breadcrumbs/breadcrumbs-actions"; +import { authActions } from "~/store/auth/auth-action"; +import { snackbarActions } from "~/store/snackbar/snackbar-actions"; +import { MY_ACCOUNT_FORM } from "~/views/my-account-panel/my-account-panel-root"; export const loadMyAccountPanel = () => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { @@ -14,4 +18,17 @@ export const loadMyAccountPanel = () => } catch (e) { return; } - }; \ No newline at end of file + }; + +export const saveEditedUser = (resource: any) => + async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { + try { + await services.userService.update(resource.uuid, resource); + services.authService.saveUser(resource); + dispatch(authActions.USER_DETAILS_SUCCESS(resource)); + dispatch(initialize(MY_ACCOUNT_FORM, resource)); + dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Profile has been updated." })); + } catch(e) { + return; + } + };