From ef5b6f3cce1728134ef6ad4ff833d2a7c812a3bb Mon Sep 17 00:00:00 2001 From: alguilhot Date: Fri, 21 Oct 2022 18:48:43 +0200 Subject: [PATCH] =?UTF-8?q?ADD:=20Ajout=20de=20nouvelles=20m=C3=A9thodes?= =?UTF-8?q?=20dans=20la=20CurrentUserSlice?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/redux/features/currentUserSlice.ts | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/bob_party/src/redux/features/currentUserSlice.ts b/bob_party/src/redux/features/currentUserSlice.ts index 6592020..c1e139b 100644 --- a/bob_party/src/redux/features/currentUserSlice.ts +++ b/bob_party/src/redux/features/currentUserSlice.ts @@ -1,4 +1,5 @@ import { createSlice, PayloadAction } from "@reduxjs/toolkit" +import { Skin } from "../../core/Skin"; import { User } from "../../core/user"; interface currentUserState { @@ -16,9 +17,44 @@ export const currentUserSlice = createSlice({ loginUser: (state, action: PayloadAction) => { state.value.push(action.payload); }, + updateSkin: (state, action: PayloadAction) =>{ + const newUser = state.value[0] + newUser.setCurrentSkin(action.payload); + state.value.pop(); + state.value.push(newUser); + }, + updatePseudo: (state, action: PayloadAction) =>{ + const newUser = state.value[0] + newUser.setUsername(action.payload); + state.value.pop(); + state.value.push(newUser); + }, + updatePassword: (state, action: PayloadAction) =>{ + const newUser = state.value[0] + newUser.setPassword(action.payload); + state.value.pop(); + state.value.push(newUser); + }, + updateNationality: (state, action: PayloadAction) =>{ + const newUser = state.value[0] + newUser.setNationality(action.payload); + state.value.pop(); + state.value.push(newUser); + }, + updateSex: (state, action: PayloadAction) =>{ + const newUser = state.value[0] + newUser.setSexe(action.payload); + state.value.pop(); + state.value.push(newUser); + } }, }); export const { loginUser } = currentUserSlice.actions +export const { updateSkin } = currentUserSlice.actions +export const { updatePseudo } = currentUserSlice.actions +export const { updatePassword } = currentUserSlice.actions +export const { updateNationality } = currentUserSlice.actions +export const { updateSex } = currentUserSlice.actions export default currentUserSlice.reducer; \ No newline at end of file