Skip to content

Commit

Permalink
Initial Structure ReviewTask
Browse files Browse the repository at this point in the history
  • Loading branch information
heronlancellot committed Oct 20, 2023
1 parent 31e226b commit 7fe1f0b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 26 deletions.
5 changes: 2 additions & 3 deletions src/components/Form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ import DialogContentText from '@mui/material/DialogContentText';
import DialogTitle from '@mui/material/DialogTitle';
import { useEffect, useState } from 'react';

export default function FormDialog(openForm, onSubmit) {
export default function FormDialog({ openForm, onSubmit }) {
const [open, setOpen] = useState<boolean>(false)
const [descriptionReview, setDescriptionReview] = useState()

console.log('onSubmit', onSubmit);

const handleConfirmation = (event: { target: { value: any; }; }) => {
let description = event.target.value;
Expand All @@ -23,7 +22,7 @@ export default function FormDialog(openForm, onSubmit) {
};

const handleSubmit = () => {
onSubmit(descriptionReview)
onSubmit(descriptionReview);
handleClose();
};

Expand Down
21 changes: 11 additions & 10 deletions src/components/Task/CardTask.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import FormDialog from '../Form';
*/


export const CardTask = ({ taskId, taskData, loading }: any) => {
export const CardTask = ({ taskId, taskData, loading, setNewReview }: any) => {
const { startTask, reviewTask, completeTask, cancelTask, hasMemberRole, hasLeaderRole, hasVoted, getMinQuorum, getQuorumApprovals } = useTaskService();
const [openError, setOpenError] = useState(false);
const [error, setError] = useState<string>();
Expand All @@ -36,18 +36,19 @@ export const CardTask = ({ taskId, taskData, loading }: any) => {
const [isMember, setIsMember] = useState<boolean>(false);
const [isLeader, setIsLeader] = useState<boolean>(false);
const [openForm, setOpenForm] = useState<boolean>(false);
const [dataForm, setDataForm] = useState<string>('');

const handleOpenForm = async () => {
setOpenForm(true);
};

const handleFormSubmit = (metadata: any) => {
setDataForm(metadata);
const handleFormSubmit = async (metadata: any) => {
console.log('metadata ', metadata);
setOpenForm(false);
}
console.log('taskId HANDLEFORMSUBMIT - CARDTASK', taskId);
console.log('dataForm HANDLEFORMSUBMIT - CARDTASK', metadata)
await reviewTask(BigInt(taskId), metadata).then(result => { setNewReview(true), handleSnackbar('Review Task process initiated with success!', 'info'), console.log('result', result) });

console.log('dataForm', dataForm)
}

const theme = useTheme();
const isSmallScreen = useMediaQuery(theme.breakpoints.down('sm'));
Expand Down Expand Up @@ -83,12 +84,12 @@ export const CardTask = ({ taskId, taskData, loading }: any) => {
break;
case "Progress":
handleOpenForm();
await reviewTask(BigInt(taskId), dataForm);
handleSnackbar('Review Task process initiated with success!', 'info')


break;
case "Review":
await reviewTask(BigInt(taskId), "Awesome, contact me on Discord!");
handleSnackbar('Review Task process initiated with success!', 'info')
handleOpenForm();

break;
default:
break;
Expand Down
30 changes: 17 additions & 13 deletions src/content/applications/Tasks/details/DetailsTask.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,30 @@ import { Helmet } from 'react-helmet-async';
import SuspenseLoader from 'src/components/SuspenseLoader'
import { useTaskService } from "src/services/tasks-service";
import { useTaskServiceHook } from "src/hooks/TaskServiceHook";
import { useEffect } from "react";
import { useEffect, useState } from "react";
import CardTasks from "../../../../components/Task/CardTask";

const DetailsTask = () => {
const theme = useTheme();
const isSmallScreen = useMediaQuery(theme.breakpoints.down('sm'));

const taskService = useTaskService();
const { taskId } = useParams();

const [newReview, setNewReview] = useState<boolean>(false);
const { handleTask, handleReview, taskData, taskReview, loading, error } = useTaskServiceHook(taskService);

useEffect(() => {
const fetchData = async () => {
await handleTask(Number(taskId));
await handleReview(Number(taskId));
};
const fetchData = async () => {
await handleTask(Number(taskId));
await handleReview(Number(taskId));
setNewReview(true)
};

useEffect(() => {
fetchData();
}, []);
console.log('newReview = ', newReview);
if (newReview) {
fetchData()
}
}, [newReview]);

return (
<>
Expand All @@ -46,7 +50,7 @@ const DetailsTask = () => {
(
<>
<Box width={isSmallScreen ? '100%' : 709} mt={isSmallScreen ? 2 : 0}>
<CardTasks taskId={taskId} taskData={taskData} loading={loading} />
<CardTasks taskId={taskId} taskData={taskData} loading={loading} setNewReview={setNewReview} />

<Box mt={4} width={isSmallScreen ? '100%' : 679} display={'flex'} flexDirection={isSmallScreen ? 'column' : 'row'} justifyContent={isSmallScreen ? 'center' : 'space-between'} alignItems={'center'}>
<Card sx={{ width: isSmallScreen ? '100%' : 192, height: 119, justifyContent: 'center', marginBottom: isSmallScreen ? '16px' : '0' }}>
Expand All @@ -63,11 +67,11 @@ const DetailsTask = () => {

<Card sx={{ width: isSmallScreen ? '100%' : 434, height: 119, justifyContent: isSmallScreen ? 'center' : 'left' }}>
<CardContent style={{ maxHeight: '200px', overflowY: 'auto' }}>
{/* <CardContent> */}
{/* <CardContent> */}
<Typography gutterBottom variant="h4" textAlign={'left'} component="div">
Reviews
</Typography>
<Divider />
<Divider />
<Typography variant="h6" textAlign={'left'} mt={1} component="div">
{taskReview ? (taskReview.map((review: any) => {
return (
Expand All @@ -78,7 +82,7 @@ const DetailsTask = () => {
</Box>
)
})) : 'No reviews provided for this task.'}
</Typography>
</Typography>
</CardContent>
</Card>
</Box>
Expand Down

0 comments on commit 7fe1f0b

Please sign in to comment.