Switched category data struct from Map to object

Moved lineByName function
This commit is contained in:
2023-07-13 18:17:57 +03:00
parent 6a0c4c9dac
commit 9437c44054
8 changed files with 46 additions and 52 deletions

View File

@ -1,41 +1,40 @@
import { isLiteralUnion } from "../utils/types"
const categories = ["PORRIDGE", "conspects", "milk", "bred", "wathing", "cloth",
"fruits_vegatables", "soup", "dinner", "conserves", "pens", "other_things"] as const
"fruits_vegatables", "soup", "dinner", "conserves", "pens", "other_things"] as const
type Category = typeof categories[number]
const isCategory = (obj: unknown): obj is Category => isLiteralUnion(obj, categories)
const isCategory = (obj: unknown): obj is Category => isLiteralUnion(obj, categories)
const categoryGraphics = new Map<Category, string>([
["PORRIDGE", "static/PORRIDGE.jpg"],
["conspects", "static/conspects.jpg"],
["milk", "static/milk.jpg"],
["bred", "static/bred.jpg"],
["wathing", "static/wathing.jpg"],
["cloth", "static/cloth.jpg"],
["fruits_vegatables", "static/fruits_vegatables.jpg"],
["soup", "static/soup.jpg"],
["dinner", "static/dinner.jpg"],
["conserves", "static/conserves.jpg"],
["pens", "static/pens.jpg"],
["other_things", "static/other_things.jpg"]
const categoryGraphics: Record<Category, string> = {
"PORRIDGE": "static/PORRIDGE.jpg",
"conspects": "static/conspects.jpg",
"milk": "static/milk.jpg",
"bred": "static/bred.jpg",
"wathing": "static/wathing.jpg",
"cloth": "static/cloth.jpg",
"fruits_vegatables": "static/fruits_vegatables.jpg",
"soup": "static/soup.jpg",
"dinner": "static/dinner.jpg",
"conserves": "static/conserves.jpg",
"pens": "static/pens.jpg",
"other_things": "static/other_things.jpg",
}
])
const categoryNames = new Map<Category, string>([
["PORRIDGE", "PORRIDGE"],
["conspects", "Конспекты"],
["milk", "Молочные продукты"],
["bred", "Хлебобулочные изделия"],
["wathing", "Моющие средства"],
["cloth", "Одежда"],
["fruits_vegatables", "Фрукты и овощи"],
["soup", "Супы"],
["dinner", "Ужин"],
["conserves", "Консервы"],
["pens", "Канцелярия"],
["other_things", "Всякая всячина"]
])
const categoryNames: Record<Category, string> = {
"PORRIDGE": "PORRIDGE",
"conspects": "Конспекты",
"milk": "Молочные продукты",
"bred": "Хлебобулочные изделия",
"wathing": "Моющие средства",
"cloth": "Одежда",
"fruits_vegatables": "Фрукты и овощи",
"soup": "Супы",
"dinner": "Ужин",
"conserves": "Консервы",
"pens": "Канцелярия",
"other_things": "Всякая всячина",
}
export type { Category }
export { categoryNames, categoryGraphics, isCategory }
export { categories, categoryNames, categoryGraphics, isCategory }

View File

@ -101,5 +101,9 @@ const lineNames: Record<Lines, string> = {
violet: "Фиолетовая",
}
const lineByName = (name: string) =>
lines.find(line => stations[line].has(name))
export type { Lines }
export { lines, stations, colors, lineNames }
export { lines, stations, colors, lineNames, lineByName }