Use the first page when missing

This commit is contained in:
Amine Ben hammou
2020-04-06 16:41:32 +02:00
committed by Veljko V
parent b8a6b7db5a
commit 420dd7c539

View File

@@ -13,15 +13,14 @@ type Props = {
export default (props: Props) => { export default (props: Props) => {
const pages = useSelector('getPages')(); const pages = useSelector('getPages')();
const selectedPage = props.value let selectedPage = pages.find((x) => x.id === parseInt(props.value, 10));
? pages.find((x) => x.id === parseInt(props.value, 10)) if (!selectedPage) selectedPage = pages[0];
: pages[0];
return ( return (
<> <>
<select <select
id={props.id} id={props.id}
data-automation-id={props.automationId} data-automation-id={props.automationId}
value={props.value} value={selectedPage.id}
onChange={onChange(props.setValue)} onChange={onChange(props.setValue)}
> >
{pages.map((page) => ( {pages.map((page) => (