flockstr/app/(app)/_layout/components/AddNoteButton.tsx

47 lines
1.2 KiB
TypeScript
Raw Normal View History

2023-10-29 12:44:24 -04:00
"use client";
2023-10-24 16:44:46 -04:00
import { useModal } from "@/app/_providers/modal/provider";
import { Button } from "@/components/ui/button";
import { RiAddFill } from "react-icons/ri";
import NewEventModal from "@/components/Modals/NewEvent";
2023-10-29 12:44:24 -04:00
import LoginModal from "@/components/Modals/Login";
import useCurrentUser from "@/lib/hooks/useCurrentUser";
2023-10-24 16:44:46 -04:00
export default function AddNoteButton() {
const modal = useModal();
2023-10-29 12:44:24 -04:00
const { currentUser } = useCurrentUser();
2023-10-24 16:44:46 -04:00
return (
<>
<Button
2023-10-29 12:44:24 -04:00
onClick={() => {
if (currentUser) {
return modal?.show(<NewEventModal />);
} else {
return modal?.show(<LoginModal />);
}
}}
2023-10-24 16:44:46 -04:00
size={"icon"}
className="xl:hidden"
>
<RiAddFill className="h-6 w-6" />
</Button>
<Button
2023-10-29 12:44:24 -04:00
onClick={() => {
if (currentUser) {
return modal?.show(<NewEventModal />);
} else {
return modal?.show(<LoginModal />);
}
}}
2023-10-24 16:44:46 -04:00
size={"lg"}
className="hidden xl:flex"
>
<div className="center gap-x-1.5">
<RiAddFill className="h-6 w-6" />
<span>Add Note</span>
</div>
</Button>
</>
);
}