mirror of
https://github.com/house-of-vanity/OutFleet.git
synced 2025-10-25 01:39:08 +00:00
feat: added redux & ducks
This commit is contained in:
32
client/src/features/certificates/duck/slice.ts
Normal file
32
client/src/features/certificates/duck/slice.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { createSlice } from '@reduxjs/toolkit';
|
||||
import type { PayloadAction } from '@reduxjs/toolkit';
|
||||
import type { CertificateDTO } from './dto';
|
||||
|
||||
export interface CertificatesState {
|
||||
loading: boolean;
|
||||
certificates: CertificateDTO[]
|
||||
error: null | string;
|
||||
}
|
||||
|
||||
const initialState: CertificatesState = {
|
||||
loading: false,
|
||||
certificates: [],
|
||||
error: null,
|
||||
};
|
||||
|
||||
export const certificateSlice = createSlice({
|
||||
name: 'certificates',
|
||||
initialState,
|
||||
reducers: {
|
||||
setLoading: (state, action: PayloadAction<boolean>) => {
|
||||
state.loading = action.payload
|
||||
},
|
||||
setUsers: (state, action: PayloadAction<CertificateDTO[]>) => {
|
||||
state.certificates = action.payload
|
||||
},
|
||||
setError: (state, action: PayloadAction<string>) => {
|
||||
state.error = action.payload
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user