add react modal and use it for days wishes

This commit is contained in:
memeriau
2022-01-29 22:55:07 +01:00
parent 2bfd8d2a7b
commit c2f4946da0
16 changed files with 203 additions and 17 deletions

View File

@@ -6,6 +6,7 @@ import javGameList from "./javGameList"
import preVolunteerAdd from "./preVolunteerAdd"
import preVolunteerCount from "./preVolunteerCount"
import teamList from "./teamList"
import ui from "./ui"
import volunteer from "./volunteer"
import volunteerAdd from "./volunteerAdd"
import volunteerList from "./volunteerList"
@@ -27,6 +28,7 @@ export default (history: History) => ({
preVolunteerAdd,
preVolunteerCount,
teamList,
ui,
volunteer,
volunteerAdd,
volunteerList,

31
src/store/ui.ts Normal file
View File

@@ -0,0 +1,31 @@
import { createSelector, createSlice, PayloadAction } from "@reduxjs/toolkit"
import { AppState } from "./index"
const initialState = {
modalId: "",
}
const uiSlice = createSlice({
name: "ui",
initialState,
reducers: {
displayModal: (state, action: PayloadAction<string>) => {
state.modalId = action.payload
},
hideModal: (state) => {
state.modalId = ""
},
},
})
export default uiSlice.reducer
export const { displayModal, hideModal } = uiSlice.actions
const selectUiData = (state: AppState) => state.ui
export const selectActiveModalId = createSelector(selectUiData, (ui) => ui.modalId)
export const MODAL_IDS = {
DAYWISHES: "DAYWISHES",
}