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

[FE] custom 되면 질문 리스트 invalidate 로직 추가 #899

Merged
merged 4 commits into from
Oct 24, 2024
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
2 changes: 1 addition & 1 deletion frontend/src/apis/checklist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const getChecklistDetail = async (id: number) => {

export const getChecklists = async (isLikeFiltered: boolean = false) => {
const response = await fetcher.get({
url: BASE_URL + (isLikeFiltered ? ENDPOINT.CHECKLISTS_LIKE : ENDPOINT.CHECKLISTS_V1),
url: BASE_URL + (isLikeFiltered ? ENDPOINT.CHECKLISTS_LIKE_V1 : ENDPOINT.CHECKLISTS_V1),
});
const data = await response.json();
return data.checklists.map(mapObjNullToUndefined).slice(0, 10);
Expand Down
1 change: 1 addition & 0 deletions frontend/src/apis/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const ENDPOINT = {
// checklist
CHECKLISTS: '/checklists',
CHECKLISTS_LIKE: '/checklists/like',
CHECKLISTS_LIKE_V1: '/v1/checklists/like',
CHECKLISTS_V1: '/v1/checklists',
CHECKLIST_QUESTION: '/checklists/questions',
CHECKLIST_ALL_QUESTION: '/custom-checklist/all',
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/_common/Subway/SubwayStations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface Props {
const SubwayStations = ({ stations }: Props) => {
return (
<>
{stations.length ? (
{stations?.length ? (
<S.Box>{stations?.map(station => <SubwayStationItem station={station} key={station.stationName} />)}</S.Box>
) : (
<span>{'보신 방과 가까운 지하철역을 찾아드릴게요.'}</span>
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/hooks/query/usePutCustomChecklist.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { useMutation } from '@tanstack/react-query';
import { useMutation, useQueryClient } from '@tanstack/react-query';

import { putCustomChecklist } from '@/apis/checklist';
import { QUERY_KEYS } from '@/constants/queryKeys';

const usePutCustomChecklist = () => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: (questionIds: number[]) => putCustomChecklist({ questionIds }),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: [QUERY_KEYS.CHECKLIST_QUESTIONS] });
},
});
};

Expand Down
Loading