From 31e226bd99ce648cb6ca9bb3056a275975d21c97 Mon Sep 17 00:00:00 2001 From: heronlancellot Date: Thu, 19 Oct 2023 01:01:53 -0300 Subject: [PATCH 1/2] Feat: Initial FormModal Structure --- src/components/Form/index.tsx | 57 ++++++++++++++++ src/components/Task/CardTask.tsx | 109 ++++++++++++++++++------------- 2 files changed, 121 insertions(+), 45 deletions(-) create mode 100644 src/components/Form/index.tsx diff --git a/src/components/Form/index.tsx b/src/components/Form/index.tsx new file mode 100644 index 0000000..021c2ed --- /dev/null +++ b/src/components/Form/index.tsx @@ -0,0 +1,57 @@ +import Button from '@mui/material/Button'; +import TextField from '@mui/material/TextField'; +import Dialog from '@mui/material/Dialog'; +import DialogActions from '@mui/material/DialogActions'; +import DialogContent from '@mui/material/DialogContent'; +import DialogContentText from '@mui/material/DialogContentText'; +import DialogTitle from '@mui/material/DialogTitle'; +import { useEffect, useState } from 'react'; + +export default function FormDialog(openForm, onSubmit) { + const [open, setOpen] = useState(false) + const [descriptionReview, setDescriptionReview] = useState() + + console.log('onSubmit', onSubmit); + + const handleConfirmation = (event: { target: { value: any; }; }) => { + let description = event.target.value; + setDescriptionReview(description); + } + + const handleClose = () => { + setOpen(false); + }; + + const handleSubmit = () => { + onSubmit(descriptionReview) + handleClose(); + }; + + useEffect(() => { + setOpen(openForm) + }, []) + + return ( + + Review Description + + + Add your Task Description + + (handleConfirmation(event))} + /> + + + + + + + ); +} diff --git a/src/components/Task/CardTask.tsx b/src/components/Task/CardTask.tsx index b2a3cc4..368f4e1 100644 --- a/src/components/Task/CardTask.tsx +++ b/src/components/Task/CardTask.tsx @@ -11,7 +11,7 @@ import Close from '@mui/icons-material/Close'; import Check from '@mui/icons-material/Check'; import { useSnackBar } from 'src/contexts/SnackBarContext'; import { ethers } from 'ethers'; -import { set } from 'date-fns'; +import FormDialog from '../Form'; /** * CardTasks Component @@ -35,6 +35,20 @@ export const CardTask = ({ taskId, taskData, loading }: any) => { const [approvals, setApprovals] = useState(); const [isMember, setIsMember] = useState(false); const [isLeader, setIsLeader] = useState(false); + const [openForm, setOpenForm] = useState(false); + const [dataForm, setDataForm] = useState(''); + + const handleOpenForm = async () => { + setOpenForm(true); + }; + + const handleFormSubmit = (metadata: any) => { + setDataForm(metadata); + setOpenForm(false); + } + + console.log('dataForm', dataForm) + const theme = useTheme(); const isSmallScreen = useMediaQuery(theme.breakpoints.down('sm')); @@ -68,7 +82,8 @@ export const CardTask = ({ taskId, taskData, loading }: any) => { handleSnackbar('Task Start process initiated with success!', 'info') break; case "Progress": - await reviewTask(BigInt(taskId), "Hello, I already finished"); + handleOpenForm(); + await reviewTask(BigInt(taskId), dataForm); handleSnackbar('Review Task process initiated with success!', 'info') break; case "Review": @@ -114,7 +129,7 @@ export const CardTask = ({ taskId, taskData, loading }: any) => { } catch (error) { setError(error.message) setOpenError(true); - } + } } useEffect(() => { @@ -177,7 +192,6 @@ export const CardTask = ({ taskId, taskData, loading }: any) => { variant="body2" style={{ textAlign: isSmallScreen ? 'left' : 'center', - // marginLeft: isSmallScreen ? 'auto' : 'unset', backgroundColor: '#000000', }} > @@ -196,42 +210,42 @@ export const CardTask = ({ taskId, taskData, loading }: any) => { {taskData.title} - - { - isLeader && taskData.status != "Canceled" && - - - {approvals} - - - } - - { - isLeader && taskData.status != "Canceled" && - - - - - - } - - { - isLeader && taskData.status != "Canceled" && - - - + + { + isLeader && taskData.status != "Canceled" && + + + {approvals} + + + } + + { + isLeader && taskData.status != "Canceled" && + + + + + + } + + { + isLeader && taskData.status != "Canceled" && + + + + + + } + + + + - } - - - - - - @@ -255,14 +269,19 @@ export const CardTask = ({ taskId, taskData, loading }: any) => { { taskData.status != "Completed" && taskData.status != "Canceled" && - + + {openForm && } + + - variant="contained" - component="span" - onClick={handleAction} - > - {action} - }