Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
9586eda
♻️ refactor : mockdata 삭제
cksrlcks Feb 10, 2025
f5ddb7c
✨ feat : 에러메세지 추출용 유틸함수 작성
cksrlcks Feb 10, 2025
5bdab62
✨ feat : useDebounce hook 작성
cksrlcks Feb 10, 2025
f118b8d
✨ feat : dashboards api, queries, type 작업
cksrlcks Feb 10, 2025
a7c42f7
✨ feat : invitations api, queries, type 작업
cksrlcks Feb 10, 2025
e5f308a
📦 chore : react-intersection-observer 패키지 추가
cksrlcks Feb 10, 2025
69456b1
✨ feat : 대시보드용 공용 카드 컴포넌트 작업
cksrlcks Feb 10, 2025
d55d498
✨ feat : 초대받은 대시보드 작업
cksrlcks Feb 10, 2025
f4b6929
🐛 fix : 나의 대시보드 리스트 총갯수 0개 노출 수정
cksrlcks Feb 10, 2025
497db02
✨ feat : axios 오류 응답 메세지 사용하도록 개선
cksrlcks Feb 10, 2025
aa3064b
✨ feat : 초대 모달 작업
cksrlcks Feb 10, 2025
7e1a8db
✨ feat : 대시보드 수정 페이지 - 정보변경 카드 작업
cksrlcks Feb 10, 2025
6aa1187
✨ feat : 대시보드 수정 페이지 - 초대내역 카드 작업
cksrlcks Feb 10, 2025
814e51d
✨ feat : 대시보드 수정 페이지 - 구성원 카드 작업
cksrlcks Feb 10, 2025
a3d82a4
✨ feat : 대시보드 수정 페이지 - 내부 카드들 배치
cksrlcks Feb 10, 2025
6da8365
✨ feat : 임시 대시보드 상세페이지 수정
cksrlcks Feb 10, 2025
d9eb442
🐛 fix : 개선하면서 안쓰게된 코드 삭제
cksrlcks Feb 10, 2025
4244617
♻️ refactor : api, queries, type 코드 컨밴션 맞추기
cksrlcks Feb 10, 2025
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
16 changes: 16 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"react-datepicker": "^7.6.0",
"react-dom": "^19.0.0",
"react-hook-form": "^7.54.2",
"react-intersection-observer": "^9.15.1",
"tailwind-merge": "^3.0.1",
"zod": "^3.24.1",
"zustand": "^5.0.3"
Expand Down
8 changes: 3 additions & 5 deletions src/apis/dashboards/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
Dashboard,
DashboardFormType,
DashboardInvitation,
DashboardInvitationResponse,
DashboardInvitationsResponse,
dashboardSchema,
DashboardsResponse,
dashboardsResponseSchema,
Expand Down Expand Up @@ -69,10 +69,9 @@ export const deleteDashboard = async (id: number) => {
return response.data;
};

// TODO : UserSchema 추가이후, Invitation schema가 작성되면 응답 검증 로직 추가 필요
// dashboard 초대 불러오기
export const getDashboardInvitations = async (id: number, { page, size }: BasePaginationParams) => {
const response = await axiosClientHelper.get<DashboardInvitation>(`/dashboards/${id}/invitations`, {
const response = await axiosClientHelper.get<DashboardInvitationsResponse>(`/dashboards/${id}/invitations`, {
params: {
page: page || 1,
size: size || 10,
Expand All @@ -81,10 +80,9 @@ export const getDashboardInvitations = async (id: number, { page, size }: BasePa
return response.data;
};

// TODO : UserSchema 추가이후, Invitation schema가 작성되면 응답 검증 로직 추가 필요
// dashboard 초대
export const inviteDashboard = async (id: number, data: InviteDashboardType) => {
const response = await axiosClientHelper.post<DashboardInvitationResponse>(`/dashboards/${id}/invitations`, data);
const response = await axiosClientHelper.post<DashboardInvitation>(`/dashboards/${id}/invitations`, data);
return response.data;
};

Expand Down
148 changes: 0 additions & 148 deletions src/apis/dashboards/mockData.ts

This file was deleted.

63 changes: 56 additions & 7 deletions src/apis/dashboards/queries.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
'use client';

import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { createDashboard, getDashboards } from '.';
import { cancelDashboardInvitation, createDashboard, deleteDashboard, getDashboardDetails, getDashboardInvitations, getDashboards, inviteDashboard, updateDashboard } from '.';
import { DashboardFormType } from './types';
import { DEFAULT_COLOR } from '@/constants/colors';

export const useDashboardsQuery = (page: number, size: number) => {
return useQuery({
Expand All @@ -16,6 +17,20 @@ export const useDashboardsQuery = (page: number, size: number) => {
});
};

export const useDashboardQuery = (id: number) => {
return useQuery({
queryKey: ['dashboard', id],
queryFn: () => getDashboardDetails(id),
});
};

export const useDashboardInvitationsQuery = (id: number, page: number, size: number) => {
return useQuery({
queryKey: ['dashboard', id, 'invitations', page, size],
queryFn: () => getDashboardInvitations(id, { page, size }),
});
};

export const useDashboardMutation = () => {
const queryClient = useQueryClient();

Expand All @@ -28,15 +43,49 @@ export const useDashboardMutation = () => {
},
});

// TODO : update query 작성
const update = () => {};
const update = useMutation({
mutationFn: ({ id, title, color }: { id: number; title: string; color: DEFAULT_COLOR }) => {
return updateDashboard(id, { title, color });
},
onSuccess: ({ id }) => {
queryClient.invalidateQueries({ queryKey: ['dashboards'] });
queryClient.invalidateQueries({ queryKey: ['dashboard', id] });
},
});

// TODO : remove query 작성
const remove = () => {};
const remove = useMutation({
mutationFn: (id: number) => {
return deleteDashboard(id);
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['dashboards'] });
},
});

const invite = useMutation({
mutationFn: ({ id, email }: { id: number; email: string }) => {
return inviteDashboard(id, { email });
},
onSuccess: (_, { id }) => {
queryClient.invalidateQueries({ queryKey: ['myInvitations'] });
queryClient.invalidateQueries({ queryKey: ['dashboard', id, 'invitations'] });
},
});

const cancel = useMutation({
mutationFn: ({ dashboardId, invitationId }: { dashboardId: number; invitationId: number }) => {
return cancelDashboardInvitation(dashboardId, invitationId);
},
onSuccess: (_, { dashboardId }) => {
queryClient.invalidateQueries({ queryKey: ['dashboard', dashboardId, 'invitations'] });
},
});

return {
create: create.mutateAsync,
update,
remove,
update: update.mutateAsync,
remove: remove.mutateAsync,
invite: invite.mutateAsync,
cancel: cancel.mutateAsync,
};
};
Loading