Skip to content

Commit bf1ec7d

Browse files
authored
Merge pull request #204 from imaginer-dev/202-ui--UI개선]-일정수정-팝업
feat: [UI개선] 일정 수정시 시작일, 끝날짜 디폴트 넣기 및 버튼UI 수정
2 parents b4004a0 + ee92052 commit bf1ec7d

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

src/components/MyCalendar/CreateEventButton.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { InputRef } from '../common/InputForm.tsx';
22
import { useState, useRef, useEffect } from 'react';
33
import { Events } from '@/utils/index.ts';
44
import { addPersonalSchedule, updatePersonalSchedule } from '@/apis/personalScheduleApi.ts';
5+
import { formatDate } from '@/utils/dateUtils.ts';
56

67
export interface eventProps {
78
id?: number;
@@ -21,11 +22,11 @@ const CreateEventDialog = ({ id, title, start_date, end_date }: eventProps) => {
2122
useEffect(() => {
2223
if (start_date) {
2324
setStartDate(start_date);
24-
startRef!.current!.value = start_date;
25+
startRef!.current!.value = formatDate(start_date);
2526
}
2627
if (end_date) {
2728
setEndDate(end_date);
28-
endRef!.current!.value = end_date;
29+
endRef!.current!.value = formatDate(end_date);
2930
}
3031
if (title) {
3132
setTitle(title);
@@ -118,7 +119,7 @@ const CreateEventDialog = ({ id, title, start_date, end_date }: eventProps) => {
118119
errorText="끝 날짜는 시작날짜보다 늦게 해주세요."
119120
/>
120121
<hr className="mb-2 mt-2" />
121-
<button className="btn w-full bg-primary text-base-100" onClick={onCreateClicked}>
122+
<button className="btn w-full bg-lime-900 text-base-100" onClick={onCreateClicked}>
122123
{id ? '수정하기' : '추가하기'}
123124
</button>
124125
</div>

src/components/common/Dialog.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,12 @@ const Dialog = forwardRef<DialogElement, Props>((props, ref) => {
3636
{title && <h3 className="text-lg font-bold">{title}</h3>}
3737
{desc && <p className={descClassName}>{desc}</p>}
3838
{children && <div>{children}</div>}
39-
<div className="modal-action flex justify-center">
40-
<button type="button" className="btn bg-primary text-base-100" onClick={() => dialogRef.current?.close()}>
39+
<div className="modal-action mt-1 flex justify-center">
40+
<button
41+
type="button"
42+
className="btn w-full bg-primary text-base-100"
43+
onClick={() => dialogRef.current?.close()}
44+
>
4145
닫기
4246
</button>
4347
</div>

src/utils/dateUtils.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,11 @@ export function formatTime(date: string): string {
2828

2929
return isAM ? `오전${formattedHours}:${formattedMinutes}` : `오후${formattedHours}:${formattedMinutes}`;
3030
}
31+
32+
export const formatDate = (dateString: string) => {
33+
const date = new Date(dateString);
34+
const year = date.getFullYear();
35+
const month = String(date.getMonth() + 1).padStart(2, '0');
36+
const day = String(date.getDate()).padStart(2, '0');
37+
return `${year}-${month}-${day}`;
38+
};

0 commit comments

Comments
 (0)