fix: Use correct values on append DayRange (#8597)

Co-authored-by: Keith Williams <keithwillcode@gmail.com>
This commit is contained in:
Babis Digos
2023-05-02 19:43:32 -03:00
committed by GitHub
co-authored by Keith Williams
parent ee9f80ae3b
commit 99f736b317
@@ -169,6 +169,7 @@ export const DayRanges = <TFieldValues extends FieldValues>({
control?: Control<TFieldValues>;
}) => {
const { t } = useLocale();
const { getValues } = useFormContext();
const { remove, fields, append } = useFieldArray({
control,
@@ -191,7 +192,7 @@ export const DayRanges = <TFieldValues extends FieldValues>({
StartIcon={Plus}
onClick={() => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const nextRange: any = getNextRange(fields[fields.length - 1]);
const nextRange: any = getNextRange(getValues(`${name}.${fields.length - 1}`));
if (nextRange) append(nextRange);
}}
/>