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

hotfix: 10/01 qa 2 #101

Merged
merged 3 commits into from
Oct 1, 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
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 @@ -3,13 +3,19 @@
import { BADGE_MAPPER, Region } from '@/constants/CITY';
import QUERY_KEYS from '@/constants/QUERY_KEYS';
import { ServerResponse } from '@/types/response';
import unique from '@/utils/unique';

Check warning on line 6 in packages/react-native/src/apis/queries/mypage/useMyBadgeQuery.ts

View workflow job for this annotation

GitHub Actions / build

'unique' is defined but never used
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 @@
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
Loading