Skip to content

Commit 2cd6f32

Browse files
committed
difrensiert aria-label på saksbehandlingstider
1 parent 2bc6523 commit 2cd6f32

File tree

8 files changed

+85
-15
lines changed

8 files changed

+85
-15
lines changed

src/components/_common/expandable/Expandable.tsx

+25-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1-
import React, { useEffect, useId, useRef, useState } from 'react';
1+
import React, { useEffect, useRef, useState } from 'react';
22
import { ExpansionCard } from '@navikt/ds-react';
33
import { BarChartIcon, BriefcaseClockIcon, CalendarIcon, TasklistIcon } from '@navikt/aksel-icons';
44
import { AnalyticsEvents, logAmplitudeEvent } from 'utils/amplitude';
55
import { classNames } from 'utils/classnames';
66
import { smoothScrollToTarget } from 'utils/scroll-to';
77
import { Shortcuts, useShortcuts } from 'utils/useShortcuts';
8+
import {
9+
ProcessingTimesVisibilityType,
10+
ProductDetailType,
11+
} from 'types/content-props/product-details';
12+
import { usePageContentProps } from 'store/pageContext';
13+
import { translator } from 'translations';
814

915
import style from './Expandable.module.scss';
1016

@@ -14,7 +20,8 @@ type Props = {
1420
analyticsOriginTag?: string;
1521
className?: string;
1622
children: React.ReactNode;
17-
expandableType?: 'processing_times' | 'payout_dates' | 'rates' | 'documentation_requirements';
23+
expandableType?: ProductDetailType;
24+
visibilityType?: ProcessingTimesVisibilityType;
1825
};
1926

