@bytebrand/fe-ui-core-autobahn 1.0.179 → 1.0.181

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/vdp/types.ts CHANGED
@@ -111,8 +111,8 @@ export interface Co2CostsSummary {
111
111
  export interface VehicleCondition {
112
112
  /** TÜV/HU validity, e.g. '03/2027' — or 'Neu' for a new HU. */
113
113
  hu: string;
114
- /** accident-free flag (Unfallfrei); null = not specified by the source ("keine Angabe"). */
115
- unfallfrei: boolean | null;
114
+ /** accident-free flag (Unfallfrei). */
115
+ unfallfrei: boolean;
116
116
  /** full service history (Scheckheftgepflegt). */
117
117
  scheckheft: boolean;
118
118
  /** warranty label, e.g. '12 Monate inkl.'. */
@@ -191,8 +191,8 @@ export interface VehicleDetail {
191
191
  fuel: string;
192
192
  /** gearbox label, e.g. 'Automatik' / 'Schaltgetriebe'. */
193
193
  gear: string;
194
- /** number of previous owners (rendered as 'N. Hand'); null = not known, the fact is not shown. */
195
- owners: number | null;
194
+ /** number of previous owners (rendered as 'N. Hand'). */
195
+ owners: number;
196
196
  /** number of seats. */
197
197
  seats: number;
198
198
  /** number of doors. */
@@ -302,7 +302,7 @@ export function defaultVdpSpecs(v: VehicleDetail): VdpSpec[] {
302
302
  [['cog', 'Getriebe', v.gear], true],
303
303
  [['users', 'Sitze', `${v.seats} Sitze`], false],
304
304
  [['door-open', 'Türen', `${v.doors} Türen`], false],
305
- ...(v.owners == null ? [] : [[['user', 'Halter', `${v.owners}. Hand`], true] as const]), // 0 Vorbesitzer is valid
305
+ [['user', 'Halter', `${v.owners}. Hand`], true], // 0 Vorbesitzer is valid
306
306
  [['palette', 'Außenfarbe', v.color], true],
307
307
  [['car-front', 'Karosserie', v.body], true],
308
308
  [['droplet', 'Verbrauch komb.', v.cons], true], // Pkw-EnVKV — exempt from this rule
@@ -6,7 +6,6 @@ import { formatTimestamp } from '../utils/DateUtils';
6
6
  import { DELIVERY_PERIODS_EXTRA } from '../constants/core';
7
7
  import moment from 'moment';
8
8
  import { IDecoratedProp } from '../types/types';
9
- import { strictAccidentStatus } from './accidentDisclosure';
10
9
  import { gasConsumptionTemplate } from './cbdSelectors';
11
10
 
12
11
  interface IDecoratedProps {
@@ -521,9 +520,6 @@ const getDecoratedLightProps = (
521
520
  title: t('cbd:mainData_accidentDamaged'),
522
521
  icon: 'wrench',
523
522
  get value() {
524
- const strict = strictAccidentStatus(car);
525
- if (strict === 'notSpecified') return t('vehicleProps:value.na');
526
- if (strict) return strict === 'accident' ? t('vehicleProps:value.damaged') : t('vehicleProps:value.accidentFree');
527
523
  return damaged ? t('vehicleProps:value.damaged') : t('vehicleProps:value.accidentFree');
528
524
  }
529
525
  },
@@ -9,7 +9,6 @@ import { EMISSION_STICKERS_ICONS, WP_EMISSION_STICKERS_ICONS } from '../constant
9
9
  import { DELIVERY_PERIODS_EXTRA } from '../constants';
10
10
  import { IDecoratedProp, ICar, IFinancingUtils } from '../types/types';
11
11
  import { getFormattedPrice } from '../utils/CommonUtils';
12
- import { strictAccidentStatus } from './accidentDisclosure';
13
12
  import { gasConsumptionTemplate } from './cbdSelectors';
14
13
 
15
14
  const formatDeliveryPeriod = (t: (key: string, options?: object) => string, deliveryPeriod: string) => {
@@ -197,9 +196,6 @@ const getDecoratedProps = (
197
196
  title: t('cbd:mainData_accidentDamaged'),
198
197
  icon: 'wrench',
199
198
  get value() {
200
- const strict = strictAccidentStatus(car);
201
- if (strict === 'notSpecified') return t('vehicleProps:value.na');
202
- if (strict) return strict === 'accident' ? t('vehicleProps:value.damaged') : t('vehicleProps:value.accidentFree');
203
199
  return damaged ? t('vehicleProps:value.damaged') : t('vehicleProps:value.accidentFree');
204
200
  }
205
201
  },
@@ -1,109 +0,0 @@
1
- import React from 'react';
2
-
3
- export type AccountMenuIconName =
4
- | 'layout-grid' | 'car-front' | 'bookmark' | 'star' | 'scale' | 'user' | 'help-circle' | 'log-out'
5
- | 'settings' | 'store';
6
- type FilledIconName = 'settings' | 'store';
7
-
8
- /**
9
- * Row icons of the Konto menu (Figma "Konto / Kontomenü", 64243:14111): Lucide-style glyphs in a
10
- * 22px frame with a 1.8px stroke, but with Figma's own geometry — e.g. its bookmark is narrower and
11
- * square-cornered, unlike lucide-react 0.288's — so the paths are Figma's export, not the lib Icon.
12
- * `at` moves each export to where Figma places it in the frame: the group inset minus half the stroke.
13
- */
14
- const GLYPHS: Record<Exclude<AccountMenuIconName, FilledIconName>, { at: [number, number]; d: string[] }> = {
15
- 'layout-grid': {
16
- at: [1.85, 1.85],
17
- d: [
18
- 'M1.81667 0.9H6.4C6.90626 0.9 7.31667 1.31041 7.31667 1.81667V6.4C7.31667 6.90626 6.90626 7.31667 6.4 7.31667H1.81667C1.31041 7.31667 0.9 6.90626 0.9 6.4V1.81667C0.9 1.31041 1.31041 0.9 1.81667 0.9Z',
19
- 'M11.9 0.9H16.4833C16.9896 0.9 17.4 1.31041 17.4 1.81667V6.4C17.4 6.90626 16.9896 7.31667 16.4833 7.31667H11.9C11.3937 7.31667 10.9833 6.90626 10.9833 6.4V1.81667C10.9833 1.31041 11.3937 0.9 11.9 0.9Z',
20
- 'M1.81667 10.9833H6.4C6.90626 10.9833 7.31667 11.3937 7.31667 11.9V16.4833C7.31667 16.9896 6.90626 17.4 6.4 17.4H1.81667C1.31041 17.4 0.9 16.9896 0.9 16.4833V11.9C0.9 11.3937 1.31041 10.9833 1.81667 10.9833Z',
21
- 'M11.9 10.9833H16.4833C16.9896 10.9833 17.4 11.3937 17.4 11.9V16.4833C17.4 16.9896 16.9896 17.4 16.4833 17.4H11.9C11.3937 17.4 10.9833 16.9896 10.9833 16.4833V11.9C10.9833 11.3937 11.3937 10.9833 11.9 10.9833Z',
22
- ],
23
- },
24
- 'car-front': {
25
- at: [1.85, 3.68333],
26
- d: [
27
- 'M2.73333 6.4L4.10833 2.275C4.20846 1.88695 4.43297 1.5424 4.74752 1.29408C5.06206 1.04575 5.44931 0.907329 5.85 0.9H12.45C12.8507 0.907329 13.2379 1.04575 13.5525 1.29408C13.867 1.5424 14.0915 1.88695 14.1917 2.275L15.5667 6.4',
28
- 'M2.73333 6.4H15.5667C16.5792 6.4 17.4 7.22081 17.4 8.23333V10.9833C17.4 11.9959 16.5792 12.8167 15.5667 12.8167H2.73333C1.72081 12.8167 0.9 11.9959 0.9 10.9833V8.23333C0.9 7.22081 1.72081 6.4 2.73333 6.4Z',
29
- 'M4.56667 12.8167V14.65M13.7333 12.8167V14.65',
30
- ],
31
- },
32
- bookmark: {
33
- at: [4.6, 1.85],
34
- d: ['M0.9 0.9H11.9V17.4L6.4 13.275L0.9 17.4V0.9Z'],
35
- },
36
- star: {
37
- at: [2.03333, 1.85],
38
- d: ['M8.96669 0.9L11.4417 6.03333L17.0334 6.85833L13 10.8L13.9167 16.3917L8.96669 13.7333L4.01669 16.3917L4.93336 10.8L0.900026 6.85833L6.49169 6.03333L8.96669 0.9Z'],
39
- },
40
- scale: {
41
- at: [1.85, 1.85],
42
- d: [
43
- 'M9.15 0.9V4.56667M9.15 4.56667V17.4M9.15 4.56667H3.65M9.15 4.56667H14.65',
44
- 'M3.65 4.56667L0.900003 10.9833H6.4L3.65 4.56667ZM14.65 4.56667L11.9 10.9833H17.4L14.65 4.56667Z',
45
- ],
46
- },
47
- user: {
48
- at: [2.76667, 2.76667],
49
- d: [
50
- 'M11.9 4.56667C11.9 6.59171 10.2584 8.23333 8.23333 8.23333C6.20829 8.23333 4.56667 6.59171 4.56667 4.56667C4.56667 2.54162 6.20829 0.9 8.23333 0.9C10.2584 0.9 11.9 2.54162 11.9 4.56667Z',
51
- 'M0.9 16.4833C0.9 12.8167 4.2 10.9833 8.23333 10.9833C12.2667 10.9833 15.5667 12.8167 15.5667 16.4833',
52
- ],
53
- },
54
- 'help-circle': {
55
- at: [1.85, 1.85],
56
- d: [
57
- 'M17.4 9.15C17.4 13.7063 13.7063 17.4 9.15 17.4C4.59365 17.4 0.9 13.7063 0.9 9.15C0.9 4.59365 4.59365 0.9 9.15 0.9C13.7063 0.9 17.4 4.59365 17.4 9.15Z',
58
- 'M6.85833 6.85833C6.84973 6.4229 6.96538 5.99402 7.19175 5.62195C7.41811 5.24988 7.74582 4.95001 8.13647 4.75748C8.52713 4.56495 8.96456 4.48772 9.39752 4.53485C9.83049 4.58197 10.2411 4.7515 10.5811 5.02357C10.9212 5.29564 11.1767 5.65898 11.3178 6.07104C11.4588 6.4831 11.4795 6.92681 11.3774 7.3502C11.2753 7.77359 11.0547 8.15913 10.7414 8.46165C10.4281 8.76417 10.035 8.97114 9.60833 9.05833V10.25',
59
- 'M9.15 13.7333H9.16',
60
- ],
61
- },
62
- 'log-out': {
63
- at: [1.85, 1.85],
64
- d: [
65
- 'M6.4 17.4H2.73333C2.2471 17.4 1.78079 17.2068 1.43697 16.863C1.09315 16.5192 0.9 16.0529 0.9 15.5667V2.73333C0.9 2.2471 1.09315 1.78079 1.43697 1.43697C1.78079 1.09315 2.2471 0.9 2.73333 0.9H6.4',
66
- 'M12.8167 4.56667L17.4 9.15L12.8167 13.7333M17.4 9.15H6.4',
67
- ],
68
- },
69
- };
70
-
71
- /** Filled Material glyphs supplied for the role rows (2026-10-28): "settings" (Bildeinstellungen)
72
- * and "store" (the dealer rows). Unlike the stroked Figma glyphs they are filled 24-unit glyphs;
73
- * viewBox 1 1 22 22 only trims their empty margin, so they keep their own size in the 22px frame.
74
- * Their masks were full 24px rects (no-ops), so dropped. */
75
- const FILLED: Record<FilledIconName, string> = {
76
- settings: 'M13.5 21.5H10.475C10.2583 21.5 10.0667 21.425 9.9 21.275C9.73334 21.125 9.63334 20.9333 9.6 20.7L9.3 18.45C9.03334 18.3667 8.76267 18.2417 8.488 18.075C8.21267 17.9083 7.95834 17.7333 7.725 17.55L5.65 18.45C5.43334 18.5333 5.221 18.5417 5.013 18.475C4.80434 18.4083 4.63334 18.275 4.5 18.075L3 15.45C2.88334 15.25 2.85 15.0373 2.9 14.812C2.95 14.5873 3.05834 14.4083 3.225 14.275L5.05 12.9C5.01667 12.75 4.996 12.6 4.988 12.45C4.97934 12.3 4.975 12.15 4.975 12C4.975 11.8667 4.97934 11.725 4.988 11.575C4.996 11.425 5.01667 11.2667 5.05 11.1L3.225 9.725C3.05834 9.59167 2.95 9.41267 2.9 9.188C2.85 8.96267 2.88334 8.75 3 8.55L4.5 5.95C4.61667 5.75 4.78334 5.61667 5 5.55C5.21667 5.48333 5.425 5.49167 5.625 5.575L7.725 6.45C7.95834 6.26667 8.21267 6.096 8.488 5.938C8.76267 5.77933 9.03334 5.65 9.3 5.55L9.6 3.3C9.63334 3.06667 9.73334 2.875 9.9 2.725C10.0667 2.575 10.2583 2.5 10.475 2.5H13.5C13.7333 2.5 13.9333 2.575 14.1 2.725C14.2667 2.875 14.3667 3.06667 14.4 3.3L14.7 5.55C15 5.66667 15.2707 5.79567 15.512 5.937C15.754 6.079 16 6.25 16.25 6.45L18.375 5.575C18.575 5.49167 18.7793 5.48333 18.988 5.55C19.196 5.61667 19.3667 5.75 19.5 5.95L21 8.55C21.1167 8.75 21.15 8.96267 21.1 9.188C21.05 9.41267 20.9417 9.59167 20.775 9.725L18.925 11.125C18.9583 11.2917 18.975 11.4417 18.975 11.575V12C18.975 12.1333 18.9707 12.2707 18.962 12.412C18.954 12.554 18.9333 12.7167 18.9 12.9L20.725 14.275C20.9083 14.4083 21.025 14.5873 21.075 14.812C21.125 15.0373 21.0833 15.25 20.95 15.45L19.45 18.05C19.3333 18.25 19.1667 18.3833 18.95 18.45C18.7333 18.5167 18.5167 18.5083 18.3 18.425L16.25 17.55C16 17.75 15.746 17.925 15.488 18.075C15.2293 18.225 14.9667 18.35 14.7 18.45L14.4 20.7C14.3667 20.9333 14.2667 21.125 14.1 21.275C13.9333 21.425 13.7333 21.5 13.5 21.5ZM12 15C12.8333 15 13.5417 14.7083 14.125 14.125C14.7083 13.5417 15 12.8333 15 12C15 11.1667 14.7083 10.4583 14.125 9.875C13.5417 9.29167 12.8333 9 12 9C11.1667 9 10.4583 9.29167 9.875 9.875C9.29167 10.4583 9 11.1667 9 12C9 12.8333 9.29167 13.5417 9.875 14.125C10.4583 14.7083 11.1667 15 12 15ZM12 13.5C11.5833 13.5 11.2293 13.354 10.938 13.062C10.646 12.7707 10.5 12.4167 10.5 12C10.5 11.5833 10.646 11.2293 10.938 10.938C11.2293 10.646 11.5833 10.5 12 10.5C12.4167 10.5 12.7707 10.646 13.062 10.938C13.354 11.2293 13.5 11.5833 13.5 12C13.5 12.4167 13.354 12.7707 13.062 13.062C12.7707 13.354 12.4167 13.5 12 13.5ZM11 20H12.975L13.325 17.325C13.8417 17.1917 14.3083 17 14.725 16.75C15.1417 16.5 15.55 16.1833 15.95 15.8L18.425 16.85L19.425 15.15L17.25 13.525C17.3333 13.2583 17.3877 13 17.413 12.75C17.4377 12.5 17.45 12.25 17.45 12C17.45 11.7333 17.4377 11.4793 17.413 11.238C17.3877 10.996 17.3333 10.75 17.25 10.5L19.425 8.85L18.45 7.15L15.925 8.2C15.5917 7.85 15.1917 7.53733 14.725 7.262C14.2583 6.98733 13.7917 6.79167 13.325 6.675L13 4H11.025L10.675 6.675C10.175 6.79167 9.70834 6.975 9.275 7.225C8.84167 7.475 8.425 7.79167 8.025 8.175L5.55 7.15L4.575 8.85L6.725 10.45C6.64167 10.7 6.58334 10.95 6.55 11.2C6.51667 11.45 6.5 11.7167 6.5 12C6.5 12.2667 6.51667 12.525 6.55 12.775C6.58334 13.025 6.64167 13.275 6.725 13.525L4.575 15.15L5.55 16.85L8.025 15.8C8.40834 16.1833 8.81667 16.5 9.25 16.75C9.68334 17 10.1583 17.1917 10.675 17.325L11 20Z',
77
- store: 'M5 6C4.71666 6 4.479 5.90433 4.287 5.713C4.09566 5.521 4 5.28333 4 5C4 4.71667 4.09566 4.479 4.287 4.287C4.479 4.09567 4.71666 4 5 4H19C19.2833 4 19.5207 4.09567 19.712 4.287C19.904 4.479 20 4.71667 20 5C20 5.28333 19.904 5.521 19.712 5.713C19.5207 5.90433 19.2833 6 19 6H5ZM5 20C4.71666 20 4.479 19.904 4.287 19.712C4.09566 19.5207 4 19.2833 4 19V14H3.825C3.50833 14 3.25 13.879 3.05 13.637C2.85 13.3957 2.78333 13.1167 2.85 12.8L3.85 7.8C3.9 7.56667 4.01666 7.375 4.2 7.225C4.38333 7.075 4.59166 7 4.825 7H19.175C19.4083 7 19.6167 7.075 19.8 7.225C19.9833 7.375 20.1 7.56667 20.15 7.8L21.15 12.8C21.2167 13.1167 21.15 13.3957 20.95 13.637C20.75 13.879 20.4917 14 20.175 14H20V19C20 19.2833 19.904 19.5207 19.712 19.712C19.5207 19.904 19.2833 20 19 20C18.7167 20 18.4793 19.904 18.288 19.712C18.096 19.5207 18 19.2833 18 19V14H14V19C14 19.2833 13.9043 19.5207 13.713 19.712C13.521 19.904 13.2833 20 13 20H5ZM6 18H12V14H6V18ZM5.05 12H18.95L18.35 9H5.65L5.05 12Z',
78
- };
79
-
80
- const AccountMenuIcon: React.FunctionComponent<{ name: AccountMenuIconName }> = ({ name }) => {
81
- if (name === 'settings' || name === 'store') {
82
- return (
83
- <svg className="acct-icon" width="22" height="22" viewBox="1 1 22 22" fill="currentColor" aria-hidden="true">
84
- <path d={FILLED[name]} />
85
- </svg>
86
- );
87
- }
88
- const { at, d } = GLYPHS[name];
89
- return (
90
- <svg
91
- className="acct-icon"
92
- width="22"
93
- height="22"
94
- viewBox="0 0 22 22"
95
- fill="none"
96
- stroke="currentColor"
97
- strokeWidth="1.8"
98
- strokeLinecap="round"
99
- strokeLinejoin="round"
100
- aria-hidden="true"
101
- >
102
- <g transform={`translate(${at[0]} ${at[1]})`}>
103
- {d.map((path) => <path key={path} d={path} />)}
104
- </g>
105
- </svg>
106
- );
107
- };
108
-
109
- export default AccountMenuIcon;
@@ -1,13 +0,0 @@
1
- import * as React from 'react';
2
-
3
- // Figma-exact valid-field checkmark (.mfield-ok, FormField/MdField's showValid) — a distinct
4
- // path/stroke from the generic lucide Check that Icon name="check" renders elsewhere, so it's
5
- // its own tiny component rather than a REGISTRY entry in Icon.tsx (which would change every
6
- // other "check" usage in the app too).
7
- const MfieldCheckIcon: React.FunctionComponent = () => (
8
- <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
9
- <path d="M13.3334 4L6.00002 11.3333L2.66669 8" stroke="#168A45" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round" />
10
- </svg>
11
- );
12
-
13
- export default MfieldCheckIcon;
@@ -1,41 +0,0 @@
1
- // Autobahn (auto.de redesign) — shared "scroll a just-opened/just-focused field to the top of the
2
- // page" behaviour, used by Dropdown.tsx and by fe-main's DualRange/RateSlider (FilterContent.tsx)
3
- // text fields on /search/detailed. On mobile, opening a dropdown's menu or focusing a text field
4
- // brings the on-screen keyboard up and/or needs room for a popover below the field — if the field
5
- // is sitting mid-page, there may not be enough space left below it once the keyboard/menu takes
6
- // its share. Scrolling the field to the very top of the page first maximizes what's available.
7
- //
8
- // Extracted out of Dropdown.tsx so it can be shared verbatim with fe-main's non-Dropdown form
9
- // fields (DualRange/RateSlider's text inputs) — same problem, same fix, one place to keep them
10
- // from drifting apart. See Dropdown.tsx's own call site for the original reasoning this was
11
- // pulled from.
12
- export function scrollFieldIntoView(field: HTMLElement): void {
13
- if (typeof window === 'undefined') return;
14
- // Mobile-only: the on-screen-keyboard/popover space problem this fixes doesn't exist on
15
- // desktop, where there's no keyboard pushing the viewport around. Same breakpoint + matchMedia
16
- // pattern as Modal.tsx/CardCarousel.tsx elsewhere in this lib.
17
- if (window.matchMedia('(min-width: 601px)').matches) return;
18
- // Anchor on whichever is higher up: the field itself, or a short field label/caption sitting
19
- // directly above it (own previous sibling, or — the common "label above a row of controls"
20
- // shape, e.g. "Marke & Modell" above the Make/Model row on /search/detailed — the wrapping
21
- // row's previous sibling). Checked by height, not by class name, so this works for ANY
22
- // caller's label without this needing to know that call site's specific markup.
23
- const MAX_LABEL_HEIGHT = 30;
24
- const asLabel = (el: Element | null): HTMLElement | null => {
25
- if (!(el instanceof HTMLElement)) return null;
26
- const h = el.getBoundingClientRect().height;
27
- return h > 0 && h <= MAX_LABEL_HEIGHT ? el : null;
28
- };
29
- const anchor =
30
- asLabel(field.previousElementSibling) ||
31
- asLabel(field.parentElement && field.parentElement.previousElementSibling) ||
32
- field;
33
- // No sticky-header reservation here: every current caller (NewMainPage '/', FilterContent on
34
- // '/search*') sits on a page where TopBar's own autoHideOnScroll is on (App.tsx: isHomePage ||
35
- // isSearchPage) — the header slides itself out of the way the instant this scroll starts,
36
- // independently of this call, so reserving space for it here would double-count.
37
- const GAP = 8;
38
- const rect = anchor.getBoundingClientRect();
39
- const targetY = window.scrollY + rect.top - GAP;
40
- window.scrollTo({ top: Math.max(0, targetY), behavior: 'smooth' });
41
- }
@@ -1,84 +0,0 @@
1
- // ADV-268 — the cookie consent store (`localStorage['cookieConfig']`: per category the DISABLED
2
- // vendor-cookie names, see COOKIE_SCHEMA) plus what the account page needs on top of it:
3
- // - when the choice last changed (`cookieConfigChangedAt`, ISO), written on every save that
4
- // changes it — the consent dialogs save through saveCookieConfig;
5
- // - a window event after each save, so a page showing the state can update live;
6
- // - openCookieSettings(), which makes the mounted CookieModal show its settings dialog again.
7
- // Storage access is guarded: with site storage blocked every read returns "no choice yet".
8
-
9
- import { COOKIE_SCHEMA } from '../constants/common';
10
-
11
- export const COOKIE_CONFIG_KEY = 'cookieConfig';
12
- export const COOKIE_CONFIG_CHANGED_AT_KEY = 'cookieConfigChangedAt';
13
- export const COOKIE_CONSENT_CHANGE_EVENT = 'autode:cookie-consent-change';
14
- export const OPEN_COOKIE_SETTINGS_EVENT = 'autode:open-cookie-settings';
15
-
16
- export interface ICookieConfig {
17
- marketing: string[];
18
- analytics: string[];
19
- }
20
-
21
- export type CookieCategoryState = 'on' | 'partial' | 'off';
22
-
23
- export interface ICookieConsentState {
24
- /** false until the visitor saved a choice in the cookie dialog */
25
- decided: boolean;
26
- /** ISO date of the last change, null when unknown (no choice yet, or saved before it was recorded) */
27
- changedAt: string | null;
28
- analytics: CookieCategoryState;
29
- marketing: CookieCategoryState;
30
- }
31
-
32
- const vendorCookies = (category: 'analytics' | 'marketing'): string[] =>
33
- Object.values(COOKIE_SCHEMA[category]).reduce((acc: string[], val: string[]) => acc.concat(val), []);
34
-
35
- const readStorage = (key: string): string | null => {
36
- try {
37
- return localStorage.getItem(key);
38
- } catch (e) {
39
- return null;
40
- }
41
- };
42
-
43
- export const saveCookieConfig = (config: ICookieConfig | Record<string, string[]>) => {
44
- const next = JSON.stringify(config);
45
- try {
46
- const previous = localStorage.getItem(COOKIE_CONFIG_KEY);
47
- localStorage.setItem(COOKIE_CONFIG_KEY, next);
48
- if (previous !== next || !localStorage.getItem(COOKIE_CONFIG_CHANGED_AT_KEY)) {
49
- localStorage.setItem(COOKIE_CONFIG_CHANGED_AT_KEY, new Date().toISOString());
50
- }
51
- } catch (e) {
52
- return;
53
- }
54
- window.dispatchEvent(new Event(COOKIE_CONSENT_CHANGE_EVENT));
55
- };
56
-
57
- export const getCookieConsentState = (): ICookieConsentState => {
58
- let config: Partial<ICookieConfig> | null = null;
59
- try {
60
- config = JSON.parse(readStorage(COOKIE_CONFIG_KEY));
61
- } catch (e) {
62
- config = null;
63
- }
64
- if (!config) return { decided: false, changedAt: null, analytics: 'off', marketing: 'off' };
65
-
66
- const categoryState = (category: 'analytics' | 'marketing'): CookieCategoryState => {
67
- const disabled = Array.isArray(config[category]) ? config[category] : [];
68
- const all = vendorCookies(category);
69
- const allowed = all.filter((cookie) => !disabled.includes(cookie)).length;
70
- if (allowed === all.length) return 'on';
71
- return allowed ? 'partial' : 'off';
72
- };
73
-
74
- return {
75
- decided: true,
76
- changedAt: readStorage(COOKIE_CONFIG_CHANGED_AT_KEY),
77
- analytics: categoryState('analytics'),
78
- marketing: categoryState('marketing')
79
- };
80
- };
81
-
82
- export const openCookieSettings = () => {
83
- window.dispatchEvent(new Event(OPEN_COOKIE_SETTINGS_EVENT));
84
- };
@@ -1,25 +0,0 @@
1
- // FINN handover v0.6 (Daniel, 15.10.2026): for the owners set here, accident and owner facts follow
2
- // only what the source states — mainData.accidentDamaged false → accident-free, true → accident,
3
- // empty → not specified; an empty owner count is not shown as "0. Hand". Every other dealer keeps
4
- // the old display (accident-free unless `damaged`). The app sets the owners once at start.
5
- let strictOwners: ReadonlyArray<string> = [];
6
-
7
- export function setStrictConditionOwners(ownerIds: ReadonlyArray<string>): void {
8
- strictOwners = (ownerIds || []).filter(Boolean);
9
- }
10
-
11
- export function isStrictConditionOwner(car: any): boolean {
12
- const ownerId = car?.metaData?.ownerId;
13
- return !!ownerId && strictOwners.includes(ownerId);
14
- }
15
-
16
- export type AccidentStatus = 'accidentFree' | 'accident' | 'notSpecified';
17
-
18
- // The strict status, or undefined when the car's owner keeps the old display.
19
- export function strictAccidentStatus(car: any): AccidentStatus | undefined {
20
- if (!isStrictConditionOwner(car)) return undefined;
21
- const value = car?.mainData?.accidentDamaged;
22
- if (value === true) return 'accident';
23
- if (value === false) return 'accidentFree';
24
- return 'notSpecified';
25
- }