Use the first page when missing
This commit is contained in:
committed by
Veljko V
parent
b8a6b7db5a
commit
420dd7c539
@@ -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) => (
|
||||||
|
Reference in New Issue
Block a user