upd: add revalidate

This commit is contained in:
oiov
2024-08-01 19:27:05 +08:00
parent ed6045e058
commit 203f989338
3 changed files with 17 additions and 3 deletions
+1 -2
View File
@@ -14,8 +14,7 @@ export default function AdminPanelLoading() {
<Skeleton className="h-32 w-full rounded-lg" />
<Skeleton className="h-32 w-full rounded-lg" />
</div>
<Skeleton className="h-[500px] w-full rounded-lg" />
<Skeleton className="h-[500px] w-full rounded-lg" />
<Skeleton className="h-[400px] w-full rounded-lg" />
</div>
</>
);
+13
View File
@@ -1,7 +1,20 @@
import { prisma } from "@/lib/db";
import { checkUserStatus } from "@/lib/dto/user";
import { getCurrentUser } from "@/lib/session";
export const revalidate = 60;
export async function GET(req: Request) {
try {
const user = checkUserStatus(await getCurrentUser());
if (user instanceof Response) return user;
if (user.role !== "ADMIN") {
return Response.json("Unauthorized", {
status: 401,
statusText: "Unauthorized",
});
}
const threeMonthsAgo = new Date();
threeMonthsAgo.setMonth(threeMonthsAgo.getMonth() - 3);
+3 -1
View File
@@ -107,7 +107,9 @@ export function NavBar({ scroll = false }: NavBarProps) {
href="/dashboard"
className="hidden text-sm font-medium text-foreground/60 transition-colors hover:text-foreground/80 md:block"
>
Dashboard
<Button className="" variant="outline" size="sm" rounded="lg">
Dashboard
</Button>
</Link>
<div className="hidden md:flex">
<ModeToggle />