- {item.image ? (
-
+ {bestList ? (
+ bestList.map((item, idx) => {
+ if (idx < 4) {
+ var address = '/detail/' + item.id.toString();
+ var star = item.star.toFixed();
+
+ return (
+
+ {item.image ? (
+
+ ) : (
+
+ )}
+
+
+
{item.name}
+
+
{star}.0
+
+
+
+ {like[idx] ? (
+
{
+ likeClick(item.id, item.like, idx, e);
+ }}
+ />
) : (
- {
+ likeClick(item.id, item.like, idx, e);
+ }}
/>
)}
-
-
-
{item.name}
-
-
{star}
-
-
-
- {like[idx] ? (
- {
- likeClick(item.id, item.like, idx, e);
- }}
- />
- ) : (
- {
- likeClick(item.id, item.like, idx, e);
- }}
- />
- )}
-
-
-
- {idx + 1}
-
-
- {item.tags.map((tag) => (
- {tag.name}
- ))}
-
- );
- }
- })
- :
}
+
+
+
{idx + 1}
+
+
+ {item.tags.map((tag) => (
+ {tag.name}
+ ))}
+
+
+
+
+
+
+
+
로그인 후 좋아요를 눌러주세요 :)
+
+
+
+
+ );
+ }
+ })
+ ) : (
+
+ )}
>
);
}
+const StyledModal = Modal.styled`
+ width: 21rem;
+ height: 16rem;
+ padding : 20px;
+ border-radius:20px;
+ background-color: white;
+ opacity: ${(props) => props.opacity};
+ transition : all 0.3s ease-in-out;`;
diff --git a/FrontEnd/rebon-frontend/src/pages/Main/MainCard/index.js b/FrontEnd/rebon-frontend/src/pages/Main/MainCard/index.js
index 025bb76f..a0b7a970 100644
--- a/FrontEnd/rebon-frontend/src/pages/Main/MainCard/index.js
+++ b/FrontEnd/rebon-frontend/src/pages/Main/MainCard/index.js
@@ -6,94 +6,130 @@ import { Link } from 'react-router-dom';
import styled from 'styled-components';
import axios from 'axios';
import Loading from '../../Login/Loading';
+import Modal, { ModalProvider, BaseModalBackground } from 'styled-react-modal';
+import { faXmark } from '@fortawesome/free-solid-svg-icons';
+import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
export default function MainCard({ tagId, cateId, data, checked, open, sort, like, changeLike }) {
const [mainInfo, setMainInfo] = useState(null);
const [subId, setSubId] = useState();
- const [token, setToken] = useState(window.sessionStorage.getItem('token'));
+ const token = window.sessionStorage.getItem('token');
const [ready, setReady] = useState(false);
+ const [isOpen, setIsOpen] = useState(false);
+ const [opacity, setOpacity] = useState(0);
+
+ const config = {
+ headers: { Authorization: `Bearer ${token}` },
+ };
+
useEffect(() => {
setReady(false);
setTimeout(function () {
if (data) {
var url = 'http://3.34.139.61:8080/api/shops?tag=' + tagId + '&category=' + cateId + '&subCategories=' + checked + '&open=' + open + '&sort=' + sort + '%2Cdesc';
- axios.get(url).then((response) => {
+ axios.get(url, config).then((response) => {
setMainInfo(response.data);
setReady(true);
});
}
- }, 1200);
+ }, 400);
}, [data, checked, open, sort, cateId]);
const likeClick = (shopId, idx, e) => {
- if (like[idx]) {
- changeLike(idx);
- const config = {
- headers: { Authorization: `Bearer ${token}` },
- };
- if (token) {
- var url = 'http://3.34.139.61:8080/api/shops/' + shopId + '/unlike';
- axios
- .post(
- url,
- {
- likeCount: 0,
- like: false,
- },
- config
- )
- .then((response) => {
- console.log(response);
- })
- .catch((error) => {
- console.log(error);
- });
+ if (token) {
+ if (like[idx]) {
+ changeLike(idx);
+
+ if (token) {
+ var url = 'http://3.34.139.61:8080/api/shops/' + shopId + '/unlike';
+ axios
+ .post(
+ url,
+ {
+ likeCount: 0,
+ like: false,
+ },
+ config
+ )
+ .then((response) => {
+ console.log(response);
+ })
+ .catch((error) => {
+ console.log(error);
+ });
+ }
+ } else {
+ changeLike(idx);
+
+ const config = {
+ headers: { Authorization: `Bearer ${token}` },
+ };
+ if (token) {
+ var url = 'http://3.34.139.61:8080/api/shops/' + shopId + '/like';
+ axios
+ .post(
+ url,
+ {
+ likeCount: 1,
+ like: true,
+ },
+ config
+ )
+ .then((response) => {
+ console.log(response);
+ })
+ .catch((error) => {
+ console.log(error);
+ });
+ }
}
} else {
- changeLike(idx);
-
- const config = {
- headers: { Authorization: `Bearer ${token}` },
- };
- if (token) {
- var url = 'http://3.34.139.61:8080/api/shops/' + shopId + '/like';
- axios
- .post(
- url,
- {
- likeCount: 1,
- like: true,
- },
- config
- )
- .then((response) => {
- console.log(response);
- })
- .catch((error) => {
- console.log(error);
- });
- }
+ // alert('로그인 후 좋아요를 눌러주세요 :)');
+ toggleModal();
}
};
- const StyledLink = styled(Link)`
- box-sizing: border-box;
- display: block;
- text-align: center;
- text-decoration: none;
- color: black;
- hover: none;
+ function toggleModal(e) {
+ setOpacity(0);
+ setIsOpen(!isOpen);
+ }
+
+ function afterOpen() {
+ setTimeout(() => {
+ setOpacity(1);
+ }, 100);
+ }
+
+ function beforeClose() {
+ return new Promise((resolve) => {
+ setOpacity(0);
+ setTimeout(resolve, 300);
+ });
+ }
+
+ const FadingBackground = styled(BaseModalBackground)`
+ opacity: ${(props) => props.opacity};
+ transition: all 0.3s ease-in-out;
`;
+ // const StyledLink = styled(Link)`
+ // box-sizing: border-box;
+ // display: block;
+ // text-align: center;
+ // text-decoration: none;
+ // color: black;
+ // hover: none;
+ // `;
+
return (
<>
{ready ? (
mainInfo ? (
mainInfo.map((item, idx) => {
var address = '/detail/' + item.id.toString();
- var star = item.star.toFixed(1);
+ var star = item.star.toFixed();
return (
@@ -106,7 +142,7 @@ export default function MainCard({ tagId, cateId, data, checked, open, sort, lik
/>
)}
- {like[idx] ? (
+ {item.like ? (
{item.name}
- {star}
+ {star}.0
{/*
{item.tags.map((tag) => (
@@ -140,6 +176,25 @@ export default function MainCard({ tagId, cateId, data, checked, open, sort, lik
))}
*/}
+
+
+
+
+
+
로그인 후 좋아요를 눌러주세요 :)
+
+
+
);
})
@@ -157,3 +212,11 @@ export default function MainCard({ tagId, cateId, data, checked, open, sort, lik
>
);
}
+const StyledModal = Modal.styled`
+ width: 21rem;
+ height: 16rem;
+ padding : 20px;
+ border-radius:20px;
+ background-color: white;
+ opacity: ${(props) => props.opacity};
+ transition : all 0.3s ease-in-out;`;
diff --git a/FrontEnd/rebon-frontend/src/pages/Main/MainShopData/index.js b/FrontEnd/rebon-frontend/src/pages/Main/MainShopData/index.js
index 2fc14e7e..6d6819cc 100644
--- a/FrontEnd/rebon-frontend/src/pages/Main/MainShopData/index.js
+++ b/FrontEnd/rebon-frontend/src/pages/Main/MainShopData/index.js
@@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react';
import axios from 'axios';
import { useLocation } from 'react-router';
import Main from '../../Main';
-import Loading from "../../Login/Loading";
+import Loading from '../../Login/Loading';
export default function MainShopData({ restCategory, accoCategory, cafeCategory }) {
const location = useLocation();
@@ -10,6 +10,10 @@ export default function MainShopData({ restCategory, accoCategory, cafeCategory
const [restData, setRestData] = useState(null);
const [accoData, setAccoData] = useState(null);
const [cafeData, setCafeData] = useState(null);
+ const [token, setToken] = useState(window.sessionStorage.getItem('token'));
+ const config = {
+ headers: { Authorization: `Bearer ${token}` },
+ };
useEffect(() => {
setReady(false);
@@ -18,71 +22,71 @@ export default function MainShopData({ restCategory, accoCategory, cafeCategory
var accoArr = [];
var cafeArr = [];
- restCategory.map((data, index) => {
- const noRest = [74, 91,29];
- if(!(noRest.includes(data.id))) {
- var url = 'http://3.34.139.61:8080/api/shops?tag=' + location.state.item.id + '&category=1&subCategories=' + data.id + '&open=false&sort=shopScore.star%2Cdesc';
+ const noRest = [74, 91, 29];
+ if (!noRest.includes(data.id)) {
+ var url = 'http://3.34.139.61:8080/api/shops?tag=' + location.state.item.id + '&category=1&subCategories=' + data.id + '&open=false&sort=shopScore.star%2Cdesc';
+ axios
+ .get(url, config)
+ .then((response) => {
+ const restState = { id: data.id, shop: response.data };
+ restArr.push(restState);
+ })
+ .catch((error) => {
+ if (error.response.status === 500) {
+ restArr.push([]);
+ } else console.log('restShop error');
+ });
+ }
+
+ setRestData(restArr);
+
+ cafeCategory.map((data, index) => {
+ const noCafe = [96];
+ if (!noCafe.includes(data.id)) {
+ var url = 'http://3.34.139.61:8080/api/shops?tag=' + location.state.item.id + '&category=2&subCategories=' + data.id + '&open=false&sort=shopScore.star%2Cdesc';
axios
- .get(url)
+ .get(url, config)
.then((response) => {
- const restState = { id: data.id, shop: response.data };
- restArr.push(restState);
+ const cafeState = { id: data.id, shop: response.data };
+ cafeArr.push(cafeState);
})
.catch((error) => {
if (error.response.status === 500) {
- restArr.push([]);
- } else console.log('restShop error');
+ cafeArr.push([]);
+ } else console.log('cafeShop error');
});
}
});
- setRestData(restArr);
-
- cafeCategory.map((data, index) => {
- const noCafe = [96];
- // if(!(noCafe.includes(data.id))){
- var url = 'http://3.34.139.61:8080/api/shops?tag=' + location.state.item.id + '&category=2&subCategories=' + data.id + '&open=false&sort=shopScore.star%2Cdesc';
- axios
- .get(url)
- .then((response) => {
- const cafeState = { id: data.id, shop: response.data };
- cafeArr.push(cafeState);
- })
- .catch((error) => {
- if (error.response.status === 500) {
- cafeArr.push([]);
- } else console.log('cafeShop error');
- });
- // }
- });
setCafeData(cafeArr);
-
accoCategory.map((data, index) => {
const noAcco = [100, 102, 99, 101, 18, 98, 17, 16];
- // if(!(noAcco.includes(data.id))) {
- var url = 'http://3.34.139.61:8080/api/shops?tag=' + location.state.item.id + '&category=3&subCategories=' + data.id + '&open=false&sort=shopScore.star%2Cdesc';
- axios
- .get(url)
- .then((response) => {
- const accoState = { id: data.id, shop: response.data };
- accoArr.push(accoState);
- })
- .catch((error) => {
- if (error.response.status === 500) {
- accoArr.push([]);
- } else console.log('accoShop error');
- });
- // }
+ if (!noAcco.includes(data.id)) {
+ var url = 'http://3.34.139.61:8080/api/shops?tag=' + location.state.item.id + '&category=3&subCategories=' + data.id + '&open=false&sort=shopScore.star%2Cdesc';
+ axios
+ .get(url, config)
+ .then((response) => {
+ const accoState = { id: data.id, shop: response.data };
+ accoArr.push(accoState);
+ })
+ .catch((error) => {
+ if (error.response.status === 500) {
+ accoArr.push([]);
+ } else console.log('accoShop error');
+ });
+ }
});
setAccoData(accoArr);
setReady(true);
}, []);
-
return (
- <>{ready ?
-