@@ -12,74 +12,84 @@ import {
1212 Typography ,
1313 styled
1414} from '@mui/material' ;
15+ import MuiAlert , { AlertProps } from '@mui/material/Alert' ;
16+ import React , { useEffect } from 'react' ;
17+ import {
18+ openProject ,
19+ resetAllState
20+ } from '../../redux/reducers/slice/appStateSlice' ;
21+ import { useDispatch , useSelector } from 'react-redux' ;
1522
1623import { MoreVert } from '@mui/icons-material' ;
17- import React , { useEffect } from 'react' ;
24+ import { RootState } from '../../redux/store' ;
25+ import Snackbar from '@mui/material/Snackbar' ;
26+ import axios from 'axios' ;
1827import imageSrc from '../../../../resources/marketplace_images/marketplace_image.png' ;
1928import { red } from '@mui/material/colors' ;
20- import axios from 'axios' ;
21- import { useDispatch , useSelector } from 'react-redux'
22- import { RootState } from '../../redux/store' ;
2329import { saveProject } from '../../helperFunctions/projectGetSaveDel' ;
2430import { useHistory } from 'react-router-dom' ;
25- import { openProject } from '../../redux/reducers/slice/appStateSlice' ;
26- import MuiAlert , { AlertProps } from '@mui/material/Alert' ;
27- import Snackbar from '@mui/material/Snackbar' ;
2831
2932interface Project {
30- forked : String ,
31- comments : string [ ]
32- createdAt : Date
33- likes : number
34- name : string
35- project : object
36- published : boolean
37- userId : number
38- username : string
39- _id : number
33+ forked : String ;
34+ comments : string [ ] ;
35+ createdAt : Date ;
36+ likes : number ;
37+ name : string ;
38+ project : object ;
39+ published : boolean ;
40+ userId : number ;
41+ username : string ;
42+ _id : number ;
4043}
4144
4245const ITEM_HEIGHT = 48 ;
43- const MarketplaceCard = ( { proj} : { proj : Project } ) => {
46+ const MarketplaceCard = ( { proj } : { proj : Project } ) => {
4447 const dispatch = useDispatch ( ) ;
4548 const history = useHistory ( ) ;
4649 const [ anchorEl , setAnchorEl ] = React . useState < null | HTMLElement > ( null ) ;
4750 const open = Boolean ( anchorEl ) ;
48- const [ alertOpen , setAlertOpen ] = React . useState < boolean > ( false )
49- const state = useSelector ( ( store :RootState ) => store . appState ) ;
51+ const [ alertOpen , setAlertOpen ] = React . useState < boolean > ( false ) ;
52+ const state = useSelector ( ( store : RootState ) => store . appState ) ;
5053 const handleClick = ( event : React . MouseEvent < HTMLElement > ) => {
5154 setAnchorEl ( event . currentTarget ) ;
5255 } ;
53- const handleClone = async ( ) => { // creates a copy of the project
56+ const handleClone = async ( ) => {
57+ // creates a copy of the project
5458 const docId = proj . _id ;
55- const response = await axios . get ( `/cloneProject/${ docId } ` , { params : { username : window . localStorage . getItem ( 'username' ) } } ) ; //passing in username as a query param is query params
59+ const response = await axios . get ( `/cloneProject/${ docId } ` , {
60+ params : { username : window . localStorage . getItem ( 'username' ) }
61+ } ) ; //passing in username as a query param is query params
5662 const project = response . data . project ;
5763 setAlertOpen ( true ) ;
5864 setAnchorEl ( null ) ;
59- return { _id : project . _id , name : project . name , published : project . published , ...project . project } ;
65+ return {
66+ _id : project . _id ,
67+ name : project . name ,
68+ published : project . published ,
69+ ...project . project
70+ } ;
6071 } ;
61-
62- const handleCloneOpen = async ( ) => {
72+
73+ const handleCloneOpen = async ( ) => {
6374 const project = await handleClone ( ) ;
6475 history . push ( '/' ) ;
6576 dispatch ( openProject ( project ) ) ;
6677 } ;
67-
78+
6879 const handleClose = ( ) => {
6980 setAnchorEl ( null ) ;
7081 } ;
7182
72-
7383 const handleAlertClose = (
7484 event : React . SyntheticEvent | Event ,
7585 reason ?: string
76- ) => {
77- if ( reason === 'clickaway' ) {
78- return ;
79- }
80- setAlertOpen ( false ) ;
81- setAnchorEl ( null )
86+ ) => {
87+ if ( reason === 'clickaway' ) {
88+ return ;
8289 }
90+ setAlertOpen ( false ) ;
91+ setAnchorEl ( null ) ;
92+ } ;
8393
8494 const Alert = React . forwardRef < HTMLDivElement , AlertProps > ( function Alert (
8595 props ,
@@ -88,7 +98,6 @@ const MarketplaceCard = ({proj} :{proj: Project}) => {
8898 return < MuiAlert elevation = { 6 } ref = { ref } variant = "filled" { ...props } /> ;
8999 } ) ;
90100
91-
92101 return (
93102 < >
94103 < Card
@@ -155,7 +164,7 @@ const MarketplaceCard = ({proj} :{proj: Project}) => {
155164 Clone and open
156165 </ MenuItem >
157166 </ Menu >
158- < Snackbar
167+ < Snackbar
159168 open = { alertOpen }
160169 autoHideDuration = { 3000 }
161170 onClose = { handleAlertClose }
0 commit comments