Merge branch 'dev' into main

This commit is contained in:
Alexis
2023-04-27 12:14:38 +02:00
6 changed files with 47 additions and 9 deletions

View File

@@ -1,3 +1,2 @@
# maple # Trouver mon député
Application permettant de trouver son député à partir de sa géolocalisation
Small app to export and share project structures.

2
env.d.ts vendored
View File

@@ -1 +1,3 @@
/// <reference types="vite/client" /> /// <reference types="vite/client" />
declare module "geojson-geometries-lookup";
declare module "pako";

8
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "maple", "name": "rep-lookup-fr",
"version": "0.0.0", "version": "0.1.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "maple", "name": "rep-lookup-fr",
"version": "0.0.0", "version": "0.1.0",
"dependencies": { "dependencies": {
"@tailwindcss/typography": "^0.5.4", "@tailwindcss/typography": "^0.5.4",
"@vueuse/core": "^10.1.0", "@vueuse/core": "^10.1.0",

View File

11
src/stores/repStore.ts Normal file
View File

@@ -0,0 +1,11 @@
import { defineStore } from "pinia";
export const useCirStore = defineStore("repStore", () => {
async function getRep(lon: number, lat: number): Promise<any> {
return fetch(`http://localhost:3000/rep?lat=${lat}&lon=${lon}`).then((t) =>
t.json()
);
}
return { getRep };
});

View File

@@ -1,7 +1,33 @@
<script lang="ts" setup></script> <script lang="ts" setup>
import { useCirStore } from "@/stores/repStore";
import { useGeolocation } from "@vueuse/core";
import { ref } from "vue";
const { coords } = useGeolocation();
const { getRep } = useCirStore();
const currentRepValue = ref<any>();
async function handleGeolocClick() {
currentRepValue.value = await getRep(
coords.value.longitude,
coords.value.latitude
);
}
</script>
<template> <template>
<div> <div>
<main class="container py-4">Main</main> <main class="container py-4">
<button
class="py-2 px-4 rounded-sm bg-white text-sm text-slate-950"
@click="handleGeolocClick"
>
Trouver mon député
</button>
<pre>
{{ currentRepValue }}
</pre>
</main>
</div> </div>
</template> </template>