fix index page WSOD on select

This commit is contained in:
b1ek 2023-05-12 19:51:23 +10:00
parent 73c1e7b007
commit db071362cb
Signed by: blek
GPG Key ID: 14546221E3595D0C
2 changed files with 14 additions and 7 deletions

View File

@ -1,7 +1,14 @@
import React from 'react';
import styled from 'styled-components';
import {getPagesArray, getPreviousAndNextPage} from "../../../utils/Pages";
const Pagination = ({totalPages, page, changePage, onChange, viewAll, showAll}) => {
const PageButtonContainer = styled.div`
margin-top: 24px;
display: inline-block;
`;
const Pagination = ({totalPages, page, changePage, onChange, viewAll, showAllEnabled}) => {
let pagesArray = getPagesArray(totalPages);
let [previousPage, nextPage] = getPreviousAndNextPage(totalPages, page);
@ -16,9 +23,9 @@ const Pagination = ({totalPages, page, changePage, onChange, viewAll, showAll})
}
return (
<section className="btnSection">
<PageButtonContainer>
{
showAll ? <button className="allBtn" onClick={viewAll}>Показать весь список</button>
showAllEnabled ? <button className="allBtn" onClick={viewAll}>Показать весь список</button>
: null
}
<div className="choiceBtn">
@ -36,7 +43,7 @@ const Pagination = ({totalPages, page, changePage, onChange, viewAll, showAll})
</svg>
</button>
</div>
</section>
</PageButtonContainer>
);
};

View File

@ -176,7 +176,7 @@ const FiltersForm = (props) => {
address: '',
rooms: { value: -1, label: 'Выберите' },
rooms: apart_sizes[5],
form_err: false
};
@ -260,7 +260,7 @@ const FiltersForm = (props) => {
<SearchBarSpacer />
<Select
onChange={e => setState({rooms: apart_sizes[e.target.value]})}
onChange={e => setState({rooms: apart_sizes[e.target.value] ?? apart_sizes[5]})}
value={state.rooms.value}
>
@ -412,7 +412,7 @@ export default class IndexPage extends React.Component {
totalPages={pages}
page={page}
onChange={(page) => this.setState({ page })}
showAll={false}
showAllEnabled={false}
/>
</IndexPageRoot>
);