Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Icon } from '@iconify/react';
import { type ReactNode, useState } from 'react';
import { type ReactNode, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useSearchParams } from 'react-router-dom';
import { Button, IconButton, InputField, Link, TimeDisplay } from '~/Components';
import { eventQuery } from '~/Components/EventQuery/utils';
import { ImageCard } from '~/Components/ImageCard';
Expand All @@ -22,7 +23,8 @@ type EventsListProps = {
export function EventsList({ events }: EventsListProps) {
const { t, i18n } = useTranslation();
const [tableView, setTableView] = useState(false);
const [query, setQuery] = useState('');
const [searchParam, setSearchParam] = useSearchParams();
const [query, setQuery] = useState(searchParam.get('search') ?? '');
const isDesktop = useDesktop();

const eventColumns = [
Expand Down Expand Up @@ -99,6 +101,18 @@ export function EventsList({ events }: EventsListProps) {
});
}

useEffect(() => {
setSearchParam((prev) => {
const next = new URLSearchParams(prev);
if (query) {
next.set('search', query);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kan du endre parameteren fra search til q?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, gjorde det nå

} else {
next.delete('search');
}
return next;
});
}, [query, setSearchParam]);

Comment thread
0xSpecter marked this conversation as resolved.
function getButton(title: string, icon: string, func: () => void, chosen: boolean) {
return (
<Button rounded={true} onClick={func} theme={chosen ? 'blue' : 'secondary'}>
Expand Down
Loading