diff --git a/assets/src/components/TermCard.js b/assets/src/components/TermCard.js index f96d6e87..d783abe6 100644 --- a/assets/src/components/TermCard.js +++ b/assets/src/components/TermCard.js @@ -1,347 +1,337 @@ /* This is the Open Access Check Tool (OACT). The publication of scientific articles as Open Access (OA), usually in the variants "Green OA" and "Gold OA", allows free access to scientific research results and their largely unhindered dissemination. Often, however, the multitude of available publication conditions makes the decision in favor of a particular journal difficult: requirements of the funding agencies and publication guidelines of the universities and colleges must be carefully compared with the offers of the publishing houses, and separately concluded publication agreements can also offer additional benefits. The "OA Compliance Check Tool" provides a comprehensive overview of the possible publication conditions for a large number of journals, especially for the Swiss university landscape, and thus supports the decision-making process. © All rights reserved. ECOLE POLYTECHNIQUE FEDERALE DE LAUSANNE, Switzerland, Scientific Information and Libraries, 2022 See LICENSE.TXT for more details. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -import React, {useState, useContext, useEffect} from "react" -import {Context} from "../ContextProvider" -import { makeStyles } from '@mui/styles'; -import "./termcard.css" -import Chip from '@mui/material/Chip'; -import DoneIcon from '@mui/icons-material/Done'; -import HighlightOffIcon from '@mui/icons-material/HighlightOff'; -import Typography from '@mui/material/Typography'; -import DateRangeIcon from '@mui/icons-material/DateRange'; -import { FaCoins, FaRegHandshake, FaUserGraduate } from 'react-icons/fa'; -import { RiFilePaper2Line } from 'react-icons/ri'; -import Button from '@mui/material/Button'; +import React, { useState, useContext, useEffect } from "react"; +import { Context } from "../ContextProvider"; +import { makeStyles } from "@mui/styles"; +import "./termcard.css"; +import Chip from "@mui/material/Chip"; +import DoneIcon from "@mui/icons-material/Done"; +import HighlightOffIcon from "@mui/icons-material/HighlightOff"; +import Typography from "@mui/material/Typography"; +import DateRangeIcon from "@mui/icons-material/DateRange"; +import { FaCoins, FaRegHandshake, FaUserGraduate } from "react-icons/fa"; +import { RiFilePaper2Line } from "react-icons/ri"; +import Button from "@mui/material/Button"; import { HiLink } from "react-icons/hi"; import { GrInfo } from "react-icons/gr"; -import Container from '@mui/material/Container' -import Grid from '@mui/material/Grid' -import Card from '@mui/material/Card'; -import CardActions from '@mui/material/CardActions'; -import CardContent from '@mui/material/CardContent'; -import Tooltip from '@mui/material/Tooltip'; -import { BsNewspaper } from 'react-icons/bs'; -import { FiFlag } from 'react-icons/fi'; -const useStyles = makeStyles((theme) =>({ - +import Container from "@mui/material/Container"; +import Grid from "@mui/material/Grid"; +import Card from "@mui/material/Card"; +import CardActions from "@mui/material/CardActions"; +import CardContent from "@mui/material/CardContent"; +import Tooltip from "@mui/material/Tooltip"; +import { BsNewspaper } from "react-icons/bs"; +import { FiFlag } from "react-icons/fi"; +const useStyles = makeStyles((theme) => ({ card: { - width: '100%', - marginTop: "1rem", - textAlign:'left' - - + width: "100%", + marginTop: "1rem", + textAlign: "left", }, root: { flexGrow: 1, - textAlign:'left', + textAlign: "left", }, chip: { margin: 0.5, - }, - + heading: { fontSize: theme.typography.pxToRem(15), fontWeight: theme.typography.fontWeightRegular, }, - -})) +})); const IDConditionTypeJournal = 3; const IDConditionTypeOrganization = 1; const IDConditionTypeAgreement = 2; -export default function TermCard({term}) { - - const classes = useStyles(); - //call the custom hook to share the state between different level componant - const {url} = useContext(Context) - const [ref, setRef] = useState("") - console.log(ref) +export default function TermCard({ term }) { + const classes = useStyles(); + //call the custom hook to share the state between different level componant + const { url } = useContext(Context); + const [ref, setRef] = useState(""); + console.log(ref); useEffect(() => { // ## Update ref term by creating a specific Reference based on the Condition set ID = C and Term.id = T - setRef( - term.map( j=> ( - j[0] && - `C${j[0]}/T${term[0].id}` - - )) - ) - },[]); // render once - - + setRef(term.map((j) => j[0] && `C${j[0]}/T${term[0].id}`)); + }, []); // render once - function handleClick () { - // ## Create mail template to report a modification, contain the actual Url and the reference Term Card - window.open(`mailto:publishsupport@epfl.ch?subject= OACT Modification request for ${encodeURIComponent(url)} Term Card Reference: ${ref[1]} &body=Request Description:`) + function handleClick() { + // ## Create mail template to report a modification, contain the actual Url and the reference Term Card + window.open( + `mailto:publishsupport@epfl.ch?subject= OACT Modification request for ${encodeURIComponent( + url + )} Term Card Reference: ${ref[1]} &body=Request Description:` + ); } - - - - console.log(`cost factor data: ${term[0].cost_factor[0].cost_factor_type.name}`) - - - const licenceIcon = - - term[0].licence?.map(i=>( - <> - { - (i.website) ? - - - - : - (i.name_or_abbrev != 'UNKNOWN') ? - - : + ) : ( + )} + + )); - } - - )) - - - - const cost = term[0].cost_factor?.map( i => ( - - - <> - { (i.cost_factor_type.name != 'UNKNOWN') ? - - - - : null - } - - - - )) - - const termArchive = term[0].ir_archiving && term[0].ir_archiving ? ( - - - - - ): ( - - ) + + + ) : null} + + )); - const embargo = ( term[0].embargo_months != null ? - - - - : null - ) + const termArchive = + term[0].ir_archiving && term[0].ir_archiving ? ( + + ) : ( + + ); - return ( -
- - - - - {term.map( j=> ( - j[0] && - <> -
{j[2].id === IDConditionTypeJournal && - } - {j[2].id === IDConditionTypeAgreement && - } - {j[2].id === IDConditionTypeOrganization && - } {j[2].condition_issuer} - {j[1] ? -
{j[1]}
: ''}
-

- { j[3] && - - } -

- - )) - } - -
- - - - - - - - - - - - - - - - {/* filter Unknow cost factor type to not display */} - - {cost} - + const embargo = + term[0].embargo_months != null ? ( + + ) : null; - {licenceIcon} - {termArchive} - {embargo} - - - - - -
+ + + - {term[0].comment ? -
- -

- - - {term[0].comment} - -

- - -
- :null} -
-
- {term.map( j=> ( - j[0] && - C{j[0]}/T{term[0].id} - )) - } -
-
-
- - {term[0].source ? - + )} +

+ + ) + )} + + + + + + + + {/* filter Unknow cost factor type to not display */} + + {cost} + + {licenceIcon} + {termArchive} + {embargo} + + + + +
+ {term[0].comment ? ( +
+

+ + + {term[0].comment} + +

+
+ ) : null} +
+
+ {term.map( + (j) => + j[0] && ( + + + C{j[0]}/T{term[0].id} + + + ) + )} +
+
+ + + {term[0].source ? ( + - :null} + + ) : null} - - -
- + + +
- ) + ); } -