blob: 3007059c611383dc75cc7cf07fdd1a852aac8f61 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
import { createSlice } from '@reduxjs/toolkit';
import type { PayloadAction } from '@reduxjs/toolkit';
import type { RootState } from '../../store';
import type { Guest } from '../../models';
type AdminAuth = {
guests?: Guest[];
token?: string;
};
const adminSlice = createSlice({
name: 'admin',
initialState: { guests: 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 const selectGuests = (state: RootState) => state.admin.guests;
export default adminSlice.reducer;
|