feat: todo markers

This commit is contained in:
Reto Aebersold 2024-01-26 10:42:28 +01:00
parent 01f7d87c3f
commit ffa871263c
3 changed files with 42 additions and 2 deletions

View File

@ -31,6 +31,13 @@ function startEditMode() {
};
editMode.value = true;
}
async function save() {
const profileData = Object.assign({}, formData.value);
// TODO: Resolve country
await user.setUserProfile(profileData);
editMode.value = false;
}
</script>
<template>
@ -53,7 +60,9 @@ function startEditMode() {
<button class="btn btn-secondary" @click="editMode = false">
{{ $t("general.cancel") }}
</button>
<button class="btn btn-primary">{{ $t("general.save") }}</button>
<button class="btn btn-primary" @click="save">
{{ $t("general.save") }}
</button>
</template>
<template v-else>
<button class="btn btn-secondary" @click="startEditMode">
@ -67,7 +76,9 @@ function startEditMode() {
<button class="btn btn-secondary" @click="editMode = false">
{{ $t("general.cancel") }}
</button>
<button class="btn btn-primary">{{ $t("general.save") }}</button>
<button class="btn btn-primary" @click="save">
{{ $t("general.save") }}
</button>
</div>
</template>
<ProfileView v-else />

View File

@ -34,6 +34,7 @@ export type Entities = {
countries: Country[];
};
// TODO: Update backend to just return the data we need {id: number, name: string}
export function useEntities() {
const user = useUserStore();
const entities: Ref<Entities | undefined> = ref();

View File

@ -20,6 +20,8 @@ if (import.meta.env.VITE_OAUTH_API_BASE_URL) {
export type AvailableLanguages = "de" | "fr" | "it";
export type InvoiceAddress = "prv" | "org";
// TODO: harmonize with to {id: number, name: string} and refactor useEntities in onboarding.ts
// Same with Organisations
type Country = {
country_id: number;
name_de: string;
@ -27,6 +29,28 @@ type Country = {
name_it: string;
};
export interface UserProfile {
first_name: string; // Maybe fields Optional?
last_name: string;
email: string;
avatar_url: string;
organisation: number | null;
is_superuser: boolean;
course_session_experts: string[];
invoice_address: InvoiceAddress | null;
street: string | null;
street_number: string | null;
postal_code: string | null;
city: string | null;
country: Country | null;
organisation_detail_name: string | null;
organisation_street: string | null;
organisation_street_number: string | null;
organisation_postal_code: string | null;
organisation_city: string | null;
organisation_country: Country | null;
}
export type UserState = {
id: string;
first_name: string;
@ -187,5 +211,9 @@ export const useUserStore = defineStore({
const r = await directUpload("/api/core/avatar/", file);
this.$state.avatar_url = r.url;
},
async setUserProfile(profileData: UserProfile) {
console.log("Save", profileData);
await itPost("/api/core/me/", profileData, { method: "PUT" });
},
},
});