Skip to content

Commit

Permalink
Remove tabs from events page
Browse files Browse the repository at this point in the history
  • Loading branch information
camilovegag committed Aug 5, 2024
1 parent 5ae4b5c commit 19173ce
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions packages/berlin/src/pages/Events.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// React and third-party libraries
import { useMemo, useState } from 'react';
import { useQuery } from '@tanstack/react-query';

// API
Expand All @@ -11,38 +10,23 @@ import useUser from '../hooks/useUser';
// Components
import { FlexColumn } from '../components/containers/FlexColumn.styled';
import { Title } from '../components/typography/Title.styled';
import * as Tabs from '../components/tabs';
import EventsCards from '../components/events';

function Events() {
const [activeTab, setActiveTab] = useState<string>('upcoming');
const { user } = useUser();
const { data: events } = useQuery({
queryKey: ['events'],
queryFn: () => fetchEvents({ serverUrl: import.meta.env.VITE_SERVER_URL }),
enabled: !!user?.id,
});

const openEvents = useMemo(() => events?.filter((event) => event.status === 'OPEN'), [events]);
const closedEvents = useMemo(
() => events?.filter((events) => events.status === 'CLOSED'),
[events],
);

const tabNames = ['upcoming', 'past'];
const tabs = {
upcoming: <EventsCards events={openEvents} errorMessage="No upcoming events..." />,
past: <EventsCards events={closedEvents} errorMessage="No past events..." />,
};

return (
<FlexColumn $gap="2rem">
<section className="flex w-full flex-col justify-between gap-2 md:flex-row md:items-center">
<Title>Events</Title>
<Tabs.TabsHeader className="tabs" tabNames={tabNames} onTabChange={setActiveTab} />
</section>
<section className="grid w-full gap-4 md:grid-cols-2">
<Tabs.TabsManager tabs={tabs} tab={activeTab} fallback={'Tab not found'} />
<EventsCards events={events} errorMessage="No events found..." />
</section>
</FlexColumn>
);
Expand Down

0 comments on commit 19173ce

Please sign in to comment.