WalidMoovin 2 years ago
parent
commit
63176751f3
  1. 2
      front/volume/src/components/Chat2.svelte
  2. 1
      front/volume/src/components/NavBar.svelte
  3. 26
      front/volume/src/components/Profile.svelte

2
front/volume/src/components/Chat2.svelte

@ -15,7 +15,7 @@
name: "You", name: "You",
text: newText, text: newText,
}; };
chatMessages = [...chatMessages.slice(-5 + 1), newMessage]; chatMessages = [...chatMessages.slice(-7 + 1), newMessage];
newText = ""; newText = "";
} }
// TODO: save to database // TODO: save to database

1
front/volume/src/components/NavBar.svelte

@ -11,7 +11,6 @@
export let clickHistory = () => {}; export let clickHistory = () => {};
export let clickFriends = () => {}; export let clickFriends = () => {};
export let clickSpectate = () => {}; export let clickSpectate = () => {};
export let clickChat = () => {};
export let clickChannels = () => {}; export let clickChannels = () => {};
</script> </script>

26
front/volume/src/components/Profile.svelte

@ -27,7 +27,23 @@
} }
async function handleAvatarUpload(event: Event) { async function handleAvatarUpload(event: Event) {
event.preventDefault(); event.preventDefault();
alert("Trying to upload avatar"); const fileInput = document.getElementById('avatar-input') as HTMLInputElement;
const file = fileInput.files[0];
const formData = new FormData();
formData.append('avatar', file);
try {
const response = await fetch('http://localhost:3001/avatar', {
method: 'POST',
body: formData
});
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
} }
async function handle2fa(event: Event) { async function handle2fa(event: Event) {
event.preventDefault(); event.preventDefault();
@ -40,8 +56,10 @@
<div class="profile-header"> <div class="profile-header">
<img class="profile-img" src="img/profileicon.png" alt="Profile Icon" /> <img class="profile-img" src="img/profileicon.png" alt="Profile Icon" />
<h3>{realname}</h3> <h3>{realname}</h3>
<form on:submit={handleAvatarUpload}> <form>
<button type="submit">Upload Avatar</button> <label for="avatar-input">Choose avatar:</label>
<input type="file" id="avatar-input" accept="image/*">
<button type="submit" id="upload-button" on:click={handleAvatarUpload}>Upload</button>
</form> </form>
</div> </div>
<div class="profile-body"> <div class="profile-body">
@ -89,7 +107,7 @@
border: 1px solid #ccc; border: 1px solid #ccc;
border-radius: 5px; border-radius: 5px;
padding: 1rem; padding: 1rem;
width: 300px; width: 375px;
} }
.profile-header { .profile-header {

Loading…
Cancel
Save