Skip to content

Commit

Permalink
add dynamic bg change feature
Browse files Browse the repository at this point in the history
  • Loading branch information
001elijah committed Jun 29, 2023
1 parent 6e413a2 commit c8ec903
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/components/BoardModalWindow/BoardModalWindow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const BoardModalWindow = ({
}) => {
const theme = useSelector(selectorTheme);
const [title, setTitle] = useState(inputTitle);
const [background, setBackground] = useState('null');
const [background, setBackground] = useState();
const [icon, setIcon] = useState('');
const [isValid, setIsValid] = useState(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ export const BoxRadioBackgroundGroup = ({ valueChange }) => {
{/* Default Background */}
<div
className={`${s.radioContainer} ${s[theme]} ${
background === null ? s.selected : ''
background === "default" ? s.selected : ''
}`}
>
<input
className={`${s.radioInput} ${s[theme]}`}
type="radio"
onClick={handleChange}
onChange={handleChange}
value="null"
value="default"
name="background"
id="radio-default"
checked={background === 'null'}
checked={background === 'default'}
/>
<label
htmlFor="radio-default"
Expand Down
12 changes: 10 additions & 2 deletions src/components/HeaderDashBoard/HeaderDashBoard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,17 @@ export const HeaderDashBoard = ({ title }) => {
useEffect(() => {
showModalWindow && dispatch(addFilters(color));
}, [color]);

useEffect(() => {
showModalWindow && icon && dispatch(updateBoard({ back: icon, board }));
}, [icon]);
const updateBoardAndFetch = async () => {
if (showModalWindow && icon) {
await dispatch(updateBoard({ back: icon, board }));
dispatch(getBoardById(board._id));
}
};

updateBoardAndFetch();
}, [icon, showModalWindow]);

return (
<>
Expand Down
2 changes: 1 addition & 1 deletion src/components/ModalFilter/ModalFilter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import clsx from 'clsx';
export const ModalFilter = ({ closeModal, colorNew, iconNew }) => {
const [colorFilter, setColorFilter] = useState('');
const theme = useSelector(selectorTheme);
const [icon, setIcon] = useState(null);
const [icon, setIcon] = useState();

useEffect(() => {
colorNew(colorFilter), iconNew(icon);
Expand Down

0 comments on commit c8ec903

Please sign in to comment.