Skip to content

Commit

Permalink
bug(api): fix spelling
Browse files Browse the repository at this point in the history
  • Loading branch information
tatarco committed Nov 14, 2024
1 parent 26614be commit d7ec40d
Showing 1 changed file with 37 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,48 @@ import { RenderCommand } from './render-command';
@Injectable()
export class InAppOutputRendererUsecase {
execute(renderCommand: RenderCommand): InAppRenderOutput {
const inApp = InAppRenderOutputSchema.parse(renderCommand.controlValues);
const inApp = InAppRenderOutputSchema.optional().parse(renderCommand.controlValues);
if (!inApp) {
throw new Error('Invalid in-app control value data');
}

return {
subject: inApp.subject,
body: inApp.body,
avatar: inApp.avatar,
primaryAction: inApp.primaryAction
? {
label: inApp.primaryAction.label,
redirect: {
url: inApp.primaryAction.redirect.url,
target: inApp.primaryAction.redirect.target as RedirectTargetEnum,
},
}
: undefined,
secondaryAction: inApp.secondaryAction
? {
label: inApp.secondaryAction?.label,
redirect: {
url: inApp.secondaryAction?.redirect.url,
target: inApp.secondaryAction?.redirect.target as RedirectTargetEnum,
},
}
: undefined,
redirect: inApp.redirect
? {
url: inApp.redirect.url,
target: inApp.redirect.target as RedirectTargetEnum,
}
: undefined,
primaryAction:
inApp.primaryAction &&
inApp.primaryAction.label &&
inApp.primaryAction.redirect &&
inApp.primaryAction.redirect.url
? {
label: inApp.primaryAction.label,
redirect: {
url: inApp.primaryAction.redirect.url,
target: inApp.primaryAction.redirect.target as RedirectTargetEnum,
},
}
: undefined,
secondaryAction:
inApp.secondaryAction &&
inApp.secondaryAction.label &&
inApp.secondaryAction.redirect &&
inApp.secondaryAction.redirect.url
? {
label: inApp.secondaryAction?.label,
redirect: {
url: inApp.secondaryAction?.redirect.url,
target: inApp.secondaryAction?.redirect.target as RedirectTargetEnum,
},
}
: undefined,
redirect:
inApp.redirect && inApp.redirect.url
? {
url: inApp.redirect.url,
target: inApp.redirect.target as RedirectTargetEnum,
}
: undefined,
data: inApp.data as Record<string, unknown>,
};
}
Expand Down

0 comments on commit d7ec40d

Please sign in to comment.