Skip to content

Commit

Permalink
fix: badge detail params change
Browse files Browse the repository at this point in the history
  • Loading branch information
shuashuai committed Sep 25, 2024
1 parent 88dabcc commit 3cf4cd6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ui/src/pages/Badges/Detail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const Index = () => {
const { data: badgeInfo, isLoading: isHeaderLoading } =
useGetBadgeInfo(badge_id);
const { data: badges, isLoading: isDetailLoading } = useBadgeDetailList({
badge_id,
badge_id: badgeInfo?.id || '',
page,
page_size: pageSize,
username: urlSearchParams.get('username') || null,
Expand Down
10 changes: 6 additions & 4 deletions ui/src/services/client/badges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ export const useGetBadgeInfo = (id: string) => {
};

export const useBadgeDetailList = (params: Type.BadgeDetailListReq) => {
if (!params.badge_id) return { data: null, isLoading: false, error: null };
const path = params.badge_id
? `/answer/api/v1/badge/awards/page?${qs.stringify(params, {
skipNulls: true,
})}`
: null;
const { data, error, mutate } = useSWR<Type.BadgeDetailListRes, Error>(
`/answer/api/v1/badge/awards/page?${qs.stringify(params, {
skipNulls: true,
})}`,
path,
(url) =>
request.get(url, {
allow404: true,
Expand Down

0 comments on commit 3cf4cd6

Please sign in to comment.