修复表单响应性问题 & 更新套餐管理接口字段
This commit is contained in:
@@ -6,7 +6,7 @@ import {RadioGroup, RadioGroupItem} from '@/components/ui/radio-group'
|
||||
import {Input} from '@/components/ui/input'
|
||||
import {Select, SelectContent, SelectItem, SelectSeparator, SelectTrigger, SelectValue} from '@/components/ui/select'
|
||||
import {Button} from '@/components/ui/button'
|
||||
import {useForm, useFormContext} from 'react-hook-form'
|
||||
import {useForm, useFormContext, useWatch} from 'react-hook-form'
|
||||
import {Alert, AlertTitle} from '@/components/ui/alert'
|
||||
import {ArrowRight, Box, CircleAlert, CopyIcon, ExternalLinkIcon, LinkIcon, Loader, Plus, Timer} from 'lucide-react'
|
||||
import {memo, ReactNode, useEffect, useRef, useState} from 'react'
|
||||
@@ -487,10 +487,10 @@ function SelectResource() {
|
||||
}
|
||||
|
||||
function SelectRegion() {
|
||||
const form = useFormContext<Schema>()
|
||||
const regionType = form.watch('regionType')
|
||||
const prov = form.watch('prov')
|
||||
const city = form.watch('city')
|
||||
const {control, setValue} = useFormContext<Schema>()
|
||||
const regionType = useWatch({control, name: 'regionType'})
|
||||
const prov = useWatch({control, name: 'prov'})
|
||||
const city = useWatch({control, name: 'city'})
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-4 md:max-w-[calc(160px*2+1rem)]">
|
||||
@@ -500,8 +500,8 @@ function SelectRegion() {
|
||||
onValueChange={(e) => {
|
||||
field.onChange(e)
|
||||
if (e === 'unlimited') {
|
||||
form.setValue('prov', '')
|
||||
form.setValue('city', '')
|
||||
setValue('prov', '')
|
||||
setValue('city', '')
|
||||
}
|
||||
}}
|
||||
defaultValue={field.value}
|
||||
@@ -525,8 +525,8 @@ function SelectRegion() {
|
||||
options={cities.options}
|
||||
value={[prov || '', city || '']}
|
||||
onChange={(value) => {
|
||||
form.setValue('prov', value[0])
|
||||
form.setValue('city', value[1])
|
||||
setValue('prov', value[0])
|
||||
setValue('city', value[1])
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
@@ -536,7 +536,7 @@ function SelectRegion() {
|
||||
|
||||
function ApplyLink() {
|
||||
const form = useFormContext<Schema>()
|
||||
const values = form.watch()
|
||||
useWatch()
|
||||
|
||||
// let type: 'open' | 'copy' = 'open'
|
||||
const type = useRef<'open' | 'copy'>('open')
|
||||
@@ -613,7 +613,7 @@ function ApplyLink() {
|
||||
|
||||
{/* 展示链接地址 */}
|
||||
<div className="bg-secondary p-4 rounded-md break-all">
|
||||
{link(values)}
|
||||
{link(form.getValues())}
|
||||
</div>
|
||||
|
||||
{/* 操作 */}
|
||||
|
||||
Reference in New Issue
Block a user