Skip to main content

Sidebar

Sidebar.

Props

  • onSearch = {function}
  • type = {string}
  • filters = {object[]}
  • query = {object}

Example with code

import { useRouter } from 'next/router';

import { getFilters } from '@pages/api/search';
import Sidebar from '@components/Sidebar';

const MyPage = ({ filters }) => {
const { query } = useRouter();

const onSearch = (fields) => {
console.log('onSearch:', fields);
};

return (
<Sidebar
type={query.type}
query={query}
filters={filters}
onSearch={onSearch}
collapsed={false}
submitOnChange
/>
);
};

export async function getServerSideProps({ req, res, query, locale }) {
const filters = await getFilters(query, { language: locale });

return {
props: {
filters,
},
};
}