This repository has been archived on 2024-12-07. You can view files and clone it, but cannot push or open issues or pull requests.
Cinemateket/src/util/navigate.ts

21 lines
377 B
TypeScript
Raw Normal View History

import { useNavigate } from 'react-router'
const navigate = useNavigate()
export const navigateToPage = (
title?: string,
page: string = '1',
type?: string,
year?: string
) => {
if (!title) navigate('')
else {
let query = `?title=${title}&page=${page}`
if (type) query += `&type=${type}`
if (year) query += `&year=${year}`
navigate(query)
}
}