import React, { useEffect, useState } from 'react' import { Card, Modal, Row, Select, Typography } from 'antd' import { getSession } from '../api' import { ScrollToTop } from './ScrollToTop' type Props = { clientId: string } export const SessionPictures = ({ clientId }: Props) => { const [urls, setUrls] = useState(null) const [activeUrl, setActiveUrl] = useState(null) const [focusPhotos, setFocusPhotos] = useState( JSON.parse(window.localStorage.getItem('focusPhotos') || '[]'), ) useEffect(() => { const get = async () => { if (urls && urls.length >= 89 * 1) { return } const { photos } = await getSession(clientId) if (photos.length) setUrls(photos) } const interval = setInterval(get, 250) return () => clearInterval(interval) }, [clientId, urls]) const closeModal = () => setActiveUrl(null) const host = process.env.NODE_ENV === 'development' ? 'http://192.168.1.107:5000' : '' if (!urls?.length) return null const photos = urls.sort((a, b) => a.split('_')[0].localeCompare(b.split('_')[0]), ) const u = urls.length / 89 const handleSelect = (v: string[]) => { console.log('SEelcted', v) window.localStorage.setItem('focusPhotos', JSON.stringify(v)) setFocusPhotos(v) } const filteredPhotos = photos.filter((name) => { const num = name.split('_')[0] return focusPhotos.includes(num) }) return ( <> large modal Session Pictures {urls.length}/ 89 loaded Select Featured Photos:
{filteredPhotos.map((src) => ( setActiveUrl(src)} src={`${host}/output/${clientId}/${src}`} alt="lol" /> ))}
{photos.map((src) => ( setActiveUrl(src)} src={`${host}/output/${clientId}/${src}`} alt="lol" /> ))}
) }