-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexit-modal.tsx
68 lines (59 loc) · 2.31 KB
/
exit-modal.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
"use client"
import { useExitModal } from "@/store/use-exit-modal"
import Image from "next/image"
import { useRouter } from "next/navigation"
import { useEffect, useState } from "react"
import { Dialog, DialogHeader, DialogTitle, DialogContent, DialogDescription, DialogFooter } from "../ui/dialog"
import { Button } from "../ui/button"
export const ExitModal = () => {
const router = useRouter()
const [isClient, setIsClient] = useState(false)
const { isOpen, close } = useExitModal()
useEffect(() => {
setIsClient(true)
}, [])
if(!isClient)
{
return null
}
return (
<Dialog open={isOpen} onOpenChange={close}>
<DialogContent className="max-w-md">
<DialogHeader>
<div className="flex items-center w-full justify-center mb-5">
<Image src={"/mascot_sad.svg"} height={80} width={80} alt="mascot_sad"/>
</div>
<DialogTitle className="text-center font-bold text-2xl">
Wait, don't go!
</DialogTitle>
<DialogDescription className="text-center text-base">
You're about to leave the lesson. Are you sure?
</DialogDescription>
</DialogHeader>
<DialogFooter className="mb-4">
<div className="flex flex-col gap-y-4 w-full">
<Button
variant={"primary"}
className="w-full"
size={"lg"}
onClick={close}
>
Keep Learning
</Button>
<Button
variant={"dangerOutline"}
className="w-full"
size={"lg"}
onClick={() => {
close();
router.push("/learn")
}}
>
End Session
</Button>
</div>
</DialogFooter>
</DialogContent>
</Dialog>
)
}