Commit 863649c8 authored by Oleksii Savran's avatar Oleksii Savran Committed by Matija Obreza

Missing flags

parent 46f9bfa3
......@@ -311,6 +311,12 @@ module.exports = {
new ReactLoadable.ReactLoadablePlugin({
filename: 'react-loadable.json',
}),
new webpack.DefinePlugin({
'ISO3_FLAGS': JSON.stringify(fs.readdirSync(path.join(process.cwd(), 'assets/images/flags')).map((s) => {
return s.slice(0, -4);
}))
}),
],
optimization: {
......
......@@ -12,6 +12,7 @@ import {User} from 'model/user/User';
import GeoRegion from 'model/geo/GeoRegion';
import Article from 'model/cms/Article';
import OAuthClient from 'model/oauth/OAuthClient';
import { flagAssetExists } from 'utilities/iso3Flags';
const SubsetLink = ({to: subset, uuid = null, edit = false, children = null}: { to?: Subset, uuid?: string, edit?: boolean, children?: any }) => {
......@@ -122,10 +123,13 @@ const CountryLink = ({ country, noflag, children }: { country: Country | string,
name = country.name;
code = country.code3;
}
return (
<Link to={ `/iso3166/${code}` }>
<span style={ {display: 'inline-block'} }>
{ !noflag && <img src={ `images/flags/${code}.png` } style={ { maxWidth: '1.25rem', padding: '0 0.25rem', verticalAlign: 'bottom' } } /> }
{ !noflag && flagAssetExists(code) && (
<img src={ `images/flags/${code}.png` } style={ { maxWidth: '1.25rem', padding: '0 0.25rem', verticalAlign: 'bottom' } } />
) }
{ children || name }
</span>
</Link>
......
declare let ISO3_FLAGS: Array<string>;
if (typeof window !== 'undefined') {
export const flagAssetExists = (iso3) => {
return ISO3_FLAGS && ISO3_FLAGS.some((code) => code === iso3);
} else {
return true;
}
};
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