From 7eb286c563cb00bbfe9a83791b038e80435d17f7 Mon Sep 17 00:00:00 2001 From: nael Date: Wed, 24 Apr 2024 21:09:03 +0200 Subject: [PATCH] :bug: Rollback --- apps/client-ts/src/components/RootLayout/index.tsx | 8 -------- .../src/components/shared/team-switcher.tsx | 12 +++++++++++- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/apps/client-ts/src/components/RootLayout/index.tsx b/apps/client-ts/src/components/RootLayout/index.tsx index 077d89d45..77b601463 100644 --- a/apps/client-ts/src/components/RootLayout/index.tsx +++ b/apps/client-ts/src/components/RootLayout/index.tsx @@ -45,7 +45,6 @@ export const RootLayout = () => { const { user } = useStytchUser(); const { data, isLoading, isError, error } = useProfile(user?.user_id!); - const {data: projects} = useProjects(); if (isLoading) { console.log("loading profiles"); @@ -70,13 +69,6 @@ export const RootLayout = () => { } }, [data, setProfile]); - // Effect for setting profile - useEffect(() => { - if (projects) { - setProjects(projects); - setIdProject(projects[0].id_user); - } - }, [projects, setIdProject, setProfile, setProjects]); // Effect for fetching projects /*useEffect(() => { diff --git a/apps/client-ts/src/components/shared/team-switcher.tsx b/apps/client-ts/src/components/shared/team-switcher.tsx index d1c1feb76..73d0bb3e6 100644 --- a/apps/client-ts/src/components/shared/team-switcher.tsx +++ b/apps/client-ts/src/components/shared/team-switcher.tsx @@ -59,6 +59,7 @@ import { useForm } from "react-hook-form" import * as z from "zod" import config from "@/lib/config" import useProjectsStore from "@/state/projectsStore" +import useProjects from "@/hooks/useProjects" const projectFormSchema = z.object({ @@ -88,8 +89,17 @@ export default function TeamSwitcher({ className }: TeamSwitcherProps) { //const { data : orgs, isLoading: isloadingOrganisations } = useOrganisations(); const { idProject, setIdProject } = useProjectStore(); + const {data: projects} = useProjects(); - const { projects } = useProjectsStore(); + //const { projects } = useProjectsStore(); + + // Effect for setting profile + useEffect(() => { + if (projects) { + setIdProject(projects[0].id_user); + } + }, [projects, setIdProject]); + if(projects){ setIsloadingProjects(false);