mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-15 17:21:35 +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;
|
id: DialogName;
|
||||||
form: UseFormReturn<T>;
|
form: UseFormReturn<T>;
|
||||||
defaultValues: T;
|
defaultValues: T;
|
||||||
|
pendingKeyword?: string;
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -38,6 +39,7 @@ export const SectionDialog = <T extends SectionItem>({
|
|||||||
id,
|
id,
|
||||||
form,
|
form,
|
||||||
defaultValues,
|
defaultValues,
|
||||||
|
pendingKeyword,
|
||||||
children,
|
children,
|
||||||
}: Props<T>) => {
|
}: Props<T>) => {
|
||||||
const { isOpen, mode, close, payload } = useDialog<T>(id);
|
const { isOpen, mode, close, payload } = useDialog<T>(id);
|
||||||
@ -61,6 +63,9 @@ export const SectionDialog = <T extends SectionItem>({
|
|||||||
if (!section) return;
|
if (!section) return;
|
||||||
|
|
||||||
if (isCreate || isDuplicate) {
|
if (isCreate || isDuplicate) {
|
||||||
|
if (pendingKeyword && values.keywords) {
|
||||||
|
values.keywords.push(pendingKeyword);
|
||||||
|
}
|
||||||
setValue(
|
setValue(
|
||||||
`sections.${id}.items`,
|
`sections.${id}.items`,
|
||||||
produce(section.items, (draft: T[]): void => {
|
produce(section.items, (draft: T[]): void => {
|
||||||
@ -72,6 +77,10 @@ export const SectionDialog = <T extends SectionItem>({
|
|||||||
if (isUpdate) {
|
if (isUpdate) {
|
||||||
if (!payload.item?.id) return;
|
if (!payload.item?.id) return;
|
||||||
|
|
||||||
|
if (pendingKeyword && values.keywords) {
|
||||||
|
values.keywords.push(pendingKeyword);
|
||||||
|
}
|
||||||
|
|
||||||
setValue(
|
setValue(
|
||||||
`sections.${id}.items`,
|
`sections.${id}.items`,
|
||||||
produce(section.items, (draft: T[]): void => {
|
produce(section.items, (draft: T[]): void => {
|
||||||
|
|||||||
Reference in New Issue
Block a user