Compare commits

...

6 Commits

Author SHA1 Message Date
Alex
e14642ed66 fix: missing user.Safe fields 2024-10-07 11:41:52 +02:00
Alex
55afc6bee9 chg admin creation 2024-10-07 11:41:31 +02:00
Alex
0c2aa68311 typo 2024-10-07 11:41:05 +02:00
Alex
580b022c42 del: Avatar image 2024-10-07 11:40:58 +02:00
Alex
dfbeabc93c add: driverslicence update 2024-10-07 11:39:53 +02:00
Alex
0314076669 translation 2024-10-07 11:37:44 +02:00
7 changed files with 79 additions and 57 deletions

View File

@@ -36,7 +36,7 @@ interface DriversLicence {
licence_number: string | ""; licence_number: string | "";
issued_date: string | ""; issued_date: string | "";
expiration_date: string | ""; expiration_date: string | "";
issuing_country: string | ""; country: string | "";
licence_categories: LicenceCategory[]; licence_categories: LicenceCategory[];
} }

View File

@@ -1,6 +1,7 @@
<script> <script>
import { quintOut } from "svelte/easing"; import { quintOut } from "svelte/easing";
import { t } from "svelte-i18n";
import { createEventDispatcher } from "svelte"; import { createEventDispatcher } from "svelte";
const modal = (/** @type {Element} */ node, { duration = 300 } = {}) => { const modal = (/** @type {Element} */ node, { duration = 300 } = {}) => {
@@ -34,7 +35,7 @@
> >
<!-- svelte-ignore a11y-missing-attribute --> <!-- svelte-ignore a11y-missing-attribute -->
<a <a
title="Close" title={$t("cancel")}
class="modal-close" class="modal-close"
on:click={closeModal} on:click={closeModal}
role="button" role="button"
@@ -52,7 +53,7 @@
d="M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z" d="M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"
/> />
</svg> </svg>
<span class="sr-only">Close modal</span> <span class="sr-only">{$t("cancel")}</span>
</a> </a>
<div class="container"> <div class="container">
<slot /> <slot />

View File

@@ -64,6 +64,8 @@ export default {
L: "Land-, Forstwirtschaftsfahrzeuge, Stapler max 40km/h", L: "Land-, Forstwirtschaftsfahrzeuge, Stapler max 40km/h",
T: "Land-, Forstwirtschaftsfahrzeuge, Stapler max 60km/h", T: "Land-, Forstwirtschaftsfahrzeuge, Stapler max 60km/h",
}, },
cancel: "Abbrechen",
confirm: "Bestätigen",
licence_categories: "Führerscheinklassen", licence_categories: "Führerscheinklassen",
subscription_model: "Mitgliedschatfsmodell", subscription_model: "Mitgliedschatfsmodell",
licence: "Führerschein", licence: "Führerschein",

View File

@@ -58,6 +58,20 @@ export const actions = {
bic: String(formData.get("bic")), bic: String(formData.get("bic")),
mandate_reference: String(formData.get("mandate_reference")), mandate_reference: String(formData.get("mandate_reference")),
}, },
drivers_licence: {
id: Number(formData.get("drivers_licence_id")),
status: Number(formData.get("licence_status")),
licence_number: String(formData.get("licence_number")),
issued_date: toRFC3339(formData.get("issued_date")),
expiration_date: toRFC3339(formData.get("expiration_date")),
country: String(formData.get("country")),
licence_categories: formData
.getAll("licence_categories[]")
.map((category) => ({
id: -1, // Use -1 as a placeholder for new categories
category: String(category),
})),
},
}; };
// Remove undefined or null properties // Remove undefined or null properties

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"
@@ -445,7 +445,7 @@
<InputField <InputField
name="licence_number" name="licence_number"
type="text" type="text"
label={$t("licencce_number")} label={$t("licence_number")}
bind:value={user.drivers_licence.licence_number} bind:value={user.drivers_licence.licence_number}
placeholder={$t("placeholder.licence_number")} placeholder={$t("placeholder.licence_number")}
toUpperCase={true} toUpperCase={true}
@@ -467,7 +467,7 @@
<InputField <InputField
name="country" name="country"
label={$t("country")} label={$t("country")}
bind:value={user.drivers_licence.issuing_country} bind:value={user.drivers_licence.country}
placeholder={$t("placeholder.issuing_country")} placeholder={$t("placeholder.issuing_country")}
/> />
<div class="licence-categories"> <div class="licence-categories">
@@ -612,10 +612,10 @@
{#if isUpdating} {#if isUpdating}
<SmallLoader width={30} message={"Aktualisiere..."} /> <SmallLoader width={30} message={"Aktualisiere..."} />
{:else} {:else}
<button type="button" class="button-dark" on:click={close} <button type="button" class="button-dark" on:click={close}>
>Abbrechen</button {$t("cancel")}</button
> >
<button type="submit" class="button-dark">Bestätigen</button> <button type="submit" class="button-dark">{$t("confirm")}</button>
{/if} {/if}
</div> </div>
</form> </form>
@@ -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;

View File

@@ -143,9 +143,12 @@ func createAdmin(userMail string, subscriptionModelID uint) (*models.User, error
SubscriptionModelID: subscriptionModelID, SubscriptionModelID: subscriptionModelID,
}, },
BankAccount: models.BankAccount{ BankAccount: models.BankAccount{
AccountHolderName: "Niemand", AccountHolderName: "",
Bank: "Keine", Bank: "",
IBAN: "DE49700500000008447644", //fake IBAN: "", //"DE49700500000008447644", //fake
},
DriversLicence: models.DriversLicence{
Status: constants.UnverifiedStatus,
}, },
}, nil }, nil

View File

@@ -72,6 +72,7 @@ func (u *User) Safe() map[string]interface{} {
"status": u.Status, "status": u.Status,
"id": u.ID, "id": u.ID,
"role_id": u.RoleID, "role_id": u.RoleID,
"company": u.Company,
"date_of_birth": u.DateOfBirth, "date_of_birth": u.DateOfBirth,
"membership": map[string]interface{}{ "membership": map[string]interface{}{
"id": u.Membership.ID, "id": u.Membership.ID,
@@ -100,6 +101,7 @@ func (u *User) Safe() map[string]interface{} {
}, },
"drivers_licence": map[string]interface{}{ "drivers_licence": map[string]interface{}{
"id": u.DriversLicence.ID, "id": u.DriversLicence.ID,
"licence_number": u.DriversLicence.LicenceNumber,
"status": u.DriversLicence.Status, "status": u.DriversLicence.Status,
"issued_date": u.DriversLicence.IssuedDate, "issued_date": u.DriversLicence.IssuedDate,
"expiration_date": u.DriversLicence.ExpirationDate, "expiration_date": u.DriversLicence.ExpirationDate,