Commit f63aff6c authored by Matija Obreza's avatar Matija Obreza
Browse files

Crops SSR and fixes

- Use new Redux state for crops list
- Don't use window.initialLanguage in SSR
parent 50151226
......@@ -25,15 +25,12 @@ const CropCard = ({crop, classes, compact = false, edit = false, ...other}: { cr
return null;
}
// @ts-ignore
const name = window.initialLanguage && crop.i18n && JSON.parse(crop.i18n).name[window.initialLanguage] || crop.name;
return compact ? (
<Grid item xs={ 12 } sm={ 6 } md={ 4 }>
<Card className={ classes.root }>
<CardHeader title={
<Link to={ `/c/${crop.shortName}${edit ? '/edit' : '' }` }>
{ name }
{ crop.name }
</Link>
}/>
<CardContent>
......@@ -47,12 +44,11 @@ const CropCard = ({crop, classes, compact = false, edit = false, ...other}: { cr
<Grid item xs={ 12 }>
<Card className={ classes.root }>
<CardHeader title={
<Link to={ `/c/${crop.shortName}${edit ? '/edit' : '' }` }>{ name }</Link>
<Link to={ `/c/${crop.shortName}${edit ? '/edit' : '' }` }>{ crop.name }</Link>
}/>
<CardContent>
<Properties>
<PropertiesItem title="Original name">{ crop.name }</PropertiesItem>
<PropertiesItem title="Localized name">{ name }</PropertiesItem>
<PropertiesItem title="Registered"><PrettyDate value={ new Date(crop.createdDate) }/></PropertiesItem>
<PropertiesItem title="Last modified"><PrettyDate value={ new Date(crop.lastModifiedDate) }/></PropertiesItem>
</Properties>
......
......@@ -52,7 +52,7 @@ const CropChips = ({crops, availableCrops, classes}: ICropChipsProps) => {
};
const mapStateToProps = (state) => ({
availableCrops: state.crop.crops,
availableCrops: state.crop.public.list,
});
export default connect(mapStateToProps, null)(withStyles(styles)(CropChips));
......@@ -40,5 +40,5 @@ class CropFilter extends React.Component<IProps, any> {
}
export default connect((state) => ({
crops: state.crop.crops,
crops: state.crop.public.list,
}), null)(CropFilter);
......@@ -75,7 +75,7 @@ const CropSelector = ({t, crops, label, single, fields, input}: ICropSelectorPro
const mapStateToProps = (state) => ({
crops: state.crop.crops,
crops: state.crop.public.list,
});
......
Supports Markdown
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