From 046d3ec9f156bb9e1d81fd1a4c7bfe8e6a066bf6 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 27 Feb 2025 16:12:00 +0100 Subject: [PATCH] use fetchResult instead of makeFetch for SocialIssuesAcc.vue component --- .../Activity/components/SocialIssuesAcc.vue | 70 ++++++++----------- .../public/vuejs/AccompanyingCourse/api.js | 15 +--- 2 files changed, 33 insertions(+), 52 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/SocialIssuesAcc.vue b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/SocialIssuesAcc.vue index 10ed84d79..1986b5bbb 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/SocialIssuesAcc.vue +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/SocialIssuesAcc.vue @@ -149,53 +149,45 @@ export default { }, }, mounted() { - /* Load others issues in multiselect - */ + /* Load other issues in multiselect */ this.issueIsLoading = true; this.actionAreLoaded = false; - getSocialIssues().then( - (response) => - new Promise((resolve) => { - this.$store.commit("updateIssuesOther", response.results); - /* Add in list the issues already associated (if not yet listed) - */ - this.socialIssuesSelected.forEach((issue) => { - if ( - this.socialIssuesList.filter( - (i) => i.id === issue.id, - ).length !== 1 - ) { - this.$store.commit("addIssueInList", issue); - } - }, this); + getSocialIssues().then((response) => { + /* Add issues to the store */ + this.$store.commit("updateIssuesOther", response); - /* Remove from multiselect the issues that are not yet in checkbox list - */ - this.socialIssuesList.forEach((issue) => { - this.$store.commit("removeIssueInOther", issue); - }, this); + /* Add in list the issues already associated (if not yet listed) */ + this.socialIssuesSelected.forEach((issue) => { + if ( + this.socialIssuesList.filter( + (i) => i.id === issue.id + ).length !== 1 + ) { + this.$store.commit("addIssueInList", issue); + } + }); - /* Filter issues - */ - this.$store.commit("filterList", "issues"); + /* Remove from multiselect the issues that are not yet in the checkbox list */ + this.socialIssuesList.forEach((issue) => { + this.$store.commit("removeIssueInOther", issue); + }); - /* Add in list the actions already associated (if not yet listed) - */ - this.socialActionsSelected.forEach((action) => { - this.$store.commit("addActionInList", action); - }, this); + /* Filter issues */ + this.$store.commit("filterList", "issues"); - /* Filter issues - */ - this.$store.commit("filterList", "actions"); + /* Add in list the actions already associated (if not yet listed) */ + this.socialActionsSelected.forEach((action) => { + this.$store.commit("addActionInList", action); + }); - this.issueIsLoading = false; - this.actionAreLoaded = true; - this.updateActionsList(); - resolve(); - }), - ); + /* Filter actions */ + this.$store.commit("filterList", "actions"); + + this.issueIsLoading = false; + this.actionAreLoaded = true; + this.updateActionsList(); + }); }, methods: { /* When choosing an issue in multiselect, add it in checkboxes (as selected), diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/api.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/api.js index 6eb2473de..a3d36eac0 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/api.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/api.js @@ -1,4 +1,4 @@ -import { fetchResults } from "ChillMainAssets/lib/api/apiMethods.ts"; +import {fetchResults} from "ChillMainAssets/lib/api/apiMethods.ts"; /* * Endpoint v.2 chill_api_single_accompanying_course__entity @@ -33,18 +33,7 @@ const getUserJobs = () => fetchResults("/api/1.0/main/user-job.json"); const getSocialIssues = () => { const url = `/api/1.0/person/social-work/social-issue.json`; - return fetch(url).then((response) => { - if (response.ok) { - return response.json(); - } - throw { - msg: "Error while retriving Social Issues.", - sta: response.status, - txt: response.statusText, - err: new Error(), - body: response.body, - }; - }); + return fetchResults(url); }; const whoami = () => {