-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: continued added details to new explorations page - Ref gestion-d…
…e-projet#2507
- Loading branch information
Showing
11 changed files
with
396 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from 'react' | ||
import useBreadcrumb from '../hooks/useBreadcrumb' | ||
import { Breadcrumbs, Link } from '@mui/material' | ||
|
||
const Breadcrumb = () => { | ||
const items = useBreadcrumb() | ||
return ( | ||
// TODO: style | ||
<Breadcrumbs> | ||
{items.map((item, index) => ( | ||
<Link key={index} href={item.url}> | ||
{item.label} | ||
</Link> | ||
))} | ||
</Breadcrumbs> | ||
) | ||
} | ||
|
||
export default Breadcrumb |
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
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,26 @@ | ||
import React from 'react' | ||
import { useLocation } from 'react-router' | ||
|
||
const useBreadCrumb = () => { | ||
const location = useLocation() | ||
const pathParts = location.pathname.split('/').filter(Boolean) | ||
console.log('test pathParts', pathParts) | ||
|
||
const items = [] | ||
|
||
// TODO: clean et externaliser | ||
// TODO: faire une fonction plus jolie pour trouver où je suis et récup les noms | ||
if (pathParts[1] === 'projects') { | ||
items.push({ label: 'Mes projets', url: 'researches/projects' }) | ||
} else if (pathParts[1] === 'requests') { | ||
items.push({ label: 'Mes requêtes', url: 'researches/requests' }) | ||
} else if (pathParts[1] === 'cohorts') { | ||
items.push({ label: 'Mes cohortes', url: 'researches/cohorts' }) | ||
} else if (pathParts[1] === 'samples') { | ||
items.push({ label: 'Mes échantillons', url: 'researches/samples' }) | ||
} | ||
|
||
return items | ||
} | ||
|
||
export default useBreadCrumb |
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,26 @@ | ||
import React, { useEffect, useState } from 'react' | ||
import services from 'services/aphp' | ||
|
||
const useProjects = (searchTerm: string, startDate?: string, endDate?: string) => { | ||
const [projectsList, setProjectsList] = useState<any[]>([]) | ||
const [total, setTotal] = useState(0) | ||
const [loading, setLoading] = useState(false) | ||
|
||
// TODO: à externaliser | ||
const fetchProjectsList = async () => { | ||
// TODO: modifier le service de sorte à ajouter les filtres + try/catch | ||
const projectsList = await services.projects.fetchProjectsList() | ||
console.log('test projectsList', projectsList) | ||
setProjectsList(projectsList.results) | ||
setTotal(projectsList.count) | ||
} | ||
|
||
useEffect(() => { | ||
// setLoading(true) | ||
console.log('test fetchPRoejctsList()', fetchProjectsList()) | ||
}, [searchTerm, startDate, endDate]) | ||
|
||
return { projectsList, total, loading } | ||
} | ||
|
||
export default useProjects |
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,28 @@ | ||
import React, { useEffect, useState } from 'react' | ||
import services from 'services/aphp' | ||
|
||
const useRequests = (projectId: string, searchTerm: string, startDate?: string, endDate?: string, page = 1) => { | ||
const [requestsList, setRequestsList] = useState<any[]>([]) | ||
const [total, setTotal] = useState(0) | ||
const [loading, setLoading] = useState(false) | ||
|
||
// TODO: à externaliser | ||
const fetchRequestsList = async () => { | ||
// TODO: modifier le service de sorte à ajouter les filtres + try/catch | ||
const rowsPerPage = 20 | ||
const offset = (page - 1) * rowsPerPage | ||
const requestsList = await services.projects.fetchRequestsList(rowsPerPage, offset) | ||
console.log('test requestsList', requestsList) | ||
setRequestsList(requestsList.results) | ||
setTotal(requestsList.count) | ||
} | ||
|
||
useEffect(() => { | ||
// setLoading(true) | ||
console.log('test fetchRequestsList()', fetchRequestsList()) | ||
}, [projectId, searchTerm, startDate, endDate, page]) | ||
|
||
return { requestsList, total, loading } | ||
} | ||
|
||
export default useRequests |
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
Oops, something went wrong.