diff --git a/client/src/containers/profile/index.tsx b/client/src/containers/profile/index.tsx index 4ddf2af6..b62ffbac 100644 --- a/client/src/containers/profile/index.tsx +++ b/client/src/containers/profile/index.tsx @@ -4,7 +4,7 @@ import { useEffect, useMemo, useRef } from "react"; import Link from "next/link"; -import { useSetAtom } from "jotai"; +import { ExtractAtomValue, useSetAtom } from "jotai"; import { useFeatureFlags } from "@/hooks/use-feature-flags"; @@ -14,13 +14,13 @@ import FileUpload, { TEMPLATE_FILES } from "@/containers/profile/file-upload"; import FileUploadDescription from "@/containers/profile/file-upload/description"; import ProfileSection from "@/containers/profile/profile-section"; import ProfileSidebar from "@/containers/profile/profile-sidebar"; -import { intersectingAtom } from "@/containers/profile/store"; +import { profileStepAtom } from "@/containers/profile/store"; import UserDetails from "@/containers/profile/user-details"; import { ScrollArea } from "@/components/ui/scroll-area"; import { SidebarTrigger } from "@/components/ui/sidebar"; -const sections = [ +export const PROFILE_SECTIONS = [ { id: "my-details", title: "My details", @@ -58,10 +58,10 @@ const sections = [ export default function Profile() { const ref = useRef(null); - const setIntersecting = useSetAtom(intersectingAtom); + const setProfileStep = useSetAtom(profileStepAtom); const featureFlags = useFeatureFlags(); const currentSections = useMemo(() => { - return sections.filter((section) => { + return PROFILE_SECTIONS.filter((section) => { const featureFlagExists = section.id in featureFlags; const isFeatureEnabled = featureFlagExists && @@ -78,9 +78,11 @@ export default function Profile() { (entries) => { entries.forEach((entry) => { if (entry.isIntersecting) { - const sectionSlug = entry.target.id; + const sectionSlug = entry.target.id as ExtractAtomValue< + typeof profileStepAtom + >; - setIntersecting(sectionSlug); + setProfileStep(sectionSlug); } }); }, @@ -95,22 +97,22 @@ export default function Profile() { }, ); - const sections = Array.from( + const PROFILE_SECTIONS = Array.from( ref.current.querySelector("#profile-sections-container")?.children || [], ); - sections.forEach((section) => observer.observe(section)); + PROFILE_SECTIONS.forEach((section) => observer.observe(section)); return () => observer.disconnect(); - }, [setIntersecting]); + }, [setProfileStep]); return (
-
+

User area

-
+
({ id: s.id, name: s.title }))} /> diff --git a/client/src/containers/profile/profile-sidebar/index.tsx b/client/src/containers/profile/profile-sidebar/index.tsx index 41f4f21a..2bd6ac64 100644 --- a/client/src/containers/profile/profile-sidebar/index.tsx +++ b/client/src/containers/profile/profile-sidebar/index.tsx @@ -8,9 +8,8 @@ import { signOut, useSession } from "next-auth/react"; import { client } from "@/lib/query-client"; import { queryKeys } from "@/lib/query-keys"; -import { cn } from "@/lib/utils"; -import { intersectingAtom } from "@/containers/profile/store"; +import { profileStepAtom } from "@/containers/profile/store"; import { Avatar, AvatarFallback } from "@/components/ui/avatar"; import { Button } from "@/components/ui/button"; @@ -45,7 +44,7 @@ const ProfileSidebar: FC = ({ navItems }) => { queryKey: queryKeys.user.me(session?.user?.id as string).queryKey, }, ); - const intersecting = useAtomValue(intersectingAtom); + const intersecting = useAtomValue(profileStepAtom); return (