From b2e37bd7db278fa146bfb7395203b4a25bb9d4d1 Mon Sep 17 00:00:00 2001 From: hanseulhee <3021062@gmail.com> Date: Tue, 10 Oct 2023 14:15:18 +0900 Subject: [PATCH 01/12] reset --- .github/delete-merged-branch-config.yml | 15 ++++++++++++++ .github/pull_request_template.md | 27 +++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 .github/delete-merged-branch-config.yml create mode 100644 .github/pull_request_template.md diff --git a/.github/delete-merged-branch-config.yml b/.github/delete-merged-branch-config.yml new file mode 100644 index 000000000..2a6d27bef --- /dev/null +++ b/.github/delete-merged-branch-config.yml @@ -0,0 +1,15 @@ +name: delete branch on close pr + +on: + pull_request: + types: [closed] + +permissions: + pull-requests: write + +jobs: + delete-branch: + runs-on: ubuntu-latest + steps: + - name: delete branch + uses: SvanBoxel/delete-merged-branch@main diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 000000000..a85814779 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,27 @@ +## 요구사항 + +### 기본 + +- [x] +- [] +- [] + +### 심화 + +- [x] +- [] + +## 주요 변경사항 + +- +- + +## 스크린샷 + +![image](이미지url) + +## 멘토에게 + +- +- +- 셀프 코드 리뷰를 통해 질문 이어가겠습니다. From e11e25f095cf9fa1909206fd16ef114c00c9442a Mon Sep 17 00:00:00 2001 From: hanseulhee <3021062@gmail.com> Date: Tue, 10 Oct 2023 14:47:30 +0900 Subject: [PATCH 02/12] =?UTF-8?q?fix:=20=EB=A8=B8=EC=A7=80=20=ED=9B=84=20?= =?UTF-8?q?=EB=B8=8C=EB=9E=9C=EC=B9=98=20=EC=82=AD=EC=A0=9C=20github=20act?= =?UTF-8?q?ion=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/delete-merged-branch-config.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/delete-merged-branch-config.yml b/.github/delete-merged-branch-config.yml index 2a6d27bef..d54933615 100644 --- a/.github/delete-merged-branch-config.yml +++ b/.github/delete-merged-branch-config.yml @@ -4,12 +4,11 @@ on: pull_request: types: [closed] -permissions: - pull-requests: write - jobs: delete-branch: runs-on: ubuntu-latest steps: - name: delete branch uses: SvanBoxel/delete-merged-branch@main + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 212e8643d8aebe6cab293e61e2800c4e9b5d6d88 Mon Sep 17 00:00:00 2001 From: hanseulhee <3021062@gmail.com> Date: Tue, 10 Oct 2023 14:50:26 +0900 Subject: [PATCH 03/12] =?UTF-8?q?env:=20workflows=20=ED=8F=B4=EB=8D=94?= =?UTF-8?q?=EB=A1=9C=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/{ => workflows}/delete-merged-branch-config.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{ => workflows}/delete-merged-branch-config.yml (100%) diff --git a/.github/delete-merged-branch-config.yml b/.github/workflows/delete-merged-branch-config.yml similarity index 100% rename from .github/delete-merged-branch-config.yml rename to .github/workflows/delete-merged-branch-config.yml From ea6b8320e8a65f0f771a46ed8337f8df658ad0b4 Mon Sep 17 00:00:00 2001 From: Injaeeee <97098671+Injaeeee@users.noreply.github.com> Date: Mon, 1 Jul 2024 15:55:23 +0900 Subject: [PATCH 04/12] =?UTF-8?q?=EB=B0=98=EC=9D=91=ED=98=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/FileInput.js | 2 ++ src/components/ProductList.css | 2 +- src/pages/AddItem.js | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/FileInput.js b/src/components/FileInput.js index 3336eab0a..840190549 100644 --- a/src/components/FileInput.js +++ b/src/components/FileInput.js @@ -17,6 +17,7 @@ function FileInput({ name, value, onChange }) { if (!inputNode) return; inputNode.value = ''; + setPreview(null); onChange(name, null); @@ -26,6 +27,7 @@ function FileInput({ name, value, onChange }) { if (!value) return; const nextpreview = URL.createObjectURL(value); + setPreview(nextpreview); }, [value]) diff --git a/src/components/ProductList.css b/src/components/ProductList.css index f049e1fdb..7356af82d 100644 --- a/src/components/ProductList.css +++ b/src/components/ProductList.css @@ -23,7 +23,7 @@ padding: 0; } -@media (max-width: 744px) { +@media (max-width: 1000px) { .ProductList { width: 696px; display: grid; diff --git a/src/pages/AddItem.js b/src/pages/AddItem.js index 4b2a62dfe..07b75a3ac 100644 --- a/src/pages/AddItem.js +++ b/src/pages/AddItem.js @@ -30,6 +30,7 @@ function AddItem() { ...prevValues, [name]: value, })); + console.log(name, value); } const handleInputChange = (e) => { From b0a684a7b912e771572a4125169271983f5251f2 Mon Sep 17 00:00:00 2001 From: Injaeeee <97098671+Injaeeee@users.noreply.github.com> Date: Mon, 1 Jul 2024 17:08:58 +0900 Subject: [PATCH 05/12] =?UTF-8?q?=E3=85=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/AddItem.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/AddItem.js b/src/pages/AddItem.js index 07b75a3ac..8f18c5c3a 100644 --- a/src/pages/AddItem.js +++ b/src/pages/AddItem.js @@ -12,15 +12,15 @@ function AddItem() { imgFile: null, }); - const [isButtonDisabled, SetisButtonDisabled] = useState(true); + const [isButtonDisabled, setIsButtonDisabled] = useState(true); useEffect(() => { const allInput = values.introduction && values.price && values.productName && values.tag; if (allInput) { - SetisButtonDisabled(false); + setIsButtonDisabled(false); } else { - SetisButtonDisabled(true); + setIsButtonDisabled(true); } }, [values]) From 1f397826c6d548de841c060db44e6fb219b7e7ce Mon Sep 17 00:00:00 2001 From: Injaeeee <97098671+Injaeeee@users.noreply.github.com> Date: Fri, 28 Jun 2024 18:25:21 +0900 Subject: [PATCH 06/12] Revert "sprint6" This reverts commit 548406fe87ef598d7fa145eb4aa56563a3d8103c. --- package-lock.json | 154 ++++------------------------------- package.json | 2 - src/Main.js | 24 ------ src/api.js | 18 +--- src/components/App.js | 55 ++++++++++++- src/components/Button.js | 15 ++-- src/components/FileInput.css | 48 ----------- src/components/FileInput.js | 49 ----------- src/components/Topbar.js | 6 +- src/index.js | 4 +- src/pages/AddItem.js | 67 --------------- src/pages/Additem.css | 42 ---------- src/pages/Items.css | 25 ------ src/pages/Items.js | 62 -------------- src/pages/NotFound.js | 15 ---- 15 files changed, 77 insertions(+), 509 deletions(-) delete mode 100644 src/Main.js delete mode 100644 src/components/FileInput.css delete mode 100644 src/components/FileInput.js delete mode 100644 src/pages/AddItem.js delete mode 100644 src/pages/Additem.css delete mode 100644 src/pages/Items.css delete mode 100644 src/pages/Items.js delete mode 100644 src/pages/NotFound.js diff --git a/package-lock.json b/package-lock.json index 6b9988e11..a1e590ee6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,9 +13,7 @@ "@testing-library/user-event": "^13.5.0", "react": "^18.2.0", "react-dom": "^18.2.0", - "react-router-dom": "^6.24.0", "react-scripts": "5.0.1", - "styled-components": "^6.1.11", "web-vitals": "^2.1.4" } }, @@ -2272,24 +2270,6 @@ "postcss-selector-parser": "^6.0.10" } }, - "node_modules/@emotion/is-prop-valid": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/@emotion/is-prop-valid/-/is-prop-valid-1.2.2.tgz", - "integrity": "sha512-uNsoYd37AFmaCdXlg6EYD1KaPOaRWRByMCYzbKUX4+hhMfrxdVSelShywL4JVaAeM/eHUOSprYBQls+/neX3pw==", - "dependencies": { - "@emotion/memoize": "^0.8.1" - } - }, - "node_modules/@emotion/memoize": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.8.1.tgz", - "integrity": "sha512-W2P2c/VRW1/1tLox0mVUalvnWXxavmv/Oum2aPsRcoDJuob75FC3Y8FbpfLwUegRcxINtGUMPq0tFCvYNTBXNA==" - }, - "node_modules/@emotion/unitless": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/@emotion/unitless/-/unitless-0.8.1.tgz", - "integrity": "sha512-KOEGMu6dmJZtpadb476IsZBclKvILjopjUii3V+7MnXIQCYh8W3NgNcgwo21n9LXZX6EDIKvqfjYxXebDwxKmQ==" - }, "node_modules/@eslint-community/eslint-utils": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", @@ -3261,14 +3241,6 @@ } } }, - "node_modules/@remix-run/router": { - "version": "1.17.0", - "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.17.0.tgz", - "integrity": "sha512-2D6XaHEVvkCn682XBnipbJjgZUU7xjLtA4dGJRBVUKpEaDYOZMENZoZjAOSb7qirxt5RupjzZxz4fK2FO+EFPw==", - "engines": { - "node": ">=14.0.0" - } - }, "node_modules/@rollup/plugin-babel": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/@rollup/plugin-babel/-/plugin-babel-5.3.1.tgz", @@ -4440,11 +4412,6 @@ "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.1.tgz", "integrity": "sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==" }, - "node_modules/@types/stylis": { - "version": "4.2.5", - "resolved": "https://registry.npmjs.org/@types/stylis/-/stylis-4.2.5.tgz", - "integrity": "sha512-1Xve+NMN7FWjY14vLoY5tL3BVEQ/n42YLwaqJIPYhotZ9uBHt87VceMwWQpzmdEt2TNXIorIFG+YeCUUW7RInw==" - }, "node_modules/@types/testing-library__jest-dom": { "version": "5.14.9", "resolved": "https://registry.npmjs.org/@types/testing-library__jest-dom/-/testing-library__jest-dom-5.14.9.tgz", @@ -5859,14 +5826,6 @@ "node": ">= 6" } }, - "node_modules/camelize": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/camelize/-/camelize-1.0.1.tgz", - "integrity": "sha512-dU+Tx2fsypxTgtLoE36npi3UqcjSSMNYfkqgmoEhtZrraP5VWq0K7FkWVTYa8eMPtnU/G2txVsfdCJTn9uzpuQ==", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/caniuse-api": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/caniuse-api/-/caniuse-api-3.0.0.tgz", @@ -6302,14 +6261,6 @@ "postcss": "^8.4" } }, - "node_modules/css-color-keywords": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/css-color-keywords/-/css-color-keywords-1.0.0.tgz", - "integrity": "sha512-FyyrDHZKEjXDpNJYvVsV960FiqQyXc/LlYmsxl2BcdMb2WPx0OGRVgTg55rPSyLSNMqP52R9r8geSp7apN3Ofg==", - "engines": { - "node": ">=4" - } - }, "node_modules/css-declaration-sorter": { "version": "6.4.1", "resolved": "https://registry.npmjs.org/css-declaration-sorter/-/css-declaration-sorter-6.4.1.tgz", @@ -6491,16 +6442,6 @@ "resolved": "https://registry.npmjs.org/css-select-base-adapter/-/css-select-base-adapter-0.1.1.tgz", "integrity": "sha512-jQVeeRG70QI08vSTwf1jHxp74JoZsr2XSgETae8/xC8ovSnL2WF87GTLO86Sbwdt2lK4Umg4HnnwMO4YF3Ce7w==" }, - "node_modules/css-to-react-native": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/css-to-react-native/-/css-to-react-native-3.2.0.tgz", - "integrity": "sha512-e8RKaLXMOFii+02mOlqwjbD00KSEKqblnpO9e++1aXS1fPQOpS1YoqdVHBqPjHNoxeF2mimzVqawm2KCbEdtHQ==", - "dependencies": { - "camelize": "^1.0.0", - "css-color-keywords": "^1.0.0", - "postcss-value-parser": "^4.0.2" - } - }, "node_modules/css-tree": { "version": "1.0.0-alpha.37", "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-1.0.0-alpha.37.tgz", @@ -6694,9 +6635,9 @@ "integrity": "sha512-b0tGHbfegbhPJpxpiBPU2sCkigAqtM9O121le6bbOlgyV+NyGyCmVfJ6QW9eRjz8CpNfWEOYBIMIGRYkLwsIYg==" }, "node_modules/csstype": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz", - "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==" + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.2.tgz", + "integrity": "sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==" }, "node_modules/damerau-levenshtein": { "version": "1.0.8", @@ -12483,9 +12424,9 @@ } }, "node_modules/nanoid": { - "version": "3.3.7", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", - "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz", + "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==", "funding": [ { "type": "github", @@ -13144,9 +13085,9 @@ } }, "node_modules/postcss": { - "version": "8.4.38", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.38.tgz", - "integrity": "sha512-Wglpdk03BSfXkHoQa3b/oulrotAkwrlLDRSOb9D0bN86FdRyE9lppSp33aHNPgBa0JKCoB+drFLZkQoRRYae5A==", + "version": "8.4.29", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.29.tgz", + "integrity": "sha512-cbI+jaqIeu/VGqXEarWkRCCffhjgXc0qjBtXpqJhTBohMUjUQnbBr0xqX3vEKudc4iviTewcJo5ajcec5+wdJw==", "funding": [ { "type": "opencollective", @@ -13162,9 +13103,9 @@ } ], "dependencies": { - "nanoid": "^3.3.7", + "nanoid": "^3.3.6", "picocolors": "^1.0.0", - "source-map-js": "^1.2.0" + "source-map-js": "^1.0.2" }, "engines": { "node": "^10 || ^12 || >=14" @@ -14730,36 +14671,6 @@ "node": ">=0.10.0" } }, - "node_modules/react-router": { - "version": "6.24.0", - "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.24.0.tgz", - "integrity": "sha512-sQrgJ5bXk7vbcC4BxQxeNa5UmboFm35we1AFK0VvQaz9g0LzxEIuLOhHIoZ8rnu9BO21ishGeL9no1WB76W/eg==", - "dependencies": { - "@remix-run/router": "1.17.0" - }, - "engines": { - "node": ">=14.0.0" - }, - "peerDependencies": { - "react": ">=16.8" - } - }, - "node_modules/react-router-dom": { - "version": "6.24.0", - "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.24.0.tgz", - "integrity": "sha512-960sKuau6/yEwS8e+NVEidYQb1hNjAYM327gjEyXlc6r3Skf2vtwuJ2l7lssdegD2YjoKG5l8MsVyeTDlVeY8g==", - "dependencies": { - "@remix-run/router": "1.17.0", - "react-router": "6.24.0" - }, - "engines": { - "node": ">=14.0.0" - }, - "peerDependencies": { - "react": ">=16.8", - "react-dom": ">=16.8" - } - }, "node_modules/react-scripts": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/react-scripts/-/react-scripts-5.0.1.tgz", @@ -15574,11 +15485,6 @@ "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" }, - "node_modules/shallowequal": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/shallowequal/-/shallowequal-1.1.0.tgz", - "integrity": "sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ==" - }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -15661,9 +15567,9 @@ } }, "node_modules/source-map-js": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.0.tgz", - "integrity": "sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", + "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", "engines": { "node": ">=0.10.0" } @@ -16074,33 +15980,6 @@ "webpack": "^5.0.0" } }, - "node_modules/styled-components": { - "version": "6.1.11", - "resolved": "https://registry.npmjs.org/styled-components/-/styled-components-6.1.11.tgz", - "integrity": "sha512-Ui0jXPzbp1phYij90h12ksljKGqF8ncGx+pjrNPsSPhbUUjWT2tD1FwGo2LF6USCnbrsIhNngDfodhxbegfEOA==", - "dependencies": { - "@emotion/is-prop-valid": "1.2.2", - "@emotion/unitless": "0.8.1", - "@types/stylis": "4.2.5", - "css-to-react-native": "3.2.0", - "csstype": "3.1.3", - "postcss": "8.4.38", - "shallowequal": "1.1.0", - "stylis": "4.3.2", - "tslib": "2.6.2" - }, - "engines": { - "node": ">= 16" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/styled-components" - }, - "peerDependencies": { - "react": ">= 16.8.0", - "react-dom": ">= 16.8.0" - } - }, "node_modules/stylehacks": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/stylehacks/-/stylehacks-5.1.1.tgz", @@ -16116,11 +15995,6 @@ "postcss": "^8.2.15" } }, - "node_modules/stylis": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/stylis/-/stylis-4.3.2.tgz", - "integrity": "sha512-bhtUjWd/z6ltJiQwg0dUfxEJ+W+jdqQd8TbWLWyeIJHlnsqmGLRFFd8e5mA0AZi/zx90smXRlN66YMTcaSFifg==" - }, "node_modules/sucrase": { "version": "3.34.0", "resolved": "https://registry.npmjs.org/sucrase/-/sucrase-3.34.0.tgz", diff --git a/package.json b/package.json index 630bf5466..7ff0d6b58 100644 --- a/package.json +++ b/package.json @@ -8,9 +8,7 @@ "@testing-library/user-event": "^13.5.0", "react": "^18.2.0", "react-dom": "^18.2.0", - "react-router-dom": "^6.24.0", "react-scripts": "5.0.1", - "styled-components": "^6.1.11", "web-vitals": "^2.1.4" }, "scripts": { diff --git a/src/Main.js b/src/Main.js deleted file mode 100644 index f0f815d2e..000000000 --- a/src/Main.js +++ /dev/null @@ -1,24 +0,0 @@ -import { BrowserRouter, Routes, Route } from 'react-router-dom'; -import App from "./components/App"; -import Items from './pages/Items'; -import AddItems from './pages/AddItem'; -import NotFound from './pages/NotFound'; - -function Main() { - - return ( - - - } > - - }> - }> - }> - - - - - ); -} - -export default Main; \ No newline at end of file diff --git a/src/api.js b/src/api.js index 7b36c0cf1..fec41c1ba 100644 --- a/src/api.js +++ b/src/api.js @@ -1,23 +1,7 @@ -const BASE_URL = 'https://panda-market-api.vercel.app'; - export async function getProducts(order = 'recent') { const query = `orderBy=${order}`; - const response = await fetch(`${BASE_URL}/products?${query}`); - const body = await response.json(); - return body; - -} - -export async function createProducts(formData) { - - - const response = await fetch(`${BASE_URL}/products?`, - { - method: 'POST', - body: formData, - - }); + const response = await fetch(`https://panda-market-api.vercel.app/products?${query}`); const body = await response.json(); return body; diff --git a/src/components/App.js b/src/components/App.js index 9036050e7..8d6db2379 100644 --- a/src/components/App.js +++ b/src/components/App.js @@ -1,17 +1,64 @@ import Topbar from './Topbar'; import './App.css'; -import { Outlet } from 'react-router-dom'; +import ProductList from './ProductList'; +import BestProductList from './BestProductList'; +import Button from './Button'; +import { useEffect, useState } from 'react'; +import { getProducts } from '../api'; function App() { + const [order, setOrder] = useState('recent'); + const [items, setItems] = useState([]); + + const sortedItems = items.sort((a, b) => b[order] - a[order]); + + const BestItems = items.sort((a, b) => b['favorite'] - a['favorite']); + + const handleFavorite = () => setOrder('favorite'); + + const handleRecent = () => setOrder('recent'); + + + + const handleLoad = async (orderQuery) => { + const { list } = await getProducts(orderQuery); + setItems(list); + console.log(list); + } + + useEffect(() => { + handleLoad(order); + }, [order]) + return ( - <> +
-
- +
+

