Use server actions instead of client-side API calls

This commit is contained in:
Darren Clarke 2024-08-05 23:31:15 +02:00
parent 5a3127dcb0
commit aa453954ed
30 changed files with 703 additions and 462 deletions

View file

@ -20,11 +20,12 @@ import {
WhatsApp as WhatsAppIcon,
Facebook as FacebookIcon,
AirlineStops as AirlineStopsIcon,
Logout as LogoutIcon,
} from "@mui/icons-material";
import { usePathname } from "next/navigation";
import Link from "next/link";
import Image from "next/image";
import { typography, fonts } from "@link-stack/ui";
import { typography, fonts, Button } from "@link-stack/ui";
import LinkLogo from "@/app/_images/link-logo-small.png";
import { useSession, signOut } from "next-auth/react";
@ -161,9 +162,9 @@ export const Sidebar: FC<SidebarProps> = ({ open, setOpen }) => {
const { data: session } = useSession();
const user = session?.user;
// const logout = () => {
// signOut({ callbackUrl: "/login" });
// };
const logout = () => {
signOut({ callbackUrl: "/login" });
};
return (
<Drawer
@ -377,18 +378,20 @@ export const Sidebar: FC<SidebarProps> = ({ open, setOpen }) => {
</Box>
</Grid>
)}
{open && (
<Grid item>
<Box
sx={{
...bodyLarge,
color: "white",
}}
>
{user?.email}
</Box>
</Grid>
)}
<Grid item>
<Box
sx={{
...bodyLarge,
color: "white",
}}
>
{user?.email}
</Box>
</Grid>
<Grid item>
<Button text="Logout" kind="secondary" onClick={logout} />
</Grid>
</Grid>
</Grid>
</Drawer>