Skip to content

Commit

Permalink
feat: improve user shelters loading and performance
Browse files Browse the repository at this point in the history
  • Loading branch information
emiliosheinz committed Jun 22, 2024
1 parent 69893dd commit 277d45f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
2 changes: 0 additions & 2 deletions src/app/user/shelters/create/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
"use client";

import { FormEditRegister } from "~/app/user/shelters/_components";

export default function CreateShelterPage() {
Expand Down
30 changes: 12 additions & 18 deletions src/app/user/shelters/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
import { Loader2 } from "lucide-react";
import { redirect } from "next/navigation";
import { Suspense, type PropsWithChildren } from "react";
import { getServerAuthSession } from "~/server/auth";
"use client";

import { useSession } from "next-auth/react";
import { redirect, usePathname } from "next/navigation";
import { type PropsWithChildren } from "react";

export default function ShelterLayout({ children }: PropsWithChildren) {
const pathname = usePathname();
const { data: session } = useSession();

export default async function ShelterLayout({ children }: PropsWithChildren) {
const session = await getServerAuthSession();
if (!session) {
redirect("/signin?callbackUrl=/user/shelters");
redirect(`/signin?callbackUrl=${pathname}`);
}
return (
<Suspense
fallback={
<div className="flex w-full justify-center pt-28">
<Loader2 className="size-8 animate-spin" />
</div>
}
>
{children}
</Suspense>
);

return children;
}

0 comments on commit 277d45f

Please sign in to comment.