mirror of
https://github.com/dyzulk/trustlab.git
synced 2026-01-26 13:32:06 +07:00
fix: allow owner role to access admin pages
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState } from "react";
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
import useSWR from "swr";
|
||||
import axios from "@/lib/axios";
|
||||
import { Plus, Search, FileText, ChevronRight, Edit3, Trash2 } from "lucide-react";
|
||||
@@ -15,7 +17,16 @@ const fetcher = (url: string) => axios.get(url).then((res) => res.data);
|
||||
|
||||
export default function AdminLegalListClient() {
|
||||
const t = useTranslations("LegalAdmin");
|
||||
const router = useRouter();
|
||||
const { user, isAdminOrOwner } = useAuth();
|
||||
const { addToast } = useToast();
|
||||
|
||||
useEffect(() => {
|
||||
if (user && !isAdminOrOwner) {
|
||||
router.push("/dashboard");
|
||||
}
|
||||
}, [user, isAdminOrOwner, router]);
|
||||
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const { data, mutate, isLoading } = useSWR("/api/admin/legal-pages", fetcher);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user