Skip to content

Commit

Permalink
chore(project): review fixes for dev utility
Browse files Browse the repository at this point in the history
  • Loading branch information
“Anton committed Jul 13, 2022
1 parent 94a68f7 commit 7a607c2
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ exports[`<ConfigSelect> > renders and matches snapshot 1`] = `
class="dropdown"
>
<select
aria-label="select_config"
aria-required="false"
class="select"
id="1235"
Expand Down
20 changes: 11 additions & 9 deletions src/components/ConfigSelect/index.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
import { useTranslation } from 'react-i18next';

import Dropdown from '../Dropdown/Dropdown';

import styles from './ConfigSelect.module.scss';

import { getStoredConfig, setStoredConfig } from '#src/utils/configOverride';
import { logDev } from '#src/utils/common';

const configs = import.meta.glob('../../../test-e2e/data/*.json');

const configOptions = Object.entries(configs).reduce<string[]>((acc, [pth]) => {
const parts = pth.split('/');
const fileName = parts.pop();
const configName = fileName?.split('.')[1] as string;
let configName = '';

try {
const parts = pth.split('/');
const fileName = parts.pop();
configName = fileName?.split('.')[1] as string;
} catch (err: unknown) {
logDev('Config file could not be processed: ' + err);
}

return [...acc, configName];
return configName ? [...acc, configName] : acc;
}, []);

const ConfigSelect = () => {
const { t } = useTranslation('common');

const selectedConfig = getStoredConfig() || '';

const onChange = (event: React.ChangeEvent<HTMLSelectElement>) => {
Expand All @@ -35,7 +38,6 @@ const ConfigSelect = () => {
name="config-select"
value={selectedConfig}
onChange={onChange}
aria-label={t('select_config')}
/>
);
};
Expand Down
3 changes: 1 addition & 2 deletions src/i18n/locales/en_US/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@
"sign_up": "Sign up",
"slide_left": "Slide left",
"slide_right": "Slide right",
"default_site_name": "My OTT Application",
"select_config": "Select config"
"default_site_name": "My OTT Application"
}
3 changes: 1 addition & 2 deletions src/i18n/locales/nl_NL/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@
"sign_up": "",
"slide_left": "",
"slide_right": "",
"default_site_name": "",
"select_config": ""
"default_site_name": ""
}

0 comments on commit 7a607c2

Please sign in to comment.