77 lines
2.2 KiB
JavaScript
77 lines
2.2 KiB
JavaScript
import { createSlice } from '@reduxjs/toolkit';
|
|
|
|
const initialState = {
|
|
modalVisible: false,
|
|
collapsed: true,
|
|
siderWidth: 300,
|
|
hovered: false,
|
|
selectedAppointment: null,
|
|
selectedScheduledAppointment: null,
|
|
scheduledModalVisible: false,
|
|
scheduledData: null,
|
|
appointmentsListModalVisible: false,
|
|
selectedDateAppointments: [],
|
|
};
|
|
|
|
const appointmentsSlice = createSlice({
|
|
name: 'appointmentsUI',
|
|
initialState,
|
|
reducers: {
|
|
openModal(state) {
|
|
state.modalVisible = true;
|
|
},
|
|
closeModal(state) {
|
|
state.modalVisible = false;
|
|
},
|
|
toggleSider(state) {
|
|
state.collapsed = !state.collapsed;
|
|
},
|
|
setSiderWidth(state, action) {
|
|
state.siderWidth = action.payload;
|
|
},
|
|
setHovered(state, action) {
|
|
state.hovered = action.payload;
|
|
},
|
|
setSelectedAppointment(state, action) {
|
|
state.selectedAppointment = action.payload;
|
|
},
|
|
setSelectedScheduledAppointment(state, action) {
|
|
state.selectedScheduledAppointment = action.payload;
|
|
},
|
|
openScheduledModal(state) {
|
|
state.scheduledModalVisible = true;
|
|
},
|
|
closeScheduledModal(state) {
|
|
state.scheduledModalVisible = false;
|
|
},
|
|
openModalWithScheduledData(state, action) {
|
|
state.modalVisible = true;
|
|
state.scheduledData = action.payload;
|
|
},
|
|
openAppointmentsListModal(state, action) {
|
|
state.appointmentsListModalVisible = true;
|
|
state.selectedDateAppointments = action.payload;
|
|
},
|
|
closeAppointmentsListModal(state) {
|
|
state.appointmentsListModalVisible = false;
|
|
state.selectedDateAppointments = [];
|
|
},
|
|
},
|
|
});
|
|
|
|
export const {
|
|
openModal,
|
|
closeModal,
|
|
toggleSider,
|
|
setSiderWidth,
|
|
setHovered,
|
|
setSelectedAppointment,
|
|
setSelectedScheduledAppointment,
|
|
openScheduledModal,
|
|
closeScheduledModal,
|
|
openModalWithScheduledData,
|
|
openAppointmentsListModal,
|
|
closeAppointmentsListModal,
|
|
} = appointmentsSlice.actions;
|
|
|
|
export default appointmentsSlice.reducer; |