From 322d205c93f93ae7dedeb590a61b932a5705ba4b Mon Sep 17 00:00:00 2001 From: wooooooood <13pft13@gmail.com> Date: Sun, 20 Aug 2023 06:15:50 +0900 Subject: [PATCH] feat(schedule): weekly select --- package.json | 1 + .../schedule/components/WeekSelector.tsx | 30 +++++++++++++++++-- yarn.lock | 5 ++++ 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 408792c..b8073d4 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "dependencies": { "@tanstack/react-query": "^4.32.6", "axios": "^1.4.0", + "dayjs": "^1.11.9", "html2canvas": "^1.4.1", "jotai": "^2.3.1", "react": "^18.2.0", diff --git a/src/features/schedule/components/WeekSelector.tsx b/src/features/schedule/components/WeekSelector.tsx index 59b34b7..3fdb4b7 100644 --- a/src/features/schedule/components/WeekSelector.tsx +++ b/src/features/schedule/components/WeekSelector.tsx @@ -1,15 +1,39 @@ +import dayjs from 'dayjs'; + import calendar from '/svg/Calendar.svg'; import arrow from '/svg/Arrow.svg'; +import { useState } from 'react'; + const WeekSelector = ({ onClick }: { onClick: () => void }) => { + const [startDate, setStartDate] = useState(dayjs(new Date())); + + const handleLeftArrowClick = () => { + setStartDate(startDate.add(-8, 'day')); + onClick(); + }; + const handleRightArrowClick = () => { + setStartDate(startDate.add(8, 'day')); + onClick(); + }; + return (