-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FE] 해커톤 구현 내용 리팩터링 #49
Changes from all commits
6aabe24
707d41b
a5c58ac
f405e1b
7b5ccc4
50cdb94
1f9b183
958bb63
dec3d79
0c33c29
decd119
360ba72
518117a
7b733d9
cb8635f
681bc1c
96cc195
6262451
ab0f629
7fe63fa
a520dda
eb386bc
7639820
a444887
e287ee4
ba54102
5725b66
996832c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"eslint.workingDirectories": ["./frontend"], | ||
"stylelint.configFile": ".stylelintrc.json", | ||
"stylelint.packageManager": "npm", | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll.stylelint": "explicit", | ||
"source.fixAll.eslint": "explicit", | ||
"source.fixAll.prettier": "explicit" | ||
}, | ||
"stylelint.validate": ["typescript", "typescriptreact"] | ||
} |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -5,15 +5,16 @@ export interface Schedules { | |||||||
times: string[]; | ||||||||
} | ||||||||
|
||||||||
export interface getMeetingResponse { | ||||||||
export interface GetMeetingResponse { | ||||||||
meetingName: string; | ||||||||
startTime: string; | ||||||||
endTime: string; | ||||||||
availableDates: string[]; | ||||||||
schedules: Schedules[]; | ||||||||
} | ||||||||
Comment on lines
13
to
14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1
Suggested change
인터페이스 네이밍을 파스칼 케이스로 통일하면 좋을 것 같아요! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아이고.. 이 부분을 놓쳤네요..! 수정하겠습니다 :) 꼼꼼한 해리 감사해요! |
||||||||
|
||||||||
const getMeeting = async (uuid = '550e8400') => { | ||||||||
// uuid 기본값은 임시 설정된 uuid | ||||||||
const getMeeting = async (uuid = '550e8400'): Promise<GetMeetingResponse> => { | ||||||||
const url = `${API_URL}/api/v1/meeting/${uuid}`; | ||||||||
|
||||||||
const response = await fetch(url, { | ||||||||
|
@@ -29,7 +30,7 @@ const getMeeting = async (uuid = '550e8400') => { | |||||||
|
||||||||
const data = await response.json(); | ||||||||
|
||||||||
return data.data as getMeetingResponse; | ||||||||
return data.data; | ||||||||
}; | ||||||||
|
||||||||
export default getMeeting; |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { API_URL } from '@constants/api'; | ||
|
||
import type { Schedules } from './getMeeting'; | ||
|
||
export const postSchedule = async (requestData: Schedules[]) => { | ||
const url = `${API_URL}/api/v1/schedule`; | ||
|
||
const response = await fetch(url, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify({ | ||
meetingId: 1, | ||
guestName: 'daon', | ||
dateTimes: requestData, | ||
}), | ||
}); | ||
|
||
if (!response.ok) { | ||
throw new Error(`HTTP error! Status: ${response.status}`); | ||
} | ||
}; | ||
|
||
// 현재 쓰지 않는 API (schedule 수정 시 사용하는 API) | ||
export const getSchedule = async () => { | ||
const url = `${API_URL}/api/v1/schedule}`; | ||
|
||
const response = await fetch(url, { | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
|
||
if (!response.ok) { | ||
throw new Error(`HTTP error! Status: ${response.status}`); | ||
} | ||
|
||
const data = await response.json(); | ||
return data; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { useContext, useMemo } from 'react'; | ||
|
||
import { TimePickerUpdateStateContext } from '@contexts/TimePickerUpdateStateProvider'; | ||
|
||
import Button from '@components/_common/Button'; | ||
import TimeSlot from '@components/_common/TimeSlot'; | ||
|
||
import useTimePick from '@hooks/useTimePick/useTimePick'; | ||
|
||
import type { GetMeetingResponse } from '@apis/getMeeting'; | ||
|
||
import { usePostScheduleMutation } from '@stores/servers/meeting/mutations'; | ||
|
||
import { s_buttonContainer, s_cell, s_table, s_th } from '../Time.styles'; | ||
import { convertToSchedule, generateScheduleMatrix } from './TimePicker.util'; | ||
|
||
export interface TimePickerProps { | ||
data: GetMeetingResponse; | ||
} | ||
|
||
export default function TimePicker({ data }: TimePickerProps) { | ||
const { isTimePickerUpdate, handleToggleIsTimePickerUpdate } = useContext( | ||
TimePickerUpdateStateContext, | ||
); | ||
|
||
const initialValue = useMemo(() => generateScheduleMatrix(data), [data]); | ||
const [ref, value] = useTimePick(isTimePickerUpdate, initialValue); | ||
|
||
const { mutate: postScheduleMutate } = usePostScheduleMutation(() => | ||
handleToggleIsTimePickerUpdate(), | ||
); | ||
|
||
const handleOnToggle = () => { | ||
const convert = convertToSchedule(value, data.availableDates, data.startTime, data.endTime); | ||
|
||
postScheduleMutate(convert); | ||
}; | ||
|
||
const formattedAvailableDates = ['', ...data.availableDates]; | ||
|
||
return ( | ||
<div> | ||
<table css={s_table} ref={ref}> | ||
<thead> | ||
<tr> | ||
{formattedAvailableDates.map((date) => ( | ||
<th key={date}>{date}</th> | ||
))} | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{value.map((row, rowIndex) => ( | ||
<tr key={rowIndex}> | ||
<th css={[s_cell, s_th]}> | ||
{String(rowIndex + Number(data.startTime.slice(0, 2)) + ':00')} | ||
</th> | ||
{row.map((_, columnIndex) => ( | ||
<TimeSlot | ||
key={rowIndex + columnIndex} | ||
isSelected={value[rowIndex][columnIndex]} | ||
isUpdate={isTimePickerUpdate} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오 훨씬 명확한 네이밍으로 바꼈네요👍🏻 |
||
/> | ||
))} | ||
</tr> | ||
))} | ||
</tbody> | ||
</table> | ||
|
||
<div css={s_buttonContainer}> | ||
<Button text="등록하기" onClick={handleOnToggle} /> | ||
</div> | ||
</div> | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 이 설정 좋은데?