Skip to content

Commit

Permalink
fix: change outer <a> to <button> to avoid having <a> inside <a> (#3287)
Browse files Browse the repository at this point in the history
  • Loading branch information
sirtawast authored Sep 6, 2024
1 parent 6a6100d commit d266b86
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
12 changes: 10 additions & 2 deletions frontend/benefit/handler/src/components/header/Header.sc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Link from 'next/link';
import BaseHeader from 'shared/components/header/Header';
import { respondAbovePx } from 'shared/styles/mediaQueries';
import styled from 'styled-components';
Expand Down Expand Up @@ -147,18 +146,27 @@ export const $Box = styled.div<$BoxProps>`
}
`;

export const $ApplicationWithMessages = styled(Link)`
export const $ApplicationWithMessages = styled.button`
text-decoration: none;
color: #222;
display: flex;
align-items: center;
padding: 0.75rem 1rem 0.75rem 1rem;
cursor: pointer;
appearance: none;
line-height: normal;
border: 0;
text-align: left;
width: 100%;
background: transparent;
div {
margin-right: 1rem;
hyphens: auto;
max-width: 130px;
&:hover {
background: ${(props) => props.theme.colors.black10};
}
&:first-child {
width: 90px;
Expand Down
14 changes: 11 additions & 3 deletions frontend/benefit/handler/src/components/header/HeaderNotifier.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { ROUTES } from 'benefit/handler/constants';
import useApplicationMessagesQuery from 'benefit/handler/hooks/useApplicationsWithMessagesQuery';
import { IconAngleRight, IconBell } from 'hds-react';
import { useRouter } from 'next/router';
import { useTranslation } from 'next-i18next';
import * as React from 'react';

Expand All @@ -20,6 +22,13 @@ const Header: React.FC = () => {
setMessageCenterActive(!messageCenterActive);
};

const router = useRouter();

const handleMessageItemClick = (id: string): void => {
setMessageCenterActive(false);
void router.push(`${ROUTES.APPLICATION}?id=${String(id)}&openDrawer=1`);
};

return (
<$HeaderNotifier
$enabled={applicationsWithMessages?.length > 0}
Expand All @@ -35,10 +44,9 @@ const Header: React.FC = () => {
<h2>{t('common:header.messages')}</h2>
<ul>
{applicationsWithMessages.map((application) => (
<li>
<li key={application.id}>
<$ApplicationWithMessages
onClick={() => setMessageCenterActive(false)}
href={`/application?id=${String(application.id)}&openDrawer=1`}
onClick={() => handleMessageItemClick(application.id)}
>
<div>
<strong>Hakemus {application.application_number}</strong>
Expand Down

0 comments on commit d266b86

Please sign in to comment.