Skip to content
Snippets Groups Projects
Commit b344a82a authored by Inès Yeterian's avatar Inès Yeterian
Browse files

change of approach : now react computes the new url

parent 46f8f612
No related branches found
No related tags found
1 merge request!4Url/year/title
......@@ -7,8 +7,12 @@ import ToucanCard from './ToucanCard'
const date = new Date()
const beginYear = 1900 + (date.getMonth() < 7 ? date.getYear()-1 : date.getYear());
function formToucanUrlId(toucan){
return toucan.title.toLowerCase().replace(/\s/g, "")+"-"+toucan.date.getFullYear();
}
function AllToucan(props){
const [urltoucans,setToucans] = useState([]);
const [toucans,setToucans] = useState([]);
const [before,setBefore] = useState((new Date(beginYear+1,6,31)).getTime());
const [after, setAfter] = useState((new Date(beginYear,7,1)).getTime());
......@@ -46,10 +50,10 @@ function AllToucan(props){
updateFrame = {updateFrame}
/>
<Card.Group centered >
{urltoucans.map( toucan => {
{toucans.map( toucan => {
return <ToucanCard
image={`${props.backURL}/toucan/img/${toucan["_id"]}`}
link={`${props.backURL}/toucan/pdf/${toucan.urlID}`}
link={`${props.backURL}/toucan/pdf/${formToucanUrlId(toucan)}+`}
header={toucan.title}
toucanId={toucan._id}
isAdmin={props.isAdmin}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment