import { parse } from 'query-string'; import React from 'react'; import { Link, Redirect, RouteComponentProps } from 'react-router-dom'; import { BackIcon } from '../components/icons'; import InfoBox from '../components/info-box'; import { dataFields } from '../data_fields'; import { User } from '../models/user'; import DataEntry from './data-components/data-entry'; import Sidebar from './sidebar'; interface MultiEditRouteParams { cat: string; } interface MultiEditProps extends RouteComponentProps { user?: User; } const MultiEdit: React.FC = (props) => { if (!props.user){ return } const cat = props.match.params.cat; if (cat === 'like') { // special case for likes return (

Like me!

Back to view Back to edit
); } const q = parse(props.location.search); let data: object; if (cat === 'like'){ data = { like: true } } else { try { // TODO: verify what happens if data is string[] data = JSON.parse(q.data as string); } catch (error) { console.error(error, q) data = {} } } return (

Copy {cat} data

{ Object.keys(data).map((key => { const info = dataFields[key] || {}; return ( ) })) }
Back to view Back to edit
); } export default MultiEdit;