Skip to content

Commit

Permalink
✏️ Typo
Browse files Browse the repository at this point in the history
  • Loading branch information
naelob committed Apr 22, 2024
1 parent 67c41ac commit 8598999
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions apps/client-ts/src/components/RootLayout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ export const RootLayout = () => {
console.log('Profiles fetch error: '+ error)
}

const { profile, setProfile } = useProfileStore();
const { setProfile } = useProfileStore();

const { idProject, setIdProject } = useProjectStore();
const { setIdProject } = useProjectStore();

const { projects, setProjects } = useProjectsStore();
const { setProjects } = useProjectsStore();

//const { data: projects, isLoading: isLoadingProjects } = useProjectsByUser(user?.user_id!);

Expand All @@ -68,33 +68,29 @@ export const RootLayout = () => {
*/

useEffect(() => {
if(data){
//console.log("data is "+ JSON.stringify(data));
if(data) {
// Set profile
setProfile({
id_user: data.id_user,
email: data.email!,
first_name: data.first_name,
last_name: data.last_name,
//id_organization: data.id_organization as string,
})
}
}, [data, setProfile]);
});

useEffect(() => {
if(data){
// Fetch and set projects
const fetchProjects = async () => {
if (data) {
const response = await fetch(`${config.API_URL}/projects/${data.id_user}`);
const projectsData = await response.json();
console.log("PROJECTS FETCHED ARE => "+ JSON.stringify(projectsData))
setIdProject(projectsData[0]?.id_project); // Assuming you want to set the first project ID
setProjects(projectsData as Project[])
const response = await fetch(`${config.API_URL}/projects/${data.id_user}`);
const projectsData = await response.json();
console.log("PROJECTS FETCHED ARE => "+ JSON.stringify(projectsData))
if(projectsData.length > 0) {
setIdProject(projectsData[0]?.id_project);
}
setProjects(projectsData as Project[]);
};
fetchProjects();

fetchProjects();
}
}, [data, setIdProject, setProfile, setProjects]);

}, [data]); // Make sure to list all used functions and data properties as dependencies

const handlePageChange = (page: string) => {
//console.log(`${base}/${page}`)
Expand Down

0 comments on commit 8598999

Please sign in to comment.