From 1a3b52ac34186f7c7c479e1eaa2449f51034a8ff Mon Sep 17 00:00:00 2001 From: Nevo David Date: Mon, 30 Dec 2024 12:53:45 +0700 Subject: [PATCH] feat: save post as draft requires no params --- .../components/launches/add.edit.model.tsx | 79 ++++++++++--------- .../src/components/launches/calendar.tsx | 10 ++- 2 files changed, 48 insertions(+), 41 deletions(-) diff --git a/apps/frontend/src/components/launches/add.edit.model.tsx b/apps/frontend/src/components/launches/add.edit.model.tsx index 74308b33d..147b21b7c 100644 --- a/apps/frontend/src/components/launches/add.edit.model.tsx +++ b/apps/frontend/src/components/launches/add.edit.model.tsx @@ -311,50 +311,52 @@ export const AddEditModal: FC<{ maximumCharacters: values[v].maximumCharacters, })); - for (const key of allKeys) { - if (key.checkValidity) { - const check = await key.checkValidity( - key?.value.map((p: any) => p.image || []), - key.settings - ); - if (typeof check === 'string') { - toaster.show(check, 'warning'); - return; + if (type !== 'draft') { + for (const key of allKeys) { + if (key.checkValidity) { + const check = await key.checkValidity( + key?.value.map((p: any) => p.image || []), + key.settings + ); + if (typeof check === 'string') { + toaster.show(check, 'warning'); + return; + } } - } - if ( - key.value.some((p) => { - return ( - countCharacters(p.content, key?.integration?.identifier || '') > - (key.maximumCharacters || 1000000) - ); - }) - ) { if ( - !(await deleteDialog( - `${key?.integration?.name} post is too long, it will be cropped, do you want to continue?`, - 'Yes, continue' - )) + key.value.some((p) => { + return ( + countCharacters(p.content, key?.integration?.identifier || '') > + (key.maximumCharacters || 1000000) + ); + }) ) { - await key.trigger(); - moveToIntegration({ - identifier: key?.integration?.id!, - toPreview: true, - }); - return; + if ( + !(await deleteDialog( + `${key?.integration?.name} post is too long, it will be cropped, do you want to continue?`, + 'Yes, continue' + )) + ) { + await key.trigger(); + moveToIntegration({ + identifier: key?.integration?.id!, + toPreview: true, + }); + return; + } } - } - if (key.value.some((p) => !p.content || p.content.length < 6)) { - setShowError(true); - return; - } + if (key.value.some((p) => !p.content || p.content.length < 6)) { + setShowError(true); + return; + } - if (!key.valid) { - await key.trigger(); - moveToIntegration({ identifier: key?.integration?.id! }); - return; + if (!key.valid) { + await key.trigger(); + moveToIntegration({ identifier: key?.integration?.id! }); + return; + } } } @@ -753,6 +755,9 @@ export const AddEditModal: FC<{ ? 'Submit for order' : !existingData.integration ? 'Add to calendar' + : // @ts-ignore + existingData?.posts?.[0]?.state === 'DRAFT' + ? 'Schedule' : 'Update'} {!postFor && ( diff --git a/apps/frontend/src/components/launches/calendar.tsx b/apps/frontend/src/components/launches/calendar.tsx index 4d6f54da9..ada2d2b6f 100644 --- a/apps/frontend/src/components/launches/calendar.tsx +++ b/apps/frontend/src/components/launches/calendar.tsx @@ -472,7 +472,7 @@ export const CalendarColumn: FC<{ 'text-textColor p-[2.5px] relative flex flex-col justify-center items-center' )} > -
+
-
- {state === 'DRAFT' ? 'Draft: ' : ''} - {removeMd(post.content).replace(/\n/g, ' ')} +
+
{state === 'DRAFT' ? 'Draft: ' : ''}
+
+ {removeMd(post.content).replace(/\n/g, ' ')} +
);