add payment section
This commit is contained in:
@@ -26,10 +26,6 @@ import {
|
||||
} from '@repo/ui/components/ui/form'
|
||||
import { Input } from '@repo/ui/components/ui/input'
|
||||
import { Label } from '@repo/ui/components/ui/label'
|
||||
import {
|
||||
NativeSelect,
|
||||
NativeSelectOption
|
||||
} from '@repo/ui/components/ui/native-select'
|
||||
import { RadioGroup, RadioGroupItem } from '@repo/ui/components/ui/radio-group'
|
||||
import { Spinner } from '@repo/ui/components/ui/spinner'
|
||||
import { HttpMethod, request as req } from '@repo/util/request'
|
||||
@@ -42,9 +38,6 @@ const formSchema = z.object({
|
||||
.number({ error: 'Deve estar entre 1 e 31' })
|
||||
.min(1, { error: 'Deve ser igual 1 ou maior' })
|
||||
.max(31, { error: 'Deve ser menor ou igual a 31' }),
|
||||
payment_method: z.enum(['BANK_SLIP', 'MANUAL'], {
|
||||
error: 'Selecione uma opção'
|
||||
}),
|
||||
subscription_frozen: z.boolean().optional()
|
||||
})
|
||||
|
||||
@@ -88,7 +81,7 @@ export default function Route({}: Route.ComponentProps) {
|
||||
},
|
||||
resolver: zodResolver(formSchema)
|
||||
})
|
||||
const { handleSubmit, formState, watch, reset } = form
|
||||
const { handleSubmit, formState, watch, reset, control } = form
|
||||
const plan = watch('plan')
|
||||
|
||||
const onSubmit = async ({ plan, ...data }: Schema) => {
|
||||
@@ -129,7 +122,7 @@ export default function Route({}: Route.ComponentProps) {
|
||||
|
||||
<CardContent className="space-y-6">
|
||||
<FormField
|
||||
control={form.control}
|
||||
control={control}
|
||||
name="plan"
|
||||
render={({ field: { value, onChange } }) => (
|
||||
<FormItem>
|
||||
@@ -166,7 +159,7 @@ export default function Route({}: Route.ComponentProps) {
|
||||
|
||||
<FieldGroup>
|
||||
<FormField
|
||||
control={form.control}
|
||||
control={control}
|
||||
name="billing_day"
|
||||
render={({ field: { onChange, ...field } }) => (
|
||||
<FormItem>
|
||||
@@ -186,31 +179,7 @@ export default function Route({}: Route.ComponentProps) {
|
||||
/>
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="payment_method"
|
||||
render={({ field }) => (
|
||||
<FormItem className="*:w-full">
|
||||
<FormLabel>Forma de pagamento</FormLabel>
|
||||
<FormControl>
|
||||
<NativeSelect {...field}>
|
||||
<NativeSelectOption value="">
|
||||
Selecione
|
||||
</NativeSelectOption>
|
||||
<NativeSelectOption value="BANK_SLIP">
|
||||
Boleto bancário
|
||||
</NativeSelectOption>
|
||||
<NativeSelectOption value="MANUAL">
|
||||
Depósito bancário
|
||||
</NativeSelectOption>
|
||||
</NativeSelect>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
control={control}
|
||||
name="subscription_frozen"
|
||||
defaultValue={false}
|
||||
render={({ field: { onChange, value, ...field } }) => (
|
||||
|
||||
Reference in New Issue
Block a user