DeleteProjectDialog update to Modal (#70)

This commit is contained in:
Vivian Phung 2024-05-16 20:26:31 -04:00 committed by GitHub
parent 5dc4d28b50
commit a69dd71117
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,20 +1,13 @@
import { useCallback } from 'react'; import { useCallback } from 'react';
import { useNavigate, useParams } from 'react-router-dom'; import { useNavigate, useParams } from 'react-router-dom';
import { useForm } from 'react-hook-form'; import { useForm } from 'react-hook-form';
import { Project } from 'gql-client';
import { import { useGQLClient } from 'context/GQLClientContext';
Button,
Dialog,
DialogHeader,
DialogBody,
DialogFooter,
Input,
Typography,
} from '@snowballtools/material-tailwind-react-fork';
import { useGQLClient } from '../../../../context/GQLClientContext';
import { useToast } from 'components/shared/Toast'; import { useToast } from 'components/shared/Toast';
import { Modal } from 'components/shared/Modal';
import { Button } from 'components/shared/Button';
import { Input } from 'components/shared/Input';
import { Project } from 'gql-client';
interface DeleteProjectDialogProp { interface DeleteProjectDialogProp {
open: boolean; open: boolean;
@ -60,51 +53,36 @@ const DeleteProjectDialog = ({
}, [client, project, handleOpen]); }, [client, project, handleOpen]);
return ( return (
<Dialog open={open} handler={handleOpen}> <Modal open={open} onOpenChange={handleOpen}>
<DialogHeader className="flex justify-between"> <Modal.Content>
<div>Delete project?</div> <Modal.Header>Delete project?</Modal.Header>
<Button
variant="outlined"
onClick={handleOpen}
className="mr-1 rounded-3xl"
>
X
</Button>
</DialogHeader>
<form onSubmit={handleSubmit(deleteProjectHandler)}> <form onSubmit={handleSubmit(deleteProjectHandler)}>
<DialogBody className="flex flex-col gap-2"> <Modal.Body>
<Typography variant="paragraph">
Deleting your project is irreversible. Enter your projects
name&nbsp;
<span className="bg-blue-100 text-blue-700">({project.name})</span>
&nbsp;below to confirm you want to permanently delete it:
</Typography>
<Input <Input
label={
"Deleting your project is irreversible. Enter your project's name " +
project.name +
' below to confirm you want to permanently delete it:'
}
id="input" id="input"
{...register('projectName', { {...register('projectName', {
required: 'Project name is required', required: 'Project name is required',
validate: (value) => value === project.name, validate: (value) => value === project.name,
})} })}
helperText="Deleting your project is irreversible."
/> />
<Typography variant="small" color="red"> </Modal.Body>
^ Deleting your project is irreversible. <Modal.Footer className="flex justify-start">
</Typography> <Button onClick={handleOpen} variant="tertiary">
</DialogBody>
<DialogFooter className="flex justify-start">
<Button variant="outlined" onClick={handleOpen} className="mr-1">
Cancel Cancel
</Button> </Button>
<Button <Button variant="danger" type="submit" disabled={!isValid}>
variant="gradient" Yes, delete project
color="red"
type="submit"
disabled={!isValid}
>
Yes, Delete project
</Button> </Button>
</DialogFooter> </Modal.Footer>
</form> </form>
</Dialog> </Modal.Content>
</Modal>
); );
}; };