Update dependencies, fix dropdown links to collections and wishlists, and fix error 404 page.

This commit is contained in:
Bradley Shellnut 2024-04-23 14:35:51 -07:00
parent ad5062b91c
commit 085cb2ef27
8 changed files with 5120 additions and 4381 deletions

View file

@ -21,53 +21,53 @@
"push": "drizzle-kit push:pg"
},
"devDependencies": {
"@melt-ui/pp": "^0.3.0",
"@melt-ui/pp": "^0.3.1",
"@melt-ui/svelte": "^0.76.3",
"@playwright/test": "^1.43.1",
"@resvg/resvg-js": "^2.6.2",
"@sveltejs/adapter-auto": "^3.2.0",
"@sveltejs/enhanced-img": "^0.2.0",
"@sveltejs/kit": "^2.5.6",
"@sveltejs/kit": "^2.5.7",
"@sveltejs/vite-plugin-svelte": "^3.1.0",
"@types/cookie": "^0.6.0",
"@types/node": "^20.12.6",
"@types/pg": "^8.11.5",
"@typescript-eslint/eslint-plugin": "^7.7.0",
"@typescript-eslint/parser": "^7.7.0",
"@typescript-eslint/eslint-plugin": "^7.7.1",
"@typescript-eslint/parser": "^7.7.1",
"autoprefixer": "^10.4.19",
"dotenv": "^16.4.5",
"drizzle-kit": "^0.20.14",
"drizzle-kit": "^0.20.17",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.36.0",
"eslint-plugin-svelte": "^2.38.0",
"just-clone": "^6.2.0",
"just-debounce-it": "^3.2.0",
"postcss": "^8.4.38",
"postcss-import": "^16.1.0",
"postcss-load-config": "^5.0.3",
"postcss-preset-env": "^9.5.4",
"postcss-preset-env": "^9.5.9",
"prettier": "^3.2.5",
"prettier-plugin-svelte": "^3.2.3",
"sass": "^1.74.1",
"satori": "^0.10.13",
"satori-html": "^0.3.2",
"svelte": "^4.2.14",
"svelte": "^4.2.15",
"svelte-check": "^3.6.9",
"svelte-headless-table": "^0.18.2",
"svelte-meta-tags": "^3.1.2",
"svelte-preprocess": "^5.1.3",
"svelte-preprocess": "^5.1.4",
"svelte-sequential-preprocessor": "^2.0.1",
"sveltekit-flash-message": "^2.4.4",
"sveltekit-rate-limiter": "^0.5.1",
"sveltekit-superforms": "^2.12.4",
"sveltekit-superforms": "^2.12.5",
"tailwindcss": "^3.4.3",
"ts-node": "^10.9.2",
"tslib": "^2.6.1",
"tsx": "^4.7.2",
"typescript": "^5.4.4",
"vite": "^5.2.8",
"vite": "^5.2.10",
"vitest": "^1.4.0",
"zod": "^3.22.4"
"zod": "^3.23.4"
},
"type": "module",
"engines": {
@ -75,22 +75,22 @@
"pnpm": ">=8"
},
"dependencies": {
"@fontsource/fira-mono": "^5.0.12",
"@fontsource/fira-mono": "^5.0.13",
"@iconify-icons/line-md": "^1.2.26",
"@iconify-icons/mdi": "^1.2.47",
"@lucia-auth/adapter-drizzle": "^1.0.7",
"@lukeed/uuid": "^2.0.1",
"@neondatabase/serverless": "^0.9.1",
"@paralleldrive/cuid2": "^2.2.2",
"@sveltejs/adapter-vercel": "^5.2.0",
"@sveltejs/adapter-vercel": "^5.3.0",
"@types/feather-icons": "^4.29.4",
"@vercel/og": "^0.5.20",
"bits-ui": "^0.21.3",
"bits-ui": "^0.21.4",
"boardgamegeekclient": "^1.9.1",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"clsx": "^2.1.1",
"cookie": "^0.6.0",
"drizzle-orm": "^0.30.7",
"drizzle-orm": "^0.30.9",
"feather-icons": "^4.29.1",
"formsnap": "^1.0.0",
"html-entities": "^2.5.2",
@ -100,7 +100,7 @@
"loader": "^2.1.1",
"lucia": "3.1.1",
"lucide-svelte": "^0.368.0",
"open-props": "^1.7.2",
"open-props": "^1.7.3",
"oslo": "^1.2.0",
"pg": "^8.11.5",
"postgres": "^3.4.4",
@ -108,9 +108,9 @@
"radix-svelte": "^0.9.0",
"svelte-french-toast": "^1.2.0",
"svelte-lazy-loader": "^1.0.0",
"tailwind-merge": "^2.2.2",
"tailwind-merge": "^2.3.0",
"tailwind-variants": "^0.2.1",
"tailwindcss-animate": "^1.0.6",
"zod-to-json-schema": "^3.22.5"
"zod-to-json-schema": "^3.23.0"
}
}

