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

공지사항 생성, 수정, 삭제 시 캐시 초기화 로직 변경 #802

Merged
merged 3 commits into from
Oct 19, 2023
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
4 changes: 2 additions & 2 deletions frontend/src/api/notice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from '@type/notice';
import { StringDateUpToDay } from '@type/time';

import { deleteFetch, getFetch, patchFetch, postFetch } from '@utils/fetch';
import { deleteFetch, getFetch, postFetch, putFetch } from '@utils/fetch';

export const transformNotice = ({
id,
Expand Down Expand Up @@ -66,7 +66,7 @@ export const modifyNotice = async ({
noticeId: number;
notice: NoticeRequest;
}) => {
return await patchFetch(`${BASE_URL}/notices/${noticeId}`, notice);
return await putFetch(`${BASE_URL}/notices/${noticeId}`, notice);
};

export const deleteNotice = async (noticeId: number) => {
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/hooks/query/notice/useCreateNotice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ export const useCreateNotice = () => {
(notice: NoticeRequest) => createNotice(notice),
{
onSuccess: () => {
queryClient.invalidateQueries([QUERY_KEY.NOTICE]);
queryClient.invalidateQueries({
predicate: ({ queryKey }) => queryKey[0] === QUERY_KEY.NOTICE,
});
},
onError: error => {
const errorMessage =
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/hooks/query/notice/useDeleteNotice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ export const useDeleteNotice = () => {
(noticeId: number) => deleteNotice(noticeId),
{
onSuccess: () => {
queryClient.invalidateQueries([QUERY_KEY.NOTICE]);
queryClient.invalidateQueries({
predicate: ({ queryKey }) => queryKey[0] === QUERY_KEY.NOTICE,
});
},
onError: error => {
const errorMessage =
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/hooks/query/notice/useModifyNotice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ export const useModifyNotice = () => {
modifyNotice({ notice, noticeId }),
{
onSuccess: () => {
queryClient.invalidateQueries([QUERY_KEY.NOTICE]);
queryClient.invalidateQueries({
predicate: ({ queryKey }) => queryKey[0] === QUERY_KEY.NOTICE,
});
},
onError: error => {
const errorMessage =
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/mocks/notice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const mockNotice = [
return res(ctx.status(200), ctx.json(MOCK_NOTICE_RESPONSE));
}),

rest.patch(`/notices/:id`, async (req, res, ctx) => {
rest.put(`/notices/:id`, async (req, res, ctx) => {
const data = await req.json();

MOCK_NOTICE_TEST = data.title;
Expand Down
Loading