From d3c2d529f64b14442e84ee35cfd663b5a50d06b7 Mon Sep 17 00:00:00 2001 From: clintonlunn Date: Sat, 6 May 2023 23:04:57 -0700 Subject: [PATCH] change from stepper to onboardingchecklist #750 --- src/components/ui/OnboardingChecklist.tsx | 35 ++++ .../users/account/ProfileEditForm.tsx | 166 ++++-------------- src/pages/u/[...slug].tsx | 12 +- 3 files changed, 72 insertions(+), 141 deletions(-) create mode 100644 src/components/ui/OnboardingChecklist.tsx diff --git a/src/components/ui/OnboardingChecklist.tsx b/src/components/ui/OnboardingChecklist.tsx new file mode 100644 index 000000000..3bcab982f --- /dev/null +++ b/src/components/ui/OnboardingChecklist.tsx @@ -0,0 +1,35 @@ +import React, { ReactElement } from 'react' + +interface OnboardingChecklistProps { + mediaCount: number + hasUsername: boolean +} + +const OnboardingChecklist = ({ mediaCount, hasUsername }: OnboardingChecklistProps): ReactElement => { + const checklistItems = [ + { + text: 'Add 3 photos to complete your profile', + isCompleted: mediaCount >= 3 + }, + { + text: 'Create a username', + isCompleted: hasUsername + } + ] + + return ( +
+
+
    + {checklistItems.map((item, index) => ( +
  • + {item.text} {item.isCompleted && } +
  • + ))} +
+
+
+ ) +} + +export default OnboardingChecklist diff --git a/src/components/users/account/ProfileEditForm.tsx b/src/components/users/account/ProfileEditForm.tsx index fb8665c89..f3a701b6a 100644 --- a/src/components/users/account/ProfileEditForm.tsx +++ b/src/components/users/account/ProfileEditForm.tsx @@ -10,7 +10,6 @@ import { doesUsernameExist } from '../../../js/userApi/user' import { checkUsername, checkWebsiteUrl } from '../../../js/utils' import { revalidateUserHomePage } from '../../../js/stores/media' import Spinner from '../../ui/Spinner' -import Stepper from '../../ui/Stepper' const UserProfileSchema = Yup.object().shape({ nick: Yup.string() @@ -50,9 +49,6 @@ export default function ProfileEditForm (): ReactElement { const [loadingName, setLoadingUser] = useState(false) const [justSubmitted, setJustSubmitted] = useState(false) const [isChanged, setChanged] = useState(false) - const [currentStep, setCurrentStep] = useState(1) - // const [isFirstLogin, setIsFirstLogin] = useState(true) - const [isFirstLogin] = useState(true) const [isLoading, setIsLoading] = useState(true) const [profile, setProfile] = useState({ @@ -62,18 +58,6 @@ export default function ProfileEditForm (): ReactElement { website: undefined }) - const handleStepClick = (index: number): void => { - setCurrentStep(index) - } - - // const goToNextStep = (): void => { - // setCurrentStep(currentStep + 1) - // } - - // const goToPreviousStep = (): void => { - // setCurrentStep(currentStep - 1) - // } - useLayoutEffect(() => { const asyncLoad = async (): Promise => { setIsLoading(true) @@ -82,7 +66,6 @@ export default function ProfileEditForm (): ReactElement { if (profile != null) { setProfile(profile) - // setIsFirstLogin(profile.loginsCount === 1) } setIsLoading(false) } @@ -133,98 +116,46 @@ export default function ProfileEditForm (): ReactElement { setLoadingUser(false) return undefined }, [profile.nick]) - - const steps = [ - { - title: 'Username', - content: ( -
- - {loadingName && ( -
- - - -
- )} -
- ) - }, - { - title: 'Display Name', - content: - }, - { - title: 'Bio', - content: - }, - { - title: 'Website', - content: - } - ] - return (
-

- Edit your profile details -

+

Edit your profile details

{isLoading - ? + ? ( + + ) : ( <> - {isFirstLogin && ( -
- {({ isValid, isSubmitting, dirty }) => ( +
+ + {({ isValid, isSubmitting, dirty }) => (
- {isFirstLogin - ? ( - <> - - {steps[currentStep].content} - - - - ) - : ( - <> -
- +
+ - {loadingName && ( -
- - - -
- )} -
+ {loadingName && ( +
+ + + +
+ )} +
- - - - - )} + + +
- {/*
- {isFirstLogin && ( - - )} - {isFirstLogin && ( - - )} - -
*/}
)}
diff --git a/src/pages/u/[...slug].tsx b/src/pages/u/[...slug].tsx index 07cee28fe..c2d564dae 100644 --- a/src/pages/u/[...slug].tsx +++ b/src/pages/u/[...slug].tsx @@ -14,6 +14,7 @@ import usePermissions from '../../js/hooks/auth/usePermissions' import { useUserProfileSeo } from '../../js/hooks/seo' import useMediaDataStore from '../../js/hooks/useMediaDS' import type { UserGalleryProps } from '../../components/media/UserGallery' +import OnboardingChecklist from '../../components/ui/OnboardingChecklist' interface UserHomeProps { uid: string @@ -57,16 +58,7 @@ const UserHomePage: NextPage = ({ uid, postId = null, serverMedia - {isAuthorized && ( -
-
-
    -
  • Please upload 3 photos to complete your profile {mediaList?.length >= 3 && }
  • -
  • Upload only your own photos
  • -
  • Keep it Safe For Work and climbing-related
  • -
-
-
)} + {isAuthorized && }