베스트 상품

+ + +
+

판매 중인 상품

+
+ + + + +
+
+ + + +
+ +
); } diff --git a/src/components/Button.js b/src/components/Button.js index f30d36f5e..f67c28287 100644 --- a/src/components/Button.js +++ b/src/components/Button.js @@ -1,15 +1,12 @@ import './Button.css'; - - - function Button({ children, onClick, select = '' }) { - const classNames = `Button ${select}`; - return ( - - ); + const classNames = `Button ${select}`; + return ( + + ); } export default Button; diff --git a/src/components/FileInput.css b/src/components/FileInput.css deleted file mode 100644 index 4044d2f34..000000000 --- a/src/components/FileInput.css +++ /dev/null @@ -1,48 +0,0 @@ -.fileInputWrapper { - display: flex; - gap: 20px; -} - -.fileInput { - display: none; -} - -.fileInputButton { - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - background-color: #f3f4f6; - width: 282px; - height: 282px; - border-radius: 12px; -} - -.fileInputCustom { - color: #9ca3af; - font-size: 16px; - font-weight: 400px; -} - -.imgPreviewWrapper { - position: relative; -} - -.previewImg { - width: 282px; - height: 282px; - border-radius: 12px; -} - -.imgRemoveButton { - position: absolute; - top: 10px; - right: 10px; - background-color: #3692ff; - color: #ffffff; - border: none; - border-radius: 50%; - width: 30px; - height: 30px; - font-size: 20px; -} diff --git a/src/components/FileInput.js b/src/components/FileInput.js deleted file mode 100644 index 3336eab0a..000000000 --- a/src/components/FileInput.js +++ /dev/null @@ -1,49 +0,0 @@ -import { useEffect, useRef, useState } from "react"; -import './FileInput.css'; - -function FileInput({ name, value, onChange }) { - const inputRef = useRef(); - const [preview, setPreview] = useState(); - - const handleChange = (e) => { - - const nextValue = e.target.files[0]; - onChange(name, nextValue); - }; - - const handleClearClick = () => { - const inputNode = inputRef.current; - - if (!inputNode) return; - - inputNode.value = ''; - setPreview(null); - onChange(name, null); - - } - - useEffect(() => { - if (!value) return; - - const nextpreview = URL.createObjectURL(value); - setPreview(nextpreview); - - }, [value]) - - return
- - - - {preview && -
- 이미지 미리보기 - - -
} -
- -} - -export default FileInput; \ No newline at end of file diff --git a/src/components/Topbar.js b/src/components/Topbar.js index c66e1da04..84f903d62 100644 --- a/src/components/Topbar.js +++ b/src/components/Topbar.js @@ -1,7 +1,7 @@ import pandaLogo from '../img/logo.png'; import './Topbar.css'; import Button from './Button' -import { Link } from 'react-router-dom'; + function Topbar() { @@ -11,8 +11,8 @@ function Topbar() { - - + + diff --git a/src/index.js b/src/index.js index 6566bd7a3..14afd6f72 100644 --- a/src/index.js +++ b/src/index.js @@ -1,10 +1,10 @@ import ReactDOM from 'react-dom/client'; -import Main from './Main'; +import App from "./components/App"; const root = ReactDOM.createRoot(document.getElementById('root')); root.render( -
+ ); \ No newline at end of file diff --git a/src/pages/AddItem.js b/src/pages/AddItem.js deleted file mode 100644 index 4b2a62dfe..000000000 --- a/src/pages/AddItem.js +++ /dev/null @@ -1,67 +0,0 @@ -import './Additem.css'; -import { useEffect, useState } from "react"; -import FileInput from "../components/FileInput"; - -function AddItem() { - - const [values, setValues] = useState({ - productName: '', - introduction: '', - price: 0, - tag: '', - imgFile: null, - }); - - const [isButtonDisabled, SetisButtonDisabled] = useState(true); - - useEffect(() => { - const allInput = values.introduction && values.price && values.productName && values.tag; - if (allInput) { - SetisButtonDisabled(false); - } - else { - SetisButtonDisabled(true); - } - - }, [values]) - - const handleChange = (name, value) => { - setValues((prevValues) => ({ - ...prevValues, - [name]: value, - })); - } - - const handleInputChange = (e) => { - const { name, value } = e.target; - handleChange(name, value); - } - - const handleSubmit = (e) => { - e.preventDefault(); - console.log(values); - } - - - return ( -
-
-

상품 등록하기

- -
-

상품 이미지

- -

상품명

- -

상품소개

- -

판매가격

- -

태그

- - - - ) -} - -export default AddItem; \ No newline at end of file diff --git a/src/pages/Additem.css b/src/pages/Additem.css deleted file mode 100644 index 38bf78f5b..000000000 --- a/src/pages/Additem.css +++ /dev/null @@ -1,42 +0,0 @@ -.button { - color: #ffffff; - border-radius: 8px; - font-size: 16px; - font-weight: 600; - width: 88px; - height: 42px; - text-decoration: none; - border: none; -} - -.disabledButton { - background-color: #9ca2af; -} - -.enabledButton { - background-color: #3692ff; -} - -.productTitle { - display: flex; - justify-content: space-between; - align-items: center; -} - -.productInput { - width: 1200px; - height: 56px; - border-radius: 12px; - background-color: #f3f4f6; - border: none; - color: #9ca3af; - font-size: 16px; - font-weight: 400; - line-height: 24px; - padding: 9px 20px 9px 16px; - outline: none; -} - -.productTextArea { - height: 200px; -} diff --git a/src/pages/Items.css b/src/pages/Items.css deleted file mode 100644 index 506124967..000000000 --- a/src/pages/Items.css +++ /dev/null @@ -1,25 +0,0 @@ -.saleProductTitle { - display: flex; - flex-direction: row; - justify-content: space-between; - align-items: center; -} - -.titleRight { - display: flex; - gap: 12px; -} - -.productSearch { - width: 325px; - height: 42px; - border-radius: 12px; - background-color: #f3f4f6; - border: none; - color: #9ca3af; - font-size: 16px; - font-weight: 400; - line-height: 24px; - padding: 9px 20px 9px 16px; - outline: none; -} diff --git a/src/pages/Items.js b/src/pages/Items.js deleted file mode 100644 index 1ad46922a..000000000 --- a/src/pages/Items.js +++ /dev/null @@ -1,62 +0,0 @@ -import ProductList from '../components/ProductList'; -import BestProductList from '../components/BestProductList'; -import Button from '../components/Button'; -import { useEffect, useState } from 'react'; -import { getProducts } from '../api'; -import './Items.css'; -import { Link, useNavigate } from 'react-router-dom'; - -function Items() { - - const [order, setOrder] = useState('recent'); - const [item, setItem] = useState([]); - - const SortedItems = item.sort((a, b) => b[order] - a[order]); - - const bestItems = item.sort((a, b) => b['favorite'] - a['favorite']); - - const handleFavorite = () => setOrder('favorite'); - - const handleRecent = () => setOrder('recent'); - - const navigate = useNavigate(); - - const handleLoad = async (orderQuery) => { - const { list } = await getProducts(orderQuery); - setItem(list); - } - - useEffect(() => { - handleLoad(order); - }, [order]) - - const handleAddItemClick = () => { - navigate('/additem'); - } - - return ( -
-

베스트 상품

- - -
-

판매 중인 상품

-
- - - - -
-
- - - -
- ) - -} - -export default Items; \ No newline at end of file diff --git a/src/pages/NotFound.js b/src/pages/NotFound.js deleted file mode 100644 index 251b65440..000000000 --- a/src/pages/NotFound.js +++ /dev/null @@ -1,15 +0,0 @@ - - -function NotFound() { - - return ( - <> -

??????

-

??????

-

??????페이지를 찾을수 없습니다

- - ) - -} - -export default NotFound; \ No newline at end of file From db773a87bdb68261d8f28a5ab989f5358b0f46c8 Mon Sep 17 00:00:00 2001 From: Injaeeee <97098671+Injaeeee@users.noreply.github.com> Date: Mon, 1 Jul 2024 15:55:23 +0900 Subject: [PATCH 07/12] =?UTF-8?q?=EB=B0=98=EC=9D=91=ED=98=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/FileInput.js | 51 +++++++++++++++++++++++++ src/components/ProductList.css | 2 +- src/pages/AddItem.js | 68 ++++++++++++++++++++++++++++++++++ 3 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 src/components/FileInput.js create mode 100644 src/pages/AddItem.js diff --git a/src/components/FileInput.js b/src/components/FileInput.js new file mode 100644 index 000000000..840190549 --- /dev/null +++ b/src/components/FileInput.js @@ -0,0 +1,51 @@ +import { useEffect, useRef, useState } from "react"; +import './FileInput.css'; + +function FileInput({ name, value, onChange }) { + const inputRef = useRef(); + const [preview, setPreview] = useState(); + + const handleChange = (e) => { + + const nextValue = e.target.files[0]; + onChange(name, nextValue); + }; + + const handleClearClick = () => { + const inputNode = inputRef.current; + + if (!inputNode) return; + + inputNode.value = ''; + + setPreview(null); + onChange(name, null); + + } + + useEffect(() => { + if (!value) return; + + const nextpreview = URL.createObjectURL(value); + + setPreview(nextpreview); + + }, [value]) + + return
+ + + + {preview && +
+ 이미지 미리보기 + + +
} +
+ +} + +export default FileInput; \ No newline at end of file diff --git a/src/components/ProductList.css b/src/components/ProductList.css index f049e1fdb..7356af82d 100644 --- a/src/components/ProductList.css +++ b/src/components/ProductList.css @@ -23,7 +23,7 @@ padding: 0; } -@media (max-width: 744px) { +@media (max-width: 1000px) { .ProductList { width: 696px; display: grid; diff --git a/src/pages/AddItem.js b/src/pages/AddItem.js new file mode 100644 index 000000000..07b75a3ac --- /dev/null +++ b/src/pages/AddItem.js @@ -0,0 +1,68 @@ +import './Additem.css'; +import { useEffect, useState } from "react"; +import FileInput from "../components/FileInput"; + +function AddItem() { + + const [values, setValues] = useState({ + productName: '', + introduction: '', + price: 0, + tag: '', + imgFile: null, + }); + + const [isButtonDisabled, SetisButtonDisabled] = useState(true); + + useEffect(() => { + const allInput = values.introduction && values.price && values.productName && values.tag; + if (allInput) { + SetisButtonDisabled(false); + } + else { + SetisButtonDisabled(true); + } + + }, [values]) + + const handleChange = (name, value) => { + setValues((prevValues) => ({ + ...prevValues, + [name]: value, + })); + console.log(name, value); + } + + const handleInputChange = (e) => { + const { name, value } = e.target; + handleChange(name, value); + } + + const handleSubmit = (e) => { + e.preventDefault(); + console.log(values); + } + + + return ( +
+
+

상품 등록하기

+ +
+

상품 이미지

+ +

상품명

+ +

상품소개

+ +

판매가격

+ +

태그

+ + + + ) +} + +export default AddItem; \ No newline at end of file From 691e9dc15eabeacc5701b5248e48a13ddc5040db Mon Sep 17 00:00:00 2001 From: Injaeeee <97098671+Injaeeee@users.noreply.github.com> Date: Mon, 1 Jul 2024 17:08:58 +0900 Subject: [PATCH 08/12] =?UTF-8?q?=E3=85=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/AddItem.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/AddItem.js b/src/pages/AddItem.js index 07b75a3ac..8f18c5c3a 100644 --- a/src/pages/AddItem.js +++ b/src/pages/AddItem.js @@ -12,15 +12,15 @@ function AddItem() { imgFile: null, }); - const [isButtonDisabled, SetisButtonDisabled] = useState(true); + const [isButtonDisabled, setIsButtonDisabled] = useState(true); useEffect(() => { const allInput = values.introduction && values.price && values.productName && values.tag; if (allInput) { - SetisButtonDisabled(false); + setIsButtonDisabled(false); } else { - SetisButtonDisabled(true); + setIsButtonDisabled(true); } }, [values]) From 5d0412370d283783ead99bf2b0ed948d2a1d11d2 Mon Sep 17 00:00:00 2001 From: Injaeeee <97098671+Injaeeee@users.noreply.github.com> Date: Mon, 1 Jul 2024 17:51:17 +0900 Subject: [PATCH 09/12] Revert "Revert "sprint6"" This reverts commit 260c35b6dfffb738723dd187bfae66f27e10ba3e. --- package-lock.json | 154 +++++++++++++++++++++++++++++++---- package.json | 2 + src/Main.js | 24 ++++++ src/api.js | 18 +++- src/components/App.js | 55 +------------ src/components/Button.js | 15 ++-- src/components/FileInput.css | 48 +++++++++++ src/components/Topbar.js | 6 +- src/index.js | 4 +- src/pages/Additem.css | 42 ++++++++++ src/pages/Items.css | 25 ++++++ src/pages/Items.js | 62 ++++++++++++++ src/pages/NotFound.js | 15 ++++ 13 files changed, 393 insertions(+), 77 deletions(-) create mode 100644 src/Main.js create mode 100644 src/components/FileInput.css create mode 100644 src/pages/Additem.css create mode 100644 src/pages/Items.css create mode 100644 src/pages/Items.js create mode 100644 src/pages/NotFound.js diff --git a/package-lock.json b/package-lock.json index a1e590ee6..6b9988e11 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,9 @@ "@testing-library/user-event": "^13.5.0", "react": "^18.2.0", "react-dom": "^18.2.0", + "react-router-dom": "^6.24.0", "react-scripts": "5.0.1", + "styled-components": "^6.1.11", "web-vitals": "^2.1.4" } }, @@ -2270,6 +2272,24 @@ "postcss-selector-parser": "^6.0.10" } }, + "node_modules/@emotion/is-prop-valid": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@emotion/is-prop-valid/-/is-prop-valid-1.2.2.tgz", + "integrity": "sha512-uNsoYd37AFmaCdXlg6EYD1KaPOaRWRByMCYzbKUX4+hhMfrxdVSelShywL4JVaAeM/eHUOSprYBQls+/neX3pw==", + "dependencies": { + "@emotion/memoize": "^0.8.1" + } + }, + "node_modules/@emotion/memoize": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.8.1.tgz", + "integrity": "sha512-W2P2c/VRW1/1tLox0mVUalvnWXxavmv/Oum2aPsRcoDJuob75FC3Y8FbpfLwUegRcxINtGUMPq0tFCvYNTBXNA==" + }, + "node_modules/@emotion/unitless": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@emotion/unitless/-/unitless-0.8.1.tgz", + "integrity": "sha512-KOEGMu6dmJZtpadb476IsZBclKvILjopjUii3V+7MnXIQCYh8W3NgNcgwo21n9LXZX6EDIKvqfjYxXebDwxKmQ==" + }, "node_modules/@eslint-community/eslint-utils": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", @@ -3241,6 +3261,14 @@ } } }, + "node_modules/@remix-run/router": { + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.17.0.tgz", + "integrity": "sha512-2D6XaHEVvkCn682XBnipbJjgZUU7xjLtA4dGJRBVUKpEaDYOZMENZoZjAOSb7qirxt5RupjzZxz4fK2FO+EFPw==", + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/@rollup/plugin-babel": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/@rollup/plugin-babel/-/plugin-babel-5.3.1.tgz", @@ -4412,6 +4440,11 @@ "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.1.tgz", "integrity": "sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==" }, + "node_modules/@types/stylis": { + "version": "4.2.5", + "resolved": "https://registry.npmjs.org/@types/stylis/-/stylis-4.2.5.tgz", + "integrity": "sha512-1Xve+NMN7FWjY14vLoY5tL3BVEQ/n42YLwaqJIPYhotZ9uBHt87VceMwWQpzmdEt2TNXIorIFG+YeCUUW7RInw==" + }, "node_modules/@types/testing-library__jest-dom": { "version": "5.14.9", "resolved": "https://registry.npmjs.org/@types/testing-library__jest-dom/-/testing-library__jest-dom-5.14.9.tgz", @@ -5826,6 +5859,14 @@ "node": ">= 6" } }, + "node_modules/camelize": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/camelize/-/camelize-1.0.1.tgz", + "integrity": "sha512-dU+Tx2fsypxTgtLoE36npi3UqcjSSMNYfkqgmoEhtZrraP5VWq0K7FkWVTYa8eMPtnU/G2txVsfdCJTn9uzpuQ==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/caniuse-api": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/caniuse-api/-/caniuse-api-3.0.0.tgz", @@ -6261,6 +6302,14 @@ "postcss": "^8.4" } }, + "node_modules/css-color-keywords": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/css-color-keywords/-/css-color-keywords-1.0.0.tgz", + "integrity": "sha512-FyyrDHZKEjXDpNJYvVsV960FiqQyXc/LlYmsxl2BcdMb2WPx0OGRVgTg55rPSyLSNMqP52R9r8geSp7apN3Ofg==", + "engines": { + "node": ">=4" + } + }, "node_modules/css-declaration-sorter": { "version": "6.4.1", "resolved": "https://registry.npmjs.org/css-declaration-sorter/-/css-declaration-sorter-6.4.1.tgz", @@ -6442,6 +6491,16 @@ "resolved": "https://registry.npmjs.org/css-select-base-adapter/-/css-select-base-adapter-0.1.1.tgz", "integrity": "sha512-jQVeeRG70QI08vSTwf1jHxp74JoZsr2XSgETae8/xC8ovSnL2WF87GTLO86Sbwdt2lK4Umg4HnnwMO4YF3Ce7w==" }, + "node_modules/css-to-react-native": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/css-to-react-native/-/css-to-react-native-3.2.0.tgz", + "integrity": "sha512-e8RKaLXMOFii+02mOlqwjbD00KSEKqblnpO9e++1aXS1fPQOpS1YoqdVHBqPjHNoxeF2mimzVqawm2KCbEdtHQ==", + "dependencies": { + "camelize": "^1.0.0", + "css-color-keywords": "^1.0.0", + "postcss-value-parser": "^4.0.2" + } + }, "node_modules/css-tree": { "version": "1.0.0-alpha.37", "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-1.0.0-alpha.37.tgz", @@ -6635,9 +6694,9 @@ "integrity": "sha512-b0tGHbfegbhPJpxpiBPU2sCkigAqtM9O121le6bbOlgyV+NyGyCmVfJ6QW9eRjz8CpNfWEOYBIMIGRYkLwsIYg==" }, "node_modules/csstype": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.2.tgz", - "integrity": "sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==" + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz", + "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==" }, "node_modules/damerau-levenshtein": { "version": "1.0.8", @@ -12424,9 +12483,9 @@ } }, "node_modules/nanoid": { - "version": "3.3.6", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz", - "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==", + "version": "3.3.7", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", + "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", "funding": [ { "type": "github", @@ -13085,9 +13144,9 @@ } }, "node_modules/postcss": { - "version": "8.4.29", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.29.tgz", - "integrity": "sha512-cbI+jaqIeu/VGqXEarWkRCCffhjgXc0qjBtXpqJhTBohMUjUQnbBr0xqX3vEKudc4iviTewcJo5ajcec5+wdJw==", + "version": "8.4.38", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.38.tgz", + "integrity": "sha512-Wglpdk03BSfXkHoQa3b/oulrotAkwrlLDRSOb9D0bN86FdRyE9lppSp33aHNPgBa0JKCoB+drFLZkQoRRYae5A==", "funding": [ { "type": "opencollective", @@ -13103,9 +13162,9 @@ } ], "dependencies": { - "nanoid": "^3.3.6", + "nanoid": "^3.3.7", "picocolors": "^1.0.0", - "source-map-js": "^1.0.2" + "source-map-js": "^1.2.0" }, "engines": { "node": "^10 || ^12 || >=14" @@ -14671,6 +14730,36 @@ "node": ">=0.10.0" } }, + "node_modules/react-router": { + "version": "6.24.0", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.24.0.tgz", + "integrity": "sha512-sQrgJ5bXk7vbcC4BxQxeNa5UmboFm35we1AFK0VvQaz9g0LzxEIuLOhHIoZ8rnu9BO21ishGeL9no1WB76W/eg==", + "dependencies": { + "@remix-run/router": "1.17.0" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "react": ">=16.8" + } + }, + "node_modules/react-router-dom": { + "version": "6.24.0", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.24.0.tgz", + "integrity": "sha512-960sKuau6/yEwS8e+NVEidYQb1hNjAYM327gjEyXlc6r3Skf2vtwuJ2l7lssdegD2YjoKG5l8MsVyeTDlVeY8g==", + "dependencies": { + "@remix-run/router": "1.17.0", + "react-router": "6.24.0" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "react": ">=16.8", + "react-dom": ">=16.8" + } + }, "node_modules/react-scripts": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/react-scripts/-/react-scripts-5.0.1.tgz", @@ -15485,6 +15574,11 @@ "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" }, + "node_modules/shallowequal": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/shallowequal/-/shallowequal-1.1.0.tgz", + "integrity": "sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ==" + }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -15567,9 +15661,9 @@ } }, "node_modules/source-map-js": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", - "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.0.tgz", + "integrity": "sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==", "engines": { "node": ">=0.10.0" } @@ -15980,6 +16074,33 @@ "webpack": "^5.0.0" } }, + "node_modules/styled-components": { + "version": "6.1.11", + "resolved": "https://registry.npmjs.org/styled-components/-/styled-components-6.1.11.tgz", + "integrity": "sha512-Ui0jXPzbp1phYij90h12ksljKGqF8ncGx+pjrNPsSPhbUUjWT2tD1FwGo2LF6USCnbrsIhNngDfodhxbegfEOA==", + "dependencies": { + "@emotion/is-prop-valid": "1.2.2", + "@emotion/unitless": "0.8.1", + "@types/stylis": "4.2.5", + "css-to-react-native": "3.2.0", + "csstype": "3.1.3", + "postcss": "8.4.38", + "shallowequal": "1.1.0", + "stylis": "4.3.2", + "tslib": "2.6.2" + }, + "engines": { + "node": ">= 16" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/styled-components" + }, + "peerDependencies": { + "react": ">= 16.8.0", + "react-dom": ">= 16.8.0" + } + }, "node_modules/stylehacks": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/stylehacks/-/stylehacks-5.1.1.tgz", @@ -15995,6 +16116,11 @@ "postcss": "^8.2.15" } }, + "node_modules/stylis": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/stylis/-/stylis-4.3.2.tgz", + "integrity": "sha512-bhtUjWd/z6ltJiQwg0dUfxEJ+W+jdqQd8TbWLWyeIJHlnsqmGLRFFd8e5mA0AZi/zx90smXRlN66YMTcaSFifg==" + }, "node_modules/sucrase": { "version": "3.34.0", "resolved": "https://registry.npmjs.org/sucrase/-/sucrase-3.34.0.tgz", diff --git a/package.json b/package.json index 7ff0d6b58..630bf5466 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,9 @@ "@testing-library/user-event": "^13.5.0", "react": "^18.2.0", "react-dom": "^18.2.0", + "react-router-dom": "^6.24.0", "react-scripts": "5.0.1", + "styled-components": "^6.1.11", "web-vitals": "^2.1.4" }, "scripts": { diff --git a/src/Main.js b/src/Main.js new file mode 100644 index 000000000..f0f815d2e --- /dev/null +++ b/src/Main.js @@ -0,0 +1,24 @@ +import { BrowserRouter, Routes, Route } from 'react-router-dom'; +import App from "./components/App"; +import Items from './pages/Items'; +import AddItems from './pages/AddItem'; +import NotFound from './pages/NotFound'; + +function Main() { + + return ( + + + } > + + }> + }> + }> + + + + + ); +} + +export default Main; \ No newline at end of file diff --git a/src/api.js b/src/api.js index fec41c1ba..7b36c0cf1 100644 --- a/src/api.js +++ b/src/api.js @@ -1,7 +1,23 @@ +const BASE_URL = 'https://panda-market-api.vercel.app'; + export async function getProducts(order = 'recent') { const query = `orderBy=${order}`; - const response = await fetch(`https://panda-market-api.vercel.app/products?${query}`); + const response = await fetch(`${BASE_URL}/products?${query}`); + const body = await response.json(); + return body; + +} + +export async function createProducts(formData) { + + + const response = await fetch(`${BASE_URL}/products?`, + { + method: 'POST', + body: formData, + + }); const body = await response.json(); return body; diff --git a/src/components/App.js b/src/components/App.js index 8d6db2379..9036050e7 100644 --- a/src/components/App.js +++ b/src/components/App.js @@ -1,64 +1,17 @@ import Topbar from './Topbar'; import './App.css'; -import ProductList from './ProductList'; -import BestProductList from './BestProductList'; -import Button from './Button'; -import { useEffect, useState } from 'react'; -import { getProducts } from '../api'; +import { Outlet } from 'react-router-dom'; function App() { - const [order, setOrder] = useState('recent'); - const [items, setItems] = useState([]); - - const sortedItems = items.sort((a, b) => b[order] - a[order]); - - const BestItems = items.sort((a, b) => b['favorite'] - a['favorite']); - - const handleFavorite = () => setOrder('favorite'); - - const handleRecent = () => setOrder('recent'); - - - - const handleLoad = async (orderQuery) => { - const { list } = await getProducts(orderQuery); - setItems(list); - console.log(list); - } - - useEffect(() => { - handleLoad(order); - }, [order]) - return ( -
+ <> -
-

베스트 상품

- - -
-

판매 중인 상품

-
- - - - -
-
- - - -
- -
+
+ ); } diff --git a/src/components/Button.js b/src/components/Button.js index f67c28287..f30d36f5e 100644 --- a/src/components/Button.js +++ b/src/components/Button.js @@ -1,12 +1,15 @@ import './Button.css'; + + + function Button({ children, onClick, select = '' }) { - const classNames = `Button ${select}`; - return ( - - ); + const classNames = `Button ${select}`; + return ( + + ); } export default Button; diff --git a/src/components/FileInput.css b/src/components/FileInput.css new file mode 100644 index 000000000..4044d2f34 --- /dev/null +++ b/src/components/FileInput.css @@ -0,0 +1,48 @@ +.fileInputWrapper { + display: flex; + gap: 20px; +} + +.fileInput { + display: none; +} + +.fileInputButton { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + background-color: #f3f4f6; + width: 282px; + height: 282px; + border-radius: 12px; +} + +.fileInputCustom { + color: #9ca3af; + font-size: 16px; + font-weight: 400px; +} + +.imgPreviewWrapper { + position: relative; +} + +.previewImg { + width: 282px; + height: 282px; + border-radius: 12px; +} + +.imgRemoveButton { + position: absolute; + top: 10px; + right: 10px; + background-color: #3692ff; + color: #ffffff; + border: none; + border-radius: 50%; + width: 30px; + height: 30px; + font-size: 20px; +} diff --git a/src/components/Topbar.js b/src/components/Topbar.js index 84f903d62..c66e1da04 100644 --- a/src/components/Topbar.js +++ b/src/components/Topbar.js @@ -1,7 +1,7 @@ import pandaLogo from '../img/logo.png'; import './Topbar.css'; import Button from './Button' - +import { Link } from 'react-router-dom'; function Topbar() { @@ -11,8 +11,8 @@ function Topbar() { - - + + diff --git a/src/index.js b/src/index.js index 14afd6f72..6566bd7a3 100644 --- a/src/index.js +++ b/src/index.js @@ -1,10 +1,10 @@ import ReactDOM from 'react-dom/client'; -import App from "./components/App"; +import Main from './Main'; const root = ReactDOM.createRoot(document.getElementById('root')); root.render( - +
); \ No newline at end of file diff --git a/src/pages/Additem.css b/src/pages/Additem.css new file mode 100644 index 000000000..38bf78f5b --- /dev/null +++ b/src/pages/Additem.css @@ -0,0 +1,42 @@ +.button { + color: #ffffff; + border-radius: 8px; + font-size: 16px; + font-weight: 600; + width: 88px; + height: 42px; + text-decoration: none; + border: none; +} + +.disabledButton { + background-color: #9ca2af; +} + +.enabledButton { + background-color: #3692ff; +} + +.productTitle { + display: flex; + justify-content: space-between; + align-items: center; +} + +.productInput { + width: 1200px; + height: 56px; + border-radius: 12px; + background-color: #f3f4f6; + border: none; + color: #9ca3af; + font-size: 16px; + font-weight: 400; + line-height: 24px; + padding: 9px 20px 9px 16px; + outline: none; +} + +.productTextArea { + height: 200px; +} diff --git a/src/pages/Items.css b/src/pages/Items.css new file mode 100644 index 000000000..506124967 --- /dev/null +++ b/src/pages/Items.css @@ -0,0 +1,25 @@ +.saleProductTitle { + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: center; +} + +.titleRight { + display: flex; + gap: 12px; +} + +.productSearch { + width: 325px; + height: 42px; + border-radius: 12px; + background-color: #f3f4f6; + border: none; + color: #9ca3af; + font-size: 16px; + font-weight: 400; + line-height: 24px; + padding: 9px 20px 9px 16px; + outline: none; +} diff --git a/src/pages/Items.js b/src/pages/Items.js new file mode 100644 index 000000000..1ad46922a --- /dev/null +++ b/src/pages/Items.js @@ -0,0 +1,62 @@ +import ProductList from '../components/ProductList'; +import BestProductList from '../components/BestProductList'; +import Button from '../components/Button'; +import { useEffect, useState } from 'react'; +import { getProducts } from '../api'; +import './Items.css'; +import { Link, useNavigate } from 'react-router-dom'; + +function Items() { + + const [order, setOrder] = useState('recent'); + const [item, setItem] = useState([]); + + const SortedItems = item.sort((a, b) => b[order] - a[order]); + + const bestItems = item.sort((a, b) => b['favorite'] - a['favorite']); + + const handleFavorite = () => setOrder('favorite'); + + const handleRecent = () => setOrder('recent'); + + const navigate = useNavigate(); + + const handleLoad = async (orderQuery) => { + const { list } = await getProducts(orderQuery); + setItem(list); + } + + useEffect(() => { + handleLoad(order); + }, [order]) + + const handleAddItemClick = () => { + navigate('/additem'); + } + + return ( +
+

베스트 상품

+ + +
+

판매 중인 상품

+
+ + + + +
+
+ + + +
+ ) + +} + +export default Items; \ No newline at end of file diff --git a/src/pages/NotFound.js b/src/pages/NotFound.js new file mode 100644 index 000000000..251b65440 --- /dev/null +++ b/src/pages/NotFound.js @@ -0,0 +1,15 @@ + + +function NotFound() { + + return ( + <> +

??????

+

??????

+

??????페이지를 찾을수 없습니다

+ + ) + +} + +export default NotFound; \ No newline at end of file From 2bf4dd77ec3273a44bcda69b35216fcf4963ebe0 Mon Sep 17 00:00:00 2001 From: Injaeeee <97098671+Injaeeee@users.noreply.github.com> Date: Mon, 1 Jul 2024 20:13:04 +0900 Subject: [PATCH 10/12] =?UTF-8?q?bestProducts=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api.js | 4 +-- src/components/BestProductList.js | 21 ++++++++++++++- src/pages/Items.js | 44 ++++++++++++++++++++++++------- 3 files changed, 57 insertions(+), 12 deletions(-) diff --git a/src/api.js b/src/api.js index 7b36c0cf1..2b49877ee 100644 --- a/src/api.js +++ b/src/api.js @@ -1,9 +1,9 @@ const BASE_URL = 'https://panda-market-api.vercel.app'; -export async function getProducts(order = 'recent') { +export async function getProducts({ order = 'recent', page = 1, pageSize }) { const query = `orderBy=${order}`; - const response = await fetch(`${BASE_URL}/products?${query}`); + const response = await fetch(`${BASE_URL}/products?${query}&page=${page}&pageSize=${pageSize}`); const body = await response.json(); return body; diff --git a/src/components/BestProductList.js b/src/components/BestProductList.js index 4e47e36be..56382fd2c 100644 --- a/src/components/BestProductList.js +++ b/src/components/BestProductList.js @@ -1,7 +1,10 @@ +import { useEffect, useState } from 'react'; +import { getProducts } from '../api'; import './BestProductList.css'; function BestProductListItem({ item }) { + return (
{item.name} @@ -13,7 +16,23 @@ function BestProductListItem({ item }) { } -function BestProductList({ items }) { +function BestProductList() { + + + const [items, setItems] = useState([]); + + + + + const handleLoad = async () => { + const { list } = await getProducts({ order: 'favorite', page: 1, pageSize: 10 }); + setItems(list); + } + + + useEffect(() => { + handleLoad(); + }, []); const displayedItems = items.slice(0, 4); return ( diff --git a/src/pages/Items.js b/src/pages/Items.js index 1ad46922a..7a6c23127 100644 --- a/src/pages/Items.js +++ b/src/pages/Items.js @@ -7,28 +7,43 @@ import './Items.css'; import { Link, useNavigate } from 'react-router-dom'; function Items() { + const navigate = useNavigate(); const [order, setOrder] = useState('recent'); const [item, setItem] = useState([]); + const [totalPages, setTotalPages] = useState(1); + const [currentPage, setCurrentPage] = useState(1); + const [pageSize, setPageSize] = useState(2); - const SortedItems = item.sort((a, b) => b[order] - a[order]); + useEffect(() => { + handleLoadMore({ order, page: currentPage, pageSize }); + }, [order]) + + useEffect(() => { + + setTotalPages(Math.ceil(item.length / pageSize)); + //Math.ceil(전체 컨텐츠 개수 / 한 페이지에 보여주고자 하는 컨텐츠의 개수) + console.log(totalPages); + + }, [item]) - const bestItems = item.sort((a, b) => b['favorite'] - a['favorite']); + + + const SortedItems = item.sort((a, b) => b[order] - a[order]); const handleFavorite = () => setOrder('favorite'); const handleRecent = () => setOrder('recent'); - const navigate = useNavigate(); - const handleLoad = async (orderQuery) => { const { list } = await getProducts(orderQuery); setItem(list); + } - useEffect(() => { - handleLoad(order); - }, [order]) + const handleLoadMore = async () => { + await handleLoad({ order, page: currentPage, pageSize }); + } const handleAddItemClick = () => { navigate('/additem'); @@ -37,7 +52,7 @@ function Items() { return (

베스트 상품

- +

판매 중인 상품

@@ -53,7 +68,18 @@ function Items() {
- +
+ + {Array.from({ length: totalPages }, (_, i) => ( + + ))} + +
) From 218b102972668cbaa2b9648089e4a8cc3ecde7e0 Mon Sep 17 00:00:00 2001 From: Injaeeee <97098671+Injaeeee@users.noreply.github.com> Date: Fri, 5 Jul 2024 19:05:06 +0900 Subject: [PATCH 11/12] =?UTF-8?q?=EB=8C=93=EA=B8=80=20api=20=EB=B0=9B?= =?UTF-8?q?=EC=95=84=EC=98=A4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Main.js | 7 +- src/api.js | 17 ++- src/components/App.js | 2 +- .../{ => BestProductList}/BestProductList.css | 2 + .../{ => BestProductList}/BestProductList.js | 17 +-- src/components/{ => Button}/Button.css | 10 ++ src/components/{ => Button}/Button.js | 4 +- src/components/CommentList/CommentList.css | 43 ++++++ src/components/CommentList/CommentList.js | 57 ++++++++ src/components/{ => FileInput}/FileInput.css | 0 src/components/{ => FileInput}/FileInput.js | 0 .../{ => ProductList}/ProductList.css | 2 + .../{ => ProductList}/ProductList.js | 14 +- src/components/{ => Topbar}/Topbar.css | 0 src/components/{ => Topbar}/Topbar.js | 4 +- src/components/pageNation/PageNation.css | 12 ++ src/components/pageNation/PageNation.js | 22 ++++ src/img/Img_inquiry_empty.png | Bin 0 -> 6785 bytes src/img/ic_back.png | Bin 0 -> 338 bytes src/img/ic_heart.png | Bin 0 -> 867 bytes src/pages/AddItem.js | 2 +- src/pages/Items.css | 6 + src/pages/Items.js | 51 +++---- src/pages/Products.css | 124 ++++++++++++++++++ src/pages/Products.js | 74 +++++++++++ 25 files changed, 419 insertions(+), 51 deletions(-) rename src/components/{ => BestProductList}/BestProductList.css (88%) rename src/components/{ => BestProductList}/BestProductList.js (72%) rename src/components/{ => Button}/Button.css (76%) rename src/components/{ => Button}/Button.js (57%) create mode 100644 src/components/CommentList/CommentList.css create mode 100644 src/components/CommentList/CommentList.js rename src/components/{ => FileInput}/FileInput.css (100%) rename src/components/{ => FileInput}/FileInput.js (100%) rename src/components/{ => ProductList}/ProductList.css (91%) rename src/components/{ => ProductList}/ProductList.js (64%) rename src/components/{ => Topbar}/Topbar.css (100%) rename src/components/{ => Topbar}/Topbar.js (86%) create mode 100644 src/components/pageNation/PageNation.css create mode 100644 src/components/pageNation/PageNation.js create mode 100644 src/img/Img_inquiry_empty.png create mode 100644 src/img/ic_back.png create mode 100644 src/img/ic_heart.png create mode 100644 src/pages/Products.css create mode 100644 src/pages/Products.js diff --git a/src/Main.js b/src/Main.js index f0f815d2e..93cad085c 100644 --- a/src/Main.js +++ b/src/Main.js @@ -3,6 +3,7 @@ import App from "./components/App"; import Items from './pages/Items'; import AddItems from './pages/AddItem'; import NotFound from './pages/NotFound'; +import Products from './pages/Products'; function Main() { @@ -11,8 +12,12 @@ function Main() { } > - }> + + }> + }> + }> + }> diff --git a/src/api.js b/src/api.js index 2b49877ee..f5fa63ef9 100644 --- a/src/api.js +++ b/src/api.js @@ -6,11 +6,23 @@ export async function getProducts({ order = 'recent', page = 1, pageSize }) { const response = await fetch(`${BASE_URL}/products?${query}&page=${page}&pageSize=${pageSize}`); const body = await response.json(); return body; +} +export async function getProduct(productSlug) { + const response = await fetch(`${BASE_URL}/products/${productSlug}`); + const body = await response.json(); + return body; } -export async function createProducts(formData) { +export async function getComment(productSlug) { + const response = await fetch(`${BASE_URL}/products/${productSlug}/comments?limit=10`) + const body = await response.json(); + return body; + +} + +export async function createProducts(formData) { const response = await fetch(`${BASE_URL}/products?`, { @@ -21,5 +33,4 @@ export async function createProducts(formData) { const body = await response.json(); return body; -} - +} \ No newline at end of file diff --git a/src/components/App.js b/src/components/App.js index 9036050e7..119747d51 100644 --- a/src/components/App.js +++ b/src/components/App.js @@ -1,5 +1,5 @@ -import Topbar from './Topbar'; +import Topbar from './Topbar/Topbar' import './App.css'; import { Outlet } from 'react-router-dom'; diff --git a/src/components/BestProductList.css b/src/components/BestProductList/BestProductList.css similarity index 88% rename from src/components/BestProductList.css rename to src/components/BestProductList/BestProductList.css index 6a7768ac8..ed71340ac 100644 --- a/src/components/BestProductList.css +++ b/src/components/BestProductList/BestProductList.css @@ -15,6 +15,8 @@ display: flex; flex-direction: column; padding: 24px 0; + border: 0; + background-color: transparent; } .BestProductListItem p, diff --git a/src/components/BestProductList.js b/src/components/BestProductList/BestProductList.js similarity index 72% rename from src/components/BestProductList.js rename to src/components/BestProductList/BestProductList.js index 56382fd2c..2c642174b 100644 --- a/src/components/BestProductList.js +++ b/src/components/BestProductList/BestProductList.js @@ -1,17 +1,21 @@ import { useEffect, useState } from 'react'; -import { getProducts } from '../api'; +import { getProducts } from '../../api'; +import { Link, useNavigate } from 'react-router-dom'; import './BestProductList.css'; function BestProductListItem({ item }) { - + const navigate = useNavigate(); + const handleAddItemClick = () => { + navigate(`/items/${item.id}`); + } return ( -
+
+ ); } @@ -21,9 +25,6 @@ function BestProductList() { const [items, setItems] = useState([]); - - - const handleLoad = async () => { const { list } = await getProducts({ order: 'favorite', page: 1, pageSize: 10 }); setItems(list); diff --git a/src/components/Button.css b/src/components/Button/Button.css similarity index 76% rename from src/components/Button.css rename to src/components/Button/Button.css index 795ab07ea..9bf3517a7 100644 --- a/src/components/Button.css +++ b/src/components/Button/Button.css @@ -22,3 +22,13 @@ font-size: 18px; font-weight: 700; } + +.disable { + background-color: #9ca3af; + color: #ffffff; +} + +.inquiry { + width: 74px; + align-self: flex-end; +} diff --git a/src/components/Button.js b/src/components/Button/Button.js similarity index 57% rename from src/components/Button.js rename to src/components/Button/Button.js index f30d36f5e..b47740fe0 100644 --- a/src/components/Button.js +++ b/src/components/Button/Button.js @@ -3,8 +3,8 @@ import './Button.css'; -function Button({ children, onClick, select = '' }) { - const classNames = `Button ${select}`; +function Button({ children, onClick, select = '', width = '' }) { + const classNames = `Button ${select} ${width}`; return (
+ ); } function ProductList({ items }) { + return (
diff --git a/src/components/Topbar.css b/src/components/Topbar/Topbar.css similarity index 100% rename from src/components/Topbar.css rename to src/components/Topbar/Topbar.css diff --git a/src/components/Topbar.js b/src/components/Topbar/Topbar.js similarity index 86% rename from src/components/Topbar.js rename to src/components/Topbar/Topbar.js index c66e1da04..c6bdeca5d 100644 --- a/src/components/Topbar.js +++ b/src/components/Topbar/Topbar.js @@ -1,6 +1,6 @@ -import pandaLogo from '../img/logo.png'; +import pandaLogo from '../../img/logo.png'; import './Topbar.css'; -import Button from './Button' +import Button from '../Button/Button'; import { Link } from 'react-router-dom'; function Topbar() { diff --git a/src/components/pageNation/PageNation.css b/src/components/pageNation/PageNation.css new file mode 100644 index 000000000..524ec334b --- /dev/null +++ b/src/components/pageNation/PageNation.css @@ -0,0 +1,12 @@ +.pageButton { + width: 40px; + height: 40px; + border-radius: 40px; + background-color: #ffffff; + border: #e5e7eb 1px solid; +} + +.active { + background-color: #3692ff; + color: #ffffff; +} diff --git a/src/components/pageNation/PageNation.js b/src/components/pageNation/PageNation.js new file mode 100644 index 000000000..63555e2ff --- /dev/null +++ b/src/components/pageNation/PageNation.js @@ -0,0 +1,22 @@ +import './PageNation.css'; + +function PageNation({ totalPages, currentPage, handlePageChange }) { + + return ( +
+ + {Array.from({ length: totalPages }, (_, i) => ( + + ))} + +
+ ) +} + +export default PageNation; \ No newline at end of file diff --git a/src/img/Img_inquiry_empty.png b/src/img/Img_inquiry_empty.png new file mode 100644 index 0000000000000000000000000000000000000000..20f0821bbf96505c51821b33d6b211a59e82f486 GIT binary patch literal 6785 zcmb_>Wm6jr(=}e)ouEaEyR;P7P+WpriWDsrcY+jm0$f-q?pjEJ2B(xz+}$k{cWHTg z|AzOS*|TSMXLe>k?1!Cm;&ipui16w0(a_L{fa=Qn|M=(sfQ$1l*O}B8{v$jObyF`i zGy;nM0Ua$jpY~r9-Ai9h5v_gT zWew@H+TC+7{Fkl768DxuM2S2C5#a(Nb;K6t#jQnaiRi)Ks%5dmzN?p)Xz$V72nC4* z#0*G;f~z{q|MJ7h6q{#Ojb>M;?n7XyjrQjHx836{+GN6n{X+l0LK6cQoRg_*YAv`+ zg0fZzUZ&eEJ{MEwDe6K?pXL}DI^-lpTY%KI5TPoYq3XV zyK%#WP_Cn0!0cWb7ZN$^FL>8+F&{?SXYQk7JDYX%1@k-eVLSYsxVQ)mja~_56j<~T z!7@+HjLdkYb3HD@O=Hw!cCx7k!X6HS1z+`wl;vyKBb1|;B3>T&#@v2J3o*j81-G^owmXKbBiCD^CDRmr2%qEr=dO2j3V61K0MkO3_vrIoLB7TzrwMIx zuhbFaBTMW1Jp?pun4ZT$S$sfq099%bV;5I4enQ7H zI}xpib^hwZ8|~ai0nL&=-Y&DCD_6!t;8c_#@py>5-5$&1&z0=1$8_6Ig?Gi%x20EY zKhZEbNV{1$5S`~CL8hN|nPdZRsI=YV<2+n$lj65=cb!8pkAQTT?v2fB$PQ$*_V~H_ z3Ku3}Vggl}*)ow&5A`fG%*x(I)<9vGM@63TP7rF}q3SE27+JjHmhUg8W%@|z;f;Fsj%$j)jFvg7 zzta-0anI^vJ3cL2h0nx?37@YFY7gO^6dg^%tH+uY-zym{H^4t)Uz}~WVEh*6{34+?S0`HXFu^&K?PRr%Kn{O=rSO>`fS!)2s_=D)#{KwM zkbYoGpFGS64GZ&pDr1JRsl6H9)7zmm0B(Bos5 zO>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fojhxF#;9f8nKJIaT73upjNx+B~lq#?7T}i8Y~arC#&cQCfD91w0=-?#=>~&;#XL& zB;aO4przbS)XJ3s20(b|(!mUAuC{7~`bSRe&GC9v2`N`tq=E^kku_y1v zwv3VR$5w&er6Rmy=nNivk98Yw<_J{SCBk;`)GEK6u(66bluGfebS1qIUTv{5t3a(J ztq9(btw(akA?-->uhddzh6RmWStN|2pI_(< z;`L=14W-R4-TAk|ws8td%~;UYTr`BR`tJH_O#Hp~mu5%aA!I|8kW)W-?z7~Ltdsj z@Ejd+Ecxyi{UY?qUMl-27srqa#&$-e|Y+y7>?`v;;MBoy0K_|IUIF+!W>Dd zsX>z~Sa`H%yYXjstytou;nCK{C!@Z?EmZj_1NZA4O3a?(Gg3+t7xxuy3^}02{Iq5J z={5JQe=+X#>B^YA^n2}J`4e|HpNyTfU+&RN{!Jo%k{0_X`qVYaoy*l@O|FVhU-{jo zMfu95=eheG)gCNVET6sVfi>IYX}9%Rg?BZaN?sx;Rkhbu+f<~gKW$CTvWOjv*IhFH i$#s0qlHUCfIq%=o>i>A|)@7iV89ZJ6T-G@yGywosX@JWB literal 0 HcmV?d00001 diff --git a/src/img/ic_heart.png b/src/img/ic_heart.png new file mode 100644 index 0000000000000000000000000000000000000000..587b90cd9484d9d524ffedc1f35165b2fbf1d7df GIT binary patch literal 867 zcmV-p1DyPcP)uyf^J?|Cq#TARiN_VxC6_uY z4pmH3*pRwfa|Op09lTV@3D-6I zc7i%ENCox?VkaHi86_P_fLDDlHS-tj3+5s8I%iHHWB>5M;Y9HMOmv zgW8e0418tt%7AM7i1KC@yKIJmEHbpP;LGkwAlMLTdxVTXf5_@VCgrsJ|64hsZS0%}0<9&eA8{ z;Wo^WQ4{M&Y6k?)S&5$1O03b0;63m0dBH13bBhYjh`kSl4-v6agOvMl4kX24;}LGW!m_0-Ll$obNC2`uAeY`4&oIAe-~#TOQ26;%eaMB zyKuO-nKtNK%ZhB*d@+ID1%^-Y6za$7{X_mAB%n#Ot?zvNN|2xlB#`O6RUEJ@9D0T0 z{9+p4f@T0GRuW0cdmFy61lKptbkzCOxiT|>fJDM8trRCGj&M6vW;2)U%me~t3(Cap tCa3?P%vP}Ss4`n9IODnGXo)2rfxnYrOeo66z3Bh|002ovPDHLkV1mS~l5hY3 literal 0 HcmV?d00001 diff --git a/src/pages/AddItem.js b/src/pages/AddItem.js index 8f18c5c3a..3e47a81a0 100644 --- a/src/pages/AddItem.js +++ b/src/pages/AddItem.js @@ -1,6 +1,6 @@ import './Additem.css'; import { useEffect, useState } from "react"; -import FileInput from "../components/FileInput"; +import FileInput from '../components/FileInput/FileInput'; function AddItem() { diff --git a/src/pages/Items.css b/src/pages/Items.css index 506124967..40561b91b 100644 --- a/src/pages/Items.css +++ b/src/pages/Items.css @@ -23,3 +23,9 @@ padding: 9px 20px 9px 16px; outline: none; } + +.pagination { + display: flex; + justify-content: center; + margin-top: 20px; +} diff --git a/src/pages/Items.js b/src/pages/Items.js index 7a6c23127..2e79b458f 100644 --- a/src/pages/Items.js +++ b/src/pages/Items.js @@ -1,54 +1,55 @@ -import ProductList from '../components/ProductList'; -import BestProductList from '../components/BestProductList'; -import Button from '../components/Button'; +import ProductList from '../components/ProductList/ProductList'; +import BestProductList from '../components/BestProductList/BestProductList'; +import Button from '../components/Button/Button'; import { useEffect, useState } from 'react'; import { getProducts } from '../api'; import './Items.css'; import { Link, useNavigate } from 'react-router-dom'; +import PageNation from '../components/pageNation/PageNation'; function Items() { const navigate = useNavigate(); const [order, setOrder] = useState('recent'); const [item, setItem] = useState([]); - const [totalPages, setTotalPages] = useState(1); + const [totalCount, setTotalCount] = useState(1); const [currentPage, setCurrentPage] = useState(1); - const [pageSize, setPageSize] = useState(2); + const [pageSize, setPageSize] = useState(10); + const [totalPages, setTotalPages] = useState(0); useEffect(() => { handleLoadMore({ order, page: currentPage, pageSize }); - }, [order]) + }, [order, currentPage]) useEffect(() => { - - setTotalPages(Math.ceil(item.length / pageSize)); + setTotalPages(Math.ceil(totalCount / pageSize)); //Math.ceil(전체 컨텐츠 개수 / 한 페이지에 보여주고자 하는 컨텐츠의 개수) - console.log(totalPages); - }, [item]) - - const SortedItems = item.sort((a, b) => b[order] - a[order]); const handleFavorite = () => setOrder('favorite'); - const handleRecent = () => setOrder('recent'); + const handleLoadMore = async () => { + await handleLoad({ order, page: currentPage, pageSize }); + } + const handleLoad = async (orderQuery) => { - const { list } = await getProducts(orderQuery); + const { list, totalCount } = await getProducts(orderQuery); setItem(list); - + setTotalCount(totalCount); } - const handleLoadMore = async () => { - await handleLoad({ order, page: currentPage, pageSize }); - } const handleAddItemClick = () => { navigate('/additem'); } + const handlePageChange = (page) => { + setCurrentPage(page); + } + return (

베스트 상품

@@ -68,18 +69,8 @@ function Items() {
-
- - {Array.from({ length: totalPages }, (_, i) => ( - - ))} - -
+ +
) diff --git a/src/pages/Products.css b/src/pages/Products.css new file mode 100644 index 000000000..9851bf4e0 --- /dev/null +++ b/src/pages/Products.css @@ -0,0 +1,124 @@ +.itemWrapper { + display: flex; + gap: 24px; + padding-bottom: 30px; + border-bottom: 1px solid #e5e7eb; +} + +.itemImg { + width: 486px; + height: 486px; + border-radius: 16px; +} + +.itemLetter { + display: flex; + flex-direction: column; + gap: 24px; + width: 100%; +} + +.itemLetterTop { + display: flex; + flex-direction: column; + gap: 24px; + padding-bottom: 10px; + border-bottom: 1px solid #e5e7eb; +} + +.itemLetterBottom { + display: flex; + flex-direction: column; + flex: 1; +} + +.itemName { + font-size: 24px; + font-weight: 600; + line-height: 28.64px; +} + +.itemTitle { + font-size: 14px; + font-weight: 500; + line-height: 16.71px; + color: #4b5563; +} + +.itemPrice { + font-size: 40px; + font-weight: 600; + line-height: 47.73px; +} + +.itemitemDescription { + font-size: 14px; + font-weight: 400; + line-height: 16.71px; + color: #1f2937; +} + +.itemTags { + display: flex; + gap: 10px; + padding: 10px 0; +} + +.itemTag { + display: flex; + justify-content: center; + align-items: center; + padding: 6px 16px; + height: 36px; + border-radius: 26px; + background-color: #f3f4f6; +} + +.itemFavorite { + display: flex; + justify-content: center; + align-items: center; + gap: 10px; + padding: 6px 16px; + height: 36px; + width: 87px; + border-radius: 26px; + border: 1px solid #e5e7eb; + margin: auto 0 0; +} + +.inquiryWrapper { + display: flex; + width: auto; + flex-direction: column; + gap: 16px; + margin: 24px 0; +} + +.inquiryInput { + width: 100%; + height: 104px; + border-radius: 12px; + background-color: #f3f4f6; + border: none; + color: #9ca3af; + font-size: 16px; + font-weight: 400; + line-height: 24px; + padding: 0 16px; + outline: none; +} + +.backButton { + display: flex; + margin: 40px auto; + gap: 10px; + background-color: #3692ff; + color: #ffffff; + border-radius: 40px; + padding: 12px 71px; + font-size: 18px; + font-weight: 600; + text-decoration: none; + border: none; +} diff --git a/src/pages/Products.js b/src/pages/Products.js new file mode 100644 index 000000000..83365032f --- /dev/null +++ b/src/pages/Products.js @@ -0,0 +1,74 @@ +import { useParams } from "react-router-dom"; +import { useEffect, useState } from "react"; +import { getProduct } from '../api'; +import './Products.css'; +import Button from "../components/Button/Button"; +import { useNavigate } from 'react-router-dom'; +import favoriteImg from '../img/ic_heart.png' +import backImg from '../img/ic_back.png' +import CommentList from "../components/CommentList/CommentList"; + + +function Products() { + const navigate = useNavigate(); + const { productSlug } = useParams(); + const [item, setItem] = useState([]); + + useEffect(() => { + handleLoad(productSlug); + }, [productSlug]); + + const handleLoad = async (productSlug) => { + const list = await getProduct(productSlug); + setItem(list); + + } + + const handleBackClick = () => { + navigate('/items'); + } + + return (
+ +
+ {item.name} +
+
+ {item.name} + {item.price}원 +
+
+ 상품소개 +

{item.description}

+ + 상품태그 +
+ {item.tags && item.tags.map((tag, index) => ( +
#{tag}
+ ))} +
+
+ + {item.favoriteCount} +
+
+
+
+ +
+ + + + +
+ + + + +
) +} + +export default Products; \ No newline at end of file From b5695c330deeedd6950bac371b0394d7d055d9ae Mon Sep 17 00:00:00 2001 From: Injaeeee <97098671+Injaeeee@users.noreply.github.com> Date: Fri, 5 Jul 2024 20:36:10 +0900 Subject: [PATCH 12/12] =?UTF-8?q?=EB=93=B1=EB=A1=9D=EB=B2=84=ED=8A=BC=20?= =?UTF-8?q?=ED=99=9C=EC=84=B1=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/AddItem.js | 2 -- src/pages/Products.js | 13 ++++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/pages/AddItem.js b/src/pages/AddItem.js index 3e47a81a0..2b28708ed 100644 --- a/src/pages/AddItem.js +++ b/src/pages/AddItem.js @@ -30,7 +30,6 @@ function AddItem() { ...prevValues, [name]: value, })); - console.log(name, value); } const handleInputChange = (e) => { @@ -40,7 +39,6 @@ function AddItem() { const handleSubmit = (e) => { e.preventDefault(); - console.log(values); } diff --git a/src/pages/Products.js b/src/pages/Products.js index 83365032f..f906ef42f 100644 --- a/src/pages/Products.js +++ b/src/pages/Products.js @@ -13,23 +13,27 @@ function Products() { const navigate = useNavigate(); const { productSlug } = useParams(); const [item, setItem] = useState([]); + const [inquiry, setInquiry] = useState(''); useEffect(() => { handleLoad(productSlug); }, [productSlug]); + const handleLoad = async (productSlug) => { const list = await getProduct(productSlug); setItem(list); - } const handleBackClick = () => { navigate('/items'); } - return (
+ const handleInquriyChange = (e) => { + setInquiry(e.target.value); + } + return (
{item.name}
@@ -57,9 +61,8 @@ function Products() {
- - - + +