-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
69 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { useSelector } from 'react-redux'; | ||
import { Modal as Mbs } from 'react-bootstrap'; | ||
|
||
const getTitle = (type) => { | ||
switch (type) { | ||
case 'addChannel': | ||
return 'Добавить канал'; | ||
|
||
default: | ||
return 'Неизвестная модалка!!! О_О'; | ||
} | ||
}; | ||
|
||
const Modal = () => { | ||
const { isOpened, type, extra } = useSelector((state) => state.modal); | ||
|
||
return ( | ||
<Mbs show={isOpened}> | ||
<Mbs.Header closeButton> | ||
<Mbs.Title>{getTitle(type)}</Mbs.Title> | ||
</Mbs.Header> | ||
<Mbs.Body>{getBody(type)}</Mbs.Body> | ||
</Mbs> | ||
); | ||
}; | ||
|
||
export default Modal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* eslint-disable no-param-reassign */ | ||
|
||
import { createSlice } from '@reduxjs/toolkit'; | ||
|
||
const initialState = { | ||
isOpened: false, | ||
type: null, | ||
extra: null, | ||
}; | ||
|
||
export const modalSlice = createSlice({ | ||
name: 'modal', | ||
initialState, | ||
reducers: { | ||
modalClose: (state) => { | ||
state.isOpened = null; | ||
state.extra = null; | ||
state.type = null; | ||
}, | ||
openModal: (state, { payload }) => { | ||
const { type, extra } = payload; | ||
state.type = type; | ||
state.extra = extra ?? null; | ||
state.isOpened = true; | ||
}, | ||
}, | ||
}); | ||
|
||
export const { modalClose } = modalSlice.actions; | ||
|
||
export default modalSlice.reducer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters