From 1752bf5198300fc93752bbe707ca56f1ec4e4c2f Mon Sep 17 00:00:00 2001 From: bniwredyc Date: Mon, 8 May 2023 20:01:11 +0200 Subject: [PATCH] code review --- src/components/Draft/Draft.tsx | 10 ++++++---- src/components/Editor/Panel/Panel.tsx | 6 ++++-- src/context/editor.tsx | 6 +++--- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/components/Draft/Draft.tsx b/src/components/Draft/Draft.tsx index 484764da..c259d627 100644 --- a/src/components/Draft/Draft.tsx +++ b/src/components/Draft/Draft.tsx @@ -19,19 +19,21 @@ type Props = { export const Draft = (props: Props) => { const { t } = useLocalize() - const handlePublishLinkClick = () => { + const handlePublishLinkClick = (e) => { + e.preventDefault() props.onPublish(props.shout) } - const handleDeleteLinkClick = () => { + const handleDeleteLinkClick = (e) => { + e.preventDefault() props.onDelete(props.shout) } return (
- {formatDate(new Date(props.shout.createdAt))}{' '} - {formatDateTime(props.shout.createdAt)()} + {formatDate(new Date(props.shout.createdAt))} +  {formatDateTime(props.shout.createdAt)()}
{props.shout.title || t('Unnamed draft')} {props.shout.subtitle} diff --git a/src/components/Editor/Panel/Panel.tsx b/src/components/Editor/Panel/Panel.tsx index becfa831..efb9221b 100644 --- a/src/components/Editor/Panel/Panel.tsx +++ b/src/components/Editor/Panel/Panel.tsx @@ -37,11 +37,13 @@ export const Panel = (props: Props) => { } }) - const handleSaveLinkClick = () => { + const handleSaveLinkClick = (e) => { + e.preventDefault() saveShout() } - const handlePublishLinkClick = () => { + const handlePublishLinkClick = (e) => { + e.preventDefault() publishShout() } diff --git a/src/context/editor.tsx b/src/context/editor.tsx index ba8912ac..cdd56cac 100644 --- a/src/context/editor.tsx +++ b/src/context/editor.tsx @@ -107,7 +107,7 @@ export const EditorProvider = (props: { children: JSX.Element }) => { openPage(router, 'article', { slug: shout.slug }) } } catch (error) { - console.error(error) + console.error('[saveShout]', error) showSnackbar({ type: 'error', body: t('Error') }) } } @@ -140,7 +140,7 @@ export const EditorProvider = (props: { children: JSX.Element }) => { publish: true }) } catch (error) { - console.error(error) + console.error('[publishShout]', error) showSnackbar({ type: 'error', body: t('Error') }) } } @@ -154,7 +154,7 @@ export const EditorProvider = (props: { children: JSX.Element }) => { openPage(router, 'feed') } catch (error) { - console.error(error) + console.error('[publishShoutById]', error) showSnackbar({ type: 'error', body: t('Error') }) } }