fix + feat: api test + error fix
This commit is contained in:
parent
9f3754776f
commit
d75d45e204
@ -3,6 +3,8 @@
|
|||||||
{ "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" }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
2
front/MyINPulse-front/fake_data/open.sh
Executable file
2
front/MyINPulse-front/fake_data/open.sh
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
#!/usr/bin/bash
|
||||||
|
json-server --watch db.json --port 5000
|
@ -10,7 +10,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { ref } from "vue";
|
import { ref, onMounted } from "vue";
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
@ -22,11 +23,21 @@
|
|||||||
const expanded = ref(false);
|
const expanded = ref(false);
|
||||||
const currentDescription = ref(props.description);
|
const currentDescription = ref(props.description);
|
||||||
|
|
||||||
const toggleExpand = () => {
|
const fetchData = async () => {
|
||||||
currentDescription.value = expanded.value
|
try {
|
||||||
? "3 problèmes essentiels à résoudre pour le client"
|
const response = await axios.get("http://localhost:5000/data"); // to edit later!
|
||||||
: "FAKE DATA";
|
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;
|
expanded.value = !expanded.value;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -39,6 +50,7 @@
|
|||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
@import "@/components/canvas/style-project.css";
|
@import "@/components/canvas/style-project.css";
|
||||||
|
|
||||||
@ -82,6 +94,4 @@
|
|||||||
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>
|
||||||
|
|
@ -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: {
|
const fetchEntrepreneurs = async () => {
|
||||||
toggleDropdown() {
|
|
||||||
this.isDropdownOpen = !this.isDropdownOpen;
|
|
||||||
console.log("Dropdown toggled:", this.isDropdownOpen); //for debug purposes
|
|
||||||
},
|
|
||||||
async fetchEntrepreneurs() {
|
|
||||||
try {
|
try {
|
||||||
const response = await axios.get("http://localhost:5000/entrepreneurs");
|
const response = await axios.get("http://localhost:5000/entrepreneurs");
|
||||||
this.entrepreneurEmails = response.data.map(e => e.email);
|
entrepreneurEmails.value = response.data.map(e => e.email);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Erreur lors de la récupération des entrepreneurs:", 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 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 |
@ -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";
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user