import React from 'react'; import { Link, Redirect } from 'react-router-dom'; import { parse } from 'query-string'; import Sidebar from './sidebar'; import CONFIG from './fields-config.json'; const MultiEdit = (props) => { if (!props.user){ return } const cat = props.match.params.cat; if (cat === 'like') { // special case for likes return ( Click all the buildings that you like and think contribute to the city! Back to view Back to edit ); } const q = parse(props.location.search); const label = field_title_from_slug(q.k); return ( Click a building to colour Set {label} to {q.v} Back to view Back to edit ); } function field_title_from_slug(slug) { const fields = CONFIG.reduce( (prev, section) => { const el = prev.concat( section.fields.filter( field => field.slug === slug ) ) return el }, [] ) if (fields.length === 1 && fields[0].title) { return fields[0].title } else { console.error('Expected single match, got', fields) } } export default MultiEdit;
Click all the buildings that you like and think contribute to the city!
Click a building to colour
Set {label} to {q.v}