generated from WildCodeSchool/create-js-monorepo
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' of github.com:WildCodeSchool/2023-09-JS-BDX-P3-La_…
…Rive_Droite into course_cvid
- Loading branch information
Showing
6 changed files
with
114 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// import React, { useEffect } from "react"; | ||
// import { useGlobalContext } from "../contexts/GlobalContext"; | ||
|
||
const currentAdmin = async (apiService) => { | ||
try { | ||
const response = await apiService.get( | ||
`${import.meta.env.VITE_BACKEND_URL}/api/users/me` | ||
); | ||
// console.log(response.data.is_admin); | ||
// console.log(response.data); | ||
// if (response.data.is_admin !== 1) { | ||
// // console.log("Unauthorized !"); | ||
// return navigate("/"); | ||
// } | ||
return response; | ||
} catch (err) { | ||
console.error(err.message); | ||
return null; | ||
} | ||
}; | ||
|
||
export default currentAdmin; | ||
|
||
// function AdminChecker() { | ||
// const globalContext = useGlobalContext(); | ||
|
||
// const currentAdmin = async (apiService) => { | ||
// try { | ||
// const response = await apiService.get( | ||
// `${import.meta.env.VITE_BACKEND_URL}/api/users/me` | ||
// ); | ||
// // console.log(response.data.is_admin); | ||
// console.log(response.data); | ||
// if (response.data.is_admin !== 1) { | ||
// // console.log("Unauthorized !"); | ||
// return globalContext.navigate("/"); | ||
// } | ||
// // return response; | ||
// } catch (err) { | ||
// console.error(err.message); | ||
// return null; | ||
// } | ||
// }; | ||
|
||
// useEffect(() => { | ||
// const checkAdmin = async () => { | ||
// await currentAdmin(globalContext.apiService); | ||
// }; | ||
|
||
// checkAdmin(); | ||
// }, [globalContext.apiService]); | ||
|
||
// return <div>AdminChecker is checking...</div>; | ||
// } | ||
|
||
// export default AdminChecker; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const currentRequestsUserProfile = async (apiService) => { | ||
try { | ||
// D'abord, on va chercher le CV de l'utilisateur, ce qui nous intéresse est l'id du CV | ||
const cvData = await apiService.get( | ||
`${import.meta.env.VITE_BACKEND_URL}/api/users/id/cvs` // TODO: remplacer le 5 par l'id de l'utilisateur connecté | ||
// `${import.meta.env.VITE_BACKEND_URL}/api/users${cvData.data.id}/cvs` // Get CV avec l'id de l'user connecté. | ||
); | ||
// console.log(cvData.data.id); | ||
|
||
// Ensuite, on va chercher les expériences de l'utilisateur via l'id du CV qu'on vient de récupérer | ||
// le but est de pouvoir faire SELECT * FROM experiences WHERE cv_id = cvData.data.id | ||
const experienceData = await apiService.get( | ||
`${import.meta.env.VITE_BACKEND_URL}/api/experiences/by-cv-id/${ | ||
cvData.data.id | ||
}` | ||
); | ||
const courseData = await apiService.get( | ||
`${import.meta.env.VITE_BACKEND_URL}/api/courses/by-cv-id/${ | ||
cvData.data.id | ||
}` | ||
); | ||
|
||
return { | ||
experiences: experienceData.data, | ||
courses: courseData.data, | ||
}; | ||
} catch (err) { | ||
console.error(err.message); | ||
return null; | ||
} | ||
}; | ||
|
||
export default currentRequestsUserProfile; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters