mirror of
https://github.com/sergeyyarkov/educt-client.git
synced 2026-10-11 10:19:22 +03:00
fix: unregister field for lesson form
This commit is contained in:
parent
1b865c6df7
commit
07cb9494f5
@ -1,4 +1,4 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
FormControl,
|
FormControl,
|
||||||
FormHelperText,
|
FormHelperText,
|
||||||
@ -52,12 +52,19 @@ const LessonForm: React.FC<LessonFormPropsType> = ({
|
|||||||
register,
|
register,
|
||||||
watch,
|
watch,
|
||||||
formState: { errors, isDirty },
|
formState: { errors, isDirty },
|
||||||
|
unregister,
|
||||||
} = reactHookForm;
|
} = reactHookForm;
|
||||||
|
|
||||||
const [isLinkedVideoUrl, setIsLinkedVideoUrl] = useState<boolean>(false);
|
const [isLinkedVideoUrl, setIsLinkedVideoUrl] = useState<boolean>(false);
|
||||||
|
|
||||||
const watchDescription = watch('description');
|
const watchDescription = watch('description');
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!isLinkedVideoUrl) {
|
||||||
|
unregister('linked_video_url');
|
||||||
|
}
|
||||||
|
}, [isLinkedVideoUrl]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={onSubmit}>
|
<form onSubmit={onSubmit}>
|
||||||
<Stack spacing={'5'}>
|
<Stack spacing={'5'}>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user