diff options
author | Michael Hunteman <michael@huntm.net> | 2024-08-25 12:44:32 -0700 |
---|---|---|
committer | Michael Hunteman <michael@huntm.net> | 2024-08-25 12:44:32 -0700 |
commit | 096a08708e2310becba56a237ef63b5cf6e3c4c4 (patch) | |
tree | 2924f9aecdcf035599558552cfdb20c2cc18f7d1 /client/src/slices/auth | |
parent | 6aee47e76d7e25206b3778aeebcc341d7b705035 (diff) |
Add admin dashboard
Diffstat (limited to 'client/src/slices/auth')
-rw-r--r-- | client/src/slices/auth/adminSlice.ts | 29 | ||||
-rw-r--r-- | client/src/slices/auth/guestSlice.ts | 29 |
2 files changed, 58 insertions, 0 deletions
diff --git a/client/src/slices/auth/adminSlice.ts b/client/src/slices/auth/adminSlice.ts new file mode 100644 index 0000000..8753b55 --- /dev/null +++ b/client/src/slices/auth/adminSlice.ts @@ -0,0 +1,29 @@ +import { createSlice } from '@reduxjs/toolkit'; +import type { PayloadAction } from '@reduxjs/toolkit'; +import type { RootState } from '../../store'; +import type { Guest } from '../api/guestSlice'; + +type AdminAuth = { + guests?: Guest[]; + token?: string; +}; + +const adminSlice = createSlice({ + name: 'admin', + initialState: { guest: undefined, token: undefined } as AdminAuth, + reducers: { + setAdmin: ( + state, + { payload: { guests, token } }: PayloadAction<AdminAuth> + ) => { + state.guests = guests; + state.token = token; + }, + }, +}); + +export const { setAdmin } = adminSlice.actions; + +export default adminSlice.reducer; + +export const selectGuests = (state: RootState) => state.admin.guests; diff --git a/client/src/slices/auth/guestSlice.ts b/client/src/slices/auth/guestSlice.ts new file mode 100644 index 0000000..701148e --- /dev/null +++ b/client/src/slices/auth/guestSlice.ts @@ -0,0 +1,29 @@ +import { createSlice } from '@reduxjs/toolkit'; +import type { PayloadAction } from '@reduxjs/toolkit'; +import type { RootState } from '../../store'; +import type { Guest } from '../api/guestSlice'; + +type GuestAuth = { + guest?: Guest; + token?: string; +}; + +const guestSlice = createSlice({ + name: 'guest', + initialState: { guest: undefined, token: undefined } as GuestAuth, + reducers: { + setGuest: ( + state, + { payload: { guest, token } }: PayloadAction<GuestAuth> + ) => { + state.guest = guest; + state.token = token; + }, + }, +}); + +export const { setGuest } = guestSlice.actions; + +export default guestSlice.reducer; + +export const selectGuest = (state: RootState) => state.guest.guest; |