-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move badge logic to gamification domain
- Loading branch information
1 parent
a29dcae
commit dec675f
Showing
7 changed files
with
40 additions
and
3 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...domains/questing/components/BadgeCard.tsx → ...ins/gamification/components/BadgeCard.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
apps/govquests-frontend/src/domains/gamification/graphql/badgeQuery.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { graphql } from "gql.tada"; | ||
|
||
export const BadgeQuery = graphql(` | ||
query GetBadge($id: ID!) { | ||
badge(id: $id) { | ||
id | ||
displayData { | ||
title | ||
description | ||
imageUrl | ||
} | ||
} | ||
} | ||
`); |
12 changes: 12 additions & 0 deletions
12
apps/govquests-frontend/src/domains/gamification/hooks/useFetchBadge.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
"use client"; | ||
|
||
import { useQuery } from "@tanstack/react-query"; | ||
import { fetchBadge } from "../services/badgeService"; | ||
|
||
export const useFetchBadge = (id: string) => { | ||
return useQuery({ | ||
queryKey: ["badge", id], | ||
queryFn: () => fetchBadge(id), | ||
enabled: !!id, | ||
}); | ||
}; |
7 changes: 7 additions & 0 deletions
7
apps/govquests-frontend/src/domains/gamification/services/badgeService.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { API_URL } from "@/lib/utils"; | ||
import request from "graphql-request"; | ||
import { BadgeQuery } from "../graphql/badgeQuery"; | ||
|
||
export const fetchBadge = async (id: string) => { | ||
return await request(API_URL, BadgeQuery, { id }); | ||
}; |
4 changes: 4 additions & 0 deletions
4
apps/govquests-frontend/src/domains/gamification/types/badgeTypes.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { ResultOf } from "gql.tada"; | ||
import { BadgeQuery } from "../graphql/badgeQuery"; | ||
|
||
export type Badge = ResultOf<typeof BadgeQuery>["badge"]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
apps/govquests-frontend/src/domains/questing/components/track/TrackDescription.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters