61 lines
1.3 KiB
TypeScript
61 lines
1.3 KiB
TypeScript
/*
|
|
* File: caseQueueSlice.ts
|
|
* Description: Redux slice for case queue state management
|
|
* Design & Developed by Tech4Biz Solutions
|
|
* Copyright (c) Spurrin Innovations. All rights reserved.
|
|
*/
|
|
|
|
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
|
|
import { Case } from './dashboardSlice';
|
|
|
|
interface CaseQueueState {
|
|
queue: Case[];
|
|
loading: boolean;
|
|
error: string | null;
|
|
}
|
|
|
|
const initialState: CaseQueueState = {
|
|
queue: [],
|
|
loading: false,
|
|
error: null,
|
|
};
|
|
|
|
/**
|
|
* Slice for managing the case queue
|
|
*/
|
|
const caseQueueSlice = createSlice({
|
|
name: 'caseQueue',
|
|
initialState,
|
|
reducers: {
|
|
fetchQueueStart(state) {
|
|
state.loading = true;
|
|
state.error = null;
|
|
},
|
|
fetchQueueSuccess(state, action: PayloadAction<Case[]>) {
|
|
state.queue = action.payload;
|
|
state.loading = false;
|
|
},
|
|
fetchQueueFailure(state, action: PayloadAction<string>) {
|
|
state.loading = false;
|
|
state.error = action.payload;
|
|
},
|
|
clearQueue(state) {
|
|
state.queue = [];
|
|
},
|
|
},
|
|
});
|
|
|
|
export const {
|
|
fetchQueueStart,
|
|
fetchQueueSuccess,
|
|
fetchQueueFailure,
|
|
clearQueue,
|
|
} = caseQueueSlice.actions;
|
|
|
|
export default caseQueueSlice.reducer;
|
|
|
|
/*
|
|
* End of File: caseQueueSlice.ts
|
|
* Design & Developed by Tech4Biz Solutions
|
|
* Copyright (c) Spurrin Innovations. All rights reserved.
|
|
*/
|