Skip to content
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
1 change: 1 addition & 0 deletions Backend/Schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export const typeDefs = `#graphql
sort: String
): [Game!]!
wishlist(userId: Int!): [Game!]!
isGameWishlisted(userId: Int!, gameId: Int!): Boolean!
game(appid: Int!): Game
genres: [String!]!
profile(userId: Int!): Profile
Expand Down
28 changes: 23 additions & 5 deletions Backend/resolvers/WishlistResolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,34 @@ export const wishlistQueryResolvers = {
{ token }: GraphQLContext
): Promise<Game[]> => {
await RequireUser(token, userId)

const { rows } = await pool.query(
`SELECT ${GAME_COLUMNS}
FROM wishlist w
JOIN games g ON g.game_id = w.game_id
WHERE w.user_id = $1
ORDER BY g.game_name`,
FROM wishlist w
JOIN games g ON g.game_id = w.game_id
WHERE w.user_id = $1
ORDER BY g.game_name`,
[userId]
)
return rows
},
isGameWishlisted: async (
_parent: unknown,
{ userId, gameId }: { userId: number; gameId: number },
{ token }: GraphQLContext
): Promise<boolean> => {
await RequireUser(token, userId)

const { rows } = await pool.query(
`SELECT EXISTS (
SELECT 1
FROM wishlist
WHERE user_id = $1
AND game_id = $2
) AS "isGameWishlisted"`,
[userId, gameId]
)
return rows[0].isGameWishlisted
}
}

Expand Down
2 changes: 1 addition & 1 deletion E2E/Mainpage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { test, expect } from './fixtures'
import { openMainPage, testCarousel } from './helpers'

const GAME_PAGE = /#\/gamepage\/\d+$/
const GAME_PAGE = /#\/GamePage\/\d+$/

async function checkFeaturedGames(page: import('@playwright/test').Page) {
const section = page
Expand Down
2 changes: 1 addition & 1 deletion E2E/MainpageToGamepage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { test, expect } from './fixtures'
import { openMainPage } from './helpers'
import type { Page } from '@playwright/test'

const GAME_PAGE = /#\/gamepage\/\d+$/
const GAME_PAGE = /#\/GamePage\/\d+$/
const WISHLIST_PAGE = /#\/WishlistPage$/

async function openTopGameAndToggleWishlist(page: Page) {
Expand Down
2 changes: 1 addition & 1 deletion E2E/Reviews.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { test, expect } from './fixtures'
import { openMainPage } from './helpers'
import type { Page } from '@playwright/test'

const GAME_PAGE = /#\/gamepage\/\d+$/
const GAME_PAGE = /#\/GamePage\/\d+$/

async function navigateFromRecentReviewToGame(
page: Page,
Expand Down
6 changes: 3 additions & 3 deletions E2E/Wishlist.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { openMainPage } from './helpers'
import type { Page } from '@playwright/test'

const WISHLIST_PAGE = /#\/WishlistPage$/
const GAME_PAGE = /#\/gamepage\/\d+$/
const GAME_PAGE = /#\/GamePage\/\d+$/

async function openDesktopWishlistPage(
page: Page,
Expand Down Expand Up @@ -48,7 +48,7 @@ async function waitForWishlistPage(page: Page) {
}

async function openWishlistedGameAndGoBack(page: Page) {
const firstGame = page.locator('a[href*="gamepage"]').first()
const firstGame = page.locator('a[href*="GamePage"]').first()

await expect(firstGame).toBeVisible()
await firstGame.click()
Expand Down Expand Up @@ -78,7 +78,7 @@ async function sortWishlistGames(page: Page) {
}

async function removeGameFromWishlist(page: Page) {
const firstGame = page.locator('a[href*="gamepage"]').first()
const firstGame = page.locator('a[href*="GamePage"]').first()

await expect(firstGame).toBeVisible()

Expand Down
2 changes: 1 addition & 1 deletion E2E/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export async function testCarousel(page: Page, heading: string) {
})

const gameCards = section.locator(
'.genre-games-row a[href*="gamepage/"]'
'.genre-games-row a[href*="GamePage/"]'
)

await expect(nextButton).toBeVisible()
Expand Down
2 changes: 1 addition & 1 deletion Frontend/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function App() {
<Routes>
<Route path="/" element={<MainPage />} />
<Route path="/GamePage" element={<GamePage />} />
<Route path="/gamepage/:gameId" element={<GamePage />} />
<Route path="/GamePage/:gameId" element={<GamePage />} />
<Route path="/SearchPage" element={<SearchPage />} />
<Route path="/SignUp" element={<SignUpPage />} />
<Route path="/SignIn" element={<SignInPage />} />
Expand Down
16 changes: 16 additions & 0 deletions Frontend/src/FrontendLogic/WishlistLogicFrontend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,19 @@ export function SaveSortOptionWishlist(query: string) {
export function GetSortOptionWishlist(): string {
return ReadStored(WISHLIST_KEY, 'discount-desc', IsString)
}

// Frontend function for checking if a specific game is wishlisted
export async function FetchIsGameWishlistedFrontend(
userId: number,
gameId: number
): Promise<boolean> {
const data = await Gql<{ isGameWishlisted: boolean }>(
`query($userId: Int!, $gameId: Int!) {
isGameWishlisted(userId: $userId, gameId: $gameId)
}`,
{ userId, gameId }
)

return data.isGameWishlisted
}

47 changes: 0 additions & 47 deletions Frontend/src/components/ActiveGameCard/ActiveGameCard.css
Original file line number Diff line number Diff line change
Expand Up @@ -49,33 +49,6 @@
gap: 1.25rem;
}

.activeGameInfoCard,
.activeGameReviewsCard {
min-width: 0;
background-color: var(--primary-component-color) !important;
color: var(--primary-text-color);
box-shadow: var(--card-shadow);
}

.activeGameReviewsCard {
display: flex;
min-height: 0;
}

.activeGameInfoContent.MuiCardContent-root {
display: flex;
flex-direction: column;
gap: 1rem;
padding: 1.25rem;
}

.activeGameInfoHeader {
display: flex;
align-items: center;
justify-content: space-between;
gap: 1rem;
}

.activeGameTitle {
min-width: 0;
margin: 0;
Expand Down Expand Up @@ -138,12 +111,6 @@
font-weight: 700;
}

.activeGameInfoMiddle {
display: flex;
flex-direction: column;
gap: 1rem;
}

.activeGameDeveloper {
line-height: 1.5;
}
Expand All @@ -165,11 +132,6 @@
color: var(--primary-text-color);
}

.activeGameInfoContent .MuiDivider-root {
width: 100%;
border-color: rgb(0 0 0 / 20%);
}

@media (max-width: 64rem) {
.activeGameLayout {
margin-block: 1rem;
Expand All @@ -180,18 +142,9 @@
align-items: start;
gap: 1rem;
}

.activeGameInfoContent.MuiCardContent-root {
padding: 1.125rem;
}
}

@media (max-width: 26rem) {
.activeGameInfoHeader {
align-items: flex-start;
flex-direction: column;
}

.activeGamePriceGroup {
justify-content: flex-start;
}
Expand Down
Loading