From d0def142a93604ad58713b654cf0f1c12851cdd8 Mon Sep 17 00:00:00 2001 From: joonhan Date: Mon, 11 Sep 2023 18:31:16 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20[WIP]=20feat:=20Add=20AttendanceCal?= =?UTF-8?q?endar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/SettingPage/AttendanceCalendar.jsx | 91 ++++++++++++++++++++ src/pages/SettingPage/index.jsx | 22 +++-- 2 files changed, 105 insertions(+), 8 deletions(-) create mode 100644 src/pages/SettingPage/AttendanceCalendar.jsx diff --git a/src/pages/SettingPage/AttendanceCalendar.jsx b/src/pages/SettingPage/AttendanceCalendar.jsx new file mode 100644 index 0000000..7fb3fe7 --- /dev/null +++ b/src/pages/SettingPage/AttendanceCalendar.jsx @@ -0,0 +1,91 @@ +import { useEffect, useState } from "react"; + +import Grid from "@mui/material/Grid"; +import Box from "@mui/material/Box"; +import Card from "@mui/material/Card"; +import CardContent from "@mui/material/CardContent"; +import Badge from "@mui/material/Badge"; +import { AdapterDateFns } from "@mui/x-date-pickers/AdapterDateFns"; +import { LocalizationProvider } from "@mui/x-date-pickers/LocalizationProvider"; +import { PickersDay } from "@mui/x-date-pickers/PickersDay"; +import { DateCalendar } from "@mui/x-date-pickers/DateCalendar"; +import Typography from "@mui/material/Typography"; + +import { format } from "date-fns"; + +import apiManager from "api/apiManager"; + +const DateType = { + WEEKDAY: 0, + WEEKEND: 1, + SUPPLEMENT: 2, +}; + +function ServerDay(props) { + const { dateMockup, day, outsideCurrentMonth, ...other } = props; + + const dayString = format(props.day, "d"); + const type = dateMockup.get(Number(dayString)); + let badgeIcon; + + if (type === DateType.WEEKDAY) { + badgeIcon = "🌞"; + } else if (type === DateType.WEEKEND) { + badgeIcon = "🌚"; + } else if (type === DateType.SUPPLEMENT) { + badgeIcon = "πŸ’§"; + } + + return ( + + + + ); +} + +const dateMockup = new Map(); +dateMockup.set(1, DateType.WEEKDAY); +dateMockup.set(2, DateType.WEEKDAY); +dateMockup.set(3, DateType.WEEKEND); +dateMockup.set(4, DateType.SUPPLEMENT); + +function AttendanceCalendar(props) { + const { data } = props; + + const handleChange = (date) => { + const dayString = format(date, "d"); + const dayNumber = Number(dayString); + dateMockup.set(dayNumber, DateType.SUPPLEMENT); + }; + + return ( + + + + + 월별 μΆœμ„ 일자 관리 + + + + + + + + + + ); +} + +export default AttendanceCalendar; diff --git a/src/pages/SettingPage/index.jsx b/src/pages/SettingPage/index.jsx index 206ff0d..90c1d1a 100644 --- a/src/pages/SettingPage/index.jsx +++ b/src/pages/SettingPage/index.jsx @@ -1,9 +1,12 @@ import { useState, useEffect } from "react"; -import OperatorTable from "./OperatorTable"; + import Container from "@mui/material/Container"; import Grid from "@mui/material/Grid"; import Alert from "@mui/material/Alert"; import Snackbar from "@mui/material/Snackbar"; + +import AttendanceCalendar from "./AttendanceCalendar"; +import OperatorTable from "./OperatorTable"; import apiManager from "api/apiManager"; function SettingPage() { @@ -14,13 +17,15 @@ function SettingPage() { const loadUserList = async () => { try { const response = await apiManager.get("/user/operatorStatus"); - setUserList(response.data.map(row => { - if (row.isOperator === true) { - return {...row, isOperator: "βœ…"} - } else { - return {...row, isOperator: "❌"} - } - })); + setUserList( + response.data.map((row) => { + if (row.isOperator === true) { + return { ...row, isOperator: "βœ…" }; + } else { + return { ...row, isOperator: "❌" }; + } + }) + ); } catch (error) { setSnackbarOpen(true); setErrorMessage(error.response.data.message); @@ -44,6 +49,7 @@ function SettingPage() { {/* EXPLAIN: μ˜€νΌλ ˆμ΄ν„° κΆŒν•œ μˆ˜μ • */} +