From d93f6fd5d52c474aa4e26d69954657e00348d78b Mon Sep 17 00:00:00 2001 From: m5r Date: Wed, 4 Aug 2021 02:46:47 +0800 Subject: [PATCH] add help modal during onboarding --- app/core/hooks/use-current-customer.ts | 6 +- app/onboarding/components/help-modal.tsx | 52 ++++++++++++++ app/onboarding/pages/welcome/step-two.tsx | 85 +++++++++++++---------- 3 files changed, 103 insertions(+), 40 deletions(-) create mode 100644 app/onboarding/components/help-modal.tsx diff --git a/app/core/hooks/use-current-customer.ts b/app/core/hooks/use-current-customer.ts index e4d9f6a..3f00caa 100644 --- a/app/core/hooks/use-current-customer.ts +++ b/app/core/hooks/use-current-customer.ts @@ -1,10 +1,10 @@ -import { useAuthenticatedSession, useQuery } from "blitz"; +import { useSession, useQuery } from "blitz"; import getCurrentCustomer from "../../customers/queries/get-current-customer"; export default function useCurrentCustomer() { - const session = useAuthenticatedSession(); - const [customer] = useQuery(getCurrentCustomer, null); + const session = useSession(); + const [customer] = useQuery(getCurrentCustomer, null, { enabled: Boolean(session.userId) }); return { customer, hasFilledTwilioCredentials: Boolean(customer && customer.accountSid && customer.authToken), diff --git a/app/onboarding/components/help-modal.tsx b/app/onboarding/components/help-modal.tsx new file mode 100644 index 0000000..5448e1b --- /dev/null +++ b/app/onboarding/components/help-modal.tsx @@ -0,0 +1,52 @@ +import type { FunctionComponent } from "react"; +import { useRef } from "react"; + +import Modal, { ModalTitle } from "../../settings/components/modal"; + +type Props = { + isHelpModalOpen: boolean; + closeModal: () => void; +}; + +const HelpModal: FunctionComponent = ({ isHelpModalOpen, closeModal }) => { + const modalCloseButtonRef = useRef(null); + return ( + +
+
+ Need help finding your Twilio credentials? +
+

+ You can check out our{" "} + + getting started + {" "} + guide to set up your account with your Twilio credentials. +

+

+ If you feel stuck, pick a date & time on{" "} + + our calendly + {" "} + and we will help you get started! +

+
+
+
+
+ +
+
+ ); +}; + +export default HelpModal; diff --git a/app/onboarding/pages/welcome/step-two.tsx b/app/onboarding/pages/welcome/step-two.tsx index ad0680a..11bd72c 100644 --- a/app/onboarding/pages/welcome/step-two.tsx +++ b/app/onboarding/pages/welcome/step-two.tsx @@ -1,13 +1,16 @@ import type { FunctionComponent } from "react"; -import { Suspense, useEffect } from "react"; +import { Suspense, useEffect, useState } from "react"; import type { BlitzPage, GetServerSideProps } from "blitz"; import { getSession, Routes, useMutation, useRouter } from "blitz"; import clsx from "clsx"; import { useForm } from "react-hook-form"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { faQuestionCircle } from "@fortawesome/pro-solid-svg-icons"; import db from "db"; import setTwilioApiFields from "../../mutations/set-twilio-api-fields"; import OnboardingLayout from "../../components/onboarding-layout"; +import HelpModal from "../../components/help-modal"; import useCurrentCustomer from "../../../core/hooks/use-current-customer"; type Form = { @@ -25,6 +28,7 @@ const StepTwo: BlitzPage = () => { const router = useRouter(); const { customer } = useCurrentCustomer(); const [setTwilioApiFieldsMutation] = useMutation(setTwilioApiFields); + const [isHelpModalOpen, setIsHelpModalOpen] = useState(false); useEffect(() => { setValue("twilioAuthToken", customer?.authToken ?? ""); @@ -45,43 +49,50 @@ const StepTwo: BlitzPage = () => { }); return ( -
-
-
- - -
-
- - -
- - -
-
+
+
+ + +
+
+ + +
+ + +
+ + + setIsHelpModalOpen(false)} isHelpModalOpen={isHelpModalOpen} /> + ); };