Skip to content

Commit 5ca4ce2

Browse files
committed
fixed duplicate HTML5Backend
1 parent f999a90 commit 5ca4ce2

File tree

5 files changed

+54
-13
lines changed

5 files changed

+54
-13
lines changed

app/src/components/marketplace/MarketplaceCard.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,20 @@ import React from 'react';
1818
import imageSrc from '../../../../resources/marketplace_images/marketplace_image.png';
1919
import { red } from '@mui/material/colors';
2020

21+
interface Project {
22+
comments: string[]
23+
createdAt: Date
24+
likes: number
25+
name: string
26+
project: object
27+
published: boolean
28+
userId: number
29+
username: string
30+
_id: number
31+
}
32+
2133
const ITEM_HEIGHT = 48;
22-
const MarketplaceCard = () => {
34+
const MarketplaceCard = ({proj} :{proj: Project}) => {
2335
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
2436
const open = Boolean(anchorEl);
2537
const handleClick = (event: React.MouseEvent<HTMLElement>) => {
@@ -58,8 +70,8 @@ const MarketplaceCard = () => {
5870
<MoreVert />
5971
</IconButton>
6072
}
61-
title="Gradient Buttons"
62-
subheader="Liam Rohn"
73+
title={proj.name}
74+
subheader={proj.username}
6375
/>
6476
<Menu
6577
id="long-menu"

app/src/components/marketplace/MarketplaceCardContainer.tsx

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,32 @@
11
import { Container, Grid } from '@mui/material';
22

33
import MarketplaceCard from './MarketplaceCard';
4-
import React from 'react';
4+
import React, {useEffect, useState} from 'react';
5+
import axios from 'axios';
56

67
const MarketplaceCardContainer = () => {
7-
const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9];
8+
9+
const [marketplaceProjects, setMarketplaceProjects] = useState([]);
10+
useEffect(() => {
11+
async function marketplaceFetch() {
12+
try {
13+
const response = await axios.get('/getMarketplaceProjects', {
14+
headers: {
15+
'Content-Type': 'application/json',
16+
},
17+
withCredentials: true,
18+
});
19+
20+
setMarketplaceProjects(response.data);
21+
22+
} catch (error) {
23+
console.error('Error fetching MP data:', error);
24+
}
25+
}
26+
marketplaceFetch();
27+
28+
}, []);
29+
830
return (
931
<>
1032
<Container>
@@ -14,9 +36,10 @@ const MarketplaceCardContainer = () => {
1436
spacing={{ xs: 2, md: 3 }}
1537
columns={{ xs: 4, sm: 8, md: 12 }}
1638
>
17-
{numbers.map((num) => (
18-
<Grid item xs={4} sm={4} md={4} key={num}>
19-
<MarketplaceCard />
39+
{marketplaceProjects.map((proj, i) => (
40+
41+
<Grid item xs={4} sm={4} md={4} key={i}>
42+
<MarketplaceCard proj={proj}/>
2043
</Grid>
2144
))}
2245
</Grid>

app/src/containers/MarketplaceContainer.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import MarketplaceCardContainer from '../components/marketplace/MarketplaceCardContainer';
2-
import React from 'react';
32
import SearchBar from '../components/marketplace/Searchbar';
3+
import React from 'react';
44

55
const MarketplaceContainer = () => {
6+
7+
8+
69
return (
710
<div style={containerStyles}>
811
<div style={contentStyles}>

app/src/index.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import {
77
HashRouter as Router,
88
Switch
99
} from 'react-router-dom';
10-
10+
import { DndProvider } from 'react-dnd';
11+
import { HTML5Backend } from 'react-dnd-html5-backend';
1112
import App from './components/App';
1213
import Cookies from 'js-cookie';
1314
import FBPassWord from './components/login/FBPassWord';
@@ -49,9 +50,11 @@ ReactDOM.render(
4950
<Route exact path="/login" component={SignIn} />
5051
<Route exact path="/signup" component={SignUp} />
5152
<Route exact path="/password" component={FBPassWord} />
52-
<PrivateRoute exact path="/" component={App} />
53+
<DndProvider backend={HTML5Backend}>
54+
<Route exact path="/marketplace" component={App} />
55+
<PrivateRoute exact path="/" component={App} />
56+
</DndProvider>
5357
<Route exact path="/dashboard" component={ProjectDashboard} />
54-
<Route exact path="/marketplace" component={App} />
5558
<Route exact path="/tutorial" component={Tutorial} />
5659
<Route exact path="/tutorialPage/:learn" component={TutorialPage} />
5760
</Switch>

server/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ app.patch(
212212
//Get from Marketplace
213213
app.get(
214214
'/getMarketplaceProjects',
215-
sessionController.isLoggedIn,
215+
// sessionController.isLoggedIn, //Maybe don't need to check if they have a session since guests should still see?
216216
marketplaceController.getPublishedProjects,
217217
(req, res) => res.status(200).json(res.locals.publishedProjects)
218218
);

0 commit comments

Comments
 (0)