-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use game selector when chosen group has more than 1 game
- Loading branch information
Showing
4 changed files
with
85 additions
and
14 deletions.
There are no files selected for viewing
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
42 changes: 42 additions & 0 deletions
42
apps/hub/src/domains/game/components/group-game-select.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { groupGamesQueryOptions } from "@/domains/game/queries"; | ||
import { | ||
AssetImage, | ||
Flex, | ||
Select, | ||
SelectContent, | ||
SelectItem, | ||
SelectTrigger, | ||
SelectValue, | ||
} from "@rivet-gg/components"; | ||
import { useSuspenseQuery } from "@tanstack/react-query"; | ||
import type { ComponentProps } from "react"; | ||
|
||
interface GroupGameSelectProps extends ComponentProps<typeof Select> { | ||
groupId: string; | ||
} | ||
|
||
export function GroupGameSelect({ groupId, ...props }: GroupGameSelectProps) { | ||
const { data } = useSuspenseQuery(groupGamesQueryOptions(groupId)); | ||
|
||
return ( | ||
<Select {...props}> | ||
<SelectTrigger> | ||
<SelectValue placeholder="Select game..." /> | ||
</SelectTrigger> | ||
<SelectContent> | ||
{data.games.map((game, index, groupList) => ( | ||
<SelectItem key={game.gameId} value={game.gameId}> | ||
<Flex gap="2" items="center"> | ||
<AssetImage | ||
src={game.logoUrl || "/games/blank/blankgame.svg"} | ||
className="mx-auto size-5 object-contain" | ||
alt="Game logo" | ||
/> | ||
{game.displayName} | ||
</Flex> | ||
</SelectItem> | ||
))} | ||
</SelectContent> | ||
</Select> | ||
); | ||
} |
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
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