From c0d4cc133ca662189138d15090a0a4c7f03e8093 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Thu, 24 Aug 2023 18:37:54 +0100 Subject: [PATCH] feat: PublishedModal component --- .../[subdomain]/editor/portfolio-editor.tsx | 34 +----------- .../[subdomain]/editor/post-editor.tsx | 47 +--------------- src/components/dashboard/PagesManager.tsx | 2 +- src/components/dashboard/PublishedModal.tsx | 53 +++++++++++++++++++ src/lib/i18n/locales/zh/dashboard.json | 2 +- 5 files changed, 59 insertions(+), 79 deletions(-) create mode 100644 src/components/dashboard/PublishedModal.tsx diff --git a/src/app/dashboard/[subdomain]/editor/portfolio-editor.tsx b/src/app/dashboard/[subdomain]/editor/portfolio-editor.tsx index f393b229..b590a2cc 100644 --- a/src/app/dashboard/[subdomain]/editor/portfolio-editor.tsx +++ b/src/app/dashboard/[subdomain]/editor/portfolio-editor.tsx @@ -10,12 +10,12 @@ import { useQueryClient } from "@tanstack/react-query" import { DashboardMain } from "~/components/dashboard/DashboardMain" import { PublishButton } from "~/components/dashboard/PublishButton" +import PublishedModal from "~/components/dashboard/PublishedModal" import { Button } from "~/components/ui/Button" import { FieldLabel } from "~/components/ui/FieldLabel" import { ImageUploader } from "~/components/ui/ImageUploader" import { Input } from "~/components/ui/Input" -import { ModalContentProps, useModalStack } from "~/components/ui/ModalStack" -import { UniLink } from "~/components/ui/UniLink" +import { useModalStack } from "~/components/ui/ModalStack" import { initialEditorState, useEditorState } from "~/hooks/useEditorState" import { useBeforeMounted } from "~/hooks/useSyncOnce" import { showConfetti } from "~/lib/confetti" @@ -433,33 +433,3 @@ const EditorExtraProperties = memo(() => { }) EditorExtraProperties.displayName = "EditorExtraProperties" - -const PublishedModal = ({ - dismiss, - transactionUrl, -}: ModalContentProps<{ - transactionUrl: string -}>) => { - const { t } = useTranslation("dashboard") - return ( - <> -
- {t( - "Your post has been securely stored on the blockchain. Now you may want to", - )} - -
-
- -
- - ) -} diff --git a/src/app/dashboard/[subdomain]/editor/post-editor.tsx b/src/app/dashboard/[subdomain]/editor/post-editor.tsx index 1ae6487b..5d4d7c03 100644 --- a/src/app/dashboard/[subdomain]/editor/post-editor.tsx +++ b/src/app/dashboard/[subdomain]/editor/post-editor.tsx @@ -25,12 +25,13 @@ import { useQueryClient } from "@tanstack/react-query" import { DashboardMain } from "~/components/dashboard/DashboardMain" import { OptionsButton } from "~/components/dashboard/OptionsButton" import { PublishButton } from "~/components/dashboard/PublishButton" +import PublishedModal from "~/components/dashboard/PublishedModal" import { Button } from "~/components/ui/Button" import { EditorToolbar } from "~/components/ui/EditorToolbar" import { FieldLabel } from "~/components/ui/FieldLabel" import { ImageUploader } from "~/components/ui/ImageUploader" import { Input } from "~/components/ui/Input" -import { ModalContentProps, useModalStack } from "~/components/ui/ModalStack" +import { useModalStack } from "~/components/ui/ModalStack" import { Switch } from "~/components/ui/Switch" import { TagInput } from "~/components/ui/TagInput" import { UniLink } from "~/components/ui/UniLink" @@ -986,47 +987,3 @@ const EditorAdvancedModal: FC<{ ) } - -const PublishedModal = ({ - dismiss, - postUrl, - transactionUrl, - twitterShareUrl, -}: ModalContentProps<{ - postUrl: string - transactionUrl: string - twitterShareUrl: string -}>) => { - const { t } = useTranslation("dashboard") - return ( - <> -
- {t( - "Your post has been securely stored on the blockchain. Now you may want to", - )} - -
-
- -
- - ) -} diff --git a/src/components/dashboard/PagesManager.tsx b/src/components/dashboard/PagesManager.tsx index 164d6c5d..c473dcc1 100644 --- a/src/components/dashboard/PagesManager.tsx +++ b/src/components/dashboard/PagesManager.tsx @@ -225,7 +225,7 @@ export const PagesManager = ({ type }: { type: NoteType }) => { {t(`New ${type.charAt(0).toUpperCase() + type.slice(1)}`)} - {type !== "portfolio" && ( + {(type === "post" || type === "page") && ( ) { + const { t } = useTranslation("dashboard") + + return ( + <> +
+ {t( + "Your publication has been securely stored on the blockchain. Now you may want to", + )} +
    + {postUrl && ( +
  • + + {t("View the post")} + +
  • + )} +
  • + + {t("View the transaction")} + +
  • + {twitterShareUrl && ( +
  • + + {t("Share to Twitter")} + +
  • + )} +
+
+
+ +
+ + ) +} diff --git a/src/lib/i18n/locales/zh/dashboard.json b/src/lib/i18n/locales/zh/dashboard.json index 9c7a163a..b7c5e940 100644 --- a/src/lib/i18n/locales/zh/dashboard.json +++ b/src/lib/i18n/locales/zh/dashboard.json @@ -141,7 +141,7 @@ "More": "更多", "Meet New Friends": "认识新朋友", "Need help?": "需要帮助?", - "Your post has been securely stored on the blockchain. Now you may want to": "你的文章已经安全地存储在区块链上。现在你可能想要", + "Your publication has been securely stored on the blockchain. Now you may want to": "你的发布已经安全地存储在区块链上。现在你可能想要", "View the post": "查看文章", "View the transaction": "查看交易", "Share to Twitter": "分享到 Twitter",