From 7da86f173bc3cb1a504326a5ca06f3a5b85f5574 Mon Sep 17 00:00:00 2001 From: Arik Chakma Date: Tue, 27 Aug 2024 07:21:36 +0600 Subject: [PATCH] wip: implement success modal --- .../Projects/SubmitProjectModal.tsx | 12 +- .../Projects/SubmitSuccessModal.tsx | 115 ++++++++++++++++++ 2 files changed, 121 insertions(+), 6 deletions(-) create mode 100644 src/components/Projects/SubmitSuccessModal.tsx diff --git a/src/components/Projects/SubmitProjectModal.tsx b/src/components/Projects/SubmitProjectModal.tsx index 476825442..10df20fb8 100644 --- a/src/components/Projects/SubmitProjectModal.tsx +++ b/src/components/Projects/SubmitProjectModal.tsx @@ -7,6 +7,7 @@ import { GitHubIcon } from '../ReactIcons/GitHubIcon.tsx'; import { SubmissionRequirement } from './SubmissionRequirement.tsx'; import { useCopyText } from '../../hooks/use-copy-text.ts'; import { getTopGitHubLanguages } from '../../lib/github.ts'; +import { SubmitSuccessModal } from './SubmitSuccessModal.tsx'; type SubmitProjectResponse = { repositoryUrl: string; @@ -211,12 +212,11 @@ export function SubmitProjectModal(props: SubmitProjectModalProps) { if (successMessage) { return ( - -
- -

{successMessage}

-
-
+ ); } diff --git a/src/components/Projects/SubmitSuccessModal.tsx b/src/components/Projects/SubmitSuccessModal.tsx new file mode 100644 index 000000000..14f7bec69 --- /dev/null +++ b/src/components/Projects/SubmitSuccessModal.tsx @@ -0,0 +1,115 @@ +import { + CheckCircle2, + Clipboard, + Facebook, + Linkedin, + Twitter, +} from 'lucide-react'; +import { getUser } from '../../lib/jwt.ts'; +import { Modal } from '../Modal'; +import { CheckIcon as ReactCheckIcon } from '../ReactIcons/CheckIcon.tsx'; +import { useCopyText } from '../../hooks/use-copy-text.ts'; +import { cn } from '../../lib/classname.ts'; + +type SubmitSuccessModalProps = { + projectId: string; + onClose: () => void; + successMessage: string; +}; + +export function SubmitSuccessModal(props: SubmitSuccessModalProps) { + const { onClose, successMessage, projectId } = props; + + const user = getUser(); + + const description = 'Check out my solution to this project on Roadmap.sh'; + const projectSolutionUrl = `${import.meta.env.DEV ? 'http://localhost:3000' : 'https://roadmap.sh'}/projects/${projectId}?u=${user?.id}`; + + const { isCopied, copyText } = useCopyText(); + + const socialShareLinks = [ + { + title: 'Twitter', + href: `https://x.com/intent/tweet?text=${description}&url=${projectSolutionUrl}`, + icon: , + }, + { + title: 'Facebook', + href: `https://www.facebook.com/sharer/sharer.php?quote=${description}&u=${projectSolutionUrl}`, + icon: , + }, + { + title: 'Linkedin', + href: `https://www.linkedin.com/sharing/share-offsite/?url=${projectSolutionUrl}`, + icon: , + }, + ]; + + return ( + +
+ + {/*

{successMessage}

*/} +

+ Solution submitted successfully! +

+

+ You can use the link to share your solution with others. +

+ +
+ { + e.currentTarget.select(); + copyText(projectSolutionUrl); + }} + /> + + +
+ +
+ {socialShareLinks.map((socialLink) => ( + + {socialLink.icon} + + ))} +
+ +

+ Share your solution with the others! +

+
+
+ ); +}