forked from Star-Nosed-Mole-Group/Scratch-Project
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathShop.jsx
More file actions
46 lines (43 loc) · 1.77 KB
/
Copy pathShop.jsx
File metadata and controls
46 lines (43 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import React, { useState } from 'react'
import { Link, useLocation } from 'react-router-dom';
import '../stylesheets/shop.css'
// import Reviews from './Reviews'
import FocusedShop from './FocusedShop';
export default function Shop(props) {
const { drinks, food, shopname, outlets, parking, sound, space, wifi, shopId, fetchShopMatches, currentUser } = props;
console.log(shopname);
const replacedName = shopname.replaceAll('"', '\'');
console.log('CurrentUser in Shop: ' + currentUser)
const [ isFocused, setIsFocused ] = useState(false);
const handleClick = () => {
if(isFocused) setIsFocused(false);
else setIsFocused(true);
}
return (
<div>
<div onClick={() => handleClick()} className='shop'>
<h2>{replacedName}</h2>
<div className="shop-averages-container">
{Object.keys(props).map(prop => {
if(!['name', 'fetchShopMatches', '_id', 'currentUser'].includes(prop)) return (<div>{prop}: {props[prop]}</div>);
})}
</div>
</div>
{isFocused && <FocusedShop
drinks={drinks}
food={food}
shopname={shopname}
outlets={outlets}
parking={parking}
sound={sound}
space={space}
wifi={wifi}
shopId={shopId}
key={`focusedShop${shopId}`}
setIsFocused={setIsFocused}
fetchShopMatches={fetchShopMatches}
currentUser={currentUser}
/>}
</div>
)
}