Skip to content

Commit

Permalink
fix(dashboard): Apply cleaner TS fix when using discriminated unions
Browse files Browse the repository at this point in the history
If the preview.result.type doesn't match, just return null.
  • Loading branch information
SokratisVidros committed Dec 13, 2024
1 parent ee1201b commit f6ee59e
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { usePreviewStep } from '@/hooks/use-preview-step';
import { EmailPreviewHeader } from '@/components/workflow-editor/steps/email/email-preview';
import { Separator } from '@/components/primitives/separator';
import { Skeleton } from '@/components/primitives/skeleton';
import { ChannelTypeEnum } from '@novu/shared';
import { cn } from '@/utils/ui';
import { useWorkflow } from '@/components/workflow-editor/workflow-provider';

Expand Down Expand Up @@ -65,9 +64,13 @@ export function ConfigureEmailStepPreview(props: ConfigureEmailStepPreviewProps)
);
}

return (
<MiniEmailPreview {...props}>
<div className="text-foreground-400 line-clamp-2 text-xs">{previewData.result.preview.subject}</div>
</MiniEmailPreview>
);
if (previewData.result.type === 'email') {
return (
<MiniEmailPreview {...props}>
<div className="text-foreground-400 line-clamp-2 text-xs">{previewData.result.preview.subject}</div>
</MiniEmailPreview>
);
}

return null;
}

0 comments on commit f6ee59e

Please sign in to comment.