auth protection
This commit is contained in:
parent
86fb4eed1d
commit
4becfe1a94
@ -1,21 +1,38 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
import { useModal } from "@/app/_providers/modal/provider";
|
import { useModal } from "@/app/_providers/modal/provider";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { RiAddFill } from "react-icons/ri";
|
import { RiAddFill } from "react-icons/ri";
|
||||||
import NewEventModal from "@/components/Modals/NewEvent";
|
import NewEventModal from "@/components/Modals/NewEvent";
|
||||||
|
import LoginModal from "@/components/Modals/Login";
|
||||||
|
import useCurrentUser from "@/lib/hooks/useCurrentUser";
|
||||||
|
|
||||||
export default function AddNoteButton() {
|
export default function AddNoteButton() {
|
||||||
const modal = useModal();
|
const modal = useModal();
|
||||||
|
const { currentUser } = useCurrentUser();
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Button
|
<Button
|
||||||
onClick={() => modal?.show(<NewEventModal />)}
|
onClick={() => {
|
||||||
|
if (currentUser) {
|
||||||
|
return modal?.show(<NewEventModal />);
|
||||||
|
} else {
|
||||||
|
return modal?.show(<LoginModal />);
|
||||||
|
}
|
||||||
|
}}
|
||||||
size={"icon"}
|
size={"icon"}
|
||||||
className="xl:hidden"
|
className="xl:hidden"
|
||||||
>
|
>
|
||||||
<RiAddFill className="h-6 w-6" />
|
<RiAddFill className="h-6 w-6" />
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
onClick={() => modal?.show(<NewEventModal />)}
|
onClick={() => {
|
||||||
|
if (currentUser) {
|
||||||
|
return modal?.show(<NewEventModal />);
|
||||||
|
} else {
|
||||||
|
return modal?.show(<LoginModal />);
|
||||||
|
}
|
||||||
|
}}
|
||||||
size={"lg"}
|
size={"lg"}
|
||||||
className="hidden xl:flex"
|
className="hidden xl:flex"
|
||||||
>
|
>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user