diff --git a/enjoy/src/renderer/components/posts/index.ts b/enjoy/src/renderer/components/posts/index.ts index 961d8bc9..449dca36 100644 --- a/enjoy/src/renderer/components/posts/index.ts +++ b/enjoy/src/renderer/components/posts/index.ts @@ -4,3 +4,4 @@ export * from "./post-card"; export * from "./post-actions"; export * from "./post-medium"; export * from "./post-recording"; +export * from "./post-story"; diff --git a/enjoy/src/renderer/components/posts/post-card.tsx b/enjoy/src/renderer/components/posts/post-card.tsx index cf4aaecf..9fdab708 100644 --- a/enjoy/src/renderer/components/posts/post-card.tsx +++ b/enjoy/src/renderer/components/posts/post-card.tsx @@ -1,10 +1,10 @@ -import { PostRecording, PostActions, PostMedium } from "@renderer/components"; import { - Avatar, - AvatarImage, - AvatarFallback, - Button, -} from "@renderer/components/ui"; + PostRecording, + PostActions, + PostMedium, + PostStory, +} from "@renderer/components"; +import { Avatar, AvatarImage, AvatarFallback } from "@renderer/components/ui"; import { formatDateTime } from "@renderer/lib/utils"; import { t } from "i18next"; import Markdown from "react-markdown"; @@ -55,6 +55,15 @@ export const PostCard = (props: { post: PostType }) => { )} + {post.targetType == "Story" && ( + <> +
+ {t("sharedStory")} +
+ + + )} + ); diff --git a/enjoy/src/renderer/components/posts/post-story.tsx b/enjoy/src/renderer/components/posts/post-story.tsx new file mode 100644 index 00000000..e98c3833 --- /dev/null +++ b/enjoy/src/renderer/components/posts/post-story.tsx @@ -0,0 +1,25 @@ +import { Link } from "react-router-dom"; + +export const PostStory = (props: { story: StoryType }) => { + const { story } = props; + return ( + +
+
+ +
+
+
+ {story.metadata?.title} +
+
+ {story.metadata?.description} +
+
+
+ + ); +}; diff --git a/enjoy/src/renderer/components/stories/story-toolbar.tsx b/enjoy/src/renderer/components/stories/story-toolbar.tsx index 6e7b4a77..b3740b3e 100644 --- a/enjoy/src/renderer/components/stories/story-toolbar.tsx +++ b/enjoy/src/renderer/components/stories/story-toolbar.tsx @@ -2,6 +2,16 @@ import { Alert, AlertTitle, AlertDescription, + AlertDialog, + AlertDialogTrigger, + AlertDialogContent, + AlertDialogHeader, + AlertDialogTitle, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogCancel, + AlertDialogAction, + Button, ScrollArea, Separator, Sheet, @@ -17,6 +27,7 @@ import { ScanTextIcon, LoaderIcon, StarIcon, + Share2Icon, } from "lucide-react"; import { t } from "i18next"; @@ -36,6 +47,7 @@ export const StoryToolbar = (props: { marked?: boolean; toggleMarked?: () => void; pendingLookups?: LookupType[]; + handleShare?: () => void; }) => { const { starred, @@ -47,6 +59,7 @@ export const StoryToolbar = (props: { toggleMarked, meanings = [], pendingLookups = [], + handleShare, } = props; const [vocabularyVisible, setVocabularyVisible] = useState( @@ -76,6 +89,27 @@ export const StoryToolbar = (props: { + + + + + + + + + {t("shareStory")} + + {t("areYouSureToShareThisStoryToCommunity")} + + + + {t("cancel")} + + + + + + { const [scanning, setScanning] = useState(false); const [marked, setMarked] = useState(true); const [doc, setDoc] = useState(null); + const { toast } = useToast(); const fetchStory = async () => { webApi @@ -118,6 +119,23 @@ export default () => { } }; + const handleShare = async () => { + webApi + .createPost({ targetId: story.id, targetType: "Story" }) + .then(() => { + toast({ + description: t("sharedStory"), + }); + }) + .catch((error) => { + toast({ + title: t("shareFailed"), + description: error.message, + variant: "destructive", + }); + }); + }; + useEffect(() => { fetchStory(); fetchMeanings(); @@ -162,6 +180,7 @@ export default () => { starred={story.starred} toggleStarred={toggleStarred} pendingLookups={pendingLookups} + handleShare={handleShare} />