The weeb for the next gen discord boat - Wamellow
wamellow.com
bot
discord
1"use client";
2
3import { guildStore } from "@/common/guilds";
4import { TooltipProvider } from "@/components/ui/tooltip";
5import { cn } from "@/utils/cn";
6import { usePathname } from "next/navigation";
7import { useCookies } from "next-client-cookies";
8import { useEffect } from "react";
9import { QueryClient, QueryClientProvider } from "react-query";
10
11const queryClient = new QueryClient();
12
13interface Props {
14 children: React.ReactNode;
15 className?: string;
16}
17
18export function Provider({ children, className }: Props) {
19 const cookies = useCookies();
20 const path = usePathname();
21
22 useEffect(() => {
23 cookies.set(
24 "lastpage",
25 path,
26 {
27 secure: process.env.NEXT_PUBLIC_BASE_URL?.startsWith("https://"),
28 sameSite: "none",
29 domain: process.env.NEXT_PUBLIC_BASE_URL?.split("://")[1],
30 expires: 28
31 }
32 );
33
34 if (!path.startsWith("/dashboard/")) guildStore.setState(undefined);
35 }, [path, cookies]);
36
37 return (
38 <TooltipProvider>
39 <QueryClientProvider client={queryClient}>
40 <main className={cn("text-neutral-400 flex flex-col items-center justify-between md:p-5 p-3 w-full max-w-7xl mt-2 md:mt-10", className)}>
41 {children}
42 </main>
43 </QueryClientProvider>
44 </TooltipProvider>
45 );
46}