feat: use orgs in profile

This commit is contained in:
Reto Aebersold 2023-11-13 20:58:21 +01:00 committed by Christian Cueni
parent 97f4e96b5c
commit bfeca6e8e0
5 changed files with 76 additions and 43 deletions

View File

@ -1,4 +1,6 @@
import { getCookieValue } from "@/router/guards"; import { getCookieValue } from "@/router/guards";
import type { Ref } from "vue";
import { ref, toValue, watchEffect } from "vue";
class FetchError extends Error { class FetchError extends Error {
response: Response; response: Response;
@ -88,3 +90,24 @@ export const itGetCached = (
return itGetPromiseCache.get(url.toString()) as Promise<any>; return itGetPromiseCache.get(url.toString()) as Promise<any>;
}; };
export function useFetch(url: Ref<RequestInfo> | RequestInfo | (() => RequestInfo)) {
const data = ref(null);
const error = ref(null);
const fetchData = () => {
data.value = null;
error.value = null;
fetch(toValue(url))
.then((res) => res.json())
.then((json) => (data.value = json))
.catch((err) => (error.value = err));
};
watchEffect(() => {
fetchData();
});
return { data, error };
}

View File

@ -5,12 +5,21 @@ import { computed, ref, watch } from "vue";
import { useUserStore } from "@/stores/user"; import { useUserStore } from "@/stores/user";
import AvatarImage from "@/components/ui/AvatarImage.vue"; import AvatarImage from "@/components/ui/AvatarImage.vue";
import { useFileUpload } from "@/composables"; import { useFileUpload } from "@/composables";
import { companies } from "@/pages/onboarding/companies";
import { useRoute } from "vue-router"; import { useRoute } from "vue-router";
import { useFetch } from "@/fetchHelpers";
import { useTranslation } from "i18next-vue";
const { t } = useTranslation();
const user = useUserStore(); const user = useUserStore();
const route = useRoute(); const route = useRoute();
const selectedCompany = ref(companies[0]);
const { data: companies } = useFetch(() => "/api/core/organisations/");
const selectedCompany = ref({
id: "0",
name: t("a.Auswählen"),
});
const validCompany = computed(() => { const validCompany = computed(() => {
return selectedCompany.value.id !== "0"; return selectedCompany.value.id !== "0";
}); });
@ -53,7 +62,7 @@ const nextRoute = computed(() => {
andere Personen einfacher finden. andere Personen einfacher finden.
</p> </p>
<ItDropdownSelect v-model="selectedCompany" :items="companies" /> <ItDropdownSelect v-if="companies" v-model="selectedCompany" :items="companies" />
<div class="mt-16 flex flex-col justify-between gap-12 lg:flex-row lg:gap-24"> <div class="mt-16 flex flex-col justify-between gap-12 lg:flex-row lg:gap-24">
<div> <div>

View File

@ -1,34 +0,0 @@
export const companies = [
{ id: "0", name: "Auswählen" },
{ id: "1", name: "Andere Broker" },
{ id: "2", name: "Andere Krankenversicherer" },
{ id: "3", name: "Andere Privatversicherer" },
{ id: "4", name: "Allianz Suisse" },
{ id: "5", name: "AON" },
{ id: "6", name: "AXA Winterthur" },
{ id: "7", name: "Baloise" },
{ id: "8", name: "CAP Rechtsschutz" },
{ id: "9", name: "Coop Rechtsschutz" },
{ id: "10", name: "CSS" },
{ id: "11", name: "Die Mobiliar" },
{ id: "12", name: "Emmental Versicherung" },
{ id: "13", name: "GENERALI Versicherungen" },
{ id: "14", name: "Groupe Mutuel" },
{ id: "15", name: "Helsana" },
{ id: "16", name: "Helvetia" },
{ id: "17", name: "Kessler & Co AG" },
{ id: "18", name: "Orion Rechtsschutz Versicherung" },
{ id: "19", name: "PAX" },
{ id: "20", name: "Sanitas" },
{ id: "21", name: "SUVA" },
{ id: "22", name: "Swica" },
{ id: "23", name: "Swiss Life" },
{ id: "24", name: "Swiss Re" },
{ id: "25", name: "Visana Services AG" },
{ id: "26", name: "VZ VermögensZentrum AG" },
{ id: "27", name: "Würth Financial Services AG" },
{ id: "28", name: "Zürich" },
{ id: "29", name: "VBV" },
{ id: "30", name: "Vaudoise" },
{ id: "31", name: "Keine Firmenzugehörigkeit" },
];

View File

@ -20,13 +20,13 @@ from vbv_lernwelt.core.views import (
check_rate_limit, check_rate_limit,
cypress_reset_view, cypress_reset_view,
generate_web_component_icons, generate_web_component_icons,
list_organisations,
me_user_view, me_user_view,
permission_denied_view, permission_denied_view,
rate_limit_exceeded_view, rate_limit_exceeded_view,
vue_home, vue_home,
vue_login, vue_login,
vue_logout, vue_logout,
list_organisations,
) )
from vbv_lernwelt.course.views import ( from vbv_lernwelt.course.views import (
course_page_api_view, course_page_api_view,

View File

@ -4,15 +4,50 @@ from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
('core', '0002_joblog'), ("core", "0002_joblog"),
] ]
operations = [ operations = [
migrations.AddField( migrations.AddField(
model_name='user', model_name="user",
name='organisation', name="organisation",
field=models.CharField(blank=True, choices=[('1', 'Andere Broker'), ('2', 'Andere Krankenversicherer'), ('3', 'Andere Privatversicherer'), ('4', 'Allianz Suisse'), ('5', 'AON'), ('6', 'AXA Winterthur'), ('7', 'Baloise'), ('8', 'CAP Rechtsschutz'), ('9', 'Coop Rechtsschutz'), ('10', 'CSS'), ('11', 'Die Mobiliar'), ('12', 'Emmental Versicherung'), ('13', 'GENERALI Versicherungen'), ('14', 'Groupe Mutuel'), ('15', 'Helsana'), ('16', 'Helvetia'), ('17', 'Kessler & Co AG'), ('18', 'Orion Rechtsschutz Versicherung'), ('19', 'PAX'), ('20', 'Sanitas'), ('21', 'SUVA'), ('22', 'Swica'), ('23', 'Swiss Life'), ('24', 'Swiss Re'), ('25', 'Visana Services AG'), ('26', 'VZ VermögensZentrum AG'), ('27', 'Würth Financial Services AG'), ('28', 'Zürich'), ('29', 'VBV'), ('30', 'Vaudoise'), ('31', 'Keine Firmenzugehörigkeit')], max_length=255), field=models.CharField(
blank=True,
choices=[
("1", "Andere Broker"),
("2", "Andere Krankenversicherer"),
("3", "Andere Privatversicherer"),
("4", "Allianz Suisse"),
("5", "AON"),
("6", "AXA Winterthur"),
("7", "Baloise"),
("8", "CAP Rechtsschutz"),
("9", "Coop Rechtsschutz"),
("10", "CSS"),
("11", "Die Mobiliar"),
("12", "Emmental Versicherung"),
("13", "GENERALI Versicherungen"),
("14", "Groupe Mutuel"),
("15", "Helsana"),
("16", "Helvetia"),
("17", "Kessler & Co AG"),
("18", "Orion Rechtsschutz Versicherung"),
("19", "PAX"),
("20", "Sanitas"),
("21", "SUVA"),
("22", "Swica"),
("23", "Swiss Life"),
("24", "Swiss Re"),
("25", "Visana Services AG"),
("26", "VZ VermögensZentrum AG"),
("27", "Würth Financial Services AG"),
("28", "Zürich"),
("29", "VBV"),
("30", "Vaudoise"),
("31", "Keine Firmenzugehörigkeit"),
],
max_length=255,
),
), ),
] ]