Skip to content

Commit 8faca9b

Browse files
committed
feat: 개인일정추가 구현
1 parent 77b9e68 commit 8faca9b

File tree

3 files changed

+64
-1
lines changed

3 files changed

+64
-1
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { useEventState } from '@/stores/myEventsStore.ts';
2+
import DialogButton from '@/components/common/DialogButton';
3+
import InputForm from '../common/InputForm';
4+
import { useState } from 'react';
5+
6+
const CreateEventButton = () => {
7+
const { addEvents } = useEventState();
8+
const [eventTitle, setTitle] = useState('');
9+
const [startDate, setStartDate] = useState('');
10+
const [endDate, setEndDate] = useState('');
11+
12+
const onTitleChanged = (event: React.ChangeEvent<HTMLInputElement>) => {
13+
setTitle(event.target.value);
14+
};
15+
16+
const onStartDateChanged = (event: React.ChangeEvent<HTMLInputElement>) => {
17+
setStartDate(event.target.value);
18+
};
19+
20+
const onEndDateChanged = (event: React.ChangeEvent<HTMLInputElement>) => {
21+
setEndDate(event.target.value);
22+
};
23+
24+
const onCreateClicked = () => {
25+
console.log('clicked! ', eventTitle, startDate, endDate);
26+
if (eventTitle !== '' && startDate !== '' && endDate !== '')
27+
addEvents({ title: eventTitle, start: startDate, end: endDate });
28+
};
29+
30+
const eventForm = (
31+
<div>
32+
<InputForm title="일정 제목" placeholder="새 일정 제목" onChange={onTitleChanged} />
33+
<InputForm title="시작 날짜" placeholder="YYYY-MM-DD" onChange={onStartDateChanged} />
34+
<InputForm title="끝 날짜" placeholder="YYYY-MM-DD" onChange={onEndDateChanged} />
35+
<hr className="m-4" />
36+
<button className="btn w-full bg-primary text-base-100" onClick={onCreateClicked}>
37+
추가하기
38+
</button>
39+
</div>
40+
);
41+
return (
42+
<div className="p-8">
43+
<DialogButton
44+
classname="btn bg-primary text-base-100 w-full"
45+
name={'새 일정 추가하기'}
46+
title={'일정 추가'}
47+
desc={' '}
48+
children={eventForm}
49+
/>
50+
</div>
51+
);
52+
};
53+
export default CreateEventButton;

src/components/common/InputForm.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,15 @@ interface Props extends HTMLProps<HTMLInputElement> {
99
errorText?: string;
1010
}
1111

12-
const InputForm: React.FC<Props> = ({ title, placeholder, hint, onChange, error = false, errorText = '', ...rest }) => {
12+
const InputForm: React.FC<Props> = ({
13+
title,
14+
placeholder,
15+
hint = '',
16+
onChange,
17+
error = false,
18+
errorText = '',
19+
...rest
20+
}) => {
1321
return (
1422
<label htmlFor={rest.id} className="form-control w-full">
1523
<div className="label">

src/pages/MyCalendarPage.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Calendar from '../components/common/Calendar.tsx';
2+
import CreateEventButton from '@/components/MyCalendar/CreateEventButton.tsx';
23

34
const MyCalendarPage: React.FC = () => {
45
return (
@@ -52,6 +53,7 @@ const MyCalendarPage: React.FC = () => {
5253
</div>
5354
</div>
5455
</main>
56+
<CreateEventButton />
5557
</div>
5658
);
5759
};

0 commit comments

Comments
 (0)