Commit 27f2c94a authored by Matija Obreza's avatar Matija Obreza
Browse files

Merge branch '68-crops-ssr' into 'master'

Resolve "Crops SSR"

Closes #68

See merge request genesys-pgr/genesys-ui!69
parents 50151226 64002f21
......@@ -25,11 +25,24 @@ app.use((req, res, next) => {
console.log('Incoming request, url:', req.url);
next();
});
// Redirect to `/` if path is `/welcome`
app.get('/welcome', (req, res) => {
const oldPath = req.url;
console.log(`Redirecting ${oldPath} to ${config.frontendPath}/`);
res.redirect(301, `${config.frontendPath}/`);
});
// Redirect to `/` if path is `/{lang}/welcome`
app.get('/*/welcome', (req, res) => {
const oldPath = req.url;
const lang = oldPath.substr(1, 3);
console.log(`Redirecting ${oldPath} to ${config.frontendPath}/${lang}`);
res.redirect(301, `${config.frontendPath}/${lang}`);
});
// Redirect to `/` if path contains `/en`
app.get('/en/*', (req, res) => {
const oldPath = req.url;
const redirectPath = oldPath.substr(3, oldPath.length);
res.redirect(`${config.frontendPath}${redirectPath}`);
res.redirect(301, `${config.frontendPath}${redirectPath}`);
});
// Enable compression
app.use(compression());
......
......@@ -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