From 297c1ac1b6b902a9274f54d752c75bc814791722 Mon Sep 17 00:00:00 2001 From: nicolas-arnaud Date: Sat, 18 Mar 2023 08:40:39 +0100 Subject: [PATCH] fixed personals profils --- .env_sample | 25 +++++++++++++++++++++ front/volume/src/App.svelte | 1 + front/volume/src/components/Channels.svelte | 19 ++++++++-------- front/volume/src/components/Profile.svelte | 8 +++---- 4 files changed, 40 insertions(+), 13 deletions(-) create mode 100644 .env_sample diff --git a/.env_sample b/.env_sample new file mode 100644 index 0000000..1e5aaa2 --- /dev/null +++ b/.env_sample @@ -0,0 +1,25 @@ +POSTGRES_HOST=postgres +POSTGRES_PORT=5432 +POSTGRES_USER=postgres_usr +POSTGRES_PASSWORD=postgres_pw +POSTGRES_DB=transcendence + +PGADMIN_DEFAULT_EMAIL=admin@pg.com +PGADMIN_DEFAULT_PASSWORD=admin + +MAIL_USER=vaganiwast@gmail.com +MAIL_PASSWORD= + +FRONT_FPS=144 + +HOST=localhost +FRONT_PORT=80 +BACK_PORT=3001 +HASH_SALT=10 + +JWT_SECRET=test +JWT_EXPIRATION_TIME=900 + +FT_OAUTH_CLIENT_ID= +FT_OAUTH_CLIENT_SECRET= +FT_OAUTH_CALLBACK_URL=http://$HOST:$BACK_PORT/log/inReturn diff --git a/front/volume/src/App.svelte b/front/volume/src/App.svelte index 836ef45..83d9c91 100644 --- a/front/volume/src/App.svelte +++ b/front/volume/src/App.svelte @@ -92,6 +92,7 @@ profileUsername = event.detail; setAppState(APPSTATE.PROFILE_ID); } +$: console.log(profileUsername) async function getDMs(username: string): Promise { const res = await fetch(API_URL + "/channels/dms/" + username, { diff --git a/front/volume/src/components/Channels.svelte b/front/volume/src/components/Channels.svelte index 84350ac..974f138 100644 --- a/front/volume/src/components/Channels.svelte +++ b/front/volume/src/components/Channels.svelte @@ -95,14 +95,13 @@ export let onSelectChannel: (channel: ChannelsType) => void; export const selectChat = (id: number) => { console.log("channel: ", id) - popup.set(bind(Alert, {message:"Did not find channel", form : false})) getChannels().then(() => { const channel = channels.find((c) => c.id === id); if (channel) { joinChannel(id); onSelectChannel(channel); } else { - alert("Did not find channel"); + popup.set(bind(Alert, {message:"Did not find channel", form : false})) } }); }; @@ -112,7 +111,7 @@ let password = ""; name = prompt("Enter a name for the new channel:"); if (name.includes("#")) { - alert("Channel name cannot contain #"); + popup.set(bind(Alert, {message:"Channel name cannot contain #", form : false})) return; } if (name) { @@ -133,7 +132,8 @@ isPrivate: channelMode === "private", }), }); - if (!response.ok) alert("Error creating channel"); + if (!response.ok) + popup.set(bind(Alert, {message:"Error creating channel", form : false})) getChannels() } }; @@ -149,7 +149,8 @@ mode: "cors", }); if (response.ok) channels = channels.filter((c) => c.id !== id); - else alert("Error deleting channel"); + else + popup.set(bind(Alert, {message:"Error deleting channel", form : false})) } }; @@ -176,12 +177,12 @@ }), }); if (response2.ok) { - alert("User invited"); + popup.set(bind(Alert, {message:"User invited", form : false})) } else { - alert("Error inviting user"); + popup.set(bind(Alert, {message:"Error inviting user", form : false})) } } else { - alert("Error getting user infos"); + popup.set(bind(Alert, {message:"Error getting user infos", form : false})) } }; @@ -205,7 +206,7 @@ if (response.ok) { channels.push(await response.json()); } else { - alert("Error changing password"); + popup.set(bind(Alert, {message:"Error changing password", form : false})) } }; diff --git a/front/volume/src/components/Profile.svelte b/front/volume/src/components/Profile.svelte index a1121c1..5d77f2d 100644 --- a/front/volume/src/components/Profile.svelte +++ b/front/volume/src/components/Profile.svelte @@ -17,17 +17,17 @@ export let username: string = $store.username; let edit: boolean = true; - let user: any = $store; + let user: Player = $store; let avatarForm: HTMLFormElement; async function getUser() { if (username !== $store.username) { edit = false; - const res = await fetch(API_URL + "/users/" + username + "/byname", { + let res = await fetch(API_URL + "/users/" + username + "/byname", { mode: "cors", }); - user = res.json(); + user = await res.json(); } } @@ -69,7 +69,7 @@

===| {user.username}'s Profile |===

{#if !edit} - avatar + avatar {:else}