Skip to content

Commit

Permalink
Organize imports, add keys to maps, add end to mapped alerts and upda…
Browse files Browse the repository at this point in the history
…t events link
  • Loading branch information
camilovegag committed Apr 29, 2024
1 parent b17e7d2 commit 2b90732
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions packages/berlin/src/components/header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { useAppStore } from '../../store';
import header from '../../data/header';

// API
import { fetchAlerts, logout } from 'api';
import { fetchAlerts, fetchEvents, fetchUserRegistrations, logout } from 'api';

// Hooks
import useUser from '../../hooks/useUser';
Expand Down Expand Up @@ -38,7 +38,6 @@ import {
LogoTextContainer,
ThemeButton,
} from './Header.styled';
import fetchUserRegistrations from 'api/src/fetchUserRegistrations';

function Header() {
const queryClient = useQueryClient();
Expand Down Expand Up @@ -69,6 +68,12 @@ function Header() {
enabled: !!user,
});

const { data: events } = useQuery({
queryKey: ['events'],
queryFn: () => fetchEvents(),
enabled: !!user,
});

const [isBurgerMenuOpen, setIsBurgerMenuOpen] = useState(false);

return (
Expand Down Expand Up @@ -96,13 +101,18 @@ function Header() {
return (
alert.link &&
alert.title && (
<NavButton to={alert.link} $color="secondary">
<NavButton
key={alert.title + 1}
to={alert.link}
$color="secondary"
end
>
{alert.title}
</NavButton>
)
);
})}
<NavButton to="/events" $color="secondary">
<NavButton to={`/events/${events?.[0].id}/cycles`} $color="secondary">
Agenda
</NavButton>
</>
Expand Down Expand Up @@ -141,13 +151,13 @@ function Header() {
return (
alert.link &&
alert.title && (
<NavButton to={alert.link} $color="secondary">
<NavButton key={alert.title + 1} to={alert.link} $color="secondary">
{alert.title}
</NavButton>
)
);
})}
<NavButton to="/events" $color="secondary">
<NavButton to={`/events/${events?.[0].id}/cycles`} $color="secondary">
Agenda
</NavButton>
</>
Expand Down

0 comments on commit 2b90732

Please sign in to comment.