fix + feat: api test + error fix

This commit is contained in:
ALAMI Adnane 2025-02-19 11:02:15 +01:00
parent 9f3754776f
commit d75d45e204
6 changed files with 89 additions and 83 deletions

View File

@ -1,8 +1,10 @@
{ {
"entrepreneurs": [ "entrepreneurs": [
{ "id": 1, "name": "Alice", "email": "alice@example.com" }, { "id": 1, "name": "Alice", "email": "alice@example.com" },
{ "id": 2, "name": "Bob", "email": "bob@example.com" }, { "id": 2, "name": "Bob", "email": "bob@example.com" },
{ "id": 3, "name": "Charlie", "email": "charlie@example.com" } { "id": 3, "name": "Charlie", "email": "charlie@example.com" }
] ],
} "data": [
{ "data": "this is a fake data to test api" }
]
}

View File

@ -0,0 +1,2 @@
#!/usr/bin/bash
json-server --watch db.json --port 5000

View File

@ -7,51 +7,63 @@
<h3>{{ title }}</h3> <h3>{{ title }}</h3>
<p>{{ currentDescription }}</p> <p>{{ currentDescription }}</p>
</div> </div>
</template> </template>
<script> <script>
import { ref } from "vue"; import { ref, onMounted } from "vue";
import axios from "axios";
export default {
props: {
title: String,
description: String
},
setup(props) { export default {
const expanded = ref(false); props: {
const currentDescription = ref(props.description); title: String,
description: String
const toggleExpand = () => { },
currentDescription.value = expanded.value
? "3 problèmes essentiels à résoudre pour le client" setup(props) {
: "FAKE DATA"; const expanded = ref(false);
const currentDescription = ref(props.description);
const fetchData = async () => {
try {
const response = await axios.get("http://localhost:5000/data"); // to edit later!
currentDescription.value = response.data.map(e => e.data);
} catch (error) {
console.error("Erreur lors de la récupération des données :", error);
}
};
const toggleExpand = async () => {
if (!expanded.value) {
await fetchData();
} else {
currentDescription.value = "3 problèmes essentiels à résoudre pour le client";
}
expanded.value = !expanded.value;
};
return {
expanded,
currentDescription,
toggleExpand
};
}
};
</script>
expanded.value = !expanded.value;
};
return {
expanded,
currentDescription,
toggleExpand
};
}
};
</script>
<style scoped>
@import "@/components/canvas/style-project.css";
<style scoped>
@import "@/components/canvas/style-project.css";
.cell { .cell {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
text-align: center; text-align: center;
transition: all 0.3s ease; transition: all 0.3s ease;
cursor: pointer; cursor: pointer;
box-shadow: 0 4px 5px rgba(0, 0, 0, 0.1); box-shadow: 0 4px 5px rgba(0, 0, 0, 0.1);
} }
.cell:not(.expanded):hover { .cell:not(.expanded):hover {
transform: scale(1.05); transform: scale(1.05);
@ -69,7 +81,7 @@
color: #666; color: #666;
} }
.expanded { .expanded {
position: fixed; position: fixed;
top: 0; top: 0;
left: 0; left: 0;
@ -81,7 +93,5 @@
align-items: center; align-items: center;
justify-content: center; justify-content: center;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
} }
</style>
</style>

View File

@ -17,39 +17,35 @@
</template> </template>
<script> <script setup>
import { ref, onMounted } from "vue";
import axios from "axios"; import axios from "axios";
export default { const isDropdownOpen = ref(false);
data() { const entrepreneurEmails = ref([]);
return {
isDropdownOpen: false, const toggleDropdown = () => {
entrepreneurEmails: [], isDropdownOpen.value = !isDropdownOpen.value;
}; console.log("Dropdown toggled:", isDropdownOpen.value); // for debug purposes
},
methods: {
toggleDropdown() {
this.isDropdownOpen = !this.isDropdownOpen;
console.log("Dropdown toggled:", this.isDropdownOpen); //for debug purposes
},
async fetchEntrepreneurs() {
try {
const response = await axios.get("http://localhost:5000/entrepreneurs");
this.entrepreneurEmails = response.data.map(e => e.email);
} catch (error) {
console.error("Erreur lors de la récupération des entrepreneurs:", error);
}
},
contactAll() {
alert("Contacter tous les entrepreneurs : " + this.entrepreneurEmails.join(", "));
},
},
mounted() {
this.fetchEntrepreneurs();
},
}; };
const fetchEntrepreneurs = async () => {
try {
const response = await axios.get("http://localhost:5000/entrepreneurs");
entrepreneurEmails.value = response.data.map(e => e.email);
} catch (error) {
console.error("Erreur lors de la récupération des entrepreneurs:", error);
}
};
const contactAll = () => {
alert("Contacter tous les entrepreneurs : " + entrepreneurEmails.value.join(", "));
};
onMounted(fetchEntrepreneurs);
</script> </script>
<style scoped> <style scoped>
header { header {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 39 KiB

View File

@ -1,10 +1,3 @@
<script setup lang="ts">
import Header from '../components/Header.vue';
import Agenda from "../components/Agenda.vue"
import ProjectComp from '../components/Project-comp.vue';
</script>
<template> <template>
<Header /> <Header />
<error-wrapper></error-wrapper> <error-wrapper></error-wrapper>
@ -25,6 +18,9 @@ import ProjectComp from '../components/Project-comp.vue';
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import Header from '../components/Header.vue';
import Agenda from "../components/Agenda.vue"
import ProjectComp from '../components/Project-comp.vue';
import { ref } from "vue"; import { ref } from "vue";