mirror of
https://github.com/BradNut/boredgame
synced 2025-09-08 17:40:22 +00:00
Remove unique on wishlist and collection ids. Only show add to buttons for now.
This commit is contained in:
parent
78f5bba669
commit
1a8ec5b905
4 changed files with 87 additions and 107 deletions
|
|
@ -26,7 +26,7 @@
|
|||
"@playwright/test": "^1.37.0",
|
||||
"@sveltejs/adapter-auto": "^1.0.3",
|
||||
"@sveltejs/adapter-vercel": "^1.0.6",
|
||||
"@sveltejs/kit": "^1.22.5",
|
||||
"@sveltejs/kit": "^1.22.6",
|
||||
"@types/cookie": "^0.5.1",
|
||||
"@types/node": "^18.17.5",
|
||||
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
||||
|
|
|
|||
|
|
@ -99,13 +99,13 @@ devDependencies:
|
|||
version: 1.37.0
|
||||
'@sveltejs/adapter-auto':
|
||||
specifier: ^1.0.3
|
||||
version: 1.0.3(@sveltejs/kit@1.22.5)
|
||||
version: 1.0.3(@sveltejs/kit@1.22.6)
|
||||
'@sveltejs/adapter-vercel':
|
||||
specifier: ^1.0.6
|
||||
version: 1.0.6(@sveltejs/kit@1.22.5)
|
||||
version: 1.0.6(@sveltejs/kit@1.22.6)
|
||||
'@sveltejs/kit':
|
||||
specifier: ^1.22.5
|
||||
version: 1.22.5(svelte@4.2.0)(vite@4.4.9)
|
||||
specifier: ^1.22.6
|
||||
version: 1.22.6(svelte@4.2.0)(vite@4.4.9)
|
||||
'@types/cookie':
|
||||
specifier: ^0.5.1
|
||||
version: 0.5.1
|
||||
|
|
@ -174,10 +174,10 @@ devDependencies:
|
|||
version: 2.0.1
|
||||
sveltekit-flash-message:
|
||||
specifier: ^2.1.3
|
||||
version: 2.1.3(@sveltejs/kit@1.22.5)(svelte@4.2.0)
|
||||
version: 2.1.3(@sveltejs/kit@1.22.6)(svelte@4.2.0)
|
||||
sveltekit-superforms:
|
||||
specifier: ^1.5.1
|
||||
version: 1.5.1(@sveltejs/kit@1.22.5)(svelte@4.2.0)(zod@3.21.4)
|
||||
version: 1.5.1(@sveltejs/kit@1.22.6)(svelte@4.2.0)(zod@3.21.4)
|
||||
tailwindcss:
|
||||
specifier: ^3.3.3
|
||||
version: 3.3.3(ts-node@10.9.1)
|
||||
|
|
@ -1308,21 +1308,21 @@ packages:
|
|||
picomatch: 2.3.1
|
||||
dev: true
|
||||
|
||||
/@sveltejs/adapter-auto@1.0.3(@sveltejs/kit@1.22.5):
|
||||
/@sveltejs/adapter-auto@1.0.3(@sveltejs/kit@1.22.6):
|
||||
resolution: {integrity: sha512-hc7O12YQqvZ1CD4fo1gMJuPzBZvuoG5kwxb2RRoz4fVoB8B2vuPO2cY751Ln0G6T/HMrAf8kCqw6Pg+wbxcstw==}
|
||||
peerDependencies:
|
||||
'@sveltejs/kit': ^1.0.0
|
||||
dependencies:
|
||||
'@sveltejs/kit': 1.22.5(svelte@4.2.0)(vite@4.4.9)
|
||||
'@sveltejs/kit': 1.22.6(svelte@4.2.0)(vite@4.4.9)
|
||||
import-meta-resolve: 2.2.0
|
||||
dev: true
|
||||
|
||||
/@sveltejs/adapter-vercel@1.0.6(@sveltejs/kit@1.22.5):
|
||||
/@sveltejs/adapter-vercel@1.0.6(@sveltejs/kit@1.22.6):
|
||||
resolution: {integrity: sha512-fo6aaEygPd/6B5Jms4Ff7R4jbADnppuLvKOWBNTGe5MGB7ZRUkl+gxHWMQx2av2knyEZkA6V8y5M6R3ML5yN4g==}
|
||||
peerDependencies:
|
||||
'@sveltejs/kit': ^1.0.0
|
||||
dependencies:
|
||||
'@sveltejs/kit': 1.22.5(svelte@4.2.0)(vite@4.4.9)
|
||||
'@sveltejs/kit': 1.22.6(svelte@4.2.0)(vite@4.4.9)
|
||||
'@vercel/nft': 0.22.6
|
||||
esbuild: 0.16.8
|
||||
transitivePeerDependencies:
|
||||
|
|
@ -1330,8 +1330,8 @@ packages:
|
|||
- supports-color
|
||||
dev: true
|
||||
|
||||
/@sveltejs/kit@1.22.5(svelte@4.2.0)(vite@4.4.9):
|
||||
resolution: {integrity: sha512-LHq+ECucoT6c6/tkrxIQtD8KVNhPFV4QQ+xOKTwBAs/Qdtff8P5gAzsIZiwEaaO6J6sYZoy5RP2VR6m8PSCgLA==}
|
||||
/@sveltejs/kit@1.22.6(svelte@4.2.0)(vite@4.4.9):
|
||||
resolution: {integrity: sha512-SDKxI/QpsReCwIn5czjT53fKlPBybbmMk67d317gUqfeORroBAFN1Z6s/x0E1JYi+04i7kKllS+Sz9wVfmUkAQ==}
|
||||
engines: {node: ^16.14 || >=18}
|
||||
hasBin: true
|
||||
requiresBuild: true
|
||||
|
|
@ -3992,24 +3992,24 @@ packages:
|
|||
magic-string: 0.30.0
|
||||
periscopic: 3.1.0
|
||||
|
||||
/sveltekit-flash-message@2.1.3(@sveltejs/kit@1.22.5)(svelte@4.2.0):
|
||||
/sveltekit-flash-message@2.1.3(@sveltejs/kit@1.22.6)(svelte@4.2.0):
|
||||
resolution: {integrity: sha512-NFhQ3t2101AM9JO5Mgj38r69ykF4BOs1Ap3567DaM1RoAaNtXRXpAuEc/DQV78HZN/Fxzw8dxyTMdIC1HztUvA==}
|
||||
peerDependencies:
|
||||
'@sveltejs/kit': 1.x
|
||||
svelte: 3.x || 4.x
|
||||
dependencies:
|
||||
'@sveltejs/kit': 1.22.5(svelte@4.2.0)(vite@4.4.9)
|
||||
'@sveltejs/kit': 1.22.6(svelte@4.2.0)(vite@4.4.9)
|
||||
svelte: 4.2.0
|
||||
dev: true
|
||||
|
||||
/sveltekit-superforms@1.5.1(@sveltejs/kit@1.22.5)(svelte@4.2.0)(zod@3.21.4):
|
||||
/sveltekit-superforms@1.5.1(@sveltejs/kit@1.22.6)(svelte@4.2.0)(zod@3.21.4):
|
||||
resolution: {integrity: sha512-OqKzxuL1P29CFiK1CD00JRsvEsRPedvrR0qXmB4uqzXAIjOS+DpLjoEaa6Cnkd4H00fRa2161GcZNeEBue/D3A==}
|
||||
peerDependencies:
|
||||
'@sveltejs/kit': 1.x
|
||||
svelte: 3.x || 4.x
|
||||
zod: 3.x
|
||||
dependencies:
|
||||
'@sveltejs/kit': 1.22.5(svelte@4.2.0)(vite@4.4.9)
|
||||
'@sveltejs/kit': 1.22.6(svelte@4.2.0)(vite@4.4.9)
|
||||
svelte: 4.2.0
|
||||
zod: 3.21.4
|
||||
dev: true
|
||||
|
|
|
|||
|
|
@ -90,13 +90,15 @@ model Collection {
|
|||
|
||||
model CollectionItem {
|
||||
id String @id @default(cuid())
|
||||
collection_id String @unique
|
||||
collection_id String
|
||||
collection Collection @relation(references: [id], fields: [collection_id], onDelete: Cascade)
|
||||
game_id String @unique
|
||||
game Game @relation(references: [id], fields: [game_id])
|
||||
times_played Int
|
||||
|
||||
@@index([game_id, collection_id])
|
||||
@@index([game_id])
|
||||
@@index([collection_id])
|
||||
@@map("collection_items")
|
||||
}
|
||||
|
||||
|
|
@ -112,7 +114,7 @@ model Wishlist {
|
|||
|
||||
model WishlistItem {
|
||||
id String @id @default(cuid())
|
||||
wishlist_id String @unique
|
||||
wishlist_id String
|
||||
wishlist Wishlist @relation(references: [id], fields: [wishlist_id], onDelete: Cascade)
|
||||
game_id String @unique
|
||||
game Game @relation(references: [id], fields: [game_id])
|
||||
|
|
@ -120,6 +122,8 @@ model WishlistItem {
|
|||
updated_at DateTime @updatedAt @db.Timestamp(6)
|
||||
|
||||
@@index([game_id, wishlist_id])
|
||||
@@index([game_id])
|
||||
@@index([wishlist_id])
|
||||
@@map("wishlist_items")
|
||||
}
|
||||
|
||||
|
|
@ -136,7 +140,7 @@ model List {
|
|||
|
||||
model ListItem {
|
||||
id String @id @default(cuid())
|
||||
list_id String @unique
|
||||
list_id String
|
||||
list List @relation(references: [id], fields: [list_id], onDelete: Cascade)
|
||||
game_id String @unique
|
||||
game Game @relation(references: [id], fields: [game_id])
|
||||
|
|
@ -144,6 +148,8 @@ model ListItem {
|
|||
updated_at DateTime @updatedAt @db.Timestamp(6)
|
||||
|
||||
@@index([game_id, list_id])
|
||||
@@index([game_id])
|
||||
@@index([list_id])
|
||||
@@map("list_items")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,72 +13,74 @@
|
|||
export let in_collection = false;
|
||||
export let lists = [];
|
||||
|
||||
const handleChange = ({ curr, next }) => {
|
||||
console.log({ curr, next });
|
||||
return next;
|
||||
}
|
||||
// const handleChange = ({ curr, next }) => {
|
||||
// console.log({ curr, next });
|
||||
// return next;
|
||||
// }
|
||||
|
||||
const {
|
||||
elements: { trigger, menu, option, label, group, groupLabel },
|
||||
states: { valueLabel, open },
|
||||
helpers: { isSelected },
|
||||
} = createSelect({
|
||||
forceVisible: true,
|
||||
onValueChange: handleChange
|
||||
});
|
||||
// const {
|
||||
// elements: { trigger, menu, option, label, group, groupLabel },
|
||||
// states: { valueLabel, open },
|
||||
// helpers: { isSelected },
|
||||
// } = createSelect({
|
||||
// forceVisible: true,
|
||||
// onValueChange: handleChange
|
||||
// });
|
||||
|
||||
console.log({ in_collection, in_wishlist });
|
||||
// console.log({ in_collection, in_wishlist });
|
||||
|
||||
let options: Record<string, string> = {};
|
||||
let list_of_lists = [];
|
||||
if (!in_collection) {
|
||||
options[collection.id] = 'Add to collection';
|
||||
}
|
||||
if (!in_wishlist) {
|
||||
options[wishlist.id] = 'Add to wishlist';
|
||||
}
|
||||
lists.forEach((list) => {
|
||||
if (!list?.in_list) {
|
||||
options[list.id] = list.name;
|
||||
}
|
||||
});
|
||||
// let options: Record<string, string> = {};
|
||||
// let list_of_lists = [];
|
||||
// if (!in_collection) {
|
||||
// options[collection.id] = 'Add to collection';
|
||||
// }
|
||||
// if (!in_wishlist) {
|
||||
// options[wishlist.id] = 'Add to wishlist';
|
||||
// }
|
||||
// lists.forEach((list) => {
|
||||
// if (!list?.in_list) {
|
||||
// options[list.id] = list.name;
|
||||
// }
|
||||
// });
|
||||
</script>
|
||||
|
||||
{#if in_wishlist}
|
||||
<form method="POST" action={`/wishlist?/remove`} use:enhance>
|
||||
<input type="hidden" name="id" value={game_id} />
|
||||
<Button variant="destructive" type="submit">
|
||||
<MinusCircle class="square-5" /> Remove from wishlist
|
||||
</Button>
|
||||
</form>
|
||||
{:else}
|
||||
<form method="POST" action='/wishlist?/add' use:enhance>
|
||||
<input type="hidden" name="id" value={game_id} />
|
||||
<Button variant="destructive" type="submit">
|
||||
<PlusCircle class="square-5" /> Add to wishlist
|
||||
</Button>
|
||||
</form>
|
||||
{/if}
|
||||
<div class="flex gap-1">
|
||||
{#if in_wishlist}
|
||||
<form method="POST" action={`/wishlist?/remove`} use:enhance>
|
||||
<input type="hidden" name="id" value={game_id} />
|
||||
<Button class="flex gap-1" variant="destructive" type="submit">
|
||||
<MinusCircle class="square-5" /> Remove from wishlist
|
||||
</Button>
|
||||
</form>
|
||||
{:else}
|
||||
<form method="POST" action='/wishlist?/add' use:enhance>
|
||||
<input type="hidden" name="id" value={game_id} />
|
||||
<Button class="flex gap-1" type="submit">
|
||||
<PlusCircle class="square-5" /> Add to wishlist
|
||||
</Button>
|
||||
</form>
|
||||
{/if}
|
||||
|
||||
{#if in_collection}
|
||||
<form method="POST" action='/collection?/remove' use:enhance>
|
||||
<input type="hidden" name="id" value={game_id} />
|
||||
<Button variant="destructive" type="submit">
|
||||
<MinusCircle class="square-5" /> Remove from collection
|
||||
</Button>
|
||||
</form>
|
||||
{:else}
|
||||
<form method="POST" action='/collection?/add' use:enhance>
|
||||
<input type="hidden" name="id" value={game_id} />
|
||||
<Button variant="destructive" type="submit">
|
||||
<PlusCircle class="square-5" /> Add to collection
|
||||
</Button>
|
||||
</form>
|
||||
{/if}
|
||||
{#if in_collection}
|
||||
<form method="POST" action='/collection?/remove' use:enhance>
|
||||
<input type="hidden" name="id" value={game_id} />
|
||||
<Button class="flex gap-1" type="submit" variant="destructive">
|
||||
<MinusCircle class="square-5" /> Remove from collection
|
||||
</Button>
|
||||
</form>
|
||||
{:else}
|
||||
<form method="POST" action='/collection?/add' use:enhance>
|
||||
<input type="hidden" name="id" value={game_id} />
|
||||
<Button class="flex gap-1" type="submit">
|
||||
<PlusCircle class="square-5" /> Add to collection
|
||||
</Button>
|
||||
</form>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-1">
|
||||
<!-- <div class="flex flex-col gap-1"> -->
|
||||
<!-- svelte-ignore a11y-label-has-associated-control - $label contains the 'for' attribute -->
|
||||
<button
|
||||
<!-- <button
|
||||
class="flex h-10 min-w-[220px] items-center justify-between rounded-md bg-white px-3 py-2 text-black-500 transition-opacity hover:opacity-90"
|
||||
use:melt={$trigger}
|
||||
aria-label="Wishlist"
|
||||
|
|
@ -107,32 +109,4 @@
|
|||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<!-- <CardFooter>
|
||||
<div class="grid gap-2 place-items-center">
|
||||
<form method="POST" action={`/collection?/${existsInCollection ? 'remove' : 'add'}`}>
|
||||
<input type="hidden" name="id" value={game.id} />
|
||||
<Button variant={existsInCollection ? 'destructive' : 'default'}>
|
||||
{collectionText}
|
||||
{#if existsInCollection}
|
||||
<iconify-icon class="ml-2" icon={minusCircle} width="24" height="24" />
|
||||
{:else}
|
||||
<iconify-icon class="ml-2" icon={plusCircle} width="24" height="24" />
|
||||
{/if}
|
||||
</Button>
|
||||
</form>
|
||||
<!-- Add dropdown for wishlist add -->
|
||||
<!--- <form method="POST" action={`/wishlist?/${existsInWishlist ? 'remove' : 'add'}`}>
|
||||
<input type="hidden" name="id" value={game.id} />
|
||||
<Button variant={existsInWishlist ? 'destructive' : 'default'}>
|
||||
{wishlistText}
|
||||
{#if existsInWishlist}
|
||||
<iconify-icon class="ml-2" icon={minusCircle} width="24" height="24" />
|
||||
{:else}
|
||||
<iconify-icon class="ml-2" icon={plusCircle} width="24" height="24" />
|
||||
{/if}
|
||||
</Button>
|
||||
</form>
|
||||
</div>
|
||||
</CardFooter> -->
|
||||
</div> -->
|
||||
Loading…
Reference in a new issue