Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/features/study/api/get-study-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type {
DailyStudyDetail,
GetDailyStudiesParams,
GetDailyStudiesResponse,
GetDailyStudyDetailParams2,
GetMonthlyCalendarParams,
JoinStudyRequest,
MonthlyCalendarResponse,
Expand Down Expand Up @@ -87,10 +86,10 @@ export const postJoinStudy = async (payload: JoinStudyRequest) => {

// 스터디 참여 유무 확인
export const getWeeklyParticipation = async (
params: GetDailyStudyDetailParams2,
studyDate: string,
): Promise<WeeklyParticipationResponse> => {
const res = await axiosInstance.get('/study/week/participation', {
params,
params: { studyDate },
});

return res.data.content;
Expand Down
6 changes: 0 additions & 6 deletions src/features/study/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ export interface DailyStudyDetail {
feedback: string;
}

export interface GetDailyStudyDetailParams2 {
year: number;
month: number;
day: number;
}

export interface GetDailyStudiesParams {
cursor?: number;
pageSize?: number;
Expand Down
3 changes: 1 addition & 2 deletions src/features/study/model/use-study-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ import {
import {
CompleteStudyRequest,
GetDailyStudiesParams,
GetDailyStudyDetailParams2,
GetMonthlyCalendarParams,
JoinStudyRequest,
MonthlyCalendarResponse,
PrepareStudyRequest,
} from '../api/types';

// 스터디 주간 참여 유무 확인 query
export const useWeeklyParticipation = (params: GetDailyStudyDetailParams2) => {
export const useWeeklyParticipation = (params: string) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이런 경우에는 따로 타입 정의를 안해도 되는걸까요?!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

모르겠습니다... 저도 고민했던 부분인데
값을 하나만 입력하는 경우라 유지보수 차원에서는 타입 정의를 하는 게 좋을 수 있지만
또 한편으로는 너무 과하게 타입 분리한다는 생각도 들어서...
이건 그냥 의견 따라 좀 더 맞다고 생각하는 쪽으로 변경하겠습니다

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저도 민주님이랑 같은 의견입니다! 너무 과하게 타입 컨벤션을 지키려고 하는걸까 싶기도 해서요!

return useQuery({
queryKey: ['weeklyParticipation', params],
queryFn: () => getWeeklyParticipation(params),
Expand Down
7 changes: 1 addition & 6 deletions src/features/study/ui/study-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,13 @@ function getWeekly(date: Date): { month: number; week: number } {

export default function StudyCard() {
const [selectedDate, setSelectedDate] = useState(new Date());
const params = {
year: selectedDate.getFullYear(),
month: selectedDate.getMonth() + 1,
day: selectedDate.getDate(),
};

const offset = selectedDate.getTimezoneOffset() * 60000; // ms단위라 60000곱해줌
const dateOffset = new Date(selectedDate.getTime() - offset);

const studyDate = dateOffset.toISOString().split('T')[0];

const { data: participationData } = useWeeklyParticipation(params);
const { data: participationData } = useWeeklyParticipation(studyDate);
const isParticipate = participationData?.isParticipate ?? false;

const { month, week } = getWeekly(selectedDate);
Expand Down
Loading