del: Avatar image

This commit is contained in:
Alex
2024-10-07 11:40:58 +02:00
parent dfbeabc93c
commit 580b022c42

View File

@@ -23,12 +23,12 @@
/** @type {App.Locals['licence_categories']} */ /** @type {App.Locals['licence_categories']} */
$: licence_categories = $page.data.licence_categories; $: licence_categories = $page.data.licence_categories;
/** @typedef {{name: string, src: string}} Avatar */ // /** @typedef {{name: string, src: string}} Avatar */
const avatarFiles = import.meta.glob("$lib/img/Avatar-*.jpeg", { // const avatarFiles = import.meta.glob("$lib/img/Avatar-*.jpeg", {
eager: true, // eager: true,
}); // });
/** @type{Avatar[]} */ // /** @type{Avatar[]} */
let avatars = []; // let avatars = [];
const TABS = ["profile", "licence", "membership", "bankaccount"]; const TABS = ["profile", "licence", "membership", "bankaccount"];
let activeTab = TABS[0]; let activeTab = TABS[0];
@@ -67,13 +67,13 @@
let showModal = false, let showModal = false,
isUploading = false, isUploading = false,
isUpdating = false, isUpdating = false,
showAvatars = false, // showAvatars = false,
password = "", password = "",
password2 = ""; password2 = "";
const open = () => (showModal = true); const open = () => (showModal = true);
const close = () => (showModal = false); const close = () => (showModal = false);
const toggleAvatars = () => (showAvatars = !showAvatars); // const toggleAvatars = () => (showAvatars = !showAvatars);
$: selectedSubscriptionModel = $: selectedSubscriptionModel =
subscriptions.find( subscriptions.find(
@@ -83,26 +83,26 @@
onMount(() => { onMount(() => {
console.dir(user); console.dir(user);
console.dir(licence_categories); console.dir(licence_categories);
avatars = Object.entries(avatarFiles).map(([path, module]) => { // avatars = Object.entries(avatarFiles).map(([path, module]) => {
if (typeof path !== "string") { // if (typeof path !== "string") {
throw new Error("Unexpected non-string path"); // throw new Error("Unexpected non-string path");
} // }
if ( // if (
typeof module !== "object" || // typeof module !== "object" ||
module === null || // module === null ||
!("default" in module) // !("default" in module)
) { // ) {
throw new Error("Unexpected module format"); // throw new Error("Unexpected module format");
} // }
const src = module.default; // const src = module.default;
if (typeof src !== "string") { // if (typeof src !== "string") {
throw new Error("Unexpected default export type"); // throw new Error("Unexpected default export type");
} // }
return { // return {
name: path.split("/").pop()?.split(".")[0] ?? "Unknown", // name: path.split("/").pop()?.split(".")[0] ?? "Unknown",
src: src, // src: src,
}; // };
}); // });
}); });
/** /**
@@ -126,28 +126,28 @@
}; };
/** @type {import('./$types').SubmitFunction} */ /** @type {import('./$types').SubmitFunction} */
const handleUpload = async () => { // const handleUpload = async () => {
isUploading = true; // isUploading = true;
return async ({ result }) => { // return async ({ result }) => {
isUploading = false; // isUploading = false;
/** @type {any} */ // /** @type {any} */
const res = result; // const res = result;
if (result.type === "success" || result.type === "redirect") { // if (result.type === "success" || result.type === "redirect") {
user.profile_picture = res.data.profile_picture; // user.profile_picture = res.data.profile_picture;
} // }
await applyAction(result); // await applyAction(result);
}; // };
}; // };
</script> </script>
<div class="hero-container"> <div class="hero-container">
<div class="hero-logo"> <!-- <div class="hero-logo">
<img <img
src={user.profile_picture ? user.profile_picture : Avatar} src={user.profile_picture ? user.profile_picture : Avatar}
alt={`${user.first_name} ${user.last_name}`} alt={`${user.first_name} ${user.last_name}`}
width="200" width="200"
/> />
</div> </div> -->
<div class="user-info"> <div class="user-info">
{#if user.status} {#if user.status}
<h3 class="hero-subtitle subtitle info-row"> <h3 class="hero-subtitle subtitle info-row">
@@ -210,7 +210,7 @@
{#if showModal} {#if showModal}
<Modal on:close={close}> <Modal on:close={close}>
<div class="avatar-container"> <!-- <div class="avatar-container">
<form <form
class="avatar-form" class="avatar-form"
action="?/uploadImage" action="?/uploadImage"
@@ -274,7 +274,7 @@
{/each} {/each}
</div> </div>
{/if} {/if}
</div> </div> -->
<form <form
class="content" class="content"
action="?/updateUser" action="?/updateUser"
@@ -751,7 +751,7 @@
font-size: 1.1rem; font-size: 1.1rem;
} }
.avatar-container { /* .avatar-container {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
@@ -811,7 +811,7 @@
height: 100%; height: 100%;
object-fit: cover; object-fit: cover;
border-radius: 50%; border-radius: 50%;
} } */
.button-container { .button-container {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;