mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2025-12-12 23:36:00 +00:00
Type item.gallery
This commit is contained in:
parent
990f837aaf
commit
5835a71588
@ -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
9
src/types/Item.d.ts
vendored
@ -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]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user