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

@ -6,7 +6,7 @@ import { latLng } from "leaflet"
import { ClickHandler, LocationMarker, TrashboxMarkers } from "../components"
import { useAddAnnouncement, useTrashboxes } from "../hooks/api"
import { categoryNames } from "../assets/category"
import { categories, categoryNames } from "../assets/category"
import { stations, lines, lineNames } from "../assets/metro"
import { isObject } from "../utils/types"
import { handleHTTPErrors } from "../utils"
@ -87,9 +87,8 @@ function AddPage() {
<option value="" hidden>
Выберите категорию
</option>
{Array.from(categoryNames).map(
([category, categoryName]) =>
<option key={category} value={category}>{categoryName}</option>
{categories.map(category =>
<option key={category} value={category}>{categoryNames[category]}</option>
)}
</Form.Select>
</Form.Group>

View File

@ -15,7 +15,7 @@ function generateStories(announcements: Announcement[]): Story[] {
return announcements.map(announcement => {
return ({
id: announcement.id,
url: announcement.src || categoryGraphics.get(announcement.category),
url: announcement.src || categoryGraphics[announcement.category],
type: announcement.src?.endsWith("mp4") ? "video" : undefined,
seeMore: ({ close }: { close: () => void }) => <AnnouncementDetails close={close} announcement={announcement} />
})