mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-15 01:01:43 +10:00
Add pending inputs as a new Keyword
Ensures that any Keywords that were intended to be added are not lost
This commit is contained in:
@ -31,6 +31,7 @@ type Props<T extends SectionItem> = {
|
||||
id: DialogName;
|
||||
form: UseFormReturn<T>;
|
||||
defaultValues: T;
|
||||
pendingKeyword?: string;
|
||||
children: React.ReactNode;
|
||||
};
|
||||
|
||||
@ -38,6 +39,7 @@ export const SectionDialog = <T extends SectionItem>({
|
||||
id,
|
||||
form,
|
||||
defaultValues,
|
||||
pendingKeyword,
|
||||
children,
|
||||
}: Props<T>) => {
|
||||
const { isOpen, mode, close, payload } = useDialog<T>(id);
|
||||
@ -61,6 +63,9 @@ export const SectionDialog = <T extends SectionItem>({
|
||||
if (!section) return;
|
||||
|
||||
if (isCreate || isDuplicate) {
|
||||
if (pendingKeyword && values.keywords) {
|
||||
values.keywords.push(pendingKeyword);
|
||||
}
|
||||
setValue(
|
||||
`sections.${id}.items`,
|
||||
produce(section.items, (draft: T[]): void => {
|
||||
@ -72,6 +77,10 @@ export const SectionDialog = <T extends SectionItem>({
|
||||
if (isUpdate) {
|
||||
if (!payload.item?.id) return;
|
||||
|
||||
if (pendingKeyword && values.keywords) {
|
||||
values.keywords.push(pendingKeyword);
|
||||
}
|
||||
|
||||
setValue(
|
||||
`sections.${id}.items`,
|
||||
produce(section.items, (draft: T[]): void => {
|
||||
|
||||
Reference in New Issue
Block a user