From d1b7ac79ce7940d4984c912a761d580aa490e908 Mon Sep 17 00:00:00 2001 From: leejin_rho Date: Sun, 30 Jun 2024 18:00:45 +0900 Subject: [PATCH 01/14] =?UTF-8?q?fix:=20InfoCalendar=20UI=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/calendar/FilterBox.tsx | 13 ++++++-- components/calendar/InfoCalendar.tsx | 16 ++++++++-- pages/calendar.tsx | 44 +++++++++++++++++++++++++--- pages/login.tsx | 2 +- 4 files changed, 65 insertions(+), 10 deletions(-) diff --git a/components/calendar/FilterBox.tsx b/components/calendar/FilterBox.tsx index 40f728f..b0d1088 100644 --- a/components/calendar/FilterBox.tsx +++ b/components/calendar/FilterBox.tsx @@ -1,8 +1,17 @@ import FilterArrow from "@/public/svgs/FilterArrow.svg"; -const FilterBox = ({ filterName }) => { +const FilterBox = ({ + filterName, + onClick, +}: { + filterName: string; + onClick: () => void; +}) => { return ( -
+
{filterName}
diff --git a/components/calendar/InfoCalendar.tsx b/components/calendar/InfoCalendar.tsx index 381d1c5..e2f6dcc 100644 --- a/components/calendar/InfoCalendar.tsx +++ b/components/calendar/InfoCalendar.tsx @@ -80,7 +80,7 @@ export default function InfoCalendar() { }; return ( -
+
{ const date = new Date(); console.log(date); + + const [isDrop, setIsDrop] = useState({ + categoryDrop: false, + regionDrop: false, + }); + return (
- - + { + setIsDrop(!isDrop); + }} + /> + {isDrop ? ( +
    + {options.map((option, index) => ( +
  • {}} + > + {option} +
  • + ))} +
+ ) : null} + { + console.log("지역"); + }} + />
-
+
diff --git a/pages/login.tsx b/pages/login.tsx index 6543f99..dcfdb24 100644 --- a/pages/login.tsx +++ b/pages/login.tsx @@ -92,7 +92,7 @@ const Login: NextPage = () => { From ef75a707a9cfc6474afd170234221779704f96fa Mon Sep 17 00:00:00 2001 From: leejin_rho Date: Mon, 1 Jul 2024 16:23:19 +0900 Subject: [PATCH 02/14] =?UTF-8?q?feat:=20challengeDetail=20=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20calendar=20api=20=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apis/calendar.ts | 1 - apis/challenge.ts | 20 +++++- apis/hooks/challenge.ts | 12 +++- components/challenge/ChallengeCalendar.tsx | 39 +++++++---- pages/calendar.tsx | 77 ++++++++++++++-------- 5 files changed, 105 insertions(+), 44 deletions(-) diff --git a/apis/calendar.ts b/apis/calendar.ts index 19d1183..49181e3 100644 --- a/apis/calendar.ts +++ b/apis/calendar.ts @@ -48,6 +48,5 @@ export const getProgramDetail = async ( ): Promise => { // const response = await client.get(`/programs/${programIdx}`); const response = await client.get(`/programs/2`); - // console.log("calenderDetail", response.data.result); return response.data.result; }; diff --git a/apis/challenge.ts b/apis/challenge.ts index 4eea8ac..ff79fbf 100644 --- a/apis/challenge.ts +++ b/apis/challenge.ts @@ -18,4 +18,22 @@ async function getMyChallengeList(): Promise { return data; } -export { getMyChallengeList }; +type AttendanceDate = { + year: number; + month: number; + day: number; +}; + +export interface GetChallengeDetailBody { + attendanceDate: AttendanceDate; +} + +async function getChallengDetail(): Promise { + const response = await client.get( + `/challenges/attendance/2?year=2024&month=6`, + ); + // console.log("challengeData", response.data.result); + return response.data.result; +} + +export { getMyChallengeList, getChallengDetail }; diff --git a/apis/hooks/challenge.ts b/apis/hooks/challenge.ts index 0ab0369..80128a4 100644 --- a/apis/hooks/challenge.ts +++ b/apis/hooks/challenge.ts @@ -1,4 +1,4 @@ -import { getMyChallengeList } from "../challenge"; +import { getMyChallengeList, getChallengDetail } from "../challenge"; import { useQuery } from "@tanstack/react-query"; function useGetMyChallengeList() { @@ -10,4 +10,12 @@ function useGetMyChallengeList() { return { data }; } -export { useGetMyChallengeList }; +function useGetChallengeDetail() { + const { data } = useQuery({ + queryKey: ["getChallengeDetail"], + queryFn: getChallengDetail, + }); + return { data }; +} + +export { useGetMyChallengeList, useGetChallengeDetail }; diff --git a/components/challenge/ChallengeCalendar.tsx b/components/challenge/ChallengeCalendar.tsx index 0e78857..ccc5287 100644 --- a/components/challenge/ChallengeCalendar.tsx +++ b/components/challenge/ChallengeCalendar.tsx @@ -2,6 +2,8 @@ import Calendar from "react-calendar"; import { useState } from "react"; import styled from "styled-components"; import LogoMark from "@/public/svgs/LogoMark.svg"; +import { useGetChallengeDetail } from "@/apis/hooks/challenge"; +import { GetChallengeDetailBody } from "@/apis/challenge"; export default function ChallengeCalendar() { type DatePiece = Date | null; @@ -13,18 +15,29 @@ export default function ChallengeCalendar() { setClickedDate(clickedDate); }; - const customTileContent = ({ date, view }) => { - // if (view === 'month' && DatesList.some(d => d.getTime() === date.getTime())) { - - const customDate = new Date(2024, 5, 19); - if (view === "month" && date.getTime() === customDate.getTime()) { - return ( -
-
- + // API 관리 + const { data } = useGetChallengeDetail(); + + const customTileContent = ({ date, view }: { date: Date; view: string }) => { + if (Array.isArray(data) && view === "month") { + const matchedData = data.find((challenge: GetChallengeDetailBody) => { + const attendanceDate = new Date( + challenge.attendanceDate.year, + challenge.attendanceDate.month - 1, + challenge.attendanceDate.day, + ); + return attendanceDate.getTime() === date.getTime(); + }); + + if (matchedData) { + return ( +
+
+ +
-
- ); + ); + } } return null; }; @@ -158,8 +171,8 @@ const StyledCalendarWrapper = styled.div` /* 일 */ .react-calendar__tile { text-align: center; - width: 2.5rem; - height: 3.75rem; + width: 3.25rem; + height: 3.25rem; display: flex; flex-direction: column; justify-content: center; diff --git a/pages/calendar.tsx b/pages/calendar.tsx index d94862d..b071487 100644 --- a/pages/calendar.tsx +++ b/pages/calendar.tsx @@ -11,7 +11,8 @@ interface DropProps { regionDrop: boolean; } -const options = ["Option 1", "Option 2", "Option 3"]; +const categories = ["운동", "예술", "학술"]; +const locations = ["서울", "경기", "그 외"]; const CalendarPage: NextPage = () => { const date = new Date(); @@ -22,36 +23,58 @@ const CalendarPage: NextPage = () => { regionDrop: false, }); + const toggleDrop = (dropName: string) => { + setIsDrop((prev: DropProps) => ({ ...prev, [dropName]: !prev[dropName] })); + }; + return (
-
- { - setIsDrop(!isDrop); - }} - /> - {isDrop ? ( -
    - {options.map((option, index) => ( -
  • {}} - > - {option} -
  • - ))} -
- ) : null} - { - console.log("지역"); - }} - /> +
+
+ { + toggleDrop("categoryDrop"); + console.log("category"); + }} + /> + {isDrop.categoryDrop ? ( +
    + {categories.map((option, index) => ( +
  • {}} + > + {option} +
  • + ))} +
+ ) : null} +
+
+ { + setIsDrop({ ...isDrop, regionDrop: !isDrop.regionDrop }); + }} + /> + {isDrop.regionDrop ? ( +
    + {locations.map((option, index) => ( +
  • {}} + > + {option} +
  • + ))} +
+ ) : null} +
From aa897e94ec3d42424fa443229369270b4332c94d Mon Sep 17 00:00:00 2001 From: leejin_rho Date: Mon, 1 Jul 2024 16:29:36 +0900 Subject: [PATCH 03/14] =?UTF-8?q?fix:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20?= =?UTF-8?q?=EB=B2=84=ED=8A=BC=20=EC=98=A4=EB=A5=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/login.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/login.tsx b/pages/login.tsx index dcfdb24..6543f99 100644 --- a/pages/login.tsx +++ b/pages/login.tsx @@ -92,7 +92,7 @@ const Login: NextPage = () => { From 72767d6b95280d5a1e9f2e9632683a59f37c4aff Mon Sep 17 00:00:00 2001 From: iOdiO89 <117376841+iOdiO89@users.noreply.github.com> Date: Mon, 1 Jul 2024 21:31:41 +0900 Subject: [PATCH 04/14] =?UTF-8?q?fix:=20=ED=94=84=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EB=9E=A8=20=EB=93=B1=EB=A1=9D=EC=8B=9C=20=ED=83=9C=EA=B7=B8=20?= =?UTF-8?q?Dropdown=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/challenge/ChallengeInput.tsx | 23 ++++++++++++++---- package.json | 1 + pages/_app.tsx | 1 + styles/dropdown.css | 31 +++++++++++++++++++++++++ yarn.lock | 20 ++++++++++++++++ 5 files changed, 71 insertions(+), 5 deletions(-) create mode 100644 styles/dropdown.css diff --git a/components/challenge/ChallengeInput.tsx b/components/challenge/ChallengeInput.tsx index b4abce2..2592b19 100644 --- a/components/challenge/ChallengeInput.tsx +++ b/components/challenge/ChallengeInput.tsx @@ -1,10 +1,15 @@ import FlexBox from "../Flexbox"; import TextInput, { TextInputProps } from "../Input"; import TextArea from "../TextArea"; +import Dropdown from "react-dropdown"; +import "react-dropdown/style.css"; + +const locationOptions = ["서울", "경기", "그 외"]; +const typeOptions = ["학술", "운동", "예술", "기타"]; interface ChallengeInputProps extends TextInputProps { title: string; - inputType: "text" | "calendar" | "textarea"; + inputType: "text" | "calendar" | "textarea" | "dropdown"; value2?: string; setValue2?: React.Dispatch>; } @@ -42,16 +47,24 @@ export default function ChallengeInput({ isError={false} type="date" /> - ~ + ~ ); break; + case "dropdown": + return ( + + + + + ); + break; default: return (