Commit c54e37c2 authored by Florian Pagnoux's avatar Florian Pagnoux
Browse files

Add links towards CSV files

parent 3866e779
PRODUCTION=true
BASENAME=/outils/baremes-ipp
CSV_PATH=/wp-content/themes/ipp/baremes
module.exports = {
basename: process.env.BASENAME || '',
isProd: process.env.PRODUCTION
isProd: process.env.PRODUCTION,
csvPath: process.env.CSV_PATH || '',
}
import {withRouter} from 'next/router'
import last from 'lodash.last'
import ParameterTable from "../components/ParameterTable"
import Layout from '../components/Layout'
import {basename} from '../config'
import {basename, csvPath} from '../config'
function getLinkToCsv(parameter, path) {
return `${csvPath || basename}${path}/${last(parameter.id.split('.'))}.csv`
}
const BreadCrum = ({links}) => (
<p><a href={basename + '/'}>Barèmes IPP</a>{links.map(({path, title}, index) => {
......@@ -18,9 +23,11 @@ const BreadCrum = ({links}) => (
const TablePage = (props) => {
const {parameter, parents} = props.router.query
const path = props.router.asPath
return <Layout fullWidth={ true }>
<BreadCrum links={parents}/>
<h1 className="box"><span>{parameter.description}</span></h1>
<a href={getLinkToCsv(parameter, path)}>Download CSV</a>
<ParameterTable parameter={parameter}/>
</Layout>
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment