From 119ca568371dec363d583d417fadf26f3f3b0bc8 Mon Sep 17 00:00:00 2001 From: "wjddusgnl676@naver.com" Date: Tue, 17 Oct 2023 23:36:53 +0900 Subject: [PATCH 01/61] =?UTF-8?q?feat=20:=20update=20package.json=20(#83)?= =?UTF-8?q?=20chart.js=20=EB=8B=A4=EC=9A=B4=EB=A1=9C=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 46 ++++++++++++++++++++++++++++++++++++++++++++++ package.json | 2 ++ 2 files changed, 48 insertions(+) diff --git a/package-lock.json b/package-lock.json index 754f69c..d11270e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,11 +9,13 @@ "version": "0.1.0", "dependencies": { "axios": "^1.4.0", + "chart.js": "^4.4.0", "eslint-config-next": "13.2.4", "framer-motion": "^10.10.0", "next": "13.2.4", "pretendard": "^1.3.6", "react": "18.2.0", + "react-chartjs-2": "^5.2.0", "react-cookie": "^4.1.1", "react-dom": "18.2.0", "react-icons": "^4.8.0", @@ -443,6 +445,11 @@ "@jridgewell/sourcemap-codec": "1.4.14" } }, + "node_modules/@kurkle/color": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@kurkle/color/-/color-0.3.2.tgz", + "integrity": "sha512-fuscdXJ9G1qb7W8VdHi+IwRqij3lBkosAm4ydQtEmbY58OzHXqQhvlxqEkoz0yssNVn38bcpRWgA9PP+OGoisw==" + }, "node_modules/@next/env": { "version": "13.2.4", "resolved": "https://registry.npmjs.org/@next/env/-/env-13.2.4.tgz", @@ -1176,6 +1183,17 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, + "node_modules/chart.js": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-4.4.0.tgz", + "integrity": "sha512-vQEj6d+z0dcsKLlQvbKIMYFHd3t8W/7L2vfJIbYcfyPcRx92CsHqECpueN8qVGNlKyDcr5wBrYAYKnfu/9Q1hQ==", + "dependencies": { + "@kurkle/color": "^0.3.0" + }, + "engines": { + "pnpm": ">=7" + } + }, "node_modules/classnames": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/classnames/-/classnames-2.3.2.tgz", @@ -3524,6 +3542,15 @@ "node": ">=0.10.0" } }, + "node_modules/react-chartjs-2": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/react-chartjs-2/-/react-chartjs-2-5.2.0.tgz", + "integrity": "sha512-98iN5aguJyVSxp5U3CblRLH67J8gkfyGNbiK3c+l1QI/G4irHMPQw44aEPmjVag+YKTyQ260NcF82GTQ3bdscA==", + "peerDependencies": { + "chart.js": "^4.1.1", + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, "node_modules/react-cookie": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/react-cookie/-/react-cookie-4.1.1.tgz", @@ -4617,6 +4644,11 @@ "@jridgewell/sourcemap-codec": "1.4.14" } }, + "@kurkle/color": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@kurkle/color/-/color-0.3.2.tgz", + "integrity": "sha512-fuscdXJ9G1qb7W8VdHi+IwRqij3lBkosAm4ydQtEmbY58OzHXqQhvlxqEkoz0yssNVn38bcpRWgA9PP+OGoisw==" + }, "@next/env": { "version": "13.2.4", "resolved": "https://registry.npmjs.org/@next/env/-/env-13.2.4.tgz", @@ -5082,6 +5114,14 @@ "supports-color": "^7.1.0" } }, + "chart.js": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-4.4.0.tgz", + "integrity": "sha512-vQEj6d+z0dcsKLlQvbKIMYFHd3t8W/7L2vfJIbYcfyPcRx92CsHqECpueN8qVGNlKyDcr5wBrYAYKnfu/9Q1hQ==", + "requires": { + "@kurkle/color": "^0.3.0" + } + }, "classnames": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/classnames/-/classnames-2.3.2.tgz", @@ -6748,6 +6788,12 @@ "loose-envify": "^1.1.0" } }, + "react-chartjs-2": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/react-chartjs-2/-/react-chartjs-2-5.2.0.tgz", + "integrity": "sha512-98iN5aguJyVSxp5U3CblRLH67J8gkfyGNbiK3c+l1QI/G4irHMPQw44aEPmjVag+YKTyQ260NcF82GTQ3bdscA==", + "requires": {} + }, "react-cookie": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/react-cookie/-/react-cookie-4.1.1.tgz", diff --git a/package.json b/package.json index f9191ad..a45e904 100644 --- a/package.json +++ b/package.json @@ -10,11 +10,13 @@ }, "dependencies": { "axios": "^1.4.0", + "chart.js": "^4.4.0", "eslint-config-next": "13.2.4", "framer-motion": "^10.10.0", "next": "13.2.4", "pretendard": "^1.3.6", "react": "18.2.0", + "react-chartjs-2": "^5.2.0", "react-cookie": "^4.1.1", "react-dom": "18.2.0", "react-icons": "^4.8.0", From 6bab24efd99504690466d1da1b514976f6b00571 Mon Sep 17 00:00:00 2001 From: "wjddusgnl676@naver.com" Date: Tue, 17 Oct 2023 23:37:15 +0900 Subject: [PATCH 02/61] =?UTF-8?q?feat=20:=20update=20api/index.js=20(#83)?= =?UTF-8?q?=20=ED=86=B5=EA=B3=84=20API=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/index.js | 3 ++- yarn.lock | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/api/index.js b/api/index.js index de8c52a..9fc858d 100644 --- a/api/index.js +++ b/api/index.js @@ -1,3 +1,4 @@ export {default as guestApi} from "./guest"; export {default as userApi} from "./user"; -export {default as storeApi} from "./store"; \ No newline at end of file +export {default as storeApi} from "./store"; +export {default as statisticsApi} from "./statistics"; \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 1e2f398..8f59e78 100644 --- a/yarn.lock +++ b/yarn.lock @@ -242,6 +242,11 @@ "@jridgewell/resolve-uri" "3.1.0" "@jridgewell/sourcemap-codec" "1.4.14" +"@kurkle/color@^0.3.0": + version "0.3.2" + resolved "https://registry.npmjs.org/@kurkle/color/-/color-0.3.2.tgz" + integrity sha512-fuscdXJ9G1qb7W8VdHi+IwRqij3lBkosAm4ydQtEmbY58OzHXqQhvlxqEkoz0yssNVn38bcpRWgA9PP+OGoisw== + "@next/env@13.2.4": version "13.2.4" resolved "https://registry.npmjs.org/@next/env/-/env-13.2.4.tgz" @@ -622,6 +627,13 @@ chalk@^4.0.0: ansi-styles "^4.1.0" supports-color "^7.1.0" +chart.js@^4.1.1, chart.js@^4.4.0: + version "4.4.0" + resolved "https://registry.npmjs.org/chart.js/-/chart.js-4.4.0.tgz" + integrity sha512-vQEj6d+z0dcsKLlQvbKIMYFHd3t8W/7L2vfJIbYcfyPcRx92CsHqECpueN8qVGNlKyDcr5wBrYAYKnfu/9Q1hQ== + dependencies: + "@kurkle/color" "^0.3.0" + classnames@^2.2.5: version "2.3.2" resolved "https://registry.npmjs.org/classnames/-/classnames-2.3.2.tgz" @@ -2100,6 +2112,11 @@ queue-microtask@^1.2.2: resolved "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz" integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A== +react-chartjs-2@^5.2.0: + version "5.2.0" + resolved "https://registry.npmjs.org/react-chartjs-2/-/react-chartjs-2-5.2.0.tgz" + integrity sha512-98iN5aguJyVSxp5U3CblRLH67J8gkfyGNbiK3c+l1QI/G4irHMPQw44aEPmjVag+YKTyQ260NcF82GTQ3bdscA== + react-cookie@^4.1.1: version "4.1.1" resolved "https://registry.npmjs.org/react-cookie/-/react-cookie-4.1.1.tgz" From f4ef8d3511d66d5331169595e078b4075cfb2854 Mon Sep 17 00:00:00 2001 From: "wjddusgnl676@naver.com" Date: Tue, 17 Oct 2023 23:37:47 +0900 Subject: [PATCH 03/61] =?UTF-8?q?feat=20:=20add=20api/statistics.js=20(#83?= =?UTF-8?q?)=20statistics=20API=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/statistics.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 api/statistics.js diff --git a/api/statistics.js b/api/statistics.js new file mode 100644 index 0000000..1d62d46 --- /dev/null +++ b/api/statistics.js @@ -0,0 +1,14 @@ +import fetcher from "api/fetcher"; + +const getDailyProfit = async(id) => { + const {data} = await fetcher.get( + `api/v1/statistics/daily/profit?storeId=${id}` + ); + return data.data; +} + +const statistics = { + getDailyProfit +} + +export default statistics; \ No newline at end of file From cfa889dcdf683d6af030a6fd1e5e3f9d6eaf3d0d Mon Sep 17 00:00:00 2001 From: "wjddusgnl676@naver.com" Date: Tue, 17 Oct 2023 23:38:11 +0900 Subject: [PATCH 04/61] =?UTF-8?q?feat=20:=20add=20services/statistics/serv?= =?UTF-8?q?ice.js=20(#83)=20statistics=20API=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/statistics.service.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 services/statistics.service.js diff --git a/services/statistics.service.js b/services/statistics.service.js new file mode 100644 index 0000000..9f059cc --- /dev/null +++ b/services/statistics.service.js @@ -0,0 +1,16 @@ +import {statisticsApi} from "api" + +const getDailyProfit = async(id) => { + try { + const data = await statisticsApi.getDailyProfit(id); + return data; + } catch (error) { + throw error; + } +} + +const statisticsService = { + getDailyProfit +} + +export default statisticsService; \ No newline at end of file From cd78a0a1dd22c0d1bb157d2847cfa1d6cc373e01 Mon Sep 17 00:00:00 2001 From: "wjddusgnl676@naver.com" Date: Tue, 17 Oct 2023 23:38:37 +0900 Subject: [PATCH 05/61] =?UTF-8?q?feat=20:=20add=20hooks/useDailyProfit.js?= =?UTF-8?q?=20(#83)=20daily=20profit=20API=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hooks/useDailyProfit.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 hooks/useDailyProfit.js diff --git a/hooks/useDailyProfit.js b/hooks/useDailyProfit.js new file mode 100644 index 0000000..a637805 --- /dev/null +++ b/hooks/useDailyProfit.js @@ -0,0 +1,21 @@ +import { useEffect, useState } from "react"; +import statisticsService from "services/statistics.service"; + +const useGetDailyProfit = (id) => { + const [data, setData] = useState(""); + + useEffect(() => { + const getDailyProfit = async() => { + if (id !== undefined) { + const fetchData = await statisticsService.getDailyProfit(id); + setData(fetchData); + } + } + + getDailyProfit(); + }, [id]); + + return data; +} + +export default useGetDailyProfit; \ No newline at end of file From 5dde260aa6ccf55d889e19461cef54225c88642a Mon Sep 17 00:00:00 2001 From: "wjddusgnl676@naver.com" Date: Wed, 18 Oct 2023 01:14:01 +0900 Subject: [PATCH 06/61] =?UTF-8?q?feat=20:=20update=20api/statics.js=20(#83?= =?UTF-8?q?)=20Daily=20Revenue=20API=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/statistics.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/api/statistics.js b/api/statistics.js index 1d62d46..708a927 100644 --- a/api/statistics.js +++ b/api/statistics.js @@ -7,8 +7,16 @@ const getDailyProfit = async(id) => { return data.data; } +const getDailyRevenue = async(id) => { + const {data} = await fetcher.get( + `api/v1/statistics/daily/revenue?storeId=${id}` + ); + return data.data; +} + const statistics = { - getDailyProfit + getDailyProfit, + getDailyRevenue } export default statistics; \ No newline at end of file From 0fbc554f2fcc3f0243ba6364245fdd89ca6fc758 Mon Sep 17 00:00:00 2001 From: "wjddusgnl676@naver.com" Date: Wed, 18 Oct 2023 01:14:54 +0900 Subject: [PATCH 07/61] =?UTF-8?q?feat=20:=20add=20organisms/dailyRevenue/i?= =?UTF-8?q?ndex.js=20(#83)=20Daily=20Revenue=20API=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/organisms/dailyRevenue/index.js | 84 ++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 components/organisms/dailyRevenue/index.js diff --git a/components/organisms/dailyRevenue/index.js b/components/organisms/dailyRevenue/index.js new file mode 100644 index 0000000..65a66d8 --- /dev/null +++ b/components/organisms/dailyRevenue/index.js @@ -0,0 +1,84 @@ +import React from 'react'; +import { useEffect, useState } from "react"; + +import { + Chart as ChartJS, + LinearScale, + CategoryScale, + BarElement, + PointElement, + LineElement, + Legend, + Tooltip, + LineController, + BarController, +} from 'chart.js'; +import { Chart } from 'react-chartjs-2'; + +import useGetDailyRevenue from '@hooks/useGetDailyRevenue'; + +ChartJS.register( + LinearScale, + CategoryScale, + BarElement, + PointElement, + LineElement, + Legend, + Tooltip, + LineController, + BarController +); + +const DailyRevenue = (props) => { + + const storeId = props.id; + + const [data, setData] = useState(""); + const getDailyRevenue = useGetDailyRevenue(storeId); + + useEffect(() => { + setData(getDailyRevenue); + },[getDailyRevenue]); + + const daysOfWeek = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']; + + const orderCountsByDay = daysOfWeek.map(day => { + const dayData = data && data.filter(dataPoint => dataPoint.day === day); + const orderCountSum = dayData && dayData.reduce((total, dataPoint) => total + dataPoint.orderCount, 0); + return orderCountSum; + }); + + const options = { + responsive: true, + plugins: { + legend: { + position: 'bottom', + }, + title: { + display: true, + text: '일별 수입 통계', + }, + }, + }; + + const chartData = { + labels: daysOfWeek, + datasets: [ + { + type: 'line', + label: '해당 상품으로 판매된 수익', + data: orderCountsByDay, + // backgroundColor: 'rgba(53, 162, 235, 0.5)', + backgroundColor: 'rgba(53, 162, 235, 0.5)', + borderWidth: 2, + fill: false, + }, + ], + } + + return ( + + ) +} + +export default DailyRevenue \ No newline at end of file From e5171bf9662e898b7f8272054520312bd238201a Mon Sep 17 00:00:00 2001 From: "wjddusgnl676@naver.com" Date: Wed, 18 Oct 2023 01:15:19 +0900 Subject: [PATCH 08/61] =?UTF-8?q?feat=20:=20add=20hooks/useGetDailyRevenue?= =?UTF-8?q?.js=20(#83)=20Daily=20Revenue=20API=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hooks/useGetDailyRevenue.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 hooks/useGetDailyRevenue.js diff --git a/hooks/useGetDailyRevenue.js b/hooks/useGetDailyRevenue.js new file mode 100644 index 0000000..4093207 --- /dev/null +++ b/hooks/useGetDailyRevenue.js @@ -0,0 +1,21 @@ +import { useEffect, useState } from "react"; +import statisticsService from "services/statistics.service"; + +const useGetDailyRevenue = (id) => { + const [data, setData] = useState(""); + + useEffect(() => { + const getDailyRevenue = async() => { + if (id !== undefined) { + const fetchData = await statisticsService.getDailyRevenue(id); + setData(fetchData); + } + } + + getDailyRevenue(); + }, [id]); + + return data; +} + +export default useGetDailyRevenue; \ No newline at end of file From b655029f956e8be3d8b5b49973d35f2bf52d0fd1 Mon Sep 17 00:00:00 2001 From: "wjddusgnl676@naver.com" Date: Wed, 18 Oct 2023 01:15:42 +0900 Subject: [PATCH 09/61] =?UTF-8?q?feat=20:=20update=20services/statics.serv?= =?UTF-8?q?ice.js=20(#83)=20Daily=20Revenue=20API=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/statistics.service.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/services/statistics.service.js b/services/statistics.service.js index 9f059cc..ac34826 100644 --- a/services/statistics.service.js +++ b/services/statistics.service.js @@ -9,8 +9,18 @@ const getDailyProfit = async(id) => { } } +const getDailyRevenue = async(id) => { + try { + const data = await statisticsApi.getDailyRevenue(id); + return data; + } catch (error) { + throw error; + } +} + const statisticsService = { - getDailyProfit + getDailyProfit, + getDailyRevenue } export default statisticsService; \ No newline at end of file From 1a9ee310e7509b16e7bab44dae047339abfe72a1 Mon Sep 17 00:00:00 2001 From: "wjddusgnl676@naver.com" Date: Wed, 18 Oct 2023 01:46:52 +0900 Subject: [PATCH 10/61] =?UTF-8?q?feat=20:=20update=20api/statistics.js=20(?= =?UTF-8?q?#83)=20=EC=9B=94=EB=B3=84=20=EC=88=98=EC=9D=B5=20API=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/statistics.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/api/statistics.js b/api/statistics.js index 708a927..5bf8b12 100644 --- a/api/statistics.js +++ b/api/statistics.js @@ -14,9 +14,17 @@ const getDailyRevenue = async(id) => { return data.data; } +const getMonthlyProfit = async(id) => { + const {data} = await fetcher.get( + `/api/v1/statistics/monthly/profit?storeId=${id}` + ); + return data.data; +} + const statistics = { getDailyProfit, - getDailyRevenue + getDailyRevenue, + getMonthlyProfit } export default statistics; \ No newline at end of file From a5593b23049b322df7f5343037aa28c7c3650cd5 Mon Sep 17 00:00:00 2001 From: "wjddusgnl676@naver.com" Date: Wed, 18 Oct 2023 01:47:22 +0900 Subject: [PATCH 11/61] =?UTF-8?q?feat=20:=20add=20orgnisms/monthlyProfit/i?= =?UTF-8?q?ndex.js=20(#83)=20=EC=9B=94=EB=B3=84=20=EC=88=98=EC=9D=B5=20API?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/organisms/monthlyProfit/index.js | 71 +++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 components/organisms/monthlyProfit/index.js diff --git a/components/organisms/monthlyProfit/index.js b/components/organisms/monthlyProfit/index.js new file mode 100644 index 0000000..8097f23 --- /dev/null +++ b/components/organisms/monthlyProfit/index.js @@ -0,0 +1,71 @@ +import React from 'react'; +import { useEffect, useState } from "react"; + +import { + Chart as ChartJS, + RadialLinearScale, + PointElement, + LineElement, + Filler, + Tooltip, + Legend, +} from 'chart.js'; +import { Radar } from 'react-chartjs-2'; + +import useGetMonthlyProfit from '@hooks/useMonthlyProfit'; + +ChartJS.register( + RadialLinearScale, + PointElement, + LineElement, + Filler, + Tooltip, + Legend +); + +const MonthlyProfit = (props) => { + + const storeId = props.id; + + const [data, setData] = useState(""); + const getMonthlyProfit = useGetMonthlyProfit(storeId); + + useEffect(() => { + setData(getMonthlyProfit); + },[getMonthlyProfit]); + + const labels = data && data.map((dataPoint) => dataPoint.time); + const profitData = data && data.map((dataPoint) => dataPoint.profit); + + const options = { + responsive: true, + plugins: { + legend: { + position: 'bottom', + }, + title: { + display: true, + text: '월별 수입 통계', + }, + }, + }; + + const chartData = { + labels: labels, + datasets: [ + { + label: '월별 수입 통계', + data: profitData, + backgroundColor: 'rgba(255, 99, 132, 0.2)', + borderColor: 'rgba(255, 99, 132, 1)', + borderWidth: 1, + }, + ], + } + + return ( + + ) +} + +export default MonthlyProfit \ No newline at end of file From 05959de4829f9c4d9f46dfee72b193e5ed94969d Mon Sep 17 00:00:00 2001 From: "wjddusgnl676@naver.com" Date: Wed, 18 Oct 2023 01:47:43 +0900 Subject: [PATCH 12/61] =?UTF-8?q?feat=20:=20add=20hooks/useMonthlyProfit.j?= =?UTF-8?q?s=20(#83)=20=EC=9B=94=EB=B3=84=20=EC=88=98=EC=9D=B5=20API=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hooks/useMonthlyProfit.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 hooks/useMonthlyProfit.js diff --git a/hooks/useMonthlyProfit.js b/hooks/useMonthlyProfit.js new file mode 100644 index 0000000..fdac3eb --- /dev/null +++ b/hooks/useMonthlyProfit.js @@ -0,0 +1,21 @@ +import { useEffect, useState } from "react"; +import statisticsService from "services/statistics.service"; + +const useGetMonthlyProfit = (id) => { + const [data, setData] = useState(""); + + useEffect(() => { + const getMonthlyProfit = async() => { + if (id !== undefined) { + const fetchData = await statisticsService.getMonthlyProfit(id); + setData(fetchData); + } + } + + getMonthlyProfit(); + }, [id]); + + return data; +} + +export default useGetMonthlyProfit; \ No newline at end of file From fa2780689333f6cb146470a757d445207eae6a45 Mon Sep 17 00:00:00 2001 From: "wjddusgnl676@naver.com" Date: Wed, 18 Oct 2023 01:48:04 +0900 Subject: [PATCH 13/61] =?UTF-8?q?feat=20:=20update=20services/statistics.s?= =?UTF-8?q?ervice.js=20(#83)=20=EC=9B=94=EB=B3=84=20=EC=88=98=EC=9D=B5=20A?= =?UTF-8?q?PI=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/statistics.service.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/services/statistics.service.js b/services/statistics.service.js index ac34826..b25eb0c 100644 --- a/services/statistics.service.js +++ b/services/statistics.service.js @@ -18,9 +18,19 @@ const getDailyRevenue = async(id) => { } } +const getMonthlyProfit = async(id) => { + try { + const data = await statisticsApi.getMonthlyProfit(id); + return data; + } catch (error) { + throw error; + } +} + const statisticsService = { getDailyProfit, - getDailyRevenue + getDailyRevenue, + getMonthlyProfit } export default statisticsService; \ No newline at end of file From 1167bb7d18d5f2593af975c9fbcd081b80bd0771 Mon Sep 17 00:00:00 2001 From: "wjddusgnl676@naver.com" Date: Wed, 18 Oct 2023 22:15:43 +0900 Subject: [PATCH 14/61] =?UTF-8?q?feat=20:=20update=20api/statistics.js=20(?= =?UTF-8?q?#83)=20week=20item=20API=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/statistics.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/api/statistics.js b/api/statistics.js index 5bf8b12..10ff814 100644 --- a/api/statistics.js +++ b/api/statistics.js @@ -21,10 +21,18 @@ const getMonthlyProfit = async(id) => { return data.data; } +const getWeekItem = async(id) => { + const {data} = await fetcher.get( + `/api/v1/statistics/week/item?storeId=${id}` + ); + return data.data; +} + const statistics = { getDailyProfit, getDailyRevenue, - getMonthlyProfit + getMonthlyProfit, + getWeekItem } export default statistics; \ No newline at end of file From 9d1d7771f5ed04b3c6ae854bc32c098fb242a91e Mon Sep 17 00:00:00 2001 From: "wjddusgnl676@naver.com" Date: Wed, 18 Oct 2023 22:16:02 +0900 Subject: [PATCH 15/61] =?UTF-8?q?feat=20:=20add=20hooks/useGetWeekItem.js?= =?UTF-8?q?=20(#83)=20week=20item=20API=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hooks/useGetWeekItem.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 hooks/useGetWeekItem.js diff --git a/hooks/useGetWeekItem.js b/hooks/useGetWeekItem.js new file mode 100644 index 0000000..3f0c93f --- /dev/null +++ b/hooks/useGetWeekItem.js @@ -0,0 +1,21 @@ +import { useEffect, useState } from "react"; +import statisticsService from "services/statistics.service"; + +const useGetWeekItem = (id) => { + const [data, setData] = useState(""); + + useEffect(() => { + const getWeekItem = async() => { + if (id !== undefined) { + const fetchData = await statisticsService.getWeekItem(id); + setData(fetchData); + } + } + + getWeekItem(); + }, [id]); + + return data; +} + +export default useGetWeekItem; \ No newline at end of file From c1634c2e9f74ed5a2542ddaea3af965b338b9345 Mon Sep 17 00:00:00 2001 From: "wjddusgnl676@naver.com" Date: Wed, 18 Oct 2023 22:16:42 +0900 Subject: [PATCH 16/61] =?UTF-8?q?feat=20:=20add=20organisms/weekItem/index?= =?UTF-8?q?.js=20(#83)=20week=20item=20API=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/organisms/weekItem/index.js | 83 ++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 components/organisms/weekItem/index.js diff --git a/components/organisms/weekItem/index.js b/components/organisms/weekItem/index.js new file mode 100644 index 0000000..3868722 --- /dev/null +++ b/components/organisms/weekItem/index.js @@ -0,0 +1,83 @@ +import React from 'react'; +import { useEffect, useState } from "react"; + +import { + Chart as ChartJS, + CategoryScale, + LinearScale, + BarElement, + Title, + Tooltip, + Legend, +} from 'chart.js'; +import { Bar } from 'react-chartjs-2'; + +import useGetWeekItem from '@hooks/useGetWeekItem'; + +ChartJS.register( + CategoryScale, + LinearScale, + BarElement, + Title, + Tooltip, + Legend +); + +const WeekItem = (props) => { + + const storeId = props.id; + + const [data, setData] = useState(""); + const getWeekItem = useGetWeekItem(storeId); + + useEffect(() => { + setData(getWeekItem); + },[getWeekItem]); + + const nameArr = data && [...new Set(data.map(item => item.name))]; + + // nameArr의 각 name 별로 count의 합계를 계산하여 countArr에 저장 + const countArr = data && nameArr.map(name => { + const sum = data + .filter(item => item.name === name) + .reduce((total, item) => total + item.count, 0); + return sum ; + }); + + const options = { + indexAxis: 'y', + elements: { + bar: { + borderWidth: 2, + }, + }, + responsive: true, + plugins: { + legend: { + position: 'bottom', + }, + title: { + display: true, + text: '일주간 아이템 별 총 개수', + }, + }, + }; + + const chartData = { + labels: nameArr, + datasets: [ + { + label: '일주간 아이템 별 총 개수', + data: countArr, + borderColor: 'rgb(53, 162, 235)', + backgroundColor: 'rgba(53, 162, 235, 0.5)', + }, + ], + } + + return ( + + ) +} + +export default WeekItem \ No newline at end of file From 9d7a1f43e3f5591c6ed8013e34f20a42324163be Mon Sep 17 00:00:00 2001 From: "wjddusgnl676@naver.com" Date: Wed, 18 Oct 2023 22:25:36 +0900 Subject: [PATCH 17/61] =?UTF-8?q?feat=20:=20update=20services/statistics.s?= =?UTF-8?q?ervice.js=20(#83)=20week=20item=20API=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/statistics.service.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/services/statistics.service.js b/services/statistics.service.js index b25eb0c..9146b15 100644 --- a/services/statistics.service.js +++ b/services/statistics.service.js @@ -27,10 +27,20 @@ const getMonthlyProfit = async(id) => { } } +const getWeekItem = async(id) => { + try { + const data = await statisticsApi.getWeekItem(id); + return data; + } catch (error) { + throw error; + } +} + const statisticsService = { getDailyProfit, getDailyRevenue, - getMonthlyProfit + getMonthlyProfit, + getWeekItem } export default statisticsService; \ No newline at end of file From 0a9acf54ada32f1923541d604b49aa2ceda34821 Mon Sep 17 00:00:00 2001 From: "wjddusgnl676@naver.com" Date: Wed, 18 Oct 2023 22:26:00 +0900 Subject: [PATCH 18/61] =?UTF-8?q?feat=20:=20update=20organisms/dailyRevenu?= =?UTF-8?q?e/index.js=20(#83)=20label=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/organisms/dailyRevenue/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/organisms/dailyRevenue/index.js b/components/organisms/dailyRevenue/index.js index 65a66d8..3514d5f 100644 --- a/components/organisms/dailyRevenue/index.js +++ b/components/organisms/dailyRevenue/index.js @@ -66,7 +66,7 @@ const DailyRevenue = (props) => { datasets: [ { type: 'line', - label: '해당 상품으로 판매된 수익', + label: '요일별 총 개수', data: orderCountsByDay, // backgroundColor: 'rgba(53, 162, 235, 0.5)', backgroundColor: 'rgba(53, 162, 235, 0.5)', From 2239791fe18e22e570e4fa0f76a19685b1ff227b Mon Sep 17 00:00:00 2001 From: "wjddusgnl676@naver.com" Date: Wed, 18 Oct 2023 22:49:12 +0900 Subject: [PATCH 19/61] =?UTF-8?q?feat=20:=20update=20api/index.js=20(#83)?= =?UTF-8?q?=20prediction=20API=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/index.js b/api/index.js index 9fc858d..c964868 100644 --- a/api/index.js +++ b/api/index.js @@ -1,4 +1,5 @@ export {default as guestApi} from "./guest"; export {default as userApi} from "./user"; export {default as storeApi} from "./store"; -export {default as statisticsApi} from "./statistics"; \ No newline at end of file +export {default as statisticsApi} from "./statistics"; +export {default as predictionApi} from "./prediction"; \ No newline at end of file From 7f8789c11192b3de008b4a9321bf92b6ded4ce6d Mon Sep 17 00:00:00 2001 From: "wjddusgnl676@naver.com" Date: Wed, 18 Oct 2023 22:49:32 +0900 Subject: [PATCH 20/61] =?UTF-8?q?feat=20:=20add=20api/prediction.js=20(#83?= =?UTF-8?q?)=20prediction=20API=20=ED=8C=8C=EC=9D=BC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/prediction.js | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 api/prediction.js diff --git a/api/prediction.js b/api/prediction.js new file mode 100644 index 0000000..f6fa7f7 --- /dev/null +++ b/api/prediction.js @@ -0,0 +1,8 @@ +import fetcher from "api/fetcher"; + + +const prediction = { + +} + +export default prediction; \ No newline at end of file From ab526aac72b15836769a2b5c08864129af1a2c0d Mon Sep 17 00:00:00 2001 From: "wjddusgnl676@naver.com" Date: Wed, 18 Oct 2023 22:49:57 +0900 Subject: [PATCH 21/61] =?UTF-8?q?feat=20:=20add=20services/prediction.serv?= =?UTF-8?q?ice.js=20(#83)=20prediction=20API=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/prediction.service.js | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 services/prediction.service.js diff --git a/services/prediction.service.js b/services/prediction.service.js new file mode 100644 index 0000000..4446232 --- /dev/null +++ b/services/prediction.service.js @@ -0,0 +1,7 @@ +import {predictionApi} from "api" + +const predictionService = { + +} + +export default predictionService; \ No newline at end of file From 773e8fe2b3956754d4e8331c11cb8dcfce3fcb90 Mon Sep 17 00:00:00 2001 From: "wjddusgnl676@naver.com" Date: Wed, 18 Oct 2023 23:42:09 +0900 Subject: [PATCH 22/61] =?UTF-8?q?feat=20:=20update=20api/prediction.js=20(?= =?UTF-8?q?#83)=20=EC=98=88=EC=B8=A1=20API=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/prediction.js | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/api/prediction.js b/api/prediction.js index f6fa7f7..9f62ec6 100644 --- a/api/prediction.js +++ b/api/prediction.js @@ -1,8 +1,38 @@ import fetcher from "api/fetcher"; +const getDailyItem = async(id) => { + const {data} = await fetcher.get( + `api/v1/statistics/daily/item?storeId=${id}` + ); + return data.data; +} + +const getDailyItemTomorrow = async(id) => { + const {data} = await fetcher.get( + `api/v1/statistics/daily/item/tomorrow?storeId=${id}` + ); + return data.data; +} + +const getProfit = async(id) => { + const {data} = await fetcher.get( + `api/v1/statistics/profit?storeId=${id}` + ); + return data.data; +} + +const getProfitTomorrow = async(id) => { + const {data} = await fetcher.get( + `api/v1/statistics/profit/tomorrow?storeId=${id}` + ); + return data.data; +} const prediction = { - + getDailyItem, + getDailyItemTomorrow, + getProfit, + getProfitTomorrow } export default prediction; \ No newline at end of file From 314cb7c4eeb854aad51e2e3264ae8eb367961c22 Mon Sep 17 00:00:00 2001 From: "wjddusgnl676@naver.com" Date: Wed, 18 Oct 2023 23:42:35 +0900 Subject: [PATCH 23/61] =?UTF-8?q?feat=20:=20update=20services/prediction.s?= =?UTF-8?q?ervice.js=20(#83)=20=EC=98=88=EC=B8=A1=20API=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/prediction.service.js | 41 +++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/services/prediction.service.js b/services/prediction.service.js index 4446232..947d11c 100644 --- a/services/prediction.service.js +++ b/services/prediction.service.js @@ -1,7 +1,46 @@ import {predictionApi} from "api" +const getDailyItem = async(id) => { + try { + const data = await statisticsApi.getWeekItem(id); + return data; + } catch (error) { + throw error; + } +} + +const getDailyItemTomorrow = async(id) => { + try { + const data = await statisticsApi.getWeekItem(id); + return data; + } catch (error) { + throw error; + } +} + +const getProfit = async(id) => { + try { + const data = await statisticsApi.getWeekItem(id); + return data; + } catch (error) { + throw error; + } +} + +const getProfitTomorrow = async(id) => { + try { + const data = await statisticsApi.getWeekItem(id); + return data; + } catch (error) { + throw error; + } +} + const predictionService = { - + getDailyItem, + getDailyItemTomorrow, + getProfit, + getProfitTomorrow } export default predictionService; \ No newline at end of file From 9d14d62c67b6c4b1a2f02b8db51024f48351e695 Mon Sep 17 00:00:00 2001 From: "wjddusgnl676@naver.com" Date: Wed, 18 Oct 2023 23:43:11 +0900 Subject: [PATCH 24/61] =?UTF-8?q?feat=20:=20update=20templates/mystoreTemp?= =?UTF-8?q?late/index.js=20(#83)=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EB=B2=84?= =?UTF-8?q?=ED=8A=BC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/templates/mystoreTemplate/index.js | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/components/templates/mystoreTemplate/index.js b/components/templates/mystoreTemplate/index.js index 1d306d0..47f55b2 100644 --- a/components/templates/mystoreTemplate/index.js +++ b/components/templates/mystoreTemplate/index.js @@ -2,6 +2,8 @@ import Router, { useRouter } from 'next/router'; import Text from '@components/atoms/text'; import Image from '@components/atoms/image'; +import Button from '@components/atoms/button'; + import { WholeDiv } from './style'; const MystoreTemplate = ({data}) => { @@ -12,12 +14,32 @@ const MystoreTemplate = ({data}) => { query: { id: data.storeId, storeName: data.name }, }) } + + const router = useRouter(); + + const statisticsOnClick = () => { + router.push({ + pathname: '/statistics', + query: { id: data.storeId }, + }) + } + + const predictionOnClick = () => { + router.push({ + pathname: '/predictio', + query: { id: data.storeId }, + }) + } return ( - - - - + +
+ + + +
+