-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: quiz status chip and delete quiz dialog
- Loading branch information
1 parent
83f7099
commit f6e900c
Showing
3 changed files
with
87 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Chip } from "@material-tailwind/react"; | ||
import { size } from "@material-tailwind/react/types/components/chip"; | ||
import { colors } from "@material-tailwind/react/types/generic"; | ||
import { QuizStatus } from "@generated/graphql.ts"; | ||
|
||
interface QuizStatusChipProps { | ||
status?: QuizStatus; | ||
size?: size; | ||
} | ||
|
||
export function QuizStatusChip({ status, size = "md" }: QuizStatusChipProps) { | ||
const color = { | ||
[QuizStatus.Pending]: "blue", | ||
[QuizStatus.Approved]: "green", | ||
[QuizStatus.Cancelled]: "red", | ||
}[status || QuizStatus.Pending]; | ||
|
||
return <Chip color={color as colors} value={status} size={size} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { useState } from "react"; | ||
import { | ||
Button, | ||
Dialog, | ||
DialogBody, | ||
DialogFooter, | ||
DialogHeader, | ||
IconButton, | ||
Typography, | ||
} from "@material-tailwind/react"; | ||
import { X } from "lucide-react"; | ||
import { toast } from "react-toastify"; | ||
|
||
export function DeleteQuiz({}: { quizId: string }) { | ||
const [isOpen, setIsOpen] = useState(false); | ||
const toggleDialog = () => setIsOpen(!isOpen); | ||
|
||
return ( | ||
<> | ||
<IconButton size="sm" variant="text" onClick={toggleDialog}> | ||
<X className="size-4 stroke-red-500" /> | ||
</IconButton> | ||
|
||
<Dialog open={isOpen} handler={toggleDialog}> | ||
<DialogHeader>Are you sure you want to delete this quiz?</DialogHeader> | ||
<DialogBody> | ||
<Typography>This action will make a soft delete of the quiz.</Typography> | ||
</DialogBody> | ||
<DialogFooter> | ||
<Button variant="gradient" color="gray" onClick={toggleDialog} className="mr-2"> | ||
Go back | ||
</Button> | ||
<Button | ||
variant="filled" | ||
color="red" | ||
onClick={() => { | ||
toast.success("Quiz deleted successful"); | ||
}} | ||
> | ||
Delete | ||
</Button> | ||
</DialogFooter> | ||
</Dialog> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters