summaryrefslogtreecommitdiff
path: root/src/features/auth
diff options
context:
space:
mode:
authorMichael Hunteman <michael@huntm.net>2024-03-01 07:44:28 -0800
committerMichael Hunteman <michael@huntm.net>2024-03-01 07:44:28 -0800
commit2b3d32a641da19c9d807f1877efcbe1a130c5e23 (patch)
tree040b0bdced188912e3fbbeafdb3d2cbbc784676f /src/features/auth
parentfa1409d205479e9943f7b7db96a4b56ff1d29d7d (diff)
Use guest for login and RSVP update
Diffstat (limited to 'src/features/auth')
-rw-r--r--src/features/auth/GuestLogin.tsx3
-rw-r--r--src/features/auth/authSlice.ts14
2 files changed, 7 insertions, 10 deletions
diff --git a/src/features/auth/GuestLogin.tsx b/src/features/auth/GuestLogin.tsx
index 8585e61..61a8fa1 100644
--- a/src/features/auth/GuestLogin.tsx
+++ b/src/features/auth/GuestLogin.tsx
@@ -20,8 +20,7 @@ function GuestLogin() {
const onSubmit = async (data: LoginRequest) => {
try {
- const user = await login(data).unwrap();
- dispatch(setCredentials(user));
+ dispatch(setCredentials(await login(data).unwrap()));
navigate('/rsvp');
} catch (e) {
console.log(e);
diff --git a/src/features/auth/authSlice.ts b/src/features/auth/authSlice.ts
index 04be93f..d5b294c 100644
--- a/src/features/auth/authSlice.ts
+++ b/src/features/auth/authSlice.ts
@@ -1,21 +1,19 @@
import { createSlice } from '@reduxjs/toolkit';
import type { RootState } from '../../store';
-import { User } from '../../apiSlice';
+import { Guest } from '../../apiSlice';
type AuthState = {
- user: User | null
- id: number | null
+ guest: Guest | null
token: string | null
}
const authSlice = createSlice({
name: 'auth',
- initialState: { user: null, token: null, id: null } as AuthState,
+ initialState: { guest: null, token: null } as AuthState,
reducers: {
setCredentials: (state, action) => {
- const { user, token, id } = action.payload;
- state.user = user;
- state.id = id;
+ const { guest, token } = action.payload;
+ state.guest = guest;
state.token = token;
}
}
@@ -25,4 +23,4 @@ export const { setCredentials } = authSlice.actions;
export default authSlice.reducer;
-export const selectCurrentUser = (state: RootState) => state.auth.user;
+export const selectCurrentGuest = (state: RootState) => state.auth.guest;