mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2025-12-13 07:46:10 +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 { useState } from 'react'
|
||||||
import { RowsPhotoAlbum } from 'react-photo-album'
|
import { RowsPhotoAlbum } from 'react-photo-album'
|
||||||
import ReactLightbox from 'yet-another-react-lightbox'
|
import ReactLightbox from 'yet-another-react-lightbox'
|
||||||
@ -15,7 +11,7 @@ import type { Item } from '#types/Item'
|
|||||||
export const GalleryView = ({ item }: { item: Item }) => {
|
export const GalleryView = ({ item }: { item: Item }) => {
|
||||||
const [index, setIndex] = useState(-1)
|
const [index, setIndex] = useState(-1)
|
||||||
const appState = useAppState()
|
const appState = useAppState()
|
||||||
const images = item.gallery.map((i, j) => {
|
const images = item.gallery?.map((i, j) => {
|
||||||
return {
|
return {
|
||||||
src: appState.assetsApi.url + `${i.directus_files_id.id}.jpg`,
|
src: appState.assetsApi.url + `${i.directus_files_id.id}.jpg`,
|
||||||
width: i.directus_files_id.width,
|
width: i.directus_files_id.width,
|
||||||
@ -23,6 +19,9 @@ export const GalleryView = ({ item }: { item: Item }) => {
|
|||||||
index: j,
|
index: j,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (!images) throw new Error('GalleryView: images is undefined')
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='tw-mx-6 tw-mb-6'>
|
<div className='tw-mx-6 tw-mb-6'>
|
||||||
<RowsPhotoAlbum
|
<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 }[]
|
type TagIds = { tags_id: string }[]
|
||||||
|
|
||||||
|
interface GalleryItem {
|
||||||
|
directus_files_id: {
|
||||||
|
id: number
|
||||||
|
width: number
|
||||||
|
height: number
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export interface Item {
|
export interface Item {
|
||||||
id: string
|
id: string
|
||||||
name: string
|
name: string
|
||||||
@ -40,6 +48,7 @@ export interface Item {
|
|||||||
telephone?: string
|
telephone?: string
|
||||||
next_appointment?: string
|
next_appointment?: string
|
||||||
type?: ItemType
|
type?: ItemType
|
||||||
|
gallery?: GalleryItem[]
|
||||||
|
|
||||||
// {
|
// {
|
||||||
// coordinates: [number, number]
|
// coordinates: [number, number]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user