feat: save post as draft requires no params

This commit is contained in:
Nevo David 2024-12-30 12:53:45 +07:00
parent 16e41794aa
commit 1a3b52ac34
2 changed files with 49 additions and 42 deletions

View File

@ -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 (
key.value.some((p) => {
return (
countCharacters(p.content, key?.integration?.identifier || '') >
(key.maximumCharacters || 1000000)
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 (
!(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,
});
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'}
</div>
{!postFor && (

View File

@ -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}
@ -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>
);