mirror of
				https://gitlab.com/Chill-Projet/chill-bundles.git
				synced 2025-10-31 09:18:24 +00:00 
			
		
		
		
	Add current user to suggested users when creating activity
This commit is contained in:
		| @@ -2,6 +2,7 @@ import "es6-promise/auto"; | ||||
| import { createStore } from "vuex"; | ||||
| import { postLocation } from "./api"; | ||||
| import prepareLocations from "./store.locations.js"; | ||||
| import { makeFetch } from "ChillMainAssets/lib/api/apiMethods"; | ||||
|  | ||||
| const debug = process.env.NODE_ENV !== "production"; | ||||
| //console.log('window.activity', window.activity); | ||||
| @@ -23,6 +24,7 @@ const removeIdFromValue = (string, id) => { | ||||
| const store = createStore({ | ||||
|   strict: debug, | ||||
|   state: { | ||||
|     me: null, | ||||
|     activity: window.activity, | ||||
|     socialIssuesOther: [], | ||||
|     socialActionsList: [], | ||||
| @@ -79,15 +81,25 @@ const store = createStore({ | ||||
|       ); | ||||
|     }, | ||||
|     suggestedUser(state) { | ||||
|       // console.log('current user', state.me) | ||||
|       const existingUserIds = state.activity.users.map((p) => p.id); | ||||
|       return state.activity.activityType.usersVisible === 0 | ||||
|         ? [] | ||||
|         : [state.activity.accompanyingPeriod.user].filter( | ||||
|             (u) => u !== null && !existingUserIds.includes(u.id), | ||||
|           ); | ||||
|       let suggestedUsers = | ||||
|         state.activity.activityType.usersVisible === 0 | ||||
|           ? [] | ||||
|           : [state.activity.accompanyingPeriod.user].filter( | ||||
|               (u) => u !== null && !existingUserIds.includes(u.id), | ||||
|             ); | ||||
|  | ||||
|       // Add the current user from the state | ||||
|       if (state.me && !existingUserIds.includes(state.me.id)) { | ||||
|         suggestedUsers.push(state.me); | ||||
|       } | ||||
|       console.log("suggested users", suggestedUsers); | ||||
|  | ||||
|       return suggestedUsers; | ||||
|     }, | ||||
|     suggestedResources(state) { | ||||
|       const resources = state.activity.accompanyingPeriod.resources; | ||||
|       // const resources = state.activity.accompanyingPeriod.resources; | ||||
|       const existingPersonIds = state.activity.persons.map((p) => p.id); | ||||
|       const existingThirdPartyIds = state.activity.thirdParties.map( | ||||
|         (p) => p.id, | ||||
| @@ -111,6 +123,9 @@ const store = createStore({ | ||||
|     }, | ||||
|   }, | ||||
|   mutations: { | ||||
|     setWhoAmI(state, me) { | ||||
|       state.me = me; | ||||
|     }, | ||||
|     // SocialIssueAcc | ||||
|     addIssueInList(state, issue) { | ||||
|       //console.log('add issue list', issue.id); | ||||
| @@ -326,9 +341,17 @@ const store = createStore({ | ||||
|       } | ||||
|       commit("updateLocation", value); | ||||
|     }, | ||||
|     getWhoAmI({ commit }) { | ||||
|       const url = `/api/1.0/main/whoami.json`; | ||||
|       makeFetch("GET", url).then((user) => { | ||||
|         commit("setWhoAmI", user); | ||||
|       }); | ||||
|     }, | ||||
|   }, | ||||
| }); | ||||
|  | ||||
| store.dispatch("getWhoAmI"); | ||||
|  | ||||
| prepareLocations(store); | ||||
|  | ||||
| export default store; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user