Skip to content
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

✨ feat(#20) 내가 받은 초대 목록 컴포넌트 제작 #99

Merged
merged 15 commits into from
Jun 28, 2024
Merged
Changes from 1 commit
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
7 changes: 4 additions & 3 deletions src/containers/mydashboard/InvitedDashboardList/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useQueryClient } from '@tanstack/react-query';
import { debounce } from 'lodash';
import Image from 'next/image';
import { useState, useEffect, useCallback } from 'react';
import { useQueryClient } from 'react-query';

import InvitationItemList from './InvitationItem';
import SearchBar from './InvitationSearch';
Expand All @@ -12,7 +12,7 @@ import { putAcceptInvitation } from '@/services/putService';
import { Invitation, InvitationsResponse } from '@/types/Invitation.interface';

export default function InvitedDashboardList() {
const { data, error, isLoading } = useFetchData<InvitationsResponse>('invitations', () => getInvitationsList());
const { data, error, isLoading } = useFetchData<InvitationsResponse>(['invitations'], () => getInvitationsList());
const [invitations, setInvitations] = useState<Invitation[]>([]);
const queryClient = useQueryClient();

Expand All @@ -26,8 +26,9 @@ export default function InvitedDashboardList() {
try {
await putAcceptInvitation(invitationId, inviteAccepted);
setInvitations((prevInvitations) => prevInvitations.filter((invitation) => invitation.id !== invitationId));
Copy link
Contributor

Choose a reason for hiding this comment

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

inviteAccepted true일 때만 대시보드 목록 다시 가져오면 좋을 것 같습니다.

queryClient.invalidateQueries(['dashboards']); // 특정 쿼리 키 무효화하여 다시 가져옴
queryClient.invalidateQueries({ queryKey: ['dashboards'] });
Copy link
Contributor

Choose a reason for hiding this comment

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

이거 좋은데, 그러면 사이드바만 다시 가져오고 대시보드 목록은 그대로 아닌가요??
-> 대시보드 목록도 같은 페이지 새로 불러오긴 해야할 것 같아요!

대시보드 목록에 새로 만든것일수록 아래로 가나요 위로 가나요??

} catch (err) {
// eslint-disable-next-line no-console
console.error('Error updating invitation:', err);
}
};
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.