Type item.gallery

This commit is contained in:
Maximilian Harz 2025-02-06 12:38:06 +01:00
parent 990f837aaf
commit 5835a71588
2 changed files with 13 additions and 5 deletions

View File

@ -1,7 +1,3 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/restrict-template-expressions */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import { useState } from 'react'
import { RowsPhotoAlbum } from 'react-photo-album'
import ReactLightbox from 'yet-another-react-lightbox'
@ -15,7 +11,7 @@ import type { Item } from '#types/Item'
export const GalleryView = ({ item }: { item: Item }) => {
const [index, setIndex] = useState(-1)
const appState = useAppState()
const images = item.gallery.map((i, j) => {
const images = item.gallery?.map((i, j) => {
return {
src: appState.assetsApi.url + `${i.directus_files_id.id}.jpg`,
width: i.directus_files_id.width,
@ -23,6 +19,9 @@ export const GalleryView = ({ item }: { item: Item }) => {
index: j,
}
})
if (!images) throw new Error('GalleryView: images is undefined')
return (
<div className='tw-mx-6 tw-mb-6'>
<RowsPhotoAlbum

9
src/types/Item.d.ts vendored
View File

@ -7,6 +7,14 @@ import type { Point } from 'geojson'
type TagIds = { tags_id: string }[]
interface GalleryItem {
directus_files_id: {
id: number
width: number
height: number
}
}
export interface Item {
id: string
name: string
@ -40,6 +48,7 @@ export interface Item {
telephone?: string
next_appointment?: string
type?: ItemType
gallery?: GalleryItem[]
// {
// coordinates: [number, number]