update oauth2 (#84)

* update oauth2

* i18n

* fix validation

* chore: auto-fix linting and formatting issues

---------

Co-authored-by: uubulb <uubulb@users.noreply.github.com>
This commit is contained in:
UUBulb
2024-12-31 23:11:41 +08:00
committed by GitHub
parent d54372fb0c
commit 5517a8df38
8 changed files with 418 additions and 435 deletions
+25
View File
@@ -1,5 +1,6 @@
import { getProfile, updateProfile } from "@/api/user"
import { Button } from "@/components/ui/button"
import { Checkbox } from "@/components/ui/checkbox"
import {
Dialog,
DialogClose,
@@ -19,8 +20,10 @@ import {
FormMessage,
} from "@/components/ui/form"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
import { ScrollArea } from "@/components/ui/scroll-area"
import { useMainStore } from "@/hooks/useMainStore"
import { asOptionalField } from "@/lib/utils"
import { zodResolver } from "@hookform/resolvers/zod"
import { useState } from "react"
import { useForm } from "react-hook-form"
@@ -32,6 +35,7 @@ const profileFormSchema = z.object({
original_password: z.string().min(5).max(72),
new_password: z.string().min(8).max(72),
new_username: z.string().min(1).max(32),
reject_password: asOptionalField(z.boolean()),
})
export const ProfileCard = ({ className }: { className: string }) => {
@@ -44,6 +48,7 @@ export const ProfileCard = ({ className }: { className: string }) => {
original_password: "",
new_password: "",
new_username: profile?.username,
reject_password: profile?.reject_password,
},
resetOptions: {
keepDefaultValues: false,
@@ -122,6 +127,26 @@ export const ProfileCard = ({ className }: { className: string }) => {
</FormItem>
)}
/>
<FormField
control={form.control}
name="reject_password"
render={({ field }) => (
<FormItem className="flex items-center space-x-2">
<FormControl>
<div className="flex items-center gap-2">
<Checkbox
checked={field.value}
onCheckedChange={field.onChange}
/>
<Label className="text-sm">
{t("RejectPassword")}
</Label>
</div>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<DialogFooter className="justify-end">
<DialogClose asChild>