feat:前端修改
This commit is contained in:
@@ -4,6 +4,7 @@ import Link from "next/link";
|
||||
import { ArrowLeft, Download, RefreshCw, Send } from "lucide-react";
|
||||
import { FormEvent, useEffect, useState } from "react";
|
||||
import { ApiError, apiFetch } from "@/lib/api";
|
||||
import { USER_TYPE } from "@/lib/roles";
|
||||
|
||||
interface HistoryItem { query_id?: string; question?: string; status?: string; row_count?: number; create_time?: string; }
|
||||
|
||||
@@ -16,15 +17,15 @@ export default function Nl2SqlPage() {
|
||||
const [message, setMessage] = useState("");
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [userType, setUserType] = useState<string | null>(null);
|
||||
const isAdmin = userType === "ADMIN";
|
||||
const canQuery = userType === "EMPLOYEE";
|
||||
const isAdmin = userType === USER_TYPE.ADMIN;
|
||||
const canQuery = userType === USER_TYPE.EMPLOYEE || userType === USER_TYPE.ADMIN;
|
||||
|
||||
useEffect(() => {
|
||||
void apiFetch<{ user: { user_type?: string } }>("/auth/me")
|
||||
.then(({ user }) => {
|
||||
const nextType = user.user_type ?? null;
|
||||
setUserType(nextType);
|
||||
if (nextType === "ADMIN") setTab("config");
|
||||
if (nextType === USER_TYPE.ADMIN) setTab("config");
|
||||
})
|
||||
.catch(() => setUserType(null));
|
||||
}, []);
|
||||
|
||||
Reference in New Issue
Block a user