diff --git a/www/js/diary/LabelTabContext.ts b/www/js/diary/LabelTabContext.ts index 24d7ade41..717a4980d 100644 --- a/www/js/diary/LabelTabContext.ts +++ b/www/js/diary/LabelTabContext.ts @@ -1,6 +1,6 @@ import { createContext } from 'react'; import { TimelineEntry, UserInputEntry } from '../types/diaryTypes'; -import { LabelOption } from '../survey/multilabel/confirmHelper'; +import { LabelOption } from '../types/labelTypes'; export type TimelineMap = Map; export type TimelineLabelMap = { diff --git a/www/js/diary/diaryHelper.ts b/www/js/diary/diaryHelper.ts index bfc0d5d39..79918207a 100644 --- a/www/js/diary/diaryHelper.ts +++ b/www/js/diary/diaryHelper.ts @@ -2,8 +2,9 @@ // these functions are being gradually migrated out of services.js import { DateTime } from 'luxon'; -import { LabelOptions } from '../survey/multilabel/confirmHelper'; +import { readableLabelToKey } from '../survey/multilabel/confirmHelper'; import { CompositeTrip } from '../types/diaryTypes'; +import { LabelOptions } from '../types/labelTypes'; export const modeColors = { pink: '#c32e85', // oklch(56% 0.2 350) // e-car diff --git a/www/js/survey/multilabel/confirmHelper.ts b/www/js/survey/multilabel/confirmHelper.ts index 51674b0c3..4c2be1012 100644 --- a/www/js/survey/multilabel/confirmHelper.ts +++ b/www/js/survey/multilabel/confirmHelper.ts @@ -4,31 +4,7 @@ import { getAngularService } from '../../angular-react-helper'; import { fetchUrlCached } from '../../services/commHelper'; import i18next from 'i18next'; import { logDebug } from '../../plugin/logger'; - -type InputDetails = { - [k in T]?: { - name: string; - labeltext: string; - choosetext: string; - key: string; - }; -}; -export type LabelOption = { - value: string; - baseMode: string; - met?: { range: any[]; mets: number }; - met_equivalent?: string; - kgCo2PerKm: number; - text?: string; -}; -export type MultilabelKey = 'MODE' | 'PURPOSE' | 'REPLACED_MODE'; -export type LabelOptions = { - [k in T]: LabelOption[]; -} & { - translations: { - [lang: string]: { [translationKey: string]: string }; - }; -}; +import { LabelOption, LabelOptions, MultilabelKey, InputDetails } from '../../types/labelTypes'; let appConfig; export let labelOptions: LabelOptions; diff --git a/www/js/types/labelTypes.ts b/www/js/types/labelTypes.ts index 9719531a8..8ac720adc 100644 --- a/www/js/types/labelTypes.ts +++ b/www/js/types/labelTypes.ts @@ -1,24 +1,24 @@ -export type LabelOptions = { - MODE: Array; - PURPOSE: Array; - REPLACE_MODE: Array; +export type InputDetails = { + [k in T]?: { + name: string; + labeltext: string; + choosetext: string; + key: string; + }; }; - -export type ModeLabel = { +export type LabelOption = { value: string; baseMode: string; + met?: { range: any[]; mets: number }; met_equivalent?: string; - met?: { - ALL: { - range: Array; - mets: number; - }; - }; kgCo2PerKm: number; - test: string; + text?: string; }; - -export type PurposeReplaceLabel = { - value: string; - test: string; +export type MultilabelKey = 'MODE' | 'PURPOSE' | 'REPLACED_MODE'; +export type LabelOptions = { + [k in T]: LabelOption[]; +} & { + translations: { + [lang: string]: { [translationKey: string]: string }; + }; };