diff --git a/db-datos/supermercado.ts b/db-datos/supermercado.ts new file mode 100644 index 0000000..e46fe9a --- /dev/null +++ b/db-datos/supermercado.ts @@ -0,0 +1,16 @@ +export enum Supermercado { + Dia = "Dia", + Carrefour = "Carrefour", + Coto = "Coto", +} + +export const hosts: { [host: string]: Supermercado } = { + "diaonline.supermercadosdia.com.ar": Supermercado.Dia, + "www.carrefour.com.ar": Supermercado.Carrefour, + "www.cotodigital3.com.ar": Supermercado.Coto, +}; +export const colorBySupermercado: { [supermercado in Supermercado]: string } = { + [Supermercado.Dia]: "#d52b1e", + [Supermercado.Carrefour]: "#19549d", + [Supermercado.Coto]: "#e20025", +}; diff --git a/sitio/src/routes/ean/[ean]/Chart.svelte b/sitio/src/routes/ean/[ean]/Chart.svelte index 07f9cda..7671455 100644 --- a/sitio/src/routes/ean/[ean]/Chart.svelte +++ b/sitio/src/routes/ean/[ean]/Chart.svelte @@ -2,26 +2,10 @@ import type { Precio } from "db-datos/schema"; // import dayjs from "dayjs"; import ChartJs from "./ChartJs.svelte"; + import { hosts, colorBySupermercado } from "db-datos/supermercado"; export let precios: Precio[]; - enum Supermercado { - Dia = "Dia", - Carrefour = "Carrefour", - Coto = "Coto", - } - - const hosts: { [host: string]: Supermercado } = { - "diaonline.supermercadosdia.com.ar": Supermercado.Dia, - "www.carrefour.com.ar": Supermercado.Carrefour, - "www.cotodigital3.com.ar": Supermercado.Coto, - }; - const colorBySupermercado: { [supermercado in Supermercado]: string } = { - [Supermercado.Dia]: "#d52b1e", - [Supermercado.Carrefour]: "#19549d", - [Supermercado.Coto]: "#e20025", - }; - $: datasets = precios .map((p) => new URL(p.url!).hostname) .filter(onlyUnique)