feat(payment): Add isEdit prop to PaymentForm and disable fields when editing

This commit is contained in:
web@ppanel 2025-03-14 14:04:10 +07:00
parent f72df3a5e8
commit 85f55def2e
2 changed files with 4 additions and 0 deletions

View File

@ -45,6 +45,7 @@ interface PaymentFormProps<T> {
loading?: boolean; loading?: boolean;
initialValues?: T; initialValues?: T;
onSubmit: (values: T) => Promise<boolean>; onSubmit: (values: T) => Promise<boolean>;
isEdit?: boolean;
} }
export default function PaymentForm<T>({ export default function PaymentForm<T>({
@ -53,6 +54,7 @@ export default function PaymentForm<T>({
loading, loading,
initialValues, initialValues,
onSubmit, onSubmit,
isEdit,
}: PaymentFormProps<T>) { }: PaymentFormProps<T>) {
const t = useTranslations('payment'); const t = useTranslations('payment');
const { common } = useGlobalStore(); const { common } = useGlobalStore();
@ -317,6 +319,7 @@ export default function PaymentForm<T>({
}} }}
defaultValue={field.value} defaultValue={field.value}
value={field.value} value={field.value}
disabled={isEdit}
> >
<FormControl> <FormControl>
<SelectTrigger> <SelectTrigger>

View File

@ -136,6 +136,7 @@ export default function PaymentTable() {
actions={{ actions={{
render: (row) => [ render: (row) => [
<PaymentForm<API.UpdatePaymentMethodRequest> <PaymentForm<API.UpdatePaymentMethodRequest>
isEdit
key='edit' key='edit'
trigger={<Button>{t('edit')}</Button>} trigger={<Button>{t('edit')}</Button>}
title={t('editPayment')} title={t('editPayment')}