front_foundation #5
@ -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
|
@ -7,12 +7,13 @@
|
|||||||
<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 {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
title: String,
|
title: String,
|
||||||
description: String
|
description: String
|
||||||
@ -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;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -36,11 +47,12 @@
|
|||||||
toggleExpand
|
toggleExpand
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
@import "@/components/canvas/style-project.css";
|
<style scoped>
|
||||||
|
@import "@/components/canvas/style-project.css";
|
||||||
|
|
||||||
.cell {
|
.cell {
|
||||||
display: flex;
|
display: flex;
|
||||||
@ -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: {
|
|
||||||
toggleDropdown() {
|
const fetchEntrepreneurs = async () => {
|
||||||
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
Il est plus logique de mettre un unique script setup.
Je vais mettre içi une fois pour toute:
je trouve beaucoup plus logique l'ordre
<script>
=><template>
=><style>
que l'ordre qui est utilisé partout dans vos fichiers (
<template>
=><script>
=><style>
)En effet, on utilise dans le template les fonctions qui sont définies dans les scripts, donc c'est plus logique de les définir avant.
C'est ce qui est utilisé par défaut dans le linter (vue-recommanded).