File diff suppressed because it is too large Load diff

View file

@ -2,11 +2,11 @@
import { applyAction, enhance } from '$app/forms';
import toast from 'svelte-french-toast';
import { ListChecks, ListTodo, LogOut, User } from 'lucide-svelte';
import * as DropdownMenu from "$components/ui/dropdown-menu";
import * as Avatar from "$components/ui/avatar";
import * as DropdownMenu from '$components/ui/dropdown-menu';
import * as Avatar from '$components/ui/avatar';
import { invalidateAll } from '$app/navigation';
import Logo from '$components/logo.svelte';
import type { Users } from "../../schema";
import type { Users } from '../../schema';
export let user: Users | null = null;
@ -49,16 +49,16 @@
<span>Profile</span>
</DropdownMenu.Item>
</a>
<a href="/collection">
<a href="/collections">
<DropdownMenu.Item>
<ListChecks class="mr-2 h-4 w-4" />
<span>Collection</span>
<span>Collections</span>
</DropdownMenu.Item>
</a>
<a href="/wishlist">
<a href="/wishlists">
<DropdownMenu.Item>
<ListTodo class="mr-2 h-4 w-4" />
<span>Wishlist</span>
<span>Wishlists</span>
</DropdownMenu.Item>
</a>
<form
@ -83,10 +83,10 @@
>
<button type="submit" class="">
<DropdownMenu.Item>
<div class="flex items-center gap-1">
<LogOut class="mr-2 h-4 w-4"/>
<span>Sign out</span>
</div>
<div class="flex items-center gap-1">
<LogOut class="mr-2 h-4 w-4" />
<span>Sign out</span>
</div>
</DropdownMenu.Item>
</button>
</form>
@ -94,12 +94,8 @@
</DropdownMenu.Content>
</DropdownMenu.Root>
{:else}
<a href="/login">
<span class="flex-auto">Login</span></a
>
<a href="/sign-up">
<span class="flex-auto">Sign Up</span></a
>
<a href="/login"> <span class="flex-auto">Login</span></a>
<a href="/sign-up"> <span class="flex-auto">Sign Up</span></a>
{/if}
</nav>
</header>

View file