2027
export const Expandable = ({
@@ -24,10 +31,11 @@ export const Expandable = ({
2431
children,
2532
className,
2633
expandableType,
34+
visibilityType,
2735
}: Props) => {
2836
const [isOpen, setIsOpen] = useState(false);
2937
const accordionRef = useRef<HTMLDivElement | null>(null);
30-
const componentId = useId();
38+
const { language } = usePageContentProps();
3139

3240
useShortcuts({
3341
shortcut: Shortcuts.SEARCH,
@@ -71,16 +79,16 @@ export const Expandable = ({
7179
};
7280

7381
const getHeaderIcon = () => {
74-
if (expandableType === 'processing_times') {
82+
if (expandableType === ProductDetailType.PROCESSING_TIMES) {
7583
return <BriefcaseClockIcon aria-hidden className={style.headerIcon} />;
7684
}
77-
if (expandableType === 'payout_dates') {
85+
if (expandableType === ProductDetailType.PAYOUT_DATES) {
7886
return <CalendarIcon aria-hidden className={style.headerIcon} />;
7987
}
80-
if (expandableType === 'rates') {
88+
if (expandableType === ProductDetailType.RATES) {
8189
return <BarChartIcon aria-hidden className={style.headerIcon} />;
8290
}
83-
if (expandableType === 'documentation_requirements') {
91+
if (expandableType === ProductDetailType.DOC_REQUIREMENTS) {
8492
return <TasklistIcon aria-hidden className={style.headerIcon} />;
8593
}
8694
return null;
@@ -105,6 +113,14 @@ export const Expandable = ({
105113
// This is the wrong use of this component, but some legacy pages have still to
106114
// be upradet editorial wise.
107115
const isLegacyUsage = !expandableType;
116+
const getProductDetailsLabel = translator('productDetailTypes', language);
117+
const getVisibilityLabel = translator('processingTimesVisibilityTypes', language);
118+
const label =
119+
expandableType === ProductDetailType.PROCESSING_TIMES &&
120+
visibilityType &&
121+
`${getProductDetailsLabel(ProductDetailType.PROCESSING_TIMES)} ${getVisibilityLabel(
122+
visibilityType
123+
)}`;
108124

109125
return (
110126
<ExpansionCard
@@ -113,9 +129,9 @@ export const Expandable = ({
113129
ref={accordionRef}
114130
onToggle={toggleExpandCollapse}
115131
open={isOpen}
116-
aria-labelledby={componentId}
132+
aria-label={label || title}
117133
>
118-
<ExpansionCard.Header className={style.header} id={componentId}>
134+
<ExpansionCard.Header className={style.header}>
119135
{getHeaderIcon()}
120136
<div className={style.headerTitle}>{title}</div>
121137
</ExpansionCard.Header>

src/components/_common/expandable/ExpandableComponentWrapper.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const ExpandableComponentWrapper = ({
1212
expandableAnchorId,
1313
analyticsOriginTag = '',
1414
type,
15+
visibilityType,
1516
children,
1617
}: Props) => {
1718
if (!expandable) {
@@ -24,6 +25,7 @@ export const ExpandableComponentWrapper = ({
2425
anchorId={expandableAnchorId}
2526
analyticsOriginTag={analyticsOriginTag}
2627
expandableType={type}
28+
visibilityType={visibilityType}
2729
>
2830
{children}
2931
</Expandable>

src/components/layouts/product-details-layout/ProductDetailsLayout.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ export const ProductDetailsLayout = ({ pageProps, layoutProps }: Props) => {
6363

6464
// The 'main_complaint' section in product details is only applicable
6565
// for product detail types === 'processing_times'
66-
if (name === 'main_complaint' && detailType !== 'processing_times') {
66+
if (
67+
name === 'main_complaint' &&
68+
detailType !== ProductDetailType.PROCESSING_TIMES
69+
) {
6770
return null;
6871
}
6972

src/components/parts/product-details/ProductDetailsPart.tsx

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import React from 'react';
22
import { ComponentMapper } from 'components/ComponentMapper';
33
import { ExpandableComponentWrapper } from 'components/_common/expandable/ExpandableComponentWrapper';
4-
import { ProductDetailType } from 'types/content-props/product-details';
4+
import {
5+
ProcessingTimesVisibilityType,
6+
ProductDetailType,
7+
} from 'types/content-props/product-details';
58
import { FilteredContent } from 'components/_common/filtered-content/FilteredContent';
69
import { EditorHelp } from 'components/_editor-only/editor-help/EditorHelp';
710
import { Language, translator } from 'translations';
@@ -14,6 +17,7 @@ import style from './ProductDetailsPart.module.scss';
1417

1518
export type PartConfigProductDetails = {
1619
detailType: ProductDetailType;
20+
processingTimesVisibility: ProcessingTimesVisibilityType;
1721
// Note: these two fields are defined as a special case on the backend
1822
// and are not included in the Graphql schema
1923
components: ComponentProps[];
@@ -56,12 +60,18 @@ export const ProductDetailsPart = ({ config }: PartComponentProps<PartType.Produ
5660
};
5761

5862
const expandableType = config.detailType as unknown as ExpandableMixin['type'];
63+
const visibilityType =
64+
config.processingTimesVisibility as unknown as ExpandableMixin['visibilityType'];
5965

6066
return (
6167
<div className={style.productDetails}>
6268
<PageContextProvider content={pageContent}>
6369
<FilteredContent {...config}>
64-
<ExpandableComponentWrapper type={expandableType} {...config}>
70+
<ExpandableComponentWrapper
71+
type={expandableType}
72+
visibilityType={visibilityType}
73+
{...config}
74+
>
6575
{components.map((component, index) => (
6676
<ComponentMapper
6777
key={index}

src/translations/default.ts

+13-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ import {
77
ToolsPageTaxonomy,
88
} from 'types/taxonomies';
99
import { Area } from 'types/areas';
10-
import { ProductDetailType } from 'types/content-props/product-details';
10+
import {
11+
ProcessingTimesVisibilityType,
12+
ProductDetailType,
13+
} from 'types/content-props/product-details';
1114

1215
const relatedContent: { [key in MenuListItemKey]: string } = {
1316
[MenuListItemKey.AppealRights]: 'Klagerettigheter',
@@ -69,6 +72,13 @@ const productDetailTypes: { [key in ProductDetailType]: string } = {
6972
[ProductDetailType.PROCESSING_TIMES]: 'saksbehandlingstider',
7073
[ProductDetailType.RATES]: 'satser',
7174
[ProductDetailType.ALL_PRODUCTS]: 'alle',
75+
[ProductDetailType.DOC_REQUIREMENTS]: 'krav til dokumentasjon',
76+
};
77+
78+
const processingTimesVisibilityTypes: { [key in ProcessingTimesVisibilityType]: string } = {
79+
[ProcessingTimesVisibilityType.ALL]: '',
80+
[ProcessingTimesVisibilityType.APPLICATION]: 'søknad',
81+
[ProcessingTimesVisibilityType.COMPLAINT]: 'klage',
7282
};
7383

7484
export const translationsBundleNb = {
@@ -169,7 +179,7 @@ export const translationsBundleNb = {
169179
STOTTEKONTAKT: 'Støttekontakt',
170180
TILRETTELAGT_TRANSPORT: 'Tilrettelagt transport (TT-kort)',
171181
},
172-
relatedContent: relatedContent,
182+
relatedContent,
173183
taxonomies,
174184
areas,
175185
products: {
@@ -328,6 +338,7 @@ export const translationsBundleNb = {
328338
},
329339
},
330340
productDetailTypes,
341+
processingTimesVisibilityTypes,
331342
payoutDates: {
332343
tableHeaderPrefix: 'Utbetalingsdatoer i',
333344
tableHeaderPrefixNoYear: 'Utbetalingsdatoer',

src/translations/en.ts

+16
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import {
66
ToolsPageTaxonomy,
77
} from 'types/taxonomies';
88
import { Area } from 'types/areas';
9+
import {
10+
ProcessingTimesVisibilityType,
11+
ProductDetailType,
12+
} from 'types/content-props/product-details';
913
import { PartialTranslations } from './default';
1014

1115
const taxonomies: {
@@ -300,6 +304,18 @@ export const translationsBundleEn: PartialTranslations = {
300304
months: 'months',
301305
},
302306
},
307+
productDetailTypes: {
308+
[ProductDetailType.PAYOUT_DATES]: 'payment dates',
309+
[ProductDetailType.PROCESSING_TIMES]: 'processing times',
310+
[ProductDetailType.RATES]: 'rates',
311+
[ProductDetailType.ALL_PRODUCTS]: 'all',
312+
[ProductDetailType.DOC_REQUIREMENTS]: 'documentation requirements',
313+
},
314+
processingTimesVisibilityTypes: {
315+
[ProcessingTimesVisibilityType.ALL]: '',
316+
[ProcessingTimesVisibilityType.APPLICATION]: 'application',
317+
[ProcessingTimesVisibilityType.COMPLAINT]: 'complaints',
318+
},
303319
payoutDates: {
304320
tableHeaderPrefix: 'Payment dates in',
305321
tableHeaderPrefixNoYear: 'Payment dates',

src/types/component-props/_mixins.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import { Taxonomy } from 'types/taxonomies';
55
import { AuthStateType } from 'store/slices/authState';
66
import { EmptyObject, OptionSetMulti, OptionSetSingle } from 'types/util-types';
77
import { Area } from 'types/areas';
8+
import {
9+
ProcessingTimesVisibilityType,
10+
ProductDetailType,
11+
} from 'types/content-props/product-details';
812

913
export type HeaderWithAnchorMixin = {
1014
title: string;
@@ -127,7 +131,8 @@ export type ExpandableMixin = {
127131
expandableTitle: string;
128132
expandableAnchorId?: string;
129133
analyticsOriginTag?: string;
130-
type?: 'processing_times' | 'payout_dates' | 'rates' | 'documentation_requirements';
134+
type?: ProductDetailType;
135+
visibilityType?: ProcessingTimesVisibilityType;
131136
};
132137

133138
export type FiltersMixin = {

src/types/content-props/product-details.ts

+7
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,11 @@ export enum ProductDetailType {
33
PAYOUT_DATES = 'payout_dates',
44
PROCESSING_TIMES = 'processing_times',
55
ALL_PRODUCTS = 'all_products',
6+
DOC_REQUIREMENTS = 'documentation_requirements',
7+
}
8+
9+
export enum ProcessingTimesVisibilityType {
10+
ALL = 'all',
11+
APPLICATION = 'application',
12+
COMPLAINT = 'complaint',
613
}

0 commit comments

Comments
 (0)