From 07752babb4e692452e1cd7f2133c4d8dde1b3b1c Mon Sep 17 00:00:00 2001 From: Michael Hunteman Date: Sun, 23 Jun 2024 13:55:42 -0700 Subject: Authenticate UI users --- client/src/features/auth/authSlice.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'client/src/features/auth') diff --git a/client/src/features/auth/authSlice.ts b/client/src/features/auth/authSlice.ts index bff2bdd..878de0c 100644 --- a/client/src/features/auth/authSlice.ts +++ b/client/src/features/auth/authSlice.ts @@ -1,4 +1,5 @@ import { createSlice } from '@reduxjs/toolkit'; +import type { PayloadAction } from '@reduxjs/toolkit'; import type { RootState } from '../../store'; import type { Guest } from '../../apiSlice'; @@ -11,8 +12,12 @@ const authSlice = createSlice({ name: 'auth', initialState: { guest: undefined, token: undefined } as AuthState, reducers: { - setCredentials: (state, action) => { - const { guest, token } = action.payload; + setCredentials: ( + state, + { + payload: { guest, token }, + }: PayloadAction<{ guest: Guest; token: string }> + ) => { state.guest = guest; state.token = token; }, -- cgit v1.2.3