@@ -19,15 +19,16 @@ import {
1919 resetAllState
2020} from '../../redux/reducers/slice/appStateSlice' ;
2121import { useDispatch , useSelector } from 'react-redux' ;
22-
2322import { MoreVert } from '@mui/icons-material' ;
2423import { RootState } from '../../redux/store' ;
2524import Snackbar from '@mui/material/Snackbar' ;
2625import axios from 'axios' ;
27- import imageSrc from '../../../../resources/marketplace_images/marketplace_image.png' ;
26+ // import imageSrc from '../../../../resources/marketplace_images/marketplace_image.png';
2827import { red } from '@mui/material/colors' ;
2928import { saveProject } from '../../helperFunctions/projectGetSaveDel' ;
3029import { useHistory } from 'react-router-dom' ;
30+ import { Amplify , Storage } from 'aws-amplify' ;
31+ import awsconfig from '../../../../src/aws-exports' ;
3132
3233interface Project {
3334 forked : String ;
@@ -47,9 +48,27 @@ const MarketplaceCard = ({ proj }: { proj: Project }) => {
4748 const dispatch = useDispatch ( ) ;
4849 const history = useHistory ( ) ;
4950 const [ anchorEl , setAnchorEl ] = React . useState < null | HTMLElement > ( null ) ;
51+ const [ s3ImgURL , setS3ImgURL ] = React . useState < null | string > ( null ) ;
5052 const open = Boolean ( anchorEl ) ;
5153 const [ alertOpen , setAlertOpen ] = React . useState < boolean > ( false ) ;
52- const state = useSelector ( ( store : RootState ) => store . appState ) ;
54+
55+ useEffect ( ( ) => {
56+ async function s3ImgFetch ( ) {
57+ Amplify . configure ( awsconfig ) ;
58+ try {
59+ const objId : string = proj . _id . toString ( ) ;
60+ // the below functions are commented out as not to incur too many charges
61+ // const response: string = await Storage.get(objId);
62+ // const response: string = await Storage.get('test');
63+ // setS3ImgURL(response);
64+ } catch ( error ) {
65+ console . error ( `Error fetching image preview for ${ proj . _id } : ` , error ) ;
66+ }
67+ }
68+ s3ImgFetch ( ) ;
69+ } , [ ] ) ;
70+
71+
5372 const handleClick = ( event : React . MouseEvent < HTMLElement > ) => {
5473 setAnchorEl ( event . currentTarget ) ;
5574 } ;
@@ -107,8 +126,8 @@ const MarketplaceCard = ({ proj }: { proj: Project }) => {
107126 sx = { { borderRadius : '12px' , height : 200 } }
108127 component = "img"
109128 height = "194"
110- image = { imageSrc }
111- alt = "component buttons "
129+ image = { s3ImgURL }
130+ alt = "component preview "
112131 />
113132 < CardHeader
114133 avatar = {
0 commit comments