-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* initial backend work * add functionality * change uuid to cuid * prevent adding users in registry mode * Prevent switching list mode when more than one user in group * redirect to main list in registry mode * update id generation * don't allow access if list was removed from registry mode * Prevent getting or creating link when not in registry mode * show claimed by public user if registry mode is de-activated * Add new lists events path to Caddyfile
- Loading branch information
Showing
35 changed files
with
822 additions
and
75 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
|
||
@not_sse { | ||
not path /wishlists/*/events | ||
not path /lists/*/events | ||
} | ||
|
||
# Handles User Images | ||
|
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
prisma/migrations/20240618010500_add_public_lists/migration.sql
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,14 @@ | ||
-- CreateTable | ||
CREATE TABLE "public_list" ( | ||
"id" TEXT NOT NULL PRIMARY KEY, | ||
"userId" TEXT NOT NULL, | ||
"groupId" TEXT NOT NULL, | ||
CONSTRAINT "public_list_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE, | ||
CONSTRAINT "public_list_groupId_fkey" FOREIGN KEY ("groupId") REFERENCES "group" ("id") ON DELETE CASCADE ON UPDATE CASCADE | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "public_list_id_key" ON "public_list"("id"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "public_list_userId_groupId_idx" ON "public_list"("userId", "groupId"); |
40 changes: 40 additions & 0 deletions
40
prisma/migrations/20240625011332_add_system_user_for_anonymous_claims/migration.sql
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,40 @@ | ||
-- CreateTable | ||
CREATE TABLE "system_user" ( | ||
"id" TEXT NOT NULL PRIMARY KEY, | ||
"username" TEXT NOT NULL, | ||
"name" TEXT DEFAULT 'Anonymous' | ||
); | ||
|
||
-- RedefineTables | ||
PRAGMA foreign_keys=OFF; | ||
CREATE TABLE "new_items" ( | ||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, | ||
"name" TEXT NOT NULL, | ||
"price" TEXT, | ||
"url" TEXT, | ||
"note" TEXT, | ||
"imageUrl" TEXT, | ||
"userId" TEXT NOT NULL, | ||
"addedById" TEXT NOT NULL, | ||
"pledgedById" TEXT, | ||
"publicPledgedById" TEXT, | ||
"approved" BOOLEAN NOT NULL DEFAULT true, | ||
"purchased" BOOLEAN NOT NULL DEFAULT false, | ||
"groupId" TEXT, | ||
CONSTRAINT "items_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE, | ||
CONSTRAINT "items_addedById_fkey" FOREIGN KEY ("addedById") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE, | ||
CONSTRAINT "items_pledgedById_fkey" FOREIGN KEY ("pledgedById") REFERENCES "user" ("id") ON DELETE SET NULL ON UPDATE CASCADE, | ||
CONSTRAINT "items_publicPledgedById_fkey" FOREIGN KEY ("publicPledgedById") REFERENCES "system_user" ("id") ON DELETE SET NULL ON UPDATE CASCADE, | ||
CONSTRAINT "items_groupId_fkey" FOREIGN KEY ("groupId") REFERENCES "group" ("id") ON DELETE CASCADE ON UPDATE CASCADE | ||
); | ||
INSERT INTO "new_items" ("addedById", "approved", "groupId", "id", "imageUrl", "name", "note", "pledgedById", "price", "purchased", "url", "userId") SELECT "addedById", "approved", "groupId", "id", "imageUrl", "name", "note", "pledgedById", "price", "purchased", "url", "userId" FROM "items"; | ||
DROP TABLE "items"; | ||
ALTER TABLE "new_items" RENAME TO "items"; | ||
CREATE UNIQUE INDEX "items_id_key" ON "items"("id"); | ||
CREATE INDEX "items_userId_idx" ON "items"("userId"); | ||
CREATE INDEX "items_pledgedById_idx" ON "items"("pledgedById"); | ||
PRAGMA foreign_key_check; | ||
PRAGMA foreign_keys=ON; | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "system_user_id_key" ON "system_user"("id"); |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
export class PublicListAPI { | ||
groupId: string; | ||
constructor(groupId: string) { | ||
this.groupId = groupId; | ||
} | ||
|
||
_makeRequest = async (method: string) => { | ||
const options: RequestInit = { | ||
method, | ||
headers: { | ||
"content-type": "application/json", | ||
accept: "application/json" | ||
} | ||
}; | ||
|
||
let url = "/api/lists"; | ||
if (method !== "GET") { | ||
options.body = JSON.stringify({ | ||
groupId: this.groupId | ||
}); | ||
} else { | ||
url += `?groupId=${this.groupId}`; | ||
} | ||
|
||
return await fetch(url, options); | ||
}; | ||
|
||
get = async () => { | ||
return await this._makeRequest("GET"); | ||
}; | ||
|
||
create = async () => { | ||
return await this._makeRequest("POST"); | ||
}; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<script lang="ts"> | ||
type AlertType = "info" | "warning" | "error"; | ||
export let title: string | null = null; | ||
export let type: AlertType; | ||
const icon = type === "info" ? "information-circle" : "warning"; | ||
const variant = type === "info" ? "primary" : type === "warning" ? "warning" : "error"; | ||
</script> | ||
|
||
<aside class="alert variant-ghost-{variant} mb-2"> | ||
<div class="alert-message flex flex-row items-center space-x-4 space-y-0"> | ||
<span><iconify-icon class="text-4xl" icon="ion:{icon}" /></span> | ||
<div> | ||
{#if title} | ||
<span class="text-xl font-bold">{title}</span> | ||
{/if} | ||
<p> | ||
<slot /> | ||
</p> | ||
</div> | ||
</div> | ||
</aside> |
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
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,21 @@ | ||
<script lang="ts"> | ||
import Alert from "$lib/components/Alert.svelte"; | ||
export let mode: ListMode; | ||
export let disabled = false; | ||
</script> | ||
|
||
<div class="flex flex-col space-y-2"> | ||
<h2 class="h2">Wishlist Mode</h2> | ||
{#if disabled} | ||
<Alert type="info"> | ||
There are other members in this group, you cannot switch the mode until you remove all but one member. | ||
</Alert> | ||
{/if} | ||
<select id="listMode" name="listMode" class="select w-fit min-w-64" bind:value={mode}> | ||
<option value="standard">Wishlist</option> | ||
{#if !disabled} | ||
<option value="registry">Registry</option> | ||
{/if} | ||
</select> | ||
</div> |
Oops, something went wrong.