diff --git a/package-lock.json b/package-lock.json index d0078f8..545b287 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,7 +21,11 @@ "@types/jest": "^27.5.2", "@types/react": "^18.2.14", "@types/react-dom": "^18.2.6", + + + "@types/styled-components": "^5.1.26", + "chart.js": "^4.3.3", "i18next": "^23.4.4", "react": "^18.2.0", @@ -4360,6 +4364,14 @@ "@types/react": "*" } }, + "node_modules/@types/react-responsive": { + "version": "8.0.5", + "resolved": "https://registry.npmjs.org/@types/react-responsive/-/react-responsive-8.0.5.tgz", + "integrity": "sha512-k3gQJgI87oP5IrVZe//3LKJFnAeFaqqWmmtl5eoYL2H3HqFcIhUaE30kRK1CsW3DHdojZxcVj4ZNc2ClsEu2PA==", + "dependencies": { + "@types/react": "*" + } + }, "node_modules/@types/react-router": { "version": "5.1.20", "resolved": "https://registry.npmjs.org/@types/react-router/-/react-router-5.1.20.tgz", diff --git a/package.json b/package.json index c7fc576..640e767 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,9 @@ "@types/jest": "^27.5.2", "@types/react": "^18.2.14", "@types/react-dom": "^18.2.6", + "@types/styled-components": "^5.1.26", + "chart.js": "^4.3.3", "i18next": "^23.4.4", "react": "^18.2.0", diff --git a/src/component/Lank/LankBox.tsx b/src/component/Lank/LankBox.tsx index f2fa449..fb04d0c 100644 --- a/src/component/Lank/LankBox.tsx +++ b/src/component/Lank/LankBox.tsx @@ -4,6 +4,7 @@ import FONT from '../../styles/Font'; import { Mobile, PC } from '../common/Responsive'; import LikeButton from './LikeButton'; import SignUpBeforeLogo from '../../assets/img/SignUpBeforeLogo.png'; +import avatar from '../../assets/img/avatar/M_Avatar.png'; const Box = styled.div` width: 67rem; @@ -106,6 +107,14 @@ const MobileLike = styled.div` position: absolute; `; +const CenteredImage = styled.img` + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); +`; + + const LankBox = ({ name, statusmessage, @@ -124,7 +133,7 @@ const LankBox = ({ {lankNum} - + @@ -140,7 +149,7 @@ const LankBox = ({ {name}
{statusmessage}
-
+ @@ -158,5 +167,4 @@ const LankBox = ({ ); }; - -export default LankBox; +export default LankBox; \ No newline at end of file diff --git a/src/component/Lank/LikeButton.tsx b/src/component/Lank/LikeButton.tsx index cdb0cd9..9f4b3ef 100644 --- a/src/component/Lank/LikeButton.tsx +++ b/src/component/Lank/LikeButton.tsx @@ -1,33 +1,67 @@ import React from 'react'; import {HeartOutlined, HeartFilled} from '@ant-design/icons'; -import styled from 'styled-components'; -class LikeButton extends React.Component{ +class LikeButton extends React.Component { state = { - isChecked: false, + isChecked: false, + loading: false, + responseData: {}, }; - - onClick = () => { - this.state.isChecked ? - this.setState({ - isChecked: false, - }) - : - this.setState({ - isChecked: true, - }); + + componentDidMount() { + this.fetchLikeStatus(); } - - render(){ - return( - -
- {this.state.isChecked ? - : - } -
-
- ) + + fetchLikeStatus = async (codyId = 0) => { + this.setState({ loading: true }); + + try { + const response = await fetch( + `http://13.209.15.210:8080/cody/like?codyId=${codyId}` + ); + const data = await response.json(); + + if (data.success) { + this.setState({ + responseData: data.data, + }); + } + } catch (error) { + console.error("좋아요 오류:", error); + } finally { + this.setState({ loading: false }); + } + }; + + onClick = () => { + this.state.isChecked + ? this.setState({ + isChecked: false, + }) + : this.setState({ + isChecked: true, + }); + }; + render() { + return ( + +
+ {this.state.isChecked ? ( + + ) : ( + + )} +
+
+ ); } -} -export default LikeButton; \ No newline at end of file + } + export default LikeButton; \ No newline at end of file diff --git a/src/pages/Lank.tsx b/src/pages/Lank.tsx index eedc0a2..238f2eb 100644 --- a/src/pages/Lank.tsx +++ b/src/pages/Lank.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { useState, useEffect } from 'react'; import styled from 'styled-components'; import FONT from '../styles/Font'; import LankBox from '../component/Lank/LankBox'; @@ -52,6 +52,8 @@ const Lank = () => { }; const isMobile = window.innerWidth < 768; + + return (
@@ -63,7 +65,7 @@ const Lank = () => {
- {lankData.map((data, index) => ( + {lankData.slice(0, expanded ? lankData.length : 3).map((data, index) => ( { lankNum={data.lankNum} /> ))} - {expanded === true - ? lankData - .slice(3) - .map((data, index) => ( - - )) - : null} - - - {MoreButtonText} - - + {lankData.length > 3 && ( + + + {MoreButtonText} + + + )}
); }; @@ -108,7 +100,7 @@ const Header = styled.div` const HeaderContainer = styled.div` width: 50rem; margin: 0 auto; - padding-top: 5rem; + padding-top: 50px; padding-bottom: 6rem; @media (max-width: 768px) { width: 100%; diff --git a/yarn.lock b/yarn.lock index 3e9188c..545e95e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2240,6 +2240,13 @@ dependencies: "@types/react" "*" +"@types/react-responsive@^8.0.5": + version "8.0.5" + resolved "https://registry.npmjs.org/@types/react-responsive/-/react-responsive-8.0.5.tgz" + integrity sha512-k3gQJgI87oP5IrVZe//3LKJFnAeFaqqWmmtl5eoYL2H3HqFcIhUaE30kRK1CsW3DHdojZxcVj4ZNc2ClsEu2PA== + dependencies: + "@types/react" "*" + "@types/react-router-dom@^5.1.0": version "5.3.3" resolved "https://registry.npmjs.org/@types/react-router-dom/-/react-router-dom-5.3.3.tgz"