NeoScan_Physician/app/modules/Dashboard/redux/dashboardSlice.ts

70 lines
1.5 KiB
TypeScript

/*
* File: dashboardSlice.ts
* Description: Redux slice for Dashboard state management
* Design & Developed by Tech4Biz Solutions
* Copyright (c) Spurrin Innovations. All rights reserved.
*/
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
// Sample case type
export interface Case {
id: string;
patientName: string;
status: 'critical' | 'urgent' | 'routine';
aiConfidence: number;
description: string;
}
// Dashboard state type
interface DashboardState {
caseQueue: Case[];
loading: boolean;
error: string | null;
}
const initialState: DashboardState = {
caseQueue: [],
loading: false,
error: null,
};
/**
* Dashboard slice for managing case queue and dashboard state
*/
const dashboardSlice = createSlice({
name: 'dashboard',
initialState,
reducers: {
fetchCasesStart(state) {
state.loading = true;
state.error = null;
},
fetchCasesSuccess(state, action: PayloadAction<Case[]>) {
state.caseQueue = action.payload;
state.loading = false;
},
fetchCasesFailure(state, action: PayloadAction<string>) {
state.loading = false;
state.error = action.payload;
},
clearCases(state) {
state.caseQueue = [];
},
},
});
export const {
fetchCasesStart,
fetchCasesSuccess,
fetchCasesFailure,
clearCases,
} = dashboardSlice.actions;
export default dashboardSlice.reducer;
/*
* End of File: dashboardSlice.ts
* Design & Developed by Tech4Biz Solutions
* Copyright (c) Spurrin Innovations. All rights reserved.
*/