2024-02-11 02:20:39 -05:00
|
|
|
import * as React from 'react';
|
2024-02-13 01:47:26 -05:00
|
|
|
import {ImageList, Box, Typography, CircularProgress} from '@mui/material';
|
2024-02-11 02:20:39 -05:00
|
|
|
import { useEffect, useState } from "react";
|
2024-02-11 21:13:30 -05:00
|
|
|
import ArtistPortfolioImage from './artistPortfolioImage';
|
2024-02-11 02:20:39 -05:00
|
|
|
|
|
|
|
const ArtistPortfolio = ({artistId}) => {
|
|
|
|
const [portfolioData, setPortfolioData] = useState([]);
|
2024-02-13 01:47:26 -05:00
|
|
|
const [loading, setLoading] = useState(true); // State for loading indicator
|
2024-02-11 02:20:39 -05:00
|
|
|
useEffect(() => {
|
|
|
|
const getData = async () => {
|
2024-02-14 21:14:25 -05:00
|
|
|
const response = await fetch('/api/discovery/artist/'+artistId+'/portfolio');
|
2024-02-13 01:47:26 -05:00
|
|
|
const data = await response.json();
|
2024-02-11 02:20:39 -05:00
|
|
|
setPortfolioData(data);
|
2024-02-13 01:47:26 -05:00
|
|
|
setLoading(false);
|
2024-02-11 02:20:39 -05:00
|
|
|
}
|
2024-02-14 23:48:46 -05:00
|
|
|
//console.log(portfolioData)
|
2024-02-11 02:20:39 -05:00
|
|
|
getData();
|
|
|
|
}, []);
|
|
|
|
return (
|
2024-02-13 01:47:26 -05:00
|
|
|
(loading) ? (
|
|
|
|
<Box sx={{textAlign:"center", paddingTop:20}}>
|
|
|
|
<Typography variant="h4" sx={{textAlign:"center"}}>
|
2024-02-14 23:48:46 -05:00
|
|
|
Loading
|
2024-02-13 01:47:26 -05:00
|
|
|
</Typography>
|
|
|
|
<CircularProgress sx={{paddingTop:5}} />
|
|
|
|
</Box>
|
|
|
|
) :
|
|
|
|
(
|
|
|
|
<ImageList cols={2} rowHeight={200} sx={{maxHeight:400}}>
|
|
|
|
{portfolioData.map((item) => (
|
|
|
|
<ArtistPortfolioImage artistId={artistId} itemId={item.id} />
|
|
|
|
))}
|
|
|
|
</ImageList>
|
|
|
|
)
|
|
|
|
)
|
2024-02-11 02:20:39 -05:00
|
|
|
}
|
|
|
|
export default ArtistPortfolio
|