Made addTask component showing functional

This commit is contained in:
Dmitriy Shishkov 2021-10-17 17:52:07 +03:00
parent 91fb0d873a
commit 3edf5edaec
No known key found for this signature in database
GPG Key ID: 14358F96FCDD8060
2 changed files with 36 additions and 24 deletions

View File

@ -1,4 +1,4 @@
import React, { useState } from "react"; import React from "react";
import SwipeableDrawer from "@mui/material/SwipeableDrawer"; import SwipeableDrawer from "@mui/material/SwipeableDrawer";
import InputBase from "@mui/material/InputBase"; import InputBase from "@mui/material/InputBase";
@ -6,11 +6,15 @@ import TrapFocus from "@mui/material/Unstable_TrapFocus";
import Box from "@mui/material/Box"; import Box from "@mui/material/Box";
import Button from "@mui/material/Button"; import Button from "@mui/material/Button";
export const AddTask: React.FC = () => { import { useAppDispatch, useAppSelector } from "../hooks";
const [open, setOpen] = useState(true); import {
open as openAction,
close as closeAction,
} from "../store/slices/uiState";
const onOpen = () => setOpen(true); export const AddTask: React.FC = () => {
const onClose = () => setOpen(false); const open = useAppSelector((state) => state.uiState.addBarOpen);
const dispatch = useAppDispatch();
return ( return (
<TrapFocus open={open}> <TrapFocus open={open}>
@ -24,8 +28,8 @@ export const AddTask: React.FC = () => {
}} }}
anchor="bottom" anchor="bottom"
open={open} open={open}
onOpen={onOpen} onOpen={() => dispatch(openAction())}
onClose={onClose} onClose={() => dispatch(closeAction())}
> >
<Box <Box
sx={{ sx={{

View File

@ -4,7 +4,13 @@ import Box from "@mui/material/Box";
import Fab from "@mui/material/Fab"; import Fab from "@mui/material/Fab";
import Add from "@mui/icons-material/Add"; import Add from "@mui/icons-material/Add";
export const AppBar: React.FC = () => ( import { useAppDispatch } from "../hooks";
import { open } from "../store/slices/uiState";
export const AppBar: React.FC = () => {
const dispatch = useAppDispatch();
return (
<Box sx={{ width: "100%", justifyContent: "center", display: "flex" }}> <Box sx={{ width: "100%", justifyContent: "center", display: "flex" }}>
<Fab <Fab
variant="extended" variant="extended"
@ -15,9 +21,11 @@ export const AppBar: React.FC = () => (
zIndex: 1, zIndex: 1,
top: -30, top: -30,
}} }}
onClick={() => dispatch(open())}
> >
<Add sx={{ marginRight: 1 }} /> <Add sx={{ marginRight: 1 }} />
Add a new task Add a new task
</Fab> </Fab>
</Box> </Box>
); );
};