Skip to content

Commit

Permalink
Merge branch 'type_interfaces' into diaryServices-rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
the-bay-kay committed Nov 15, 2023
2 parents e6a21ca + 361cc28 commit 570d7a7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 44 deletions.
2 changes: 1 addition & 1 deletion www/js/diary/LabelTabContext.ts
Original file line number Diff line number Diff line change
@@ -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<string, TimelineEntry>;
export type TimelineLabelMap = {
Expand Down
3 changes: 2 additions & 1 deletion www/js/diary/diaryHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 1 addition & 25 deletions www/js/survey/multilabel/confirmHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T extends string> = {
[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<T extends string = MultilabelKey> = {
[k in T]: LabelOption[];
} & {
translations: {
[lang: string]: { [translationKey: string]: string };
};
};
import { LabelOption, LabelOptions, MultilabelKey, InputDetails } from '../../types/labelTypes';

let appConfig;
export let labelOptions: LabelOptions<MultilabelKey>;
Expand Down
34 changes: 17 additions & 17 deletions www/js/types/labelTypes.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
export type LabelOptions = {
MODE: Array<ModeLabel>;
PURPOSE: Array<PurposeReplaceLabel>;
REPLACE_MODE: Array<PurposeReplaceLabel>;
export type InputDetails<T extends string> = {
[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<number>;
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<T extends string = MultilabelKey> = {
[k in T]: LabelOption[];
} & {
translations: {
[lang: string]: { [translationKey: string]: string };
};
};

0 comments on commit 570d7a7

Please sign in to comment.