Skip to content

Commit

Permalink
merge: 10/01 qa 2 (#101)
Browse files Browse the repository at this point in the history
merge: 10/01 qa 2 (#101)
  • Loading branch information
d0422 authored Oct 1, 2024
2 parents dc8d667 + c715910 commit 9b4c33b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
17 changes: 16 additions & 1 deletion packages/react-native/src/apis/queries/mypage/useMyBadgeQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@ import { BADGE_MAPPER, Region } from '@/constants/CITY';
import QUERY_KEYS from '@/constants/QUERY_KEYS';
import { ServerResponse } from '@/types/response';
import unique from '@/utils/unique';
import { badgePath } from '@/components/common/Badge';

interface BadgeResponse {
region: Region;
count: number;
}

interface Badge {
count: number;
badgeRegion: keyof typeof badgePath;
}

export default function useMyBadgeQuery() {
const authAxios = useAuthAxios();
const getBadges = async () => {
Expand All @@ -21,7 +27,16 @@ export default function useMyBadgeQuery() {
badgeRegion: BADGE_MAPPER[badge.region],
}));

return unique(badges, 'badgeRegion');
return badges.reduce((merge, item) => {
const findedItem = merge.find(
(element) => element.badgeRegion === item.badgeRegion,
);
if (findedItem) {
findedItem.count += item.count;
return merge;
}
return [...merge, item];
}, [] as Badge[]);
};

return useSuspenseQuery({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface UseSpotDetailQueryParams {
}

export interface SpotResponse {
id: number;
id?: number;
contentId: number;
title: string;
image: string;
Expand Down
3 changes: 1 addition & 2 deletions packages/react-native/src/apis/useAuthAxios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ const getNewToken = async (baseURL: string, refresh: string) => {
};

const requestDebounceKeyValue: Record<string, number> = {};
const controller = new AbortController();

const useAuthAxios = () => {
const controller = new AbortController();
const { access, refresh, setAccess, setRefresh } = useToken();

const instance = axios.create({
Expand All @@ -53,7 +53,6 @@ const useAuthAxios = () => {
const requestKey = config.url;
const isExistRequest =
requestDebounceKeyValue[requestKey] === currentTime.getTime();

if (isExistRequest) {
controller.abort();
return config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default withSuspense(function TripPlannerDetail() {
);

const deleteSpot = () => {
if (!targetSpot) return;
if (!targetSpot || !targetSpot.id) return;
deleteSelectedSpots(targetSpot.id);
};

Expand Down

0 comments on commit 9b4c33b

Please sign in to comment.