From 31820dd417595ec06f9d2e9f00c434d2448a1f46 Mon Sep 17 00:00:00 2001 From: Mat95rix7 Date: Wed, 8 May 2024 16:59:24 +0200 Subject: [PATCH 1/3] Modification aussi dans le ReadMe Explication dans le ReadME --- README.md | 5 +++-- stores/discord.js | 2 +- stores/task.js | 8 ++++---- stores/user.js | 10 +++++----- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 78a69d7..3a0372e 100644 --- a/README.md +++ b/README.md @@ -76,10 +76,11 @@ Pour accéder à l'aperçu de la version de production, visitez http://milestone Voici les étapes à suivre pour se connecter en tant qu'administrateur : -1. Copier le fichier `.default` en `.env` avec la commande `cp .default .env` puis le remplir avec un nom d'utilisateur et un mot de passe admin. +1. Renommer le fichier `.default` en `.env` avec la commande `cp .default .env` puis le remplir avec un nom d'utilisateur et un mot de passe admin et vous avez la possibilite de laisser URL de base comme elle est ou la changer mais absolument l'indiquer. +URL de Base du serveur par defaut est : http://localhost:3000/api -2. `node prisma/seed.js` pour injecter les données dans la base de données. +2. Executer la commande `node prisma/seed.js` pour injecter les données dans la base de données. 3. Exécuter la commande `npx prisma generate` pour générer cet utilisateur avec le rôle admin. diff --git a/stores/discord.js b/stores/discord.js index d54ec56..2f2142a 100644 --- a/stores/discord.js +++ b/stores/discord.js @@ -7,7 +7,7 @@ export const useDiscordStore = defineStore("discord", { }), actions: { async fetchDiscordUser(jwt) { - const res = await fetch("http://localhost:3000/api/discord-id", { + const res = await fetch(`${import.meta.env.VITE_APP_API_URL}/discord-id`, { method: "GET", headers: { "Content-Type": "application/json", diff --git a/stores/task.js b/stores/task.js index c424dab..97e1fe1 100644 --- a/stores/task.js +++ b/stores/task.js @@ -8,7 +8,7 @@ export const useTaskStore = defineStore("tasks", { actions: { async setTasks() { const res = await fetch( - "http://localhost:3000/api/task", + `${import.meta.env.VITE_APP_API_URL}/task`, { method: "GET", } @@ -38,7 +38,7 @@ export const useTaskStore = defineStore("tasks", { async addTask(jwt, title, content, completed) { console.log("addTask", title, content, completed, jwt); const res = await fetch( - "http://localhost:3000/api/task", + `${import.meta.env.VITE_APP_API_URL}/task`, { method: "POST", headers: { @@ -73,7 +73,7 @@ export const useTaskStore = defineStore("tasks", { async updateTask(jwt, id, title, content, completed, isContentPrivate) { const res = await fetch( - "http://localhost:3000/api/task/" + id, + `${import.meta.env.VITE_APP_API_URL}/task/${id}` , { method: "PUT", headers: { @@ -118,7 +118,7 @@ export const useTaskStore = defineStore("tasks", { return; } const res = await fetch( - "http://localhost:3000/api/task/" + id, + `${import.meta.env.VITE_APP_API_URL}/task/${id}`, { //await fait attendre que toute la fonction soit déroulée headers: { diff --git a/stores/user.js b/stores/user.js index a77cd51..fa485de 100644 --- a/stores/user.js +++ b/stores/user.js @@ -7,7 +7,7 @@ export const useUserStore = defineStore("users", { }), actions: { async setUsers(jwt) { - const res = await fetch("http://localhost:3000/api/user", { + const res = await fetch(`${import.meta.env.VITE_APP_API_URL}/user`, { method: "GET", headers: { "Content-Type": "application/json", @@ -33,7 +33,7 @@ export const useUserStore = defineStore("users", { }, async addUser(jwt, name, role, password, discordId, twitchId) { - const res = await fetch("http://localhost:3000/api/user", { + const res = await fetch(`${import.meta.env.VITE_APP_API_URL}/user`, { method: "POST", headers: { "Content-Type": "application/json", @@ -74,7 +74,7 @@ export const useUserStore = defineStore("users", { if (!conf) { return; } - const res = await fetch(`http://localhost:3000/api/user/${id}`, { + const res = await fetch(`${import.meta.env.VITE_APP_API_URL}/user/${id}`, { method: "DELETE", headers: { "Content-Type": "application/json", @@ -104,7 +104,7 @@ export const useUserStore = defineStore("users", { }, async updateUser(jwt, id, name, role, password, discordId, twitchId) { - const res = await fetch(`http://localhost:3000/api/user/${id}`, { + const res = await fetch(`${import.meta.env.VITE_APP_API_URL}/user/${id}`, { method: "PUT", headers: { "Content-Type": "application/json", @@ -144,7 +144,7 @@ export const useUserStore = defineStore("users", { async checkThirdPartyUserExistence(userId) { try { const res = await fetch( - `http://localhost:3000/api/third-party/${userId}` + `${import.meta.env.VITE_APP_API_URL}`/third-party/`${userId}` ); const data = await res.json(); From e07c19ac997bf84d0b2612381e3a9366506724a6 Mon Sep 17 00:00:00 2001 From: Mat95rix7 Date: Wed, 8 May 2024 17:03:27 +0200 Subject: [PATCH 2/3] Utilisateur se modifie un par un --- components/LoginForm.vue | 2 +- components/ModifUser.vue | 10 ++++++++-- components/TaskList.vue | 25 +++++++++++-------------- components/UserList.vue | 15 ++++++++++++--- 4 files changed, 32 insertions(+), 20 deletions(-) diff --git a/components/LoginForm.vue b/components/LoginForm.vue index 5c230b9..05c3233 100644 --- a/components/LoginForm.vue +++ b/components/LoginForm.vue @@ -130,7 +130,7 @@ const login = async (isAdmin = true) => { : { name: username.value, }; - const res = await fetch("http://localhost:3000/api/login", { + const res = await fetch(`${import.meta.env.VITE_APP_API_URL}/login`, { method: "POST", headers: { "Content-Type": "application/json", diff --git a/components/ModifUser.vue b/components/ModifUser.vue index 22514b6..3b81bcf 100644 --- a/components/ModifUser.vue +++ b/components/ModifUser.vue @@ -18,7 +18,7 @@ - + {{ error }} @@ -31,11 +31,12 @@ const jwt = jwtStore.jwt; const userStore = useUserStore(); const emit = defineEmits(["close", "errorOnUpdateUser"]); -const { id, name, role, password } = defineProps({ +const { id, name, role, password, isSelected } = defineProps({ id: Number, name: String, role: String, password: String, + isSelected: Boolean }); const nameInput = ref(name); @@ -56,6 +57,11 @@ const editUser = async () => { } await userStore.setUsers(jwt); }; +const endUserEdit = () => { + for (let currentUser of userStore.users){ + currentUser.isSelected = false + } +};