表格与页面样式调整
This commit is contained in:
@@ -14,6 +14,7 @@ import {
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
DialogTrigger,
|
||||
} from "@/components/ui/dialog"
|
||||
import { Field, FieldError, FieldLabel } from "@/components/ui/field"
|
||||
import { Input } from "@/components/ui/input"
|
||||
@@ -30,18 +31,15 @@ const Schema = z.object({
|
||||
type FormValues = z.infer<typeof Schema>
|
||||
|
||||
interface UpdateDeductionDialogProps {
|
||||
open: boolean
|
||||
onOpenChange: (open: boolean) => void
|
||||
currentUser: User | null
|
||||
user: User
|
||||
onSuccess: () => void
|
||||
}
|
||||
|
||||
export function DeductionDialog({
|
||||
open,
|
||||
onOpenChange,
|
||||
currentUser,
|
||||
user,
|
||||
onSuccess,
|
||||
}: UpdateDeductionDialogProps) {
|
||||
const [open, setOpen] = useState(false)
|
||||
const [isLoading, setIsLoading] = useState(false)
|
||||
|
||||
const {
|
||||
@@ -58,17 +56,16 @@ export function DeductionDialog({
|
||||
})
|
||||
|
||||
const onSubmit = async (data: FormValues) => {
|
||||
if (!currentUser) return
|
||||
setIsLoading(true)
|
||||
try {
|
||||
const result = await getDeduction({
|
||||
user_id: currentUser.id,
|
||||
user_id: user.id,
|
||||
amount: data.deduction,
|
||||
})
|
||||
|
||||
if (result.success) {
|
||||
toast.success("扣款成功")
|
||||
onOpenChange(false)
|
||||
setOpen(false)
|
||||
reset()
|
||||
onSuccess()
|
||||
} else {
|
||||
@@ -86,16 +83,19 @@ export function DeductionDialog({
|
||||
if (!open) {
|
||||
reset()
|
||||
}
|
||||
onOpenChange(open)
|
||||
setOpen(open)
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={handleOpenChange}>
|
||||
<DialogTrigger asChild>
|
||||
<Button size="sm">扣款</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent className="max-w-2xl max-h-[90vh] overflow-y-auto">
|
||||
<DialogHeader>
|
||||
<DialogTitle>扣款</DialogTitle>
|
||||
<DialogDescription>
|
||||
扣减用户 {currentUser?.name || currentUser?.username} 的余额
|
||||
扣减用户 {user.name || user.username} 的余额
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user