Skip to content

Commit

Permalink
feat: save post as draft requires no params
Browse files Browse the repository at this point in the history
  • Loading branch information
nevo-david committed Dec 30, 2024
1 parent 16e4179 commit 1a3b52a
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 41 deletions.
79 changes: 42 additions & 37 deletions apps/frontend/src/components/launches/add.edit.model.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

Expand Down Expand Up @@ -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'}
</div>
{!postFor && (
Expand Down
10 changes: 6 additions & 4 deletions apps/frontend/src/components/launches/calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ export const CalendarColumn: FC<{
'text-textColor p-[2.5px] relative flex flex-col justify-center items-center'
)}
>
<div className="relative w-full flex flex-col items-center p-[2.5px]">
<div className="relative w-full flex flex-col items-center p-[2.5px] h-[56px]">
<CalendarItem
display={display as 'day' | 'week' | 'month'}
isBeforeNow={isBeforeNow}
Expand Down Expand Up @@ -606,9 +606,11 @@ const CalendarItem: FC<{
src={`/icons/platforms/${post.integration?.providerIdentifier}.png`}
/>
</div>
<div className="whitespace-pre-wrap line-clamp-3">
{state === 'DRAFT' ? 'Draft: ' : ''}
{removeMd(post.content).replace(/\n/g, ' ')}
<div className="whitespace-nowrap line-clamp-2">
<div className="text-left">{state === 'DRAFT' ? 'Draft: ' : ''}</div>
<div className="w-full overflow-hidden overflow-ellipsis text-left">
{removeMd(post.content).replace(/\n/g, ' ')}
</div>
</div>
</div>
);
Expand Down

0 comments on commit 1a3b52a

Please sign in to comment.