-
+
+
+ Localisation
+
+
+
+
+ Envoyer localisation
+
+
+
+ Posts
+
-
+
Créer
@@ -52,11 +64,13 @@ onMounted(() => {
{{ post.country }}
@@ -67,6 +81,4 @@ onMounted(() => {
-
\ No newline at end of file
+
diff --git a/summer2024-frontend/src/views/CreatePostView.vue b/summer2024-frontend/src/views/CreatePostView.vue
index b731358..5fcd86b 100644
--- a/summer2024-frontend/src/views/CreatePostView.vue
+++ b/summer2024-frontend/src/views/CreatePostView.vue
@@ -8,7 +8,14 @@ import { Label } from '@/components/ui/label/index.js'
import { toTypedSchema } from '@vee-validate/zod'
import { z } from 'zod'
import { onMounted, onUnmounted, ref } from 'vue'
-import { AlertCircle, ArrowLeft, ArrowRight, CircleCheckBig, CirclePlus, RefreshCcw } from 'lucide-vue-next'
+import {
+ AlertCircle,
+ ArrowLeft,
+ ArrowRight,
+ CircleCheckBig,
+ CirclePlus,
+ RefreshCcw
+} from 'lucide-vue-next'
import {
Carousel,
CarouselContent,
@@ -18,18 +25,20 @@ import {
} from '@/components/ui/carousel/index.js'
import { Card, CardContent } from '@/components/ui/card/index.js'
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert/index.js'
-import { useAuthStore } from '@/stores/auth.js'
-import { API_BASE_URL, S3_BUCKET, S3_ENDPOINT } from '@/config.js'
+import { getCityAndCountry } from '@/lib/utils.js'
+import { useAdminPostsStore } from '@/stores/adminPosts.js'
-const authStore = useAuthStore()
+const adminPostStore = useAdminPostsStore()
-const formSchema = toTypedSchema(z.object({
- description: z.string().min(1),
- latitude: z.number(),
- longitude: z.number(),
- city: z.string().min(1),
- country: z.string().min(1)
-}))
+const formSchema = toTypedSchema(
+ z.object({
+ description: z.string().min(1),
+ latitude: z.number(),
+ longitude: z.number(),
+ city: z.string().min(1),
+ country: z.string().min(1)
+ })
+)
const form = useForm({
validationSchema: formSchema
})
@@ -47,82 +56,17 @@ const formStatus = ref({
})
const onSubmit = form.handleSubmit(async (values) => {
- if (!authStore.isAuth)
- return
- console.log('Envoi du post...')
- if (selectedFiles.value.length === 0)
- return
formContainer.value.classList.add('hidden')
formStatus.value.sending = true
-
- const assets = []
- for (const file of selectedFiles.value) {
- console.log('Contact API asset')
- const response = await fetch(API_BASE_URL + '/admin/assets', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- 'X-admin-token': authStore.adminToken
- },
- body: JSON.stringify({ filename: file.file.name })
- })
-
- if (!response.ok) {
- console.log('Contact API asset failed: ' + response.statusText + '\n\n' + response.body)
- formStatus.value.sending = false
- formStatus.value.error = true
- formStatus.value.errorMsg = 'Une erreur est survenue à la préparation de l\'envoi d\'un média : ' + response.statusText
- formContainer.value.classList.remove('invisible')
- return
- }
- const responseBody = await response.json()
- const mediaUploadFormData = new FormData()
- for (const [key, value] of Object.entries(responseBody.formData)) {
- mediaUploadFormData.append(key, value)
- }
- mediaUploadFormData.append('key', '${filename}')
- mediaUploadFormData.append('Content-Type', file.file.type)
- mediaUploadFormData.append('file', file.file, responseBody.filename)
-
- console.log('Envoi image sur s3')
- const s3Response = await fetch(`${S3_ENDPOINT}/${S3_BUCKET}/`, {
- method: 'POST',
- body: mediaUploadFormData
- })
- if (!s3Response.ok) {
- console.log('Envoi media S3 failed: ' + s3Response.statusText + '\n\n' + s3Response.body)
- formStatus.value.sending = false
- formStatus.value.error = true
- formStatus.value.errorMsg = 'Une erreur est survenue pendant l\'envoi d\'un média : ' + s3Response.statusText
- formContainer.value.classList.remove('invisible')
- return
- }
-
- assets.push(responseBody.id)
- }
-
- const response = await fetch(API_BASE_URL + '/admin/posts', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- 'X-admin-token': authStore.adminToken
- },
- body: JSON.stringify({
- description: values.description,
- latitude: values.latitude,
- longitude: values.longitude,
- city: values.city,
- country: values.country,
- assets: assets
- })
- })
- if (!response.ok) {
- console.log('POST post API failed: ' + response.statusText + '\n\n' + response.body)
+ try {
+ await adminPostStore.createPost(values, selectedFiles.value)
+ } catch (e) {
formStatus.value.sending = false
formStatus.value.error = true
- formStatus.value.errorMsg = 'Une erreur est survenue lors de l\'envoi du poste : ' + response.statusText
+ formStatus.value.errorMsg = e.message
formContainer.value.classList.remove('hidden')
- return
+
+ throw e
}
formStatus.value.sending = false
@@ -159,24 +103,21 @@ function mediaReorder(index, diff) {
selectedFiles.value[index + diff] = tmp
}
-function getCityAndCountry() {
+function updateCityAndCountry() {
const lat = latitudeInput.value.value
const lon = longitudeInput.value.value
- if (!lat || !lon)
- return
- fetch(`https://nominatim.openstreetmap.org/reverse?lat=${lat}&lon=${lon}&format=jsonv2`)
- .then((resp) => resp.json()).then((resp) => {
- form.setFieldValue('city', resp.address.village)
- form.setFieldValue('country', resp.address.country)
+ if (!lat || !lon) return
+
+ getCityAndCountry(lat, lon).then((cityAndCountry) => {
+ form.setFieldValue('city', cityAndCountry[0])
+ form.setFieldValue('country', cityAndCountry[1])
})
-
}
-
-
+
-
+
+
+
+
@@ -289,5 +243,4 @@ function getCityAndCountry() {
-
+
diff --git a/summer2024-frontend/src/views/EditPostView.vue b/summer2024-frontend/src/views/EditPostView.vue
new file mode 100644
index 0000000..9bdc1d4
--- /dev/null
+++ b/summer2024-frontend/src/views/EditPostView.vue
@@ -0,0 +1,278 @@
+
+
+
+
+
+
+
+
+
+ Retour
+
+
+
+
+ Erreur...
+ {{ formStatus.errorMsg }}
+
+
+
+ Post modifié !
+
+
Sending...
+
+
+
+
+
+
diff --git a/summer2024-frontend/src/views/LoginView.vue b/summer2024-frontend/src/views/LoginView.vue
index 45d063c..6e4dabf 100644
--- a/summer2024-frontend/src/views/LoginView.vue
+++ b/summer2024-frontend/src/views/LoginView.vue
@@ -1,5 +1,4 @@
@@ -57,7 +56,6 @@ function onLogin() {
Token invalide
-
@@ -68,15 +66,11 @@ function onLogin() {
-
- Login
-
+ Login
-
\ No newline at end of file
+
diff --git a/summer2024-frontend/src/views/MapView.vue b/summer2024-frontend/src/views/MapView.vue
index 6eb1fd8..8e02ba8 100644
--- a/summer2024-frontend/src/views/MapView.vue
+++ b/summer2024-frontend/src/views/MapView.vue
@@ -1,48 +1,76 @@
-
-
+
-
-
-
-
-
+
+
+
+
-
-
+
+ class="-translate-x-1/2 -translate-y-1/2 p-1 rounded-lg bg-indigo-950 hover:bg-indigo-900 transition-colors duration-200"
+ >
@@ -52,30 +80,69 @@ onMounted(() => {
-
+
+
+
+
+
+
+
+
+
+
+ Dernière position, {{ locationStore.lastLocation.formatedDate }}
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+ Objectif : {{ loc.name }}
+ Arrivée : {{ loc.formatedDate }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
\ No newline at end of file
+
diff --git a/summer2024-frontend/src/views/NotFoundView.vue b/summer2024-frontend/src/views/NotFoundView.vue
new file mode 100644
index 0000000..63403cd
--- /dev/null
+++ b/summer2024-frontend/src/views/NotFoundView.vue
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
diff --git a/summer2024-frontend/src/views/PostsView.vue b/summer2024-frontend/src/views/PostsView.vue
index 70c0707..54dc984 100644
--- a/summer2024-frontend/src/views/PostsView.vue
+++ b/summer2024-frontend/src/views/PostsView.vue
@@ -1,74 +1,176 @@
+
+
+
+
+
+
+
+
+ Retour
+
+
+
+
+ Erreur...
+ {{ formStatus.errorMsg }}
+
+
+
+ Localisation envoyée !
+
+
Sending...
+
+
+
+
+
+
diff --git a/summer2024-frontend/vite.config.js b/summer2024-frontend/vite.config.js
index f9b8b3b..4754cfc 100644
--- a/summer2024-frontend/vite.config.js
+++ b/summer2024-frontend/vite.config.js
@@ -1,5 +1,3 @@
-import { fileURLToPath, URL } from 'node:url'
-
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
@@ -11,19 +9,22 @@ import path from 'node:path'
export default defineConfig({
css: {
postcss: {
- plugins: [tailwind(), autoprefixer()],
- },
+ plugins: [tailwind(), autoprefixer()]
+ }
},
plugins: [
- vue(),
+ vue()
],
resolve: {
alias: {
//'@': fileURLToPath(new URL('./src', import.meta.url))
- '@': path.resolve(__dirname, './src'),
+ '@': path.resolve(__dirname, './src')
}
},
server: {
cors: false
+ },
+ esbuild: {
+ drop: []
}
})