Skip to content

Commit

Permalink
Add Success Page
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-gordon committed Oct 31, 2023
1 parent 86607c3 commit dd1cec2
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 24 deletions.
4 changes: 3 additions & 1 deletion app/src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export const Header = memo(function SharedHeader() {
const isSignUpPage = pathname === "/i";
const isNewPage = pathname === "/new";
const isPrivacyPolicyPage = pathname === "/privacy-policy";
const isSuccessPage = pathname === "/success";
const isInfoPage = isBlogPage || isChangelogPage || isRoadmapPage;
const isEditor =
!isSponsorPage &&
Expand All @@ -61,7 +62,8 @@ export const Header = memo(function SharedHeader() {
!isInfoPage &&
!isLogInPage &&
!isSignUpPage &&
!isNewPage;
!isNewPage &&
!isSuccessPage;
const isLoggedIn = useIsLoggedIn();
const isProUser = useIsProUser();
const lastChart = useLastChart((state) => state.lastChart);
Expand Down
2 changes: 2 additions & 0 deletions app/src/components/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const ForgotPassword = lazy(() => import("../pages/ForgotPassword"));
const DesignSystem = lazy(() => import("../pages/DesignSystem"));
const PrivacyPolicy = lazy(() => import("../pages/PrivacyPolicy"));
const CookiePolicy = lazy(() => import("../pages/CookiePolicy"));
const Success = lazy(() => import("../pages/Success"));
import Page404 from "../pages/404";
import { useSupportLegacyNRoute } from "../lib/useSupportLegacyNRoute";

Expand Down Expand Up @@ -76,6 +77,7 @@ export default function Router() {
<Route path="/reset-password" element={<ResetPassword />} />
<Route path="/privacy-policy" element={<PrivacyPolicy />} />
<Route path="/cookie-policy" element={<CookiePolicy />} />
<Route path="/success" element={<Success />} />
<Route path="*" element={<Page404 />} />
</Route>
</Routes>
Expand Down
16 changes: 0 additions & 16 deletions app/src/components/WelcomeMessage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { t } from "@lingui/macro";
import { lazy, Suspense, useEffect, useState } from "react";
const Confetti = lazy(() => import("react-confetti"));

import { ReactComponent as Success } from "./Success.svg";

Expand All @@ -10,10 +8,6 @@ import { ReactComponent as Success } from "./Success.svg";
* after first signing up
*/
export function WelcomeMessage() {
const [windowSize, setWindowSize] = useState<[number, number] | null>(null);
useEffect(() => {
setWindowSize([window.innerWidth, window.innerHeight]);
}, []);
return (
<>
<div
Expand All @@ -26,16 +20,6 @@ export function WelcomeMessage() {
{t`Log in to start creating flowcharts.`}
</p>
</div>
{windowSize && (
<Suspense fallback={null}>
<Confetti
width={windowSize[0]}
height={windowSize[1]}
numberOfPieces={50}
colors={["#e9efff", "#7f96ff", "#ffe590", "#e3ffdc", "#8252eb"]}
/>
</Suspense>
)}
</>
);
}
7 changes: 0 additions & 7 deletions app/src/pages/LogIn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { useForm } from "react-hook-form";
import { useMutation } from "react-query";

import { Warning } from "../components/Warning";
import { WelcomeMessage } from "../components/WelcomeMessage";
import { isError } from "../lib/helpers";
import { supabase } from "../lib/supabaseClient";
import { Button2, InputWithLabel, P, Page } from "../ui/Shared";
Expand Down Expand Up @@ -69,10 +68,6 @@ export default function Login() {
[mutate]
);

const [newSignUp] = useState(() => {
return window.location.hash === "#success";
});

if (success) {
return (
<div className="pt-12 grid justify-items-center content-start gap-4 w-full max-w-[440px] mx-auto text-center">
Expand Down Expand Up @@ -104,7 +99,6 @@ export default function Login() {
return (
<Page size="sm">
{showAuthWallWarning && <AuthWallWarning />}
{newSignUp && <WelcomeMessage />}
<PageTitle className="text-center mb-6">{t`Sign In`}</PageTitle>
<Button2
leftIcon={<GoogleSVG />}
Expand Down Expand Up @@ -196,7 +190,6 @@ function AuthWallWarning() {
}

function checkForAuthWallWarningAndRedirect(search: string): [boolean, string] {
debugger;
const params = new URLSearchParams(search);
const showAuthWallWarning = params.get("showAuthWallWarning") === "true";
const redirectUrl = decodeURIComponent(params.get("redirectUrl") || "/"); // default to home page
Expand Down
103 changes: 103 additions & 0 deletions app/src/pages/Success.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import { ReactNode, Suspense, lazy, useEffect, useState } from "react";
import { Button2, Page } from "../ui/Shared";
import { FileCsv, FloppyDisk, MagicWand, TreeStructure } from "phosphor-react";
import classNames from "classnames";
import { Trans, t } from "@lingui/macro";
import { Link, useNavigate } from "react-router-dom";
const Confetti = lazy(() => import("react-confetti"));

export default function Success() {
const [windowSize, setWindowSize] = useState<[number, number] | null>(null);
const [numPieces, setNumPieces] = useState(200);
useEffect(() => {
setWindowSize([window.innerWidth, window.innerHeight]);
// reduce the num pieces by 50 every 2 seconds
const interval = setInterval(() => {
setNumPieces((num) => {
if (num < 50) {
clearInterval(interval);
return 0;
}
return num - 50;
});
}, 2000);
}, []);
const navigate = useNavigate();
return (
<>
<Page className="justify-center">
<h2 className="text-3xl font-bold text-center">
<Trans>Subscription Successful!</Trans>
</h2>
<div className="grid gap-6 mb-6">
<p className="text-center text-lg text-wrap-balance leading-normal">
<Trans>Here are some Pro features you can now enjoy.</Trans>
</p>
<div className="grid grid-cols-3">
<ProFeature
title={t`Save your Work`}
icon={FloppyDisk}
className="text-green-500"
/>
<ProFeature
title={t`Create with AI`}
icon={MagicWand}
className="text-purple-500"
/>
<ProFeature
title={t`Import from CSV`}
icon={FileCsv}
className="text-orange-500"
/>
</div>
</div>
<p className="text-center text-lg text-wrap-balance leading-normal mb-8">
<Trans>
Feel free to explore and reach out to us through the{" "}
<Link to="/o" className="font-bold underline">
Feedback
</Link>{" "}
page should you have any concerns.
</Trans>
</p>
<Button2
size="lg"
leftIcon={<TreeStructure />}
onClick={() => {
navigate("/");
}}
>
<Trans>Go to the Editor</Trans>
</Button2>
</Page>
{windowSize && (
<Suspense fallback={null}>
<Confetti
width={windowSize[0]}
height={windowSize[1]}
numberOfPieces={numPieces}
wind={0.02}
colors={["#e9efff", "#7f96ff", "#ffe590", "#e3ffdc", "#8252eb"]}
/>
</Suspense>
)}
</>
);
}

function ProFeature({
title,
icon: Icon,
className,
}: {
title: ReactNode;
icon: typeof FloppyDisk;
className?: string;
}) {
return (
<div className={classNames("flex flex-col items-center", className)}>
<Icon className="w-24 h-24 mb-2" weight="light" />
<p className="text-center font-bold">{title}</p>
</div>
);
}

0 comments on commit dd1cec2

Please sign in to comment.