metaforecast/src/web/platforms.ts

26 lines
593 B
TypeScript
Raw Normal View History

2022-04-05 21:02:54 +00:00
import { Forecast, platforms } from "../backend/platforms";
2022-03-16 21:02:34 +00:00
export interface PlatformConfig {
name: string;
label: string;
color: string;
}
export type FrontendForecast = Forecast & {
platformLabel: string;
visualization?: any;
};
2022-04-05 21:02:54 +00:00
export const addLabelsToForecasts = (
forecasts: Forecast[]
): FrontendForecast[] => {
const platformNameToLabel = Object.fromEntries(
platforms.map((platform) => [platform.name, platform.label])
);
return forecasts.map((result) => ({
...result,
platformLabel: platformNameToLabel[result.platform] || result.platform,
}));
};