From f11be741c59a9b18ba157cd46081628cd38b356c Mon Sep 17 00:00:00 2001 From: Bilal Dieumegard Date: Mon, 16 Dec 2024 12:11:47 +0100 Subject: [PATCH] Ajout des 3 points lors de l'ecriture d'un message. --- src/lib/components/ui/ProfileCard.svelte | 5 +- src/lib/components/ui/UserChat.svelte | 103 ++++++++++++++--------- src/routes/api/channels/+server.ts | 6 ++ src/routes/chats/+page.server.ts | 8 +- src/routes/chats/+page.svelte | 6 +- 5 files changed, 77 insertions(+), 51 deletions(-) diff --git a/src/lib/components/ui/ProfileCard.svelte b/src/lib/components/ui/ProfileCard.svelte index 8475786..3794768 100644 --- a/src/lib/components/ui/ProfileCard.svelte +++ b/src/lib/components/ui/ProfileCard.svelte @@ -2,10 +2,10 @@ import Button from '$lib/components/ui/button/button.svelte'; export let user; + export let userId; export let show = false; // Contrôle si la carte est visible export let onClose = () => {}; // Fonction pour fermer la carte - console.log(user) const disconnect = async () => { try { @@ -35,10 +35,11 @@
- Profile + Profile

{user.username}

{user.name} {user.surname}

+

{user.email}

diff --git a/src/lib/components/ui/UserChat.svelte b/src/lib/components/ui/UserChat.svelte index 4b057be..63e4735 100644 --- a/src/lib/components/ui/UserChat.svelte +++ b/src/lib/components/ui/UserChat.svelte @@ -2,49 +2,29 @@ export let user; -
- Profile -
- {user.username} -
- {user.state} - {#if user.state === "En ligne"} - - - - {:else if status === "Ecrit"} - - - - {/if} +
+
+ Profile +
+ {user.username} +
+ {user.state} +
+ {#if user.state === "En ligne"} +
+ {:else if user.state === "Ecrit"} +
+ + + +
+ {/if}
diff --git a/src/routes/api/channels/+server.ts b/src/routes/api/channels/+server.ts index 654ca4c..f5bf13c 100644 --- a/src/routes/api/channels/+server.ts +++ b/src/routes/api/channels/+server.ts @@ -75,6 +75,12 @@ export async function GET({ url }) { channels = channels.concat(canaux); + channels = channels.filter((channel, index, self) => + index === self.findIndex((t) => ( + t.id === channel.id + )) + ); + channels = sortChannels(channels); channels = channels.slice(0, 10); diff --git a/src/routes/chats/+page.server.ts b/src/routes/chats/+page.server.ts index 491e754..68a3ec2 100644 --- a/src/routes/chats/+page.server.ts +++ b/src/routes/chats/+page.server.ts @@ -1,4 +1,4 @@ -export async function load({ fetch }) { +export async function load({ fetch, locals }) { try { // Appel API ou récupération de données @@ -12,12 +12,14 @@ export async function load({ fetch }) { // Retourner les données à la page sous forme de props return { - channels + channels, + userId: locals.userId }; } catch (error) { console.error('Erreur lors du chargement des canaux:', error); return { - channels: [] + channels: [], + userId: locals.userId }; } } \ No newline at end of file diff --git a/src/routes/chats/+page.svelte b/src/routes/chats/+page.svelte index 84f78f4..2573938 100644 --- a/src/routes/chats/+page.svelte +++ b/src/routes/chats/+page.svelte @@ -35,22 +35,18 @@ }); function openProfileCard() { - console.log('openProfileCard'); showProfileCard = true; // Inverser l'état pour afficher/masquer le ProfilCard } function closeProfileCard() { - console.log('closeProfileCard'); showProfileCard = false; // Inverser l'état pour afficher/masquer le ProfilCard } function openCreateChat() { - console.log('openCreateChat'); showCreateChat = true; // Afficher le composant CreateChat } function closeCreateChat() { - console.log('closeCreateChat'); showCreateChat = false; // Fermer le composant CreateChat } @@ -112,7 +108,7 @@
- +