Skip to content

Commit d3e74c5

Browse files
committed
Updated server to match client
1 parent 8d84baf commit d3e74c5

File tree

9 files changed

+19
-19
lines changed

9 files changed

+19
-19
lines changed

client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "client",
33
"version": "0.1.0",
44
"private": true,
5-
"proxy": "http://localhost:3001",
5+
"proxy": "http://localhost:3000",
66
"dependencies": {
77
"@testing-library/jest-dom": "^5.16.5",
88
"@testing-library/react": "^13.4.0",

client/src/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const App = () => {
3333
element:<SneakerDetails data={sneakers}/>
3434
},
3535
{
36-
path:"/comment/create/:sneaker_id",
36+
path:"/reviews/create/:sneaker_id",
3737
element: <CreateComment />
3838
},
3939
{

client/src/components/CommentBtn.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ const CommentBtn = (props) => {
1414
body: JSON.stringify({num_votes: num_votes + 1})
1515
}
1616

17-
fetch('/api/comments/' + props.id, options)
17+
fetch('/api/reviews/' + props.id, options)
1818
setNumVotes((num_votes) => num_votes + 1)
1919
}
2020

2121
return (
2222
<button className='commentBtn' id={props.id} onClick={updateCount}>
23-
{num_votes + ' ❤️ ' } <br/ > <br/ > {props.comments}
23+
{num_votes + ' ❤️ ' } <br/ > <br/ > {props.reviews}
2424
</button>
2525
)
2626

client/src/components/SneakersCard.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Link } from 'react-router-dom'
66
const SneakersCard = (props) => {
77

88
return (
9-
<div className="SneakersCard" style={{ backgroundImage:`url(${props.img_url})`}} >
9+
<div className="SneakersCard" style={{ backgroundImage:`url(${props.image_url})`}} >
1010
<div className="SneakersCard-info">
1111
<h3 className="brand_name">{props.brand_name}</h3>
1212
{/* <p className="description">{props.description}</p> */}

client/src/pages/CreateComment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const CreateComment = () => {
2929
body: JSON.stringify(comment)
3030
}
3131

32-
await fetch('/api/comments/' + sneaker_id, options)
32+
await fetch('/api/reviews/' + sneaker_id, options)
3333
window.location.href = '/'
3434
}
3535

client/src/pages/ReadSneakers.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ const ReadSneakers = (props) => {
1717
const handleBrandSort = () => {
1818
const sortedSneakers = [...posts].sort((a, b) => {
1919
if (brandSortOrder === 'ascending') {
20-
return a.brand_name.localeCompare(b.brand_name);
20+
return a.name.localeCompare(b.name);
2121
} else {
22-
return b.brand_name.localeCompare(a.brand_name);
22+
return b.name.localeCompare(a.name);
2323
}
2424
});
2525
setPosts([...sortedSneakers]);
@@ -68,11 +68,11 @@ const ReadSneakers = (props) => {
6868
posts.map((post,index) =>
6969
<SneakersCard key={post.id}
7070
id={post.id}
71-
brand_name={post.brand_name}
71+
brand_name={post.name}
7272
description={post.description}
7373
sizes={post.sizes}
7474
price={post.price}
75-
img_url={post.img_url} />
75+
image_url={post.image_url} />
7676
) : <h3 className="noResults">{'No Sneakers Yet 😞'}</h3>
7777
}
7878
</div>

client/src/pages/SneakerDetails.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ import './SneakerDetails.css'
66
const SneakerDetails = ({data}) => {
77

88
const {id} = useParams();
9-
const [post, setPost] = useState({id: 0, brand_name: "", description: "", sizes: "", price: "", img_url: ""})
9+
const [post, setPost] = useState({id: 0, name: "", description: "", sizes: "", price: "", image_url: ""})
1010
const [comments, setComments] = useState([])
1111

1212
useEffect(() => {
1313
const result = data.filter(item => item.id === parseInt(id))[0];
1414

15-
setPost({id: parseInt(result.id), brand_name: result.brand_name, description: result.description, sizes: result.sizes, price: result.price, img_url: result.img_url});
15+
setPost({id: parseInt(result.id), name: result.name, description: result.description, sizes: result.sizes, price: result.price, image_url: result.image_url});
1616

1717

1818
const fetchComments = async () => {
19-
const response = await fetch('/api/comments/' + id)
19+
const response = await fetch('/api/reviews/' + id)
2020
const data = await response.json()
2121
setComments(data)
2222
}
@@ -29,20 +29,20 @@ const SneakerDetails = ({data}) => {
2929
return (
3030
<div className="out">
3131
<div className="details-banner">
32-
<h3 className="brand_name">{post.brand_name}</h3>
32+
<h3 className="brand_name">{post.name}</h3>
3333
<div className="details-container">
3434
<p className="details-description">{post.description}</p>
3535
</div>
3636
</div>
3737

3838
<div className="flex-container">
39-
<div className="left-side" style={{ backgroundImage:`url(${post.img_url})`}}>
39+
<div className="left-side" style={{ backgroundImage:`url(${post.image_url})`}}>
4040
</div>
4141
<div className="right-side">
4242
{/* <p>{"✔️ Sizes: " + post.sizes }</p> */}
4343
<p className="details-price">{"🏷️ Price: " + post.price}</p>
44-
<p className="right-side-brand_name">{post.brand_name}</p>
45-
<Link to={'../../comment/create/'+ id }><button className="addCommentBtn">Create Comment</button></Link>
44+
<p className="right-side-brand_name">{post.name}</p>
45+
<Link to={'../../comment/reviews/'+ id }><button className="addCommentBtn">Review</button></Link>
4646
</div>
4747
</div>
4848

client/vite.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default defineConfig({
66
server: {
77
proxy: {
88
'/api': {
9-
target: 'http://localhost:3001'
9+
target: 'http://localhost:3000'
1010
}
1111
}
1212
}

server/controllers/reviews.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const createReview = async (req, res) => {
2020
const getReviews = async (req, res) => {
2121
try {
2222
const results = await pool.query(
23-
"SELECT * FROM reviews ORDER BY reviewid ASC"
23+
"SELECT * FROM reviews ORDER BY review_id ASC"
2424
);
2525
res.status(200).json(results.rows);
2626
} catch (error) {

0 commit comments

Comments
 (0)