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
|
|
|
|
2024-02-18 01:44:48 -05:00
|
|
|
const ArtistPortfolio = ({masonry,columns,artistId}) => {
|
2024-02-11 02:20:39 -05:00
|
|
|
const [portfolioData, setPortfolioData] = useState([]);
|
2024-02-25 18:34:51 -05:00
|
|
|
const [profileId, setArtistId] = useState(artistId)
|
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-25 18:34:51 -05:00
|
|
|
const response = await fetch('/api/discovery/artist/'+profileId+'/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-15 21:49:12 -05:00
|
|
|
(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>
|
2024-02-18 06:59:55 -05:00
|
|
|
<Box sx={{paddingTop:"2%"}}/>
|
|
|
|
<CircularProgress />
|
2024-02-13 01:47:26 -05:00
|
|
|
</Box>
|
|
|
|
) :
|
|
|
|
(
|
2024-02-18 01:44:48 -05:00
|
|
|
(masonry) ? (
|
2024-02-25 18:34:51 -05:00
|
|
|
<ImageList variant='masonry' cols={columns} sx={{ width:"100%" }}>
|
2024-02-13 01:47:26 -05:00
|
|
|
{portfolioData.map((item) => (
|
2024-02-25 18:34:51 -05:00
|
|
|
<ArtistPortfolioImage artistId={profileId} itemId={item.id} />
|
2024-02-13 01:47:26 -05:00
|
|
|
))}
|
|
|
|
</ImageList>
|
2024-02-18 01:44:48 -05:00
|
|
|
):(
|
2024-02-25 18:34:51 -05:00
|
|
|
<ImageList cols={columns} sx={{ width:"100%" }}>
|
|
|
|
{portfolioData.map((item) => (
|
|
|
|
<ArtistPortfolioImage artistId={profileId} itemId={item.id} />
|
2024-02-18 01:44:48 -05:00
|
|
|
))}
|
|
|
|
</ImageList>
|
|
|
|
)
|
2024-02-13 01:47:26 -05:00
|
|
|
)
|
|
|
|
)
|
2024-02-11 02:20:39 -05:00
|
|
|
}
|
|
|
|
export default ArtistPortfolio
|