From 56c9270fdb1e2942cb44438667890fd52eb29b61 Mon Sep 17 00:00:00 2001 From: sam Date: Sat, 12 Aug 2023 17:01:01 +0200 Subject: [PATCH] edit member page progress --- .../@[username]/[memberName]/+page.svelte | 4 +- .../[memberName]/edit/+layout.svelte | 171 ++++++++++++++++++ .../@[username]/[memberName]/edit/+layout.ts | 31 ++++ .../[memberName]/edit/+page.svelte | 151 ++++++++++++++++ 4 files changed, 355 insertions(+), 2 deletions(-) create mode 100644 frontend/src/routes/@[username]/[memberName]/edit/+layout.svelte create mode 100644 frontend/src/routes/@[username]/[memberName]/edit/+layout.ts create mode 100644 frontend/src/routes/@[username]/[memberName]/edit/+page.svelte diff --git a/frontend/src/routes/@[username]/[memberName]/+page.svelte b/frontend/src/routes/@[username]/[memberName]/+page.svelte index 504448a..9089959 100644 --- a/frontend/src/routes/@[username]/[memberName]/+page.svelte +++ b/frontend/src/routes/@[username]/[memberName]/+page.svelte @@ -65,7 +65,7 @@ You are currently viewing the public profile of {data.display_name ?? data.name}. -
Edit profile +
Edit profile
{/if}
@@ -93,7 +93,7 @@

This member's profile is empty! You can customize it by going to the edit memberedit member page. (only you can see this)

diff --git a/frontend/src/routes/@[username]/[memberName]/edit/+layout.svelte b/frontend/src/routes/@[username]/[memberName]/edit/+layout.svelte new file mode 100644 index 0000000..2f8c259 --- /dev/null +++ b/frontend/src/routes/@[username]/[memberName]/edit/+layout.svelte @@ -0,0 +1,171 @@ + + + + Edit member profile - pronouns.cc + + +

+ Edit profile + + + + + +

+ +{#if error} + +{/if} + + + +
+ +
+ + + +

+ If you want to delete this member, type {deleteModalPronoun} name ({$member.name}) below: +

+

+ +

+ {#if deleteError} + + {/if} +
+ + + + +
diff --git a/frontend/src/routes/@[username]/[memberName]/edit/+layout.ts b/frontend/src/routes/@[username]/[memberName]/edit/+layout.ts new file mode 100644 index 0000000..1520af7 --- /dev/null +++ b/frontend/src/routes/@[username]/[memberName]/edit/+layout.ts @@ -0,0 +1,31 @@ +import type { PrideFlag, MeUser, APIError, Member, PronounsJson } from "$lib/api/entities"; +import { apiFetchClient } from "$lib/api/fetch"; +import { error, redirect } from "@sveltejs/kit"; + +import pronounsRaw from "$lib/pronouns.json"; +import type { LayoutLoad } from "./$types"; +const pronouns = pronounsRaw as PronounsJson; + +export const ssr = false; + +export const load = (async ({ params }) => { + try { + const user = await apiFetchClient(`/users/@me`); + const member = await apiFetchClient(`/users/@me/members/${params.memberName}`); + const flags = await apiFetchClient("/users/@me/flags"); + + if (user.name !== params.username || member.user.name !== params.username || member.name !== params.memberName) { + throw redirect(303, `/@${user.name}/${member.name}`); + } + + return { + user, + member, + pronouns: pronouns.autocomplete, + flags, + }; + } catch (e) { + if ("code" in e) throw error(500, e as APIError); + throw e; + } +}) satisfies LayoutLoad; diff --git a/frontend/src/routes/@[username]/[memberName]/edit/+page.svelte b/frontend/src/routes/@[username]/[memberName]/edit/+page.svelte new file mode 100644 index 0000000..dbd4eaa --- /dev/null +++ b/frontend/src/routes/@[username]/[memberName]/edit/+page.svelte @@ -0,0 +1,151 @@ + + +
+
+
+
+ {#if $member.avatar === ""} + + {:else if $member.avatar} + New avatar + {:else} + + {/if} +
+
+ +

+ Only PNG, JPEG, GIF, and WebP images can be used + as avatars. Avatars cannot be larger than 1 MB, and animated avatars will be made static. +

+

+ + ($member.avatar = "")}>Remove avatar +

+
+
+
+
+ + +

+ + The member name is only used as part of the link to their profile page. +

+
+ {#if !memberNameValid} +

That member name is not valid.

+ {/if} + + + +

+ + Your display name is used in page titles and as a header. +

+
+
+
+

Names

+ {#each $member.names as _, index} + moveName(index, true)} + moveDown={() => moveName(index, false)} + remove={() => removeName(index)} + /> + {/each} +
+ + + +