From 5ac69a54d1d7451daeddf2a72325523985246b83 Mon Sep 17 00:00:00 2001 From: Muhsin Keloth Date: Mon, 5 Sep 2022 12:45:38 +0530 Subject: [PATCH] Set last account id on account change --- app/javascript/dashboard/api/auth.js | 9 ++++++++ app/javascript/dashboard/api/endPoints.js | 4 ++++ .../sidebarComponents/AccountSelector.vue | 11 ++++++++- .../dashboard/store/modules/auth.js | 10 ++++++++ .../api/v1/profiles_controller_spec.rb | 23 +++++++++++++++++++ 5 files changed, 56 insertions(+), 1 deletion(-) diff --git a/app/javascript/dashboard/api/auth.js b/app/javascript/dashboard/api/auth.js index 76042103f..ef1762f46 100644 --- a/app/javascript/dashboard/api/auth.js +++ b/app/javascript/dashboard/api/auth.js @@ -147,4 +147,13 @@ export default { deleteAvatar() { return axios.delete(endPoints('deleteAvatar').url); }, + + setActiveAccount({ accountId }) { + const urlData = endPoints('setActiveAccount'); + return axios.put(urlData.url, { + profile: { + account_id: accountId, + }, + }); + }, }; diff --git a/app/javascript/dashboard/api/endPoints.js b/app/javascript/dashboard/api/endPoints.js index c9d0955ef..8deb8d56a 100644 --- a/app/javascript/dashboard/api/endPoints.js +++ b/app/javascript/dashboard/api/endPoints.js @@ -40,6 +40,10 @@ const endPoints = { deleteAvatar: { url: '/api/v1/profile/avatar', }, + + setActiveAccount: { + url: '/api/v1/profile/set_active_account', + }, }; export default page => { diff --git a/app/javascript/dashboard/components/layout/sidebarComponents/AccountSelector.vue b/app/javascript/dashboard/components/layout/sidebarComponents/AccountSelector.vue index e6e7df48e..482b36d3d 100644 --- a/app/javascript/dashboard/components/layout/sidebarComponents/AccountSelector.vue +++ b/app/javascript/dashboard/components/layout/sidebarComponents/AccountSelector.vue @@ -13,7 +13,7 @@ :key="account.id" class="account-selector" > - +