Added accuracy warning to Geoloc button

This commit is contained in:
Alexis
2023-05-15 18:47:50 +02:00
parent edcaee9080
commit cf57db4963
3 changed files with 61 additions and 2 deletions

View File

@@ -41,6 +41,13 @@ async function handleGeolocClick() {
/>
<span>Géolocalisation</span>
</RepButton>
<div
v-if="!lastError && coords.accuracy > 1000"
class="mt-4 max-w-lg mx-auto text-sm text-red-400"
>
Position peu précise ; votre député sera peut être différement de notre
résultat
</div>
<div v-if="lastError" class="mt-4 max-w-lg mx-auto text-sm text-red-400">
{{ lastError }}
</div>

View File

@@ -1,13 +1,28 @@
<script lang="ts" setup>
import type { Organisation } from "@/models/org";
import RepButton from "./RepButton.vue";
import type { Depute } from "@/models/rep";
import { computed } from "vue";
import { computed, onMounted, ref } from "vue";
const apiUrl = import.meta.env.VITE_API_URL;
const props = defineProps<{
rep: Depute;
}>();
const politicalPartyId = props.rep.acteur.mandats.mandat.find(
(m) => m.typeOrgane === "GP" && !m.dateFin
)?.organes.organeRef;
const repPoliticalParty = ref<Organisation | null>(null);
onMounted(async () => {
repPoliticalParty.value = await fetch(
`${apiUrl}/org?id=${politicalPartyId}`
).then((t) => t.json());
});
const repImage = computed(() => {
const imageRef = props.rep.acteur.uid["#text"].replace("PA", "");
return `https://www2.assemblee-nationale.fr/static/tribun/16/photos/carre/${imageRef}.jpg`;
@@ -88,6 +103,10 @@ const regionBgFile = computed(() => {
<h1 class="mt-4 text-center font-bold text-3xl">
{{ repFullName }}
</h1>
<div class="text-center text-xl font-bold" v-if="repPoliticalParty">
{{ repPoliticalParty.organe.libelle }}
</div>
<hr class="my-5 opacity-10" />
<h2 class="text-center font-bold text-xl">
{{ repMandate?.election?.lieu.departement }} -
{{ repMandate?.election?.lieu.numCirco }}e circonscription
@@ -99,7 +118,7 @@ const regionBgFile = computed(() => {
/>
</header>
<h3 class="mt-2 text-center font-medium text-lg">
<h3 class="text-center font-medium text-lg">
{{ rep.acteur.profession.libelleCourant }}
</h3>

33
src/models/org.ts Normal file
View File

@@ -0,0 +1,33 @@
export interface Organisation {
organe: {
"@xmlns": string;
"@xmlns:xsi": string;
"@xsi:type": string;
uid: string;
codeType: string;
libelle: string;
libelleEdition: string;
libelleAbrege: string;
libelleAbrev: string;
viMoDe: ViMoDe;
organeParent: null;
chambre: null;
regime: string;
legislature: string;
secretariat: Secretariat;
positionPolitique: string;
preseance: string;
couleurAssociee: string;
};
}
export interface Secretariat {
secretaire01: null;
secretaire02: null;
}
export interface ViMoDe {
dateDebut: Date;
dateAgrement: null;
dateFin: null;
}