tripoli.cloud/app/src/hooks/usePhotos.ts

19 lines
598 B
TypeScript
Raw Normal View History

import { useEffect, useState } from 'react';
import { getAlbums, getPhotoTiles } from '../api/photos';
import type { Album, PhotoScope, PhotoTile } from '../types';
const SCOPES: PhotoScope[] = ['Tout', 'Personnes', 'Lieux'];
export function usePhotos() {
const [albums, setAlbums] = useState<Album[]>([]);
const [tiles, setTiles] = useState<PhotoTile[]>([]);
const [scope, setScope] = useState<PhotoScope>('Tout');
useEffect(() => {
void getAlbums().then(setAlbums);
void getPhotoTiles().then(setTiles);
}, []);
return { albums, tiles, scopes: SCOPES, scope, setScope };
}