Skip to content

Commit 65239d2

Browse files
authored
Merge pull request #118 from part3-4team-Taskify/Newfeat
[Feat] 라이브러리 변경
2 parents 83c67fa + 3edc93d commit 65239d2

File tree

4 files changed

+156
-76
lines changed

4 files changed

+156
-76
lines changed

package-lock.json

Lines changed: 126 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
"@tanstack/react-query": "^5.68.0",
1313
"axios": "^1.8.3",
1414
"clsx": "^2.1.1",
15+
"date-fns": "^4.1.0",
1516
"lucide-react": "^0.485.0",
1617
"moment": "^2.30.1",
17-
"next": "15.2.2",
18+
"next": "^15.2.4",
1819
"prettier-plugin-tailwindcss": "^0.6.11",
1920
"react": "^19.0.0",
21+
"react-datepicker": "^8.2.1",
2022
"react-datetime": "^3.3.1",
2123
"react-dom": "^19.0.0",
2224
"react-hook-form": "^7.54.2",

src/components/modalInput/ModalInput.tsx

Lines changed: 22 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import moment from "moment";
22
import Image from "next/image";
33
import { ChangeEvent, useState, KeyboardEvent, useEffect } from "react";
4-
import Datetime from "react-datetime";
4+
import DatePicker from "react-datepicker";
5+
import "react-datepicker/dist/react-datepicker.css";
56
import ColorTagChip, { getTagColor } from "./chips/ColorTagChip";
67
import { inputClassNames } from "./InputClassNames";
78
import clsx from "clsx";
9+
import { format } from "date-fns";
810

911
type ModalInputType = "제목" | "마감일" | "태그";
1012

@@ -31,8 +33,9 @@ export default function ModalInput({
3133
}: ModalInputProps) {
3234
const [tagInput, setTagInput] = useState<string>("");
3335
const [tags, setTags] = useState<Tag[]>([]);
34-
const [isCalendarOpen, setIsCalendarOpen] = useState(false);
35-
const [selectedDate, setSelectedDate] = useState(defaultValue);
36+
const [selectedDate, setSelectedDate] = useState<Date | null>(
37+
defaultValue ? new Date(defaultValue) : null
38+
);
3639

3740
useEffect(() => {
3841
if (label === "태그" && defaultValueArray.length > 0) {
@@ -77,17 +80,12 @@ export default function ModalInput({
7780
onValueChange(updatedTags.map((tag) => tag.text));
7881
};
7982

80-
// ✅ 마감일 포맷 수정 (YYYY-MM-DD HH:mm)
81-
const handleDateChange = (date: moment.Moment | string) => {
82-
if (moment.isMoment(date)) {
83-
const formatted = date.format("YYYY-MM-DD HH:mm"); // ← 이 줄이 핵심!
84-
setSelectedDate(formatted);
83+
const handleDateChange = (date: Date | null) => {
84+
setSelectedDate(date);
85+
if (date) {
86+
const formatted = format(date, "yyyy-MM-dd HH:mm");
8587
onValueChange([formatted]);
86-
} else {
87-
setSelectedDate(date);
88-
onValueChange([date]);
8988
}
90-
setIsCalendarOpen(false);
9189
};
9290

9391
let inputElement = null;
@@ -110,39 +108,28 @@ export default function ModalInput({
110108
case "마감일":
111109
inputElement = (
112110
<div className="relative w-full max-w-[520px]">
113-
<div
114-
className="flex items-center gap-2 w-full h-[48px] border border-[var(--color-gray3)] rounded-md px-2 sm:px-4 cursor-pointer focus-within:border-[var(--primary)]"
115-
onClick={() => setIsCalendarOpen(!isCalendarOpen)}
116-
>
111+
<div className="flex items-center gap-2 w-full h-[48px] border border-[var(--color-gray3)] rounded-md px-2 sm:px-4 focus-within:border-[var(--primary)]">
117112
<Image
118113
src="/svgs/calendar.svg"
119114
width={20}
120115
height={20}
121116
alt="Deadline"
122117
priority
123118
/>
124-
<input
125-
type="text"
126-
placeholder="날짜를 입력해주세요"
127-
value={selectedDate}
119+
<DatePicker
120+
selected={selectedDate}
121+
onChange={handleDateChange}
122+
showTimeSelect
123+
timeFormat="HH:mm"
124+
timeIntervals={15}
125+
dateFormat="yyyy-MM-dd HH:mm"
126+
placeholderText="날짜를 입력해주세요"
128127
className="w-full h-full font-18r outline-none bg-transparent"
129-
readOnly
128+
popperPlacement="bottom-start"
129+
popperContainer={({ children }) => <div>{children}</div>}
130+
popperClassName="custom-datepicker-popper"
130131
/>
131132
</div>
132-
133-
{isCalendarOpen && (
134-
<div
135-
className="absolute top-full left-0 mt-2 w-full max-w-[520px] z-50 bg-white border border-[var(--color-gray3)] rounded-md shadow-lg"
136-
onMouseDown={(e) => e.preventDefault()}
137-
>
138-
<Datetime
139-
dateFormat="YYYY.MM.DD"
140-
timeFormat="HH:mm"
141-
input={false}
142-
onChange={handleDateChange}
143-
/>
144-
</div>
145-
)}
146133
</div>
147134
);
148135
break;

0 commit comments

Comments
 (0)