Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert ZetkinBlocks to editorJsBlocks to make DeliveryErrors handle properly #2267

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/features/emails/utils/deliveryProblems.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { OutputData } from '@editorjs/editorjs';

import blockProblems from '../components/EmailEditor/EmailSettings/utils/blockProblems';
import { DeliveryProblem } from '../types';
import { DeliveryProblem, EmailContent } from '../types';
import { ZetkinEmail } from 'utils/types/zetkin';
import zetkinBlocksToEditorjsBlocks from './zetkinBlocksToEditorjsBlocks';

export default function deliveryProblems(
email: ZetkinEmail
Expand All @@ -12,13 +11,14 @@ export default function deliveryProblems(
if (!email.content) {
problems.push(DeliveryProblem.EMPTY);
} else {
const parsedContent: OutputData = JSON.parse(email.content);
const parsedContent: EmailContent = JSON.parse(email.content);

if (parsedContent.blocks.length === 0) {
problems.push(DeliveryProblem.EMPTY);
}
const convertedBlocks = zetkinBlocksToEditorjsBlocks(parsedContent.blocks);

const hasProblems = parsedContent.blocks.some(
const hasProblems = convertedBlocks.some(
(block) => !!blockProblems(block).length
);

Expand Down
Loading