review
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
import { Fragment } from 'react'
|
||||
import { Trash2Icon, PlusIcon, CircleQuestionMarkIcon } from 'lucide-react'
|
||||
import {
|
||||
Trash2Icon,
|
||||
PlusIcon,
|
||||
CircleQuestionMarkIcon,
|
||||
ArrowRightIcon
|
||||
} from 'lucide-react'
|
||||
import { useForm, useFieldArray, Controller, useWatch } from 'react-hook-form'
|
||||
import { useParams } from 'react-router'
|
||||
import { ErrorMessage } from '@hookform/error-message'
|
||||
@@ -58,7 +63,7 @@ type Schema = z.infer<typeof formSchemaAssigned>
|
||||
type AssignedProps = {
|
||||
onSubmit: (value: any) => void | Promise<void>
|
||||
courses: Promise<{ hits: Course[] }>
|
||||
defaultValues?: { enrollments: object[] }
|
||||
defaultValues?: { enrollments: object[]; coupon?: object }
|
||||
}
|
||||
|
||||
export function Assigned({ courses, onSubmit, defaultValues }: AssignedProps) {
|
||||
@@ -67,6 +72,7 @@ export function Assigned({ courses, onSubmit, defaultValues }: AssignedProps) {
|
||||
const form = useForm({
|
||||
resolver: zodResolver(formSchemaAssigned),
|
||||
defaultValues: {
|
||||
coupon: defaultValues?.coupon || {},
|
||||
enrollments: defaultValues?.enrollments?.map((e: any) => ({
|
||||
...e,
|
||||
scheduled_for: e.scheduled_for ? new Date(e.scheduled_for) : undefined
|
||||
@@ -74,7 +80,6 @@ export function Assigned({ courses, onSubmit, defaultValues }: AssignedProps) {
|
||||
}
|
||||
})
|
||||
|
||||
console.log(defaultValues)
|
||||
const { formState, control, handleSubmit, setValue } = form
|
||||
const { fields, remove, append } = useFieldArray({
|
||||
control,
|
||||
@@ -263,11 +268,12 @@ export function Assigned({ courses, onSubmit, defaultValues }: AssignedProps) {
|
||||
<div className="flex justify-end">
|
||||
<Button
|
||||
type="submit"
|
||||
variant="secondary"
|
||||
className="cursor-pointer"
|
||||
disabled={formState.isSubmitting}
|
||||
>
|
||||
{formState.isSubmitting && <Spinner />}
|
||||
Continuar
|
||||
Continuar <ArrowRightIcon />
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user