lint
This commit is contained in:
@@ -9,7 +9,6 @@ import {
|
||||
DrawerFooter,
|
||||
DrawerHeader,
|
||||
DrawerTitle,
|
||||
DrawerTrigger,
|
||||
} from "@/components/ui/drawer"
|
||||
import { useState } from "react";
|
||||
import { AdminApi } from "@/lib/api";
|
||||
|
||||
@@ -17,7 +17,6 @@ import { Label } from "@/components/ui/label"
|
||||
import { useUser } from "@/hooks/admin/user/use-user";
|
||||
import { User } from "@/lib/types/user";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { updateUser } from "@/lib/api/admin/user";
|
||||
import { AdminApi } from "@/lib/api";
|
||||
import { toast } from "sonner";
|
||||
import {
|
||||
@@ -42,10 +41,15 @@ export function UserInfoEditor({
|
||||
}) {
|
||||
const { user, isLoading, error } = useUser(userId);
|
||||
|
||||
const [saveLoading, setSaveLoading] = React.useState(false);
|
||||
const handleSave = async (user: updateUser) => {
|
||||
// const [saveLoading, setSaveLoading] = React.useState(false);
|
||||
const handleSave = async (user: {
|
||||
username: string;
|
||||
nickname: string;
|
||||
email: string | null;
|
||||
phone: string | null;
|
||||
}) => {
|
||||
try {
|
||||
setSaveLoading(true);
|
||||
// setSaveLoading(true);
|
||||
const res = await AdminApi.user.update(userId, user);
|
||||
if (res) {
|
||||
toast.success("保存成功");
|
||||
@@ -57,14 +61,14 @@ export function UserInfoEditor({
|
||||
} catch (error) {
|
||||
toast.error((error as Error).message || "保存失败");
|
||||
} finally {
|
||||
setSaveLoading(false);
|
||||
// setSaveLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
const [removeLoading, setRemoveLoading] = React.useState(false);
|
||||
// const [removeLoading, setRemoveLoading] = React.useState(false);
|
||||
const handleRemove = async (userId: string) => {
|
||||
try {
|
||||
setRemoveLoading(true);
|
||||
// setRemoveLoading(true);
|
||||
await AdminApi.user.remove(userId, true);
|
||||
toast.success("注销成功");
|
||||
onUserSoftDelete(userId);
|
||||
@@ -72,22 +76,22 @@ export function UserInfoEditor({
|
||||
} catch (error) {
|
||||
toast.error((error as Error).message || "注销失败");
|
||||
} finally {
|
||||
setRemoveLoading(false);
|
||||
// setRemoveLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
const [passwordDialogOpen, setPasswordDialogOpen] = React.useState(false);
|
||||
const [setPasswordLoading, setSetPasswordLoading] = React.useState(false);
|
||||
// const [setPasswordLoading, setSetPasswordLoading] = React.useState(false);
|
||||
const handleSetPassword = async (userId: string, password: string) => {
|
||||
try {
|
||||
setSetPasswordLoading(true);
|
||||
// setSetPasswordLoading(true);
|
||||
await AdminApi.user.setPassword(userId, password);
|
||||
toast.success("密码修改成功");
|
||||
setPasswordDialogOpen(false);
|
||||
} catch (error) {
|
||||
toast.error((error as Error).message || "密码修改失败");
|
||||
} finally {
|
||||
setSetPasswordLoading(false);
|
||||
// setSetPasswordLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,8 +113,8 @@ export function UserInfoEditor({
|
||||
e.preventDefault()
|
||||
const formData = new FormData(e.currentTarget);
|
||||
handleSave({
|
||||
username: formData.get("username")?.toString()!,
|
||||
nickname: formData.get("nickname")?.toString()!,
|
||||
username: formData.get("username")?.toString() as unknown as string,
|
||||
nickname: formData.get("nickname")?.toString() as unknown as string,
|
||||
email: formData.get("email")?.toString() || null,
|
||||
phone: formData.get("phone")?.toString() || null,
|
||||
})
|
||||
|
||||
@@ -8,14 +8,14 @@ import { useState } from "react";
|
||||
import { UserInfoEditor } from "./components/user-info-editor";
|
||||
import { User } from "@/lib/types/user";
|
||||
import { CreateUserEditor } from "./components/create-user-editor";
|
||||
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger } from "@/components/ui/alert-dialog";
|
||||
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@/components/ui/alert-dialog";
|
||||
import { AdminApi } from "@/lib/api";
|
||||
import { toast } from "sonner";
|
||||
import { ApiError } from "next/dist/server/api-utils";
|
||||
|
||||
|
||||
export default function Page() {
|
||||
const { users, isLoading, error, total, page, pageSize, mutate, refresh } = useUserList();
|
||||
const { users, isLoading, error, mutate, refresh } = useUserList();
|
||||
const [editorUserId, setEditorUserId] = useState("");
|
||||
|
||||
const handleUserUpdateLocal = async (newUser: User) => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client"
|
||||
|
||||
import React, { use, useState } from "react"
|
||||
import React, { useState } from "react"
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
@@ -13,25 +13,9 @@ import { Input } from "@/components/ui/input"
|
||||
import { Label } from "@/components/ui/label"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { toast } from "sonner"
|
||||
import { Textarea } from "@/components/ui/textarea"
|
||||
import { Plus } from "lucide-react"
|
||||
import { Resource } from "@/lib/types/resource"
|
||||
import { AdminApi } from "@/lib/api"
|
||||
import useSWR from "swr"
|
||||
import { ApiError } from "next/dist/server/api-utils"
|
||||
import { Skeleton } from "@/components/ui/skeleton"
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
AlertDialogTrigger,
|
||||
} from "@/components/ui/alert-dialog"
|
||||
|
||||
|
||||
interface BlogEditProps {
|
||||
id: string;
|
||||
@@ -41,7 +25,7 @@ interface BlogEditProps {
|
||||
|
||||
export default function BlogEdit({ id, children, onRefresh }: BlogEditProps) {
|
||||
const [open, setOpen] = useState(false)
|
||||
const { data: blog, error, isLoading, mutate } = useSWR(
|
||||
const { data: blog, mutate } = useSWR(
|
||||
open ? `/api/admin/web/blog/${id}` : null,
|
||||
() => AdminApi.web.blog.get(id),
|
||||
{
|
||||
|
||||
@@ -3,7 +3,6 @@ import {
|
||||
TableBody,
|
||||
TableCaption,
|
||||
TableCell,
|
||||
TableFooter,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
|
||||
@@ -6,7 +6,7 @@ import AddBlog from "./components/AddBlog";
|
||||
import { Button } from "@/components/ui/button";
|
||||
|
||||
export default function Page() {
|
||||
const { blogs, error, isLoading, refresh } = useBlogList();
|
||||
const { blogs, refresh } = useBlogList();
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -153,7 +153,7 @@ export default function AddResource({ children, refresh }: AddResourceProps) {
|
||||
</div>
|
||||
</div>
|
||||
<DialogFooter>
|
||||
<Button type="submit" onClick={handleSubmit}>保存</Button>
|
||||
<Button type="submit" onClick={handleSubmit} disabled={loading}>保存</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
@@ -43,7 +43,7 @@ interface ResourceEditProps {
|
||||
export default function ResourceEdit({ children, id, onRefresh }: ResourceEditProps) {
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
const { data: resource, error, isLoading, mutate } = useSWR<Resource>(
|
||||
const { data: resource, isLoading, mutate } = useSWR<Resource>(
|
||||
open ? [`/api/admin/web/resource/${id}`] : null,
|
||||
() => AdminApi.web.resource.get(id),
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@ import { Button } from "@/components/ui/button";
|
||||
import AddResource from "./components/AddResource";
|
||||
|
||||
export default function Page() {
|
||||
const { resources, error, isLoading, mutate, refresh } = useResourceList();
|
||||
const { resources, refresh } = useResourceList();
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user