lint
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { useCallback } from "react"
|
||||
import {
|
||||
Alert,
|
||||
AlertDescription,
|
||||
|
||||
@@ -15,8 +15,6 @@ import {
|
||||
import { useUserStore } from "@/store/useUserStore";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useEffect } from "react";
|
||||
// import { useUserMe } from "@/hooks/user/use-user-me";
|
||||
// import { toast } from "sonner";
|
||||
|
||||
export default function ConsoleMenuLayout({
|
||||
children,
|
||||
@@ -30,7 +28,7 @@ export default function ConsoleMenuLayout({
|
||||
if (userStore.initialized && !userStore.user) {
|
||||
router.replace('/console/login')
|
||||
}
|
||||
}, [userStore])
|
||||
}, [userStore, router])
|
||||
|
||||
return (
|
||||
<SidebarProvider>
|
||||
|
||||
@@ -3,17 +3,15 @@
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Field, FieldDescription, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet } from "@/components/ui/field";
|
||||
import { useUserStore } from "@/store/useUserStore";
|
||||
import { Checkbox } from "@radix-ui/react-checkbox";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCaption,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "@/components/ui/table"
|
||||
import { ReactElement, useMemo, useState } from "react";
|
||||
import { ReactElement, useState } from "react";
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
|
||||
@@ -27,6 +27,7 @@ import { AlertCircle } from "lucide-react";
|
||||
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger } from "@/components/ui/alert-dialog";
|
||||
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog";
|
||||
import { AdminAPI } from "@/lib/api/client";
|
||||
import { UserEntity } from "@/lib/api/endpoints/admin.client";
|
||||
|
||||
export function UserInfoEditor({
|
||||
onClose,
|
||||
@@ -35,7 +36,7 @@ export function UserInfoEditor({
|
||||
userId,
|
||||
}: {
|
||||
onClose: () => void,
|
||||
onUserUpdate: (user: User) => void,
|
||||
onUserUpdate: (user: UserEntity) => void,
|
||||
onUserSoftDelete: (userId: string) => void,
|
||||
userId: string
|
||||
}) {
|
||||
|
||||
@@ -6,19 +6,19 @@ import { TooltipContent, TooltipProvider, TooltipTrigger, Tooltip } from "@/comp
|
||||
import { useUserList } from "@/hooks/admin/user/use-user-list";
|
||||
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 } from "@/components/ui/alert-dialog";
|
||||
import { toast } from "sonner";
|
||||
import { ApiError } from "next/dist/server/api-utils";
|
||||
import { AdminAPI } from "@/lib/api/client";
|
||||
import { UserEntity } from "@/lib/api/endpoints/admin.client";
|
||||
|
||||
|
||||
export default function Page() {
|
||||
const { users, isLoading, error, mutate, refresh } = useUserList();
|
||||
const [editorUserId, setEditorUserId] = useState("");
|
||||
|
||||
const handleUserUpdateLocal = async (newUser: User) => {
|
||||
const handleUserUpdateLocal = async (newUser: UserEntity) => {
|
||||
await mutate(
|
||||
(data) => {
|
||||
if (!data) return data;
|
||||
|
||||
@@ -1,67 +1,67 @@
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { InputOTP, InputOTPGroup, InputOTPSlot } from "@/components/ui/input-otp";
|
||||
import { REGEXP_ONLY_DIGITS_AND_CHARS } from "input-otp";
|
||||
import { useState, useCallback } from "react";
|
||||
import { toast } from "sonner";
|
||||
import LoginHeader from "./LoginHeader";
|
||||
import { SendCodeFormData } from "./types";
|
||||
import { Label } from "@/components/ui/label";
|
||||
// import { Button } from "@/components/ui/button";
|
||||
// import { Input } from "@/components/ui/input";
|
||||
// import { InputOTP, InputOTPGroup, InputOTPSlot } from "@/components/ui/input-otp";
|
||||
// import { REGEXP_ONLY_DIGITS_AND_CHARS } from "input-otp";
|
||||
// import { useState, useCallback } from "react";
|
||||
// import { toast } from "sonner";
|
||||
// import LoginHeader from "./LoginHeader";
|
||||
// import { SendCodeFormData } from "./types";
|
||||
// import { Label } from "@/components/ui/label";
|
||||
|
||||
export default function EmailLoginMode({ onSendCode }: { onSendCode: (data: SendCodeFormData) => Promise<boolean> }) {
|
||||
const [email, setEmail] = useState("");
|
||||
const handleSendCode = useCallback(() => {
|
||||
if (!email.trim().match(/^[^\s@]+@[^\s@]+\.[^\s@]+$/)) {
|
||||
toast.error('请输入正确的邮箱地址');
|
||||
return;
|
||||
}
|
||||
onSendCode({
|
||||
type: 'email',
|
||||
email,
|
||||
})
|
||||
}, [email, onSendCode]);
|
||||
// export default function EmailLoginMode({ onSendCode }: { onSendCode: (data: SendCodeFormData) => Promise<boolean> }) {
|
||||
// const [email, setEmail] = useState("");
|
||||
// const handleSendCode = useCallback(() => {
|
||||
// if (!email.trim().match(/^[^\s@]+@[^\s@]+\.[^\s@]+$/)) {
|
||||
// toast.error('请输入正确的邮箱地址');
|
||||
// return;
|
||||
// }
|
||||
// onSendCode({
|
||||
// type: 'email',
|
||||
// email,
|
||||
// })
|
||||
// }, [email, onSendCode]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<LoginHeader />
|
||||
<div className="grid gap-3">
|
||||
<Label htmlFor="email">电子邮箱</Label>
|
||||
<Input
|
||||
id="email-login-mode-email"
|
||||
name="email"
|
||||
type="text"
|
||||
placeholder="电子邮箱"
|
||||
value={email}
|
||||
onChange={(e) => setEmail(e.target.value)}
|
||||
required />
|
||||
</div>
|
||||
<div className="grid gap-3">
|
||||
<div className="flex items-center h-4">
|
||||
<Label htmlFor="code">验证码</Label>
|
||||
</div>
|
||||
<div className="flex gap-5">
|
||||
<InputOTP
|
||||
id="email-login-mode-code"
|
||||
name="code"
|
||||
maxLength={6}
|
||||
pattern={REGEXP_ONLY_DIGITS_AND_CHARS}
|
||||
required
|
||||
>
|
||||
<InputOTPGroup>
|
||||
<InputOTPSlot index={0} />
|
||||
<InputOTPSlot index={1} />
|
||||
<InputOTPSlot index={2} />
|
||||
<InputOTPSlot index={3} />
|
||||
<InputOTPSlot index={4} />
|
||||
<InputOTPSlot index={5} />
|
||||
</InputOTPGroup>
|
||||
</InputOTP>
|
||||
<Button type="button" variant="secondary" onClick={handleSendCode}>获取验证码</Button>
|
||||
</div>
|
||||
</div>
|
||||
<Button type="submit" className="w-full">
|
||||
注册并登录
|
||||
</Button>
|
||||
</>
|
||||
)
|
||||
}
|
||||
// return (
|
||||
// <>
|
||||
// <LoginHeader />
|
||||
// <div className="grid gap-3">
|
||||
// <Label htmlFor="email">电子邮箱</Label>
|
||||
// <Input
|
||||
// id="email-login-mode-email"
|
||||
// name="email"
|
||||
// type="text"
|
||||
// placeholder="电子邮箱"
|
||||
// value={email}
|
||||
// onChange={(e) => setEmail(e.target.value)}
|
||||
// required />
|
||||
// </div>
|
||||
// <div className="grid gap-3">
|
||||
// <div className="flex items-center h-4">
|
||||
// <Label htmlFor="code">验证码</Label>
|
||||
// </div>
|
||||
// <div className="flex gap-5">
|
||||
// <InputOTP
|
||||
// id="email-login-mode-code"
|
||||
// name="code"
|
||||
// maxLength={6}
|
||||
// pattern={REGEXP_ONLY_DIGITS_AND_CHARS}
|
||||
// required
|
||||
// >
|
||||
// <InputOTPGroup>
|
||||
// <InputOTPSlot index={0} />
|
||||
// <InputOTPSlot index={1} />
|
||||
// <InputOTPSlot index={2} />
|
||||
// <InputOTPSlot index={3} />
|
||||
// <InputOTPSlot index={4} />
|
||||
// <InputOTPSlot index={5} />
|
||||
// </InputOTPGroup>
|
||||
// </InputOTP>
|
||||
// <Button type="button" variant="secondary" onClick={handleSendCode}>获取验证码</Button>
|
||||
// </div>
|
||||
// </div>
|
||||
// <Button type="submit" className="w-full">
|
||||
// 注册并登录
|
||||
// </Button>
|
||||
// </>
|
||||
// )
|
||||
// }
|
||||
|
||||
@@ -27,7 +27,7 @@ export default function Login() {
|
||||
if (userStore.user) {
|
||||
router.replace('/console')
|
||||
}
|
||||
}, [userStore])
|
||||
}, [userStore, router])
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -41,7 +41,7 @@ export default function Login() {
|
||||
e.preventDefault();
|
||||
const formData = new FormData(e.currentTarget);
|
||||
|
||||
let handler = (await (async () => {
|
||||
const handler = (await (async () => {
|
||||
if (loginMode === 'password') {
|
||||
return import('./components/PasswordLoginMode');
|
||||
} else if (loginMode === 'sms') {
|
||||
|
||||
Reference in New Issue
Block a user