From bb9aa1aee6b6676a448dbfebbfb771d86cd56979 Mon Sep 17 00:00:00 2001 From: Nevo David Date: Mon, 5 Jan 2026 22:34:36 +0700 Subject: [PATCH] feat: fix post edit --- .../components/new-launch/manage.modal.tsx | 100 +++++++++++++----- .../components/new-launch/select.current.tsx | 27 ++--- 2 files changed, 85 insertions(+), 42 deletions(-) diff --git a/apps/frontend/src/components/new-launch/manage.modal.tsx b/apps/frontend/src/components/new-launch/manage.modal.tsx index b118ab73..8f59d674 100644 --- a/apps/frontend/src/components/new-launch/manage.modal.tsx +++ b/apps/frontend/src/components/new-launch/manage.modal.tsx @@ -4,6 +4,7 @@ import React, { FC, ReactNode, useCallback, + useEffect, useMemo, useRef, useState, @@ -74,9 +75,11 @@ export const ManageModal: FC = (props) => { locked, current, activateExitButton, + setHide, } = useLaunchStore( useShallow((state) => ({ hide: state.hide, + setHide: state.setHide, date: state.date, setDate: state.setDate, current: state.current, @@ -92,6 +95,12 @@ export const ManageModal: FC = (props) => { })) ); + useEffect(() => { + if (hide) { + setHide(false); + } + }, [hide]); + const currentIntegrationText = useMemo(() => { if (current === 'global') { return ''; @@ -100,20 +109,22 @@ export const ManageModal: FC = (props) => { const currentIntegration = integrations.find((p) => p.id === current)!; return ( -
-
- {currentIntegration.identifier} - -
-
{currentIntegration.name} {t('channel_settings', 'Settings')}
+
+
+ {currentIntegration.identifier} +
+
+ {currentIntegration.name} {t('channel_settings', 'Settings')} +
+
); }, [current]); @@ -158,7 +169,10 @@ export const ManageModal: FC = (props) => { setLoading(true); if ( !(await deleteDialog( - t('are_you_sure_you_want_to_delete_post', 'Are you sure you want to delete this post?'), + t( + 'are_you_sure_you_want_to_delete_post', + 'Are you sure you want to delete this post?' + ), t('yes_delete_it', 'Yes, delete it!') )) ) { @@ -191,9 +205,14 @@ export const ManageModal: FC = (props) => { for (const item of notEnoughChars) { toaster.show( - '' + - item.integration.name + - ' ' + t('post_needs_content_or_image', 'Your post should have at least one character or one image.'), + `${capitalize(item.integration.identifier.split('-')[0])} (${ + item.integration.name + }):` + + ' ' + + t( + 'post_needs_content_or_image', + 'Your post should have at least one character or one image.' + ), 'warning' ); setLoading(false); @@ -203,7 +222,12 @@ export const ManageModal: FC = (props) => { for (const item of checkAllValid) { if (item.valid === false) { - toaster.show(t('please_fix_your_settings', 'Please fix your settings'), 'warning'); + toaster.show( + `${capitalize(item.integration.identifier.split('-')[0])} (${ + item.integration.name + }): ${t('please_fix_your_settings', 'Please fix your settings')}`, + 'warning' + ); item.fix(); setLoading(false); setShowSettings(true); @@ -240,7 +264,10 @@ export const ManageModal: FC = (props) => { for (const item of sliceNeeded) { toaster.show( - `${item?.integration?.name} (${item?.integration?.identifier}) ${t('post_is_too_long', 'post is too long, please fix it')}`, + `${item?.integration?.name} (${item?.integration?.identifier}) ${t( + 'post_is_too_long', + 'post is too long, please fix it' + )}`, 'warning' ); item.preview(); @@ -265,7 +292,10 @@ export const ManageModal: FC = (props) => { const shortLink = !shortLinkUrl.ask ? false : await deleteDialog( - t('shortlink_urls_question', 'Do you want to shortlink the URLs? it will let you get statistics over clicks'), + t( + 'shortlink_urls_question', + 'Do you want to shortlink the URLs? it will let you get statistics over clicks' + ), t('yes_shortlink_it', 'Yes, shortlink it!') ); @@ -486,9 +516,16 @@ export const ManageModal: FC = (props) => { selectedIntegrations.length === 0 || loading || locked } onClick={schedule('draft')} - className="cursor-pointer disabled:cursor-not-allowed px-[20px] h-[44px] bg-btnSimple justify-center items-center flex rounded-[8px] text-[15px] font-[600]" + className="relative cursor-pointer disabled:cursor-not-allowed px-[20px] h-[44px] bg-btnSimple justify-center items-center flex rounded-[8px] text-[15px] font-[600]" > - {t('save_as_draft', 'Save as Draft')} + {loading && ( +
+
+
+ )} +
+ {t('save_as_draft', 'Save as Draft')} +
)} {addEditSets && ( @@ -509,9 +546,19 @@ export const ManageModal: FC = (props) => { selectedIntegrations.length === 0 || loading || locked } onClick={schedule('schedule')} - className="text-white min-w-[180px] btnSub disabled:cursor-not-allowed disabled:opacity-80 outline-none gap-[8px] flex justify-center items-center h-[44px] rounded-[8px] bg-[#612BD3] ps-[20px] pe-[16px]" + className="text-white relative min-w-[180px] btnSub disabled:cursor-not-allowed disabled:opacity-80 outline-none gap-[8px] flex justify-center items-center h-[44px] rounded-[8px] bg-[#612BD3] ps-[20px] pe-[16px]" > -
+ {loading && ( +
+
+
+ )} +
{selectedIntegrations.length === 0 ? t('check_circles_above', 'Check the circles above') : dummy @@ -563,7 +610,10 @@ After using the addPostFor{num} it will create a new addPostContentFor{num+ 1} f `} labels={{ title: t('your_assistant', 'Your Assistant'), - initial: t('assistant_initial_message', 'Hi! I can help you to refine your social media posts.'), + initial: t( + 'assistant_initial_message', + 'Hi! I can help you to refine your social media posts.' + ), }} />
diff --git a/apps/frontend/src/components/new-launch/select.current.tsx b/apps/frontend/src/components/new-launch/select.current.tsx index f687643c..07fda877 100644 --- a/apps/frontend/src/components/new-launch/select.current.tsx +++ b/apps/frontend/src/components/new-launch/select.current.tsx @@ -43,14 +43,13 @@ export function useHasScroll(ref: RefObject): boolean { } export const SelectCurrent: FC = () => { - const { selectedIntegrations, current, setCurrent, locked, setHide, hide } = + const { selectedIntegrations, current, setCurrent, locked, setHide } = useLaunchStore( useShallow((state) => ({ selectedIntegrations: state.selectedIntegrations, current: state.current, setCurrent: state.setCurrent, locked: state.locked, - hide: state.hide, setHide: state.setHide, })) ); @@ -58,14 +57,6 @@ export const SelectCurrent: FC = () => { const contentRef = useRef(null); const hasScroll = useHasScroll(contentRef); - useEffect(() => { - if (!hide) { - return; - } - - setHide(false); - }, [hide]); - return ( <>
@@ -146,12 +137,11 @@ export const SelectCurrent: FC = () => { export const IsGlobal: FC<{ id: string }> = ({ id }) => { const t = useT(); - const { isInternal } = - useLaunchStore( - useShallow((state) => ({ - isInternal: !!state.internal.find(p => p.integration.id === id), - })) - ); + const { isInternal } = useLaunchStore( + useShallow((state) => ({ + isInternal: !!state.internal.find((p) => p.integration.id === id), + })) + ); if (!isInternal) { return null; @@ -160,7 +150,10 @@ export const IsGlobal: FC<{ id: string }> = ({ id }) => { return (
);