@@ -60,16 +60,25 @@ export const SetHookDialog: React.FC<{ account: IAccount }> = ({ account }) => {
|
|||||||
handleSubmit,
|
handleSubmit,
|
||||||
control,
|
control,
|
||||||
watch,
|
watch,
|
||||||
|
setValue,
|
||||||
formState: { errors },
|
formState: { errors },
|
||||||
} = useForm<SetHookData>({
|
} = useForm<SetHookData>({
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
HookNamespace: snap.files?.[snap.active]?.name?.split(".")?.[0] || "",
|
HookNamespace: snap.files?.[snap.activeWat]?.name?.split(".")?.[0] || "",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const { fields, append, remove } = useFieldArray({
|
const { fields, append, remove } = useFieldArray({
|
||||||
control,
|
control,
|
||||||
name: "HookParameters", // unique name for your Field Array
|
name: "HookParameters", // unique name for your Field Array
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Update value if activeWat changes
|
||||||
|
useEffect(() => {
|
||||||
|
setValue(
|
||||||
|
"HookNamespace",
|
||||||
|
snap.files?.[snap.activeWat]?.name?.split(".")?.[0] || ""
|
||||||
|
);
|
||||||
|
}, [snap.activeWat, snap.files, setValue]);
|
||||||
// const {
|
// const {
|
||||||
// fields: grantFields,
|
// fields: grantFields,
|
||||||
// append: grantAppend,
|
// append: grantAppend,
|
||||||
@@ -156,7 +165,7 @@ export const SetHookDialog: React.FC<{ account: IAccount }> = ({ account }) => {
|
|||||||
{...register("HookNamespace", { required: true })}
|
{...register("HookNamespace", { required: true })}
|
||||||
autoComplete={"off"}
|
autoComplete={"off"}
|
||||||
defaultValue={
|
defaultValue={
|
||||||
snap.files?.[snap.active]?.name?.split(".")?.[0] || ""
|
snap.files?.[snap.activeWat]?.name?.split(".")?.[0] || ""
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
{errors.HookNamespace?.type === "required" && (
|
{errors.HookNamespace?.type === "required" && (
|
||||||
|
|||||||
Reference in New Issue
Block a user