Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

added complete setup modal

Steven Teyc37edc8baf64
diff --git a/components/app/modals/complete-setup-modal.tsx b/components/app/modals/complete-setup-modal.tsx
new file mode 100644
index 0000000000..cd7931431c
--- /dev/null
+++ b/components/app/modals/complete-setup-modal.tsx
@@ -0,0 +1,91 @@
+import { useRouter } from "next/router";
+import Link from "next/link";
+import {
+ Dispatch,
+ SetStateAction,
+ useCallback,
+ useMemo,
+ useState,
+} from "react";
+import BlurImage from "@/components/shared/blur-image";
+import Modal from "@/components/shared/modal";
+import { CheckCircleFill, ExpandingArrow } from "@/components/shared/icons";
+
+function CompleteSetupModal({
+ showCompleteSetupModal,
+ setShowCompleteSetupModal,
+}: {
+ showCompleteSetupModal: boolean;
+ setShowCompleteSetupModal: Dispatch<SetStateAction<boolean>>;
+}) {
+ const router = useRouter();
+ const { slug } = router.query as { slug: string };
+
+ const tasks = [
+ { display: "Set up your custom domain", cta: `/${slug}/settings` },
+ { display: "Invite your teammates", cta: `/${slug}/settings/people` },
+ { display: "Import your links", cta: `/${slug}` },
+ ];
+
+ return (
+ <Modal
+ showModal={showCompleteSetupModal}
+ setShowModal={setShowCompleteSetupModal}
+ >
+ <div className="inline-block w-full transform overflow-hidden bg-white align-middle shadow-xl transition-all sm:max-w-md sm:rounded-2xl sm:border sm:border-gray-200">
+ <div className="flex flex-col items-center justify-center space-y-3 border-b border-gray-200 px-4 py-4 pt-8 sm:px-16">
+ <BlurImage
+ src={`/_static/logo.png`}
+ alt={"Invite Teammate"}
+ className="h-10 w-10 rounded-full"
+ width={20}
+ height={20}
+ />
+ <h3 className="text-lg font-medium">You're almost there!</h3>
+ <p className="text-center text-sm text-gray-500">
+ Complete the following steps and start sharing your branded short
+ links.
+ </p>
+ </div>
+ <div className="flex flex-col space-y-6 bg-gray-50 px-4 py-8 text-left sm:px-12">
+ <div className="grid divide-y divide-gray-200 rounded-lg border border-gray-200 bg-white">
+ {tasks.map(({ display, cta }) => (
+ <a target="_blank" rel="noreferrer" href={cta}>
+ <div className="group flex items-center justify-between p-3">
+ <div className="flex items-center space-x-3">
+ <CheckCircleFill className="h-5 w-5 text-gray-400" />
+ <p className="text-sm">{display}</p>
+ </div>
+ <div className="mr-5">
+ <ExpandingArrow />
+ </div>
+ </div>
+ </a>
+ ))}
+ </div>
+ </div>
+ </div>
+ </Modal>
+ );
+}
+
+export function useCompleteSetupModal() {
+ const [showCompleteSetupModal, setShowCompleteSetupModal] = useState(false);
+
+ const CompleteSetupModalCallback = useCallback(() => {
+ return (
+ <CompleteSetupModal
+ showCompleteSetupModal={showCompleteSetupModal}
+ setShowCompleteSetupModal={setShowCompleteSetupModal}
+ />
+ );
+ }, [showCompleteSetupModal, setShowCompleteSetupModal]);
+
+ return useMemo(
+ () => ({
+ setShowCompleteSetupModal,
+ CompleteSetupModal: CompleteSetupModalCallback,
+ }),
+ [setShowCompleteSetupModal, CompleteSetupModalCallback],
+ );
+}
diff --git a/components/shared/modal.tsx b/components/shared/modal.tsx
index f3c4d97ff4..d52c8bb4ec 100644
--- a/components/shared/modal.tsx
+++ b/components/shared/modal.tsx
@@ -75,7 +75,7 @@ export default function Modal({
return (
<AnimatePresence>
{showModal && (
- <FocusTrap>
+ <FocusTrap focusTrapOptions={{ initialFocus: false }}>
<div className="absolute">
<motion.div
ref={mobileModalRef}
diff --git a/pages/app/[slug]/index.tsx b/pages/app/[slug]/index.tsx
index ce562c692c..3f6f9525b2 100644
--- a/pages/app/[slug]/index.tsx
+++ b/pages/app/[slug]/index.tsx
@@ -6,6 +6,7 @@ import AppLayout from "components/layout/app";
import useProject from "@/lib/swr/use-project";
import { useAcceptInviteModal } from "@/components/app/modals/accept-invite-modal";
import { useEffect } from "react";
+import { useCompleteSetupModal } from "@/components/app/modals/complete-setup-modal";
export default function ProjectLinks() {
const { project, error } = useProject();
@@ -13,13 +14,17 @@ export default function ProjectLinks() {
const { AddEditLinkModal, AddEditLinkButton } = useAddEditLinkModal({});
const { AcceptInviteModal, setShowAcceptInviteModal } =
useAcceptInviteModal();
+ const { CompleteSetupModal, setShowCompleteSetupModal } =
+ useCompleteSetupModal();
// handle errors
useEffect(() => {
if (error && (error.status === 409 || error.status === 410)) {
setShowAcceptInviteModal(true);
+ } else if (!project.domainVerified) {
+ setShowCompleteSetupModal(true);
}
- }, [error]);
+ }, [error, project.domainVerified]);
if (error && error.status === 404) {
return <ErrorPage statusCode={404} />;
@@ -28,6 +33,7 @@ export default function ProjectLinks() {
return (
<AppLayout>
{project && <AddEditLinkModal />}
+ {!project.domainVerified && <CompleteSetupModal />}
{error && (error.status === 409 || error.status === 410) && (
<AcceptInviteModal />
)}
diff --git a/pages/app/welcome.tsx b/pages/app/welcome.tsx
index 7795047141..0db7e56cd8 100644
--- a/pages/app/welcome.tsx
+++ b/pages/app/welcome.tsx
@@ -12,7 +12,7 @@ const staggerChildVariants = {
};
export default function Welcome() {
- const [state, setState] = useState("interim");
+ const [state, setState] = useState("intro");
const { setShowAddProjectModal, AddProjectModal } = useAddProjectModal({
closeWithX: true,