@ -1,4 +1,5 @@
import type { SvelteComponent } from 'svelte';
import { collections } from '../schema';
export type Message = { status: 'error' | 'success' | 'warning' | 'info'; text: string };
@ -29,7 +30,7 @@ export type BoredStore = {
export enum ToastType {
INFO = 'INFO',
ERROR = 'ERROR',
WARNING = 'WARNING'
WARNING = 'WARNING',
}
export type ToastData = {
@ -86,11 +87,11 @@ export type DesignerType = {
export type ArtistType = {
id: string;
}
};
export type ExpansionType = {
id: string;
}
};
export type BGGLinkType =
| 'boardgamecategory'
@ -174,3 +175,5 @@ export type SearchQuery = {
lt_year_published?: number;
fields?: string;
};
export type UICollection = Pick<typeof collections, 'id' | 'cuid' | 'name'>;

View file

@ -0,0 +1,38 @@
<script lang="ts">
import { page } from '$app/stores';
</script>
<div class="error">
{#if $page.status === 404}
<h1>The page you requested doesn't exist! 🤷‍♂️</h1>
<h3 class="mt-6"><a href="/">Go Home</a></h3>
{:else}
<h1 class="h1">Unexpected Error</h1>
<h3 class="mt-6">We're investigating the issue.</h3>
{/if}
{#if $page.error?.errorId}
<p class="mt-6">Error ID: {$page.error.errorId}</p>
{/if}
</div>
<style style="postcss">
.error {
display: grid;
place-items: center;
text-align: center;
margin-top: 4rem;
}
h1 {
font-size: 1.125rem;
line-height: 1.75rem;
font-weight: 600;
}
h3 {
font-size: 1rem;
line-height: 1.5rem;
font-weight: 600;
}
</style>

View file

@ -1,4 +1,4 @@
import { type Actions, error, fail } from '@sveltejs/kit';
import { type Actions, error } from '@sveltejs/kit';
import { and, eq } from 'drizzle-orm';
import { zod } from 'sveltekit-superforms/adapters';
import { superValidate } from 'sveltekit-superforms/server';
@ -8,6 +8,7 @@ import db from '$lib/drizzle.js';
import { notSignedInMessage } from '$lib/flashMessages.js';
import { collections, games, collection_items } from '../../../../../schema.js';
import { search_schema } from '$lib/zodValidation';
import type { UICollection } from '$lib/types';
export async function load(event) {
const { locals, params, url } = event;
@ -32,81 +33,66 @@ export async function load(event) {
const searchForm = await superValidate(searchData, zod(search_schema));
const listManageForm = await superValidate(zod(modifyListGameSchema));
try {
const collection = await db.query.collections.findFirst({
columns: {
id: true,
cuid: true,
name: true,
},
where: and(eq(collections.user_id, user.id), eq(collections.cuid, id)),
});
console.log('collection', collection);
const collection: UICollection | undefined = await db.query.collections.findFirst({
columns: {
id: true,
cuid: true,
name: true,
},
where: and(eq(collections.user_id, user.id), eq(collections.cuid, id)),
});
console.log('collection', collection);
if (!collection) {
console.log('Collection was not found');
return fail(404, {});
// collection = await prisma.collection.create({
// data: {
// user_id: session.userId
// }
// });
}
if (!collection) {
console.log('Collection was not found');
error(404, 'Collection was not found');
}
const collectionItems = await db.query.collection_items.findMany({
columns: {
collection_id: true,
times_played: true,
},
where: eq(collection_items.collection_id, collection.id),
with: {
game: {
columns: {
id: true,
name: true,
thumb_url: true,
},
const collectionItems = await db.query.collection_items.findMany({
columns: {
collection_id: true,
times_played: true,
},
where: eq(collection_items.collection_id, collection.id),
with: {
game: {
columns: {
id: true,
name: true,
thumb_url: true,
},
},
offset: skip,
limit,
});
},
offset: skip,
limit,
});
console.log('collection_items', collectionItems);
console.log('collection_items', collectionItems);
const items: ListGame[] = [];
for (const item of collectionItems) {
console.log('item', item);
const game = item.game;
if (game) {
items.push({
id: game.id,
collection_id: item.collection_id,
game_name: game.name ?? "Game doesn't have a name",
thumb_url: game.thumb_url,
times_played: item.times_played ?? 0,
in_collection: true,
});
}
const items: ListGame[] = [];
for (const item of collectionItems) {
console.log('item', item);
const game = item.game;
if (game) {
items.push({
game_id: '',
in_wishlist: false,
wishlist_id: '',
id: game.id,
collection_id: item.collection_id,
game_name: game.name ?? "Game doesn't have a name",
thumb_url: game.thumb_url,
times_played: item.times_played ?? 0,
in_collection: true,
});
}
return {
searchForm,
listManageForm,
collection,
items,
};
} catch (e) {
console.error(e);
}
return {
searchForm,
listManageForm,
collection: {
name: "Collection doesn't have a name",
},
items: [],
collection,
items,
};
}

View file

@ -1,10 +1,11 @@
<script lang="ts">
// import { tick, onDestroy } from 'svelte';
import Game from '$components/Game.svelte';
import type { UICollection } from '$lib/types';
export let data;
console.log(`Page data: ${JSON.stringify(data)}`);
let collection = data?.collection ?? {};
let collection: UICollection = data?.collection ?? {};
let items = data?.items || [];
console.log('items', items);

View file

@ -1,4 +1,4 @@
import { error, type Actions } from '@sveltejs/kit';
import { fail, error, type Actions } from '@sveltejs/kit';
import { and, eq } from 'drizzle-orm';
import { zod } from 'sveltekit-superforms/adapters';
import { superValidate } from 'sveltekit-superforms/server';
@ -6,7 +6,7 @@ import { redirect } from 'sveltekit-flash-message/server';
import { modifyListGameSchema } from '$lib/validations/zod-schemas';
import db from '$lib/drizzle.js';
import { notSignedInMessage } from '$lib/flashMessages.js';
import { collections, games, wishlist_items, wishlists } from '../../../../schema.js';
import { games, wishlist_items, wishlists } from '../../../../schema.js';
export async function load(event) {
const user = event.locals.user;
@ -14,31 +14,23 @@ export async function load(event) {
redirect(302, '/login', notSignedInMessage, event);
}
try {
const userWishlists = await db.query.wishlists.findMany({
columns: {
cuid: true,
name: true,
created_at: true,
},
where: eq(wishlists.user_id, user.id),
});
console.log('wishlists', userWishlists);
const userWishlists = await db.query.wishlists.findMany({
columns: {
cuid: true,
name: true,
created_at: true,
},
where: eq(wishlists.user_id, user.id),
});
console.log('wishlists', userWishlists);
if (userWishlists?.length === 0) {
console.log('Wishlists not found');
return fail(404, {});
}
return {
wishlists: userWishlists,
};
} catch (e) {
console.error(e);
if (userWishlists?.length === 0) {
console.log('Wishlists not found');
return fail(404, {});
}
return {
wishlists: [],
wishlists: userWishlists,
};
}