-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
297 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { | ||
Chart as ChartJS, | ||
CategoryScale, | ||
LinearScale, | ||
PointElement, | ||
LineElement, | ||
Tooltip, | ||
Legend, | ||
ChartOptions, | ||
ChartData, | ||
Filler, | ||
} from "chart.js"; | ||
import { Line } from "react-chartjs-2"; | ||
|
||
ChartJS.register( | ||
CategoryScale, | ||
LinearScale, | ||
PointElement, | ||
LineElement, | ||
Tooltip, | ||
Legend, | ||
Filler | ||
); | ||
|
||
interface ChartProps { | ||
data: number[]; | ||
labelTitle: string; | ||
label: string[]; | ||
} | ||
|
||
const Chart = ({ data, labelTitle, label }: ChartProps) => { | ||
const chartData: ChartData<"line"> = { | ||
labels: label, | ||
datasets: [ | ||
{ | ||
label: labelTitle, | ||
data: data, | ||
borderColor: labelTitle !== "매출액" ? "#FF6854" : "#657166", | ||
backgroundColor: labelTitle !== "매출액" ? "#ff68546a" : "#6571666a", | ||
fill: true, | ||
pointRadius: 6, | ||
pointHoverRadius: 8, // 마우스 올릴 때 점 크기 | ||
pointBackgroundColor: labelTitle !== "매출액" ? "#FF6854" : "#657166", // 점 내부 색상 | ||
pointBorderColor: labelTitle !== "매출액" ? "#FF6854" : "#657166", // 점 테두리 색상 | ||
pointBorderWidth: 2, // 점 테두리 두께 | ||
}, | ||
], | ||
}; | ||
|
||
const options: ChartOptions<"line"> = { | ||
responsive: true, | ||
plugins: { | ||
legend: { | ||
display: true, | ||
position: "bottom", | ||
}, | ||
}, | ||
scales: { | ||
y: { | ||
beginAtZero: true, | ||
max: Math.max(...data) + 30, | ||
}, | ||
}, | ||
}; | ||
|
||
return ( | ||
<div className=""> | ||
<Line data={chartData} options={options} height={50} /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Chart; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { twMerge } from "tailwind-merge"; | ||
import Chart from "./Chart"; | ||
import { useState } from "react"; | ||
|
||
const PAY_DATA_FILTER = ["일일 매출", "월간 매출", "연간 매출"]; | ||
|
||
const DashBoard = () => { | ||
const [payDataTab, setPayDataTab] = useState("일일 매출"); | ||
|
||
return ( | ||
<div className="pl-[150px] pr-5 min-h-[calc(100vh-50px)] bg-gradient-to-t from-white/0 via-[#BFCDB7]/30 to-white/0"> | ||
<h1 className="font-bold text-[27px] mb-4">회원 데이터</h1> | ||
<div className=" px-2"> | ||
<p className="text-main-green font-bold mb-2">누적 회원 수</p> | ||
<div | ||
className="border border-main-green02 w-[170px] h-[50px] flex gap-2 | ||
items-center justify-center text-main-green01 font-bold rounded-[10px]" | ||
> | ||
총 구독 회원 <p className="text-[25px] text-header-red">127명</p> | ||
</div> | ||
<Chart | ||
data={[60, 80, 120, 120, 140]} | ||
labelTitle="누적 회원 수" | ||
label={["4주전", "3주전", "2주전", "1주전", "오늘"]} | ||
/> | ||
<div className="mt-10"> | ||
<p className="font-bold mb-5">신규 회원 수</p> | ||
<Chart | ||
data={[30, 20, 40, 0, 15]} | ||
labelTitle="신규 회원 수" | ||
label={["4주전", "3주전", "2주전", "1주전", "오늘"]} | ||
/> | ||
</div> | ||
|
||
{/* 결제 데이터 */} | ||
<div className="mt-10"> | ||
<p className="font-bold text-[20px] mb-5">결제 데이터</p> | ||
|
||
<ul className="flex gap-5 font-bold mb-5"> | ||
{PAY_DATA_FILTER.map((payData, idx) => { | ||
return ( | ||
<li | ||
key={idx} | ||
className={twMerge( | ||
`w-[80px] h-[30px] bg-white flex items-center justify-center | ||
border border-header-green rounded-[3px] text-header-green cursor-pointer | ||
${ | ||
payDataTab === payData && | ||
"text-main-beige01 bg-header-green border-none" | ||
}` | ||
)} | ||
onClick={() => setPayDataTab(payData)} | ||
> | ||
{payData} | ||
</li> | ||
); | ||
})} | ||
</ul> | ||
<Chart | ||
labelTitle="매출액" | ||
data={[15, 13, 20, 0, 10]} | ||
label={["1/17", "1/22", "2/1", "2/11", "오늘"]} | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default DashBoard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { useSearchParams } from "react-router"; | ||
import DashBoard from "../components/Admin/DashBoard"; | ||
|
||
const Admin = () => { | ||
const [tabName] = useSearchParams(); | ||
console.log(tabName.get("tab")); | ||
return ( | ||
<div> | ||
{(tabName.get("tab") === "dashboard" || !tabName.get("tab")) && ( | ||
<DashBoard /> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default Admin; |