{#if items.length === 0}
-
No games in your collection
+
No gamesTable in your collection
{:else}
{#each items as game (game.game_id)}
diff --git a/src/routes/(app)/(protected)/collections/add/+page.server.ts b/src/routes/(app)/(protected)/collections/add/+page.server.ts
index 174fbbc..76af777 100644
--- a/src/routes/(app)/(protected)/collections/add/+page.server.ts
+++ b/src/routes/(app)/(protected)/collections/add/+page.server.ts
@@ -1,13 +1,14 @@
-import { redirect } from 'sveltekit-flash-message/server';
-import { notSignedInMessage } from '$lib/flashMessages';
-import { userNotAuthenticated } from '$lib/server/auth-utils';
+import { notSignedInMessage } from '$lib/flashMessages'
+import { userNotAuthenticated } from '$lib/server/auth-utils'
+import { redirect } from 'sveltekit-flash-message/server'
export async function load(event) {
- const { locals } = event;
- const { user, session } = locals;
- if (userNotAuthenticated(user, session)) {
- redirect(302, '/login', notSignedInMessage, event);
+ const { locals } = event
+
+ const authedUser = await locals.getAuthedUser()
+ if (!authedUser) {
+ throw redirect(302, '/login', notSignedInMessage, event)
}
- return {};
+ return {}
}
diff --git a/src/routes/(app)/(protected)/collections/add/bgg/+page.server.ts b/src/routes/(app)/(protected)/collections/add/bgg/+page.server.ts
index 4150aea..e4c350f 100644
--- a/src/routes/(app)/(protected)/collections/add/bgg/+page.server.ts
+++ b/src/routes/(app)/(protected)/collections/add/bgg/+page.server.ts
@@ -1,19 +1,20 @@
-import { redirect } from '@sveltejs/kit';
-import { superValidate } from 'sveltekit-superforms/server';
-import { zod } from 'sveltekit-superforms/adapters';
-import type { PageServerLoad } from '../$types';
-import { BggForm } from '$lib/zodValidation';
-import { userNotAuthenticated } from '$lib/server/auth-utils';
-import { notSignedInMessage } from '$lib/flashMessages';
+import { notSignedInMessage } from '$lib/flashMessages'
+import { userNotAuthenticated } from '$lib/server/auth-utils'
+import { BggForm } from '$lib/zodValidation'
+import { redirect } from '@sveltejs/kit'
+import { zod } from 'sveltekit-superforms/adapters'
+import { superValidate } from 'sveltekit-superforms/server'
+import type { PageServerLoad } from '../$types'
export const load: PageServerLoad = async (event) => {
- const { locals } = event;
- const { user, session } = locals;
- if (userNotAuthenticated(user, session)) {
- redirect(302, '/login', notSignedInMessage, event);
+ const { locals } = event
+
+ const authedUser = await locals.getAuthedUser()
+ if (!authedUser) {
+ throw redirect(302, '/login', notSignedInMessage, event)
}
- const form = await superValidate({}, zod(BggForm));
+ const form = await superValidate({}, zod(BggForm))
- return { form };
-};
+ return { form }
+}
diff --git a/src/routes/(app)/(protected)/list/+layout.server.ts b/src/routes/(app)/(protected)/list/+layout.server.ts
index 30ca610..fd76692 100644
--- a/src/routes/(app)/(protected)/list/+layout.server.ts
+++ b/src/routes/(app)/(protected)/list/+layout.server.ts
@@ -1,5 +1,5 @@
import { notSignedInMessage } from '$lib/flashMessages'
-import { wishlists } from '$lib/server/api/databases/tables'
+import { wishlistsTable } from '$lib/server/api/databases/tables'
import { db } from '$lib/server/api/packages/drizzle'
import { eq } from 'drizzle-orm'
import { redirect } from 'sveltekit-flash-message/server'
@@ -14,7 +14,7 @@ export async function load(event) {
try {
const dbWishlists = await db.query.wishlists.findMany({
- where: eq(wishlists.user_id, authedUser.id),
+ where: eq(wishlistsTable.user_id, authedUser.id),
})
return {
diff --git a/src/routes/(app)/(protected)/list/+layout.svelte b/src/routes/(app)/(protected)/list/+layout.svelte
index 6d59e3a..21bc4cf 100644
--- a/src/routes/(app)/(protected)/list/+layout.svelte
+++ b/src/routes/(app)/(protected)/list/+layout.svelte
@@ -1,8 +1,8 @@
\ No newline at end of file
diff --git a/src/routes/(app)/(protected)/profile/security/+layout.server.ts b/src/routes/(app)/(protected)/profile/security/+layout.server.ts
deleted file mode 100644
index e2ef8d4..0000000
--- a/src/routes/(app)/(protected)/profile/security/+layout.server.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-export const load = async () => {
- return {}
-}
diff --git a/src/routes/(app)/(protected)/profile/security/+layout.svelte b/src/routes/(app)/(protected)/profile/security/+layout.svelte
deleted file mode 100644
index c3382ba..0000000
--- a/src/routes/(app)/(protected)/profile/security/+layout.svelte
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
- {@render children()}
-
diff --git a/src/routes/(app)/(protected)/profile/security/mfa/+page.svelte b/src/routes/(app)/(protected)/profile/security/mfa/+page.svelte
deleted file mode 100644
index 0182587..0000000
--- a/src/routes/(app)/(protected)/profile/security/mfa/+page.svelte
+++ /dev/null
@@ -1,83 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/src/routes/(app)/(protected)/settings/+layout.svelte b/src/routes/(app)/(protected)/settings/+layout.svelte
new file mode 100644
index 0000000..c4620d3
--- /dev/null
+++ b/src/routes/(app)/(protected)/settings/+layout.svelte
@@ -0,0 +1,15 @@
+
+
+
+ {@render children()}
+
\ No newline at end of file
diff --git a/src/routes/(app)/(protected)/settings/+page.server.ts b/src/routes/(app)/(protected)/settings/+page.server.ts
new file mode 100644
index 0000000..38077bd
--- /dev/null
+++ b/src/routes/(app)/(protected)/settings/+page.server.ts
@@ -0,0 +1,8 @@
+// +page.server.ts
+import { redirect } from '@sveltejs/kit'
+import type { PageServerLoad } from './$types'
+
+export const load: PageServerLoad = async () => {
+ // Redirect to a different page
+ throw redirect(307, '/settings/profile')
+}
diff --git a/src/routes/(app)/(protected)/profile/+page.server.ts b/src/routes/(app)/(protected)/settings/profile/+page.server.ts
similarity index 88%
rename from src/routes/(app)/(protected)/profile/+page.server.ts
rename to src/routes/(app)/(protected)/settings/profile/+page.server.ts
index 15e4e46..77cab00 100644
--- a/src/routes/(app)/(protected)/profile/+page.server.ts
+++ b/src/routes/(app)/(protected)/settings/profile/+page.server.ts
@@ -1,9 +1,6 @@
-import { updateEmailDto } from '$lib/dtos/update-email.dto'
-import { updateProfileDto } from '$lib/dtos/update-profile.dto'
import { notSignedInMessage } from '$lib/flashMessages'
import { usersTable } from '$lib/server/api/databases/tables'
import { db } from '$lib/server/api/packages/drizzle'
-import { changeEmailSchema, profileSchema } from '$lib/validations/account'
import { type Actions, fail } from '@sveltejs/kit'
import { eq } from 'drizzle-orm'
import { redirect } from 'sveltekit-flash-message/server'
@@ -11,6 +8,7 @@ import { zod } from 'sveltekit-superforms/adapters'
import { message, setError, superValidate } from 'sveltekit-superforms/server'
import { z } from 'zod'
import type { PageServerLoad } from './$types'
+import { updateEmailSchema, updateProfileSchema } from './schemas'
export const load: PageServerLoad = async (event) => {
const { locals } = event
@@ -28,14 +26,14 @@ export const load: PageServerLoad = async (event) => {
// where: eq(usersTable.id, user!.id!),
// });
- const profileForm = await superValidate(zod(profileSchema), {
+ const profileForm = await superValidate(zod(updateProfileSchema), {
defaults: {
firstName: authedUser?.firstName ?? '',
lastName: authedUser?.lastName ?? '',
username: authedUser?.username ?? '',
},
})
- const emailForm = await superValidate(zod(changeEmailSchema), {
+ const emailForm = await superValidate(zod(updateEmailSchema), {
defaults: {
email: authedUser?.email ?? '',
},
@@ -66,7 +64,7 @@ export const actions: Actions = {
redirect(302, '/login', notSignedInMessage, event)
}
- const form = await superValidate(event, zod(updateProfileDto))
+ const form = await superValidate(event, zod(updateProfileSchema))
const { error } = await locals.api.me.update.profile.$put({ json: form.data }).then(locals.parseApiResponse)
console.log('data from profile update', error)
@@ -84,7 +82,7 @@ export const actions: Actions = {
return message(form, { type: 'success', message: 'Profile updated successfully!' })
},
changeEmail: async (event) => {
- const form = await superValidate(event, zod(updateEmailDto))
+ const form = await superValidate(event, zod(updateEmailSchema))
const newEmail = form.data?.email
if (!form.valid || !newEmail || (newEmail !== '' && !changeEmailIfNotEmpty.safeParse(form.data).success)) {
diff --git a/src/routes/(app)/(protected)/profile/+page.svelte b/src/routes/(app)/(protected)/settings/profile/+page.svelte
similarity index 73%
rename from src/routes/(app)/(protected)/profile/+page.svelte
rename to src/routes/(app)/(protected)/settings/profile/+page.svelte
index 7434d86..7943447 100644
--- a/src/routes/(app)/(protected)/profile/+page.svelte
+++ b/src/routes/(app)/(protected)/settings/profile/+page.svelte
@@ -1,27 +1,24 @@
+
+
+ {#if !hasSetupTwoFactor}
+
Multi Factor Authentication is: Disabled
+
+ {:else}
+
Multi Factor Authentication is: Enabled
+
+ {/if}
+
+
+
+
\ No newline at end of file
diff --git a/src/routes/(app)/(protected)/profile/security/password/change/+page.server.ts b/src/routes/(app)/(protected)/settings/security/change/password/+page.server.ts
similarity index 94%
rename from src/routes/(app)/(protected)/profile/security/password/change/+page.server.ts
rename to src/routes/(app)/(protected)/settings/security/change/password/+page.server.ts
index c2b9f75..e708aa5 100644
--- a/src/routes/(app)/(protected)/profile/security/password/change/+page.server.ts
+++ b/src/routes/(app)/(protected)/settings/security/change/password/+page.server.ts
@@ -1,6 +1,6 @@
import { notSignedInMessage } from '$lib/flashMessages'
+import { usersTable } from '$lib/server/api/databases/tables'
import { db } from '$lib/server/api/packages/drizzle'
-import { changeUserPasswordSchema } from '$lib/validations/account'
import { type Actions, fail } from '@sveltejs/kit'
import { eq } from 'drizzle-orm'
import type { Cookie } from 'lucia'
@@ -8,8 +8,8 @@ import { Argon2id } from 'oslo/password'
import { redirect } from 'sveltekit-flash-message/server'
import { zod } from 'sveltekit-superforms/adapters'
import { setError, superValidate } from 'sveltekit-superforms/server'
-import type { PageServerLoad } from '../../../$types'
-import { usersTable } from '../../../../../../../lib/server/api/databases/tables'
+import type { PageServerLoad } from './$types'
+import { changeUserPasswordSchema } from './schemas'
export const load: PageServerLoad = async (event) => {
const { locals } = event
diff --git a/src/routes/(app)/(protected)/profile/security/password/change/+page.svelte b/src/routes/(app)/(protected)/settings/security/change/password/+page.svelte
similarity index 67%
rename from src/routes/(app)/(protected)/profile/security/password/change/+page.svelte
rename to src/routes/(app)/(protected)/settings/security/change/password/+page.svelte
index e5c7422..302379a 100644
--- a/src/routes/(app)/(protected)/profile/security/password/change/+page.svelte
+++ b/src/routes/(app)/(protected)/settings/security/change/password/+page.svelte
@@ -1,22 +1,22 @@
+ {:else}
+
Please scan the following QR Code
+

+
+
+ Enter Code
+
+
+ This is the code from your authenticator app.
+
+
+
+
+ Enter Password
+
+
+ Please enter your current password.
+
+
+
Submit
+
+
Secret: {secret}
+ {/if}
+
+
+
\ No newline at end of file
diff --git a/src/routes/(app)/(protected)/settings/security/mfa/totp/schemas.ts b/src/routes/(app)/(protected)/settings/security/mfa/totp/schemas.ts
new file mode 100644
index 0000000..fd14c28
--- /dev/null
+++ b/src/routes/(app)/(protected)/settings/security/mfa/totp/schemas.ts
@@ -0,0 +1,14 @@
+import { z } from 'zod'
+
+export const addTwoFactorSchema = z.object({
+ current_password: z.string({ required_error: 'Current Password is required' }),
+ two_factor_code: z.string({ required_error: 'Two Factor Code is required' }).trim(),
+})
+
+export type AddTwoFactorSchema = typeof addTwoFactorSchema
+
+export const removeTwoFactorSchema = addTwoFactorSchema.pick({
+ current_password: true,
+})
+
+export type RemoveTwoFactorSchema = typeof removeTwoFactorSchema
diff --git a/src/routes/(app)/(protected)/wishlists/+page.server.ts b/src/routes/(app)/(protected)/wishlists/+page.server.ts
index db80d2c..f211518 100644
--- a/src/routes/(app)/(protected)/wishlists/+page.server.ts
+++ b/src/routes/(app)/(protected)/wishlists/+page.server.ts
@@ -1,5 +1,5 @@
import { notSignedInMessage } from '$lib/flashMessages.js'
-import { games, wishlist_items, wishlists } from '$lib/server/api/databases/tables'
+import { gamesTable, wishlist_items, wishlistsTable } from '$lib/server/api/databases/tables'
import { db } from '$lib/server/api/packages/drizzle'
import { userNotAuthenticated } from '$lib/server/auth-utils'
import { modifyListGameSchema } from '$lib/validations/zod-schemas'
@@ -23,7 +23,7 @@ export async function load(event) {
name: true,
createdAt: true,
},
- where: eq(wishlists.user_id, authedUser.id),
+ where: eq(wishlistsTable.user_id, authedUser.id),
})
console.log('wishlists', userWishlists)
@@ -50,7 +50,7 @@ export const actions: Actions = {
try {
const game = await db.query.games.findFirst({
- where: eq(games.id, form.data.id),
+ where: eq(gamesTable.id, form.data.id),
})
if (!game) {
@@ -65,7 +65,7 @@ export const actions: Actions = {
if (game) {
const wishlist = await db.query.wishlists.findFirst({
- where: eq(wishlists.user_id, authedUser.id),
+ where: eq(wishlistsTable.user_id, authedUser.id),
})
if (!wishlist) {
@@ -90,18 +90,20 @@ export const actions: Actions = {
// Create new wishlist
create: async (event) => {
const { locals } = event
- const { user, session } = locals
- if (userNotAuthenticated(user, session)) {
- return fail(401)
+
+ const authedUser = await locals.getAuthedUser()
+ if (!authedUser) {
+ throw redirect(302, '/login', notSignedInMessage, event)
}
return error(405, 'Method not allowed')
},
// Delete a wishlist
delete: async (event) => {
const { locals } = event
- const { user, session } = locals
- if (userNotAuthenticated(user, session)) {
- return fail(401)
+
+ const authedUser = await locals.getAuthedUser()
+ if (!authedUser) {
+ throw redirect(302, '/login', notSignedInMessage, event)
}
return error(405, 'Method not allowed')
},
@@ -116,8 +118,8 @@ export const actions: Actions = {
const form = await superValidate(event, zod(modifyListGameSchema))
try {
- const game = await db.query.games.findFirst({
- where: eq(games.id, form.data.id),
+ const game = await db.query.gamesTable.findFirst({
+ where: eq(gamesTable.id, form.data.id),
})
if (!game) {
@@ -131,8 +133,8 @@ export const actions: Actions = {
}
if (game) {
- const wishlist = await db.query.wishlists.findFirst({
- where: eq(wishlists.user_id, authedUser.id),
+ const wishlist = await db.query.wishlistsTable.findFirst({
+ where: eq(wishlistsTable.user_id, authedUser.id),
})
if (!wishlist) {
diff --git a/src/routes/(app)/(protected)/wishlists/+page.svelte b/src/routes/(app)/(protected)/wishlists/+page.svelte
index 9678631..a65577f 100644
--- a/src/routes/(app)/(protected)/wishlists/+page.svelte
+++ b/src/routes/(app)/(protected)/wishlists/+page.svelte
@@ -1,18 +1,18 @@
Your Wishlists | Bored Game
-
Your wishlists
+
Your wishlistsTable
{#if wishlists.length === 0}
-
You have no wishlists
+
You have no wishlistsTable
{:else}
{#each wishlists as wishlist}
diff --git a/src/routes/(app)/(protected)/wishlists/[cuid]/+page.server.ts b/src/routes/(app)/(protected)/wishlists/[cuid]/+page.server.ts
index 5093585..2ec8923 100644
--- a/src/routes/(app)/(protected)/wishlists/[cuid]/+page.server.ts
+++ b/src/routes/(app)/(protected)/wishlists/[cuid]/+page.server.ts
@@ -7,7 +7,7 @@ import { and, eq } from 'drizzle-orm'
import { redirect } from 'sveltekit-flash-message/server'
import { zod } from 'sveltekit-superforms/adapters'
import { superValidate } from 'sveltekit-superforms/server'
-import { games, wishlist_items, wishlists } from '../../../../../lib/server/api/databases/tables'
+import { gamesTable, wishlist_items, wishlistsTable } from '../../../../../lib/server/api/databases/tables'
export async function load(event) {
const { params, locals } = event
@@ -24,8 +24,8 @@ export async function load(event) {
param: { cuid },
})
.then(locals.parseApiResponse)
- // const wishlist = await db.query.wishlists.findMany({
- // where: and(eq(wishlists.user_id, authedUser.id), eq(wishlists.cuid, cuid)),
+ // const wishlist = await db.query.wishlistsTable.findMany({
+ // where: and(eq(wishlistsTable.user_id, authedUser.id), eq(wishlistsTable.cuid, cuid)),
// });
if (errors) {
return error(500, 'Failed to fetch wishlist')
@@ -51,15 +51,16 @@ export const actions: Actions = {
// Add game to a wishlist
add: async (event) => {
const { locals } = event
- const { user, session } = locals
- if (userNotAuthenticated(user, session)) {
- return fail(401)
+
+ const authedUser = await locals.getAuthedUser()
+ if (!authedUser) {
+ throw redirect(302, '/login', notSignedInMessage, event)
}
const form = await superValidate(event, zod(modifyListGameSchema))
try {
- const game = await db.query.games.findFirst({
- where: eq(games.id, form.data.id),
+ const game = await db.query.gamesTable.findFirst({
+ where: eq(gamesTable.id, form.data.id),
})
if (!game) {
@@ -73,8 +74,8 @@ export const actions: Actions = {
}
if (game) {
- const wishlist = await db.query.wishlists.findFirst({
- where: eq(wishlists.user_id, user!.id!),
+ const wishlist = await db.query.wishlistsTable.findFirst({
+ where: eq(wishlistsTable.user_id, authedUser.id),
})
if (!wishlist) {
@@ -99,33 +100,36 @@ export const actions: Actions = {
// Create new wishlist
create: async (event) => {
const { locals } = event
- const { user, session } = locals
- if (userNotAuthenticated(user, session)) {
- return fail(401)
+
+ const authedUser = await locals.getAuthedUser()
+ if (!authedUser) {
+ throw redirect(302, '/login', notSignedInMessage, event)
}
return error(405, 'Method not allowed')
},
// Delete a wishlist
delete: async (event) => {
const { locals } = event
- const { user, session } = locals
- if (userNotAuthenticated(user, session)) {
- return fail(401)
+
+ const authedUser = await locals.getAuthedUser()
+ if (!authedUser) {
+ throw redirect(302, '/login', notSignedInMessage, event)
}
return error(405, 'Method not allowed')
},
// Remove game from a wishlist
remove: async (event) => {
const { locals } = event
- const { user, session } = locals
- if (userNotAuthenticated(user, session)) {
- return fail(401)
+
+ const authedUser = await locals.getAuthedUser()
+ if (!authedUser) {
+ throw redirect(302, '/login', notSignedInMessage, event)
}
const form = await superValidate(event, zod(modifyListGameSchema))
try {
- const game = await db.query.games.findFirst({
- where: eq(games.id, form.data.id),
+ const game = await db.query.gamesTable.findFirst({
+ where: eq(gamesTable.id, form.data.id),
})
if (!game) {
@@ -139,8 +143,8 @@ export const actions: Actions = {
}
if (game) {
- const wishlist = await db.query.wishlists.findFirst({
- where: eq(wishlists.user_id, user!.id!),
+ const wishlist = await db.query.wishlistsTable.findFirst({
+ where: eq(wishlistsTable.user_id, authedUser.id),
})
if (!wishlist) {
diff --git a/src/routes/(app)/(protected)/wishlists/[cuid]/+page.svelte b/src/routes/(app)/(protected)/wishlists/[cuid]/+page.svelte
index 12ea5c4..4eb0cca 100644
--- a/src/routes/(app)/(protected)/wishlists/[cuid]/+page.svelte
+++ b/src/routes/(app)/(protected)/wishlists/[cuid]/+page.svelte
@@ -1,9 +1,9 @@
@@ -18,7 +18,7 @@
{/each}
{:else}
- Sorry no games found!
+ Sorry no gamesTable found!
{/if}
diff --git a/src/routes/(app)/+page.server.ts b/src/routes/(app)/+page.server.ts
index ad7d0cc..e8606fe 100644
--- a/src/routes/(app)/+page.server.ts
+++ b/src/routes/(app)/+page.server.ts
@@ -2,7 +2,7 @@ import { db } from '$lib/server/api/packages/drizzle'
import { fail } from '@sveltejs/kit'
import { eq } from 'drizzle-orm'
import type { MetaTagsProps } from 'svelte-meta-tags'
-import { collections, usersTable, wishlists } from '../../lib/server/api/databases/tables'
+import { collections, usersTable, wishlistsTable } from '../../lib/server/api/databases/tables'
import type { PageServerLoad } from './$types'
// import { userFullyAuthenticated } from '$lib/server/auth-utils';
@@ -24,7 +24,7 @@ export const load: PageServerLoad = async (event) => {
url: new URL(url.pathname, url.origin).href,
locale: 'en_US',
title: 'Home',
- description: 'Bored Game, keep track of your games',
+ description: 'Bored Game, keep track of your gamesTable',
images: [image],
siteName: 'Bored Game',
},
@@ -33,7 +33,7 @@ export const load: PageServerLoad = async (event) => {
site: '@boredgame',
cardType: 'summary_large_image',
title: 'Home | Bored Game',
- description: 'Bored Game, keep track of your games',
+ description: 'Bored Game, keep track of your gamesTable',
image: `${new URL(url.pathname, url.origin).href}og?header=Bored Game&page=Home&content=Keep track of your games`,
imageAlt: 'Home | Bored Game',
},
@@ -44,7 +44,7 @@ export const load: PageServerLoad = async (event) => {
const { data: collectionsData, error: collectionsError } = await locals.api.collections.$get().then(locals.parseApiResponse)
if (wishlistsError || collectionsError) {
- return fail(500, 'Failed to fetch wishlists or collections')
+ return fail(500, 'Failed to fetch wishlistsTable or collections')
}
console.log('Wishlists', wishlistsData.wishlists)
diff --git a/src/routes/(app)/+page.svelte b/src/routes/(app)/+page.svelte
index d2a5055..63d16cb 100644
--- a/src/routes/(app)/+page.svelte
+++ b/src/routes/(app)/+page.svelte
@@ -1,31 +1,31 @@
{#if user}
Welcome, {welcomeName}!
-
You wishlists:
+
You wishlistsTable:
{#each wishlists as wishlist}
{wishlist.name}
{/each}
@@ -38,7 +38,7 @@
{:else}
Welcome to Bored Game!
-
Track the board games you own, the ones you want, and whether you play them enough.
+
Track the board gamesTable you own, the ones you want, and whether you play them enough.
Get started by joining the wait list or log in if you already have an account.
{/if}
diff --git a/src/routes/(app)/about/+page.svelte b/src/routes/(app)/about/+page.svelte
index 9dd3f37..f2b6915 100644
--- a/src/routes/(app)/about/+page.svelte
+++ b/src/routes/(app)/about/+page.svelte
@@ -6,7 +6,7 @@
About Bored Game
- One day we were bored and wanted to play one of our board games.
+ One day we were bored and wanted to play one of our board gamesTable.
Our problem was that we didn't know which one to play.
Rather than just pick a game I decided to make this overcomplicated solution.
I hope you enjoy using it!
diff --git a/src/routes/(app)/game/[id]/+page.server.ts b/src/routes/(app)/game/[id]/+page.server.ts
index 8fd02b9..7e37c23 100644
--- a/src/routes/(app)/game/[id]/+page.server.ts
+++ b/src/routes/(app)/game/[id]/+page.server.ts
@@ -1,4 +1,4 @@
-import { collection_items, collections, expansions, games, wishlist_items, wishlists } from '$lib/server/api/databases/tables'
+import { collection_items, collections, expansionsTable, gamesTable, wishlist_items, wishlistsTable } from '$lib/server/api/databases/tables'
import { db } from '$lib/server/api/packages/drizzle'
import { createCategory } from '$lib/utils/db/categoryUtils'
import { createExpansion } from '$lib/utils/db/expansionUtils'
@@ -15,7 +15,7 @@ export const load: PageServerLoad = async ({ params, locals, fetch }) => {
const { user } = locals
const { id } = params
const game = await db.query.games.findFirst({
- where: eq(games.id, id),
+ where: eq(gamesTable.id, id),
with: {
publishers_to_games: {
with: {
@@ -62,7 +62,7 @@ export const load: PageServerLoad = async ({ params, locals, fetch }) => {
}
const gameExpansions = await db.query.expansions.findMany({
- where: eq(expansions.base_game_id, game.id),
+ where: eq(expansionsTable.base_game_id, game.id),
with: {
game: {
columns: {
@@ -78,7 +78,7 @@ export const load: PageServerLoad = async ({ params, locals, fetch }) => {
let wishlistItem
if (user) {
const wishlist = await db.query.wishlists.findFirst({
- where: eq(wishlists.user_id, user.id),
+ where: eq(wishlistsTable.user_id, user.id),
})
// TODO: Select wishlist items based on wishlist
@@ -155,7 +155,7 @@ async function syncGameAndConnectedData(locals: App.Locals, game: Game, eventFet
boredGame.categories = categories
boredGame.mechanics = mechanics
boredGame.publishers = publishers
- // boredGame.expansions = expansions;
+ // boredGame.expansionsTable = expansionsTable;
return createOrUpdateGame(locals, boredGame, externalGame.external_id)
}
}
diff --git a/src/routes/(app)/search/+error.svelte b/src/routes/(app)/search/+error.svelte
index f26c443..808e9a2 100644
--- a/src/routes/(app)/search/+error.svelte
+++ b/src/routes/(app)/search/+error.svelte
@@ -1,5 +1,5 @@
-There was an error searching for games! 🤦♂️
-Please try again later. 🙇🏼
+There was an error searching for gamesTable! 🤦
+Please try again later. 🙇