diff --git a/apps/api/src/app/review/usecases/replace/replace.usecase.ts b/apps/api/src/app/review/usecases/replace/replace.usecase.ts index b1d1c0c0..31d410a9 100644 --- a/apps/api/src/app/review/usecases/replace/replace.usecase.ts +++ b/apps/api/src/app/review/usecases/replace/replace.usecase.ts @@ -64,11 +64,23 @@ export class Replace { }, }; replaceOperation = { - $toDouble: { - $replaceAll: { - input: { $toString: '$' + path }, - find: find, - replacement: replace, + $cond: { + if: { $eq: [formattedReplace, ''] }, + then: null, + else: { + $cond: { + if: { $eq: [{ $type: '$' + path }, 'number'] }, + then: { + $toDouble: { + $replaceAll: { + input: { $toString: '$' + path }, + find: find, + replacement: formattedReplace, + }, + }, + }, + else: formattedReplace, + }, }, }, }; diff --git a/apps/widget/src/components/widget/Widget.tsx b/apps/widget/src/components/widget/Widget.tsx index 003ff7c4..37eb42d9 100644 --- a/apps/widget/src/components/widget/Widget.tsx +++ b/apps/widget/src/components/widget/Widget.tsx @@ -56,15 +56,18 @@ export function Widget() { setPromptContinueAction(undefined); }; const onClose = () => { - if ( - [ + let isImportNotOnProgress = false; + if (importConfig.mode === TemplateModeEnum.AUTOMATIC) + isImportNotOnProgress = [PhasesEnum.CONFIGURE, PhasesEnum.CONFIRM].includes(phase); + else + isImportNotOnProgress = [ PhasesEnum.VALIDATE, PhasesEnum.IMAGE_UPLOAD, PhasesEnum.UPLOAD, PhasesEnum.COMPLETE, - PhasesEnum.CONFIRM, - ].includes(phase) - ) { + ].includes(phase); + + if (isImportNotOnProgress) { setPhase(PhasesEnum.VALIDATE); resetAppState(); closeWidget();