Skip to content

Commit 1a3b52a

Browse files
committed
feat: save post as draft requires no params
1 parent 16e4179 commit 1a3b52a

File tree

2 files changed

+48
-41
lines changed

2 files changed

+48
-41
lines changed

apps/frontend/src/components/launches/add.edit.model.tsx

Lines changed: 42 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -311,50 +311,52 @@ export const AddEditModal: FC<{
311311
maximumCharacters: values[v].maximumCharacters,
312312
}));
313313

314-
for (const key of allKeys) {
315-
if (key.checkValidity) {
316-
const check = await key.checkValidity(
317-
key?.value.map((p: any) => p.image || []),
318-
key.settings
319-
);
320-
if (typeof check === 'string') {
321-
toaster.show(check, 'warning');
322-
return;
314+
if (type !== 'draft') {
315+
for (const key of allKeys) {
316+
if (key.checkValidity) {
317+
const check = await key.checkValidity(
318+
key?.value.map((p: any) => p.image || []),
319+
key.settings
320+
);
321+
if (typeof check === 'string') {
322+
toaster.show(check, 'warning');
323+
return;
324+
}
323325
}
324-
}
325326

326-
if (
327-
key.value.some((p) => {
328-
return (
329-
countCharacters(p.content, key?.integration?.identifier || '') >
330-
(key.maximumCharacters || 1000000)
331-
);
332-
})
333-
) {
334327
if (
335-
!(await deleteDialog(
336-
`${key?.integration?.name} post is too long, it will be cropped, do you want to continue?`,
337-
'Yes, continue'
338-
))
328+
key.value.some((p) => {
329+
return (
330+
countCharacters(p.content, key?.integration?.identifier || '') >
331+
(key.maximumCharacters || 1000000)
332+
);
333+
})
339334
) {
340-
await key.trigger();
341-
moveToIntegration({
342-
identifier: key?.integration?.id!,
343-
toPreview: true,
344-
});
345-
return;
335+
if (
336+
!(await deleteDialog(
337+
`${key?.integration?.name} post is too long, it will be cropped, do you want to continue?`,
338+
'Yes, continue'
339+
))
340+
) {
341+
await key.trigger();
342+
moveToIntegration({
343+
identifier: key?.integration?.id!,
344+
toPreview: true,
345+
});
346+
return;
347+
}
346348
}
347-
}
348349

349-
if (key.value.some((p) => !p.content || p.content.length < 6)) {
350-
setShowError(true);
351-
return;
352-
}
350+
if (key.value.some((p) => !p.content || p.content.length < 6)) {
351+
setShowError(true);
352+
return;
353+
}
353354

354-
if (!key.valid) {
355-
await key.trigger();
356-
moveToIntegration({ identifier: key?.integration?.id! });
357-
return;
355+
if (!key.valid) {
356+
await key.trigger();
357+
moveToIntegration({ identifier: key?.integration?.id! });
358+
return;
359+
}
358360
}
359361
}
360362

@@ -753,6 +755,9 @@ export const AddEditModal: FC<{
753755
? 'Submit for order'
754756
: !existingData.integration
755757
? 'Add to calendar'
758+
: // @ts-ignore
759+
existingData?.posts?.[0]?.state === 'DRAFT'
760+
? 'Schedule'
756761
: 'Update'}
757762
</div>
758763
{!postFor && (

apps/frontend/src/components/launches/calendar.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ export const CalendarColumn: FC<{
472472
'text-textColor p-[2.5px] relative flex flex-col justify-center items-center'
473473
)}
474474
>
475-
<div className="relative w-full flex flex-col items-center p-[2.5px]">
475+
<div className="relative w-full flex flex-col items-center p-[2.5px] h-[56px]">
476476
<CalendarItem
477477
display={display as 'day' | 'week' | 'month'}
478478
isBeforeNow={isBeforeNow}
@@ -606,9 +606,11 @@ const CalendarItem: FC<{
606606
src={`/icons/platforms/${post.integration?.providerIdentifier}.png`}
607607
/>
608608
</div>
609-
<div className="whitespace-pre-wrap line-clamp-3">
610-
{state === 'DRAFT' ? 'Draft: ' : ''}
611-
{removeMd(post.content).replace(/\n/g, ' ')}
609+
<div className="whitespace-nowrap line-clamp-2">
610+
<div className="text-left">{state === 'DRAFT' ? 'Draft: ' : ''}</div>
611+
<div className="w-full overflow-hidden overflow-ellipsis text-left">
612+
{removeMd(post.content).replace(/\n/g, ' ')}
613+
</div>
612614
</div>
613615
</div>
614616
);

0 commit comments

Comments
 (0)