feat: Add dropdown component (#10358)
This PR adds dropdown primitives to help compose custom dropdowns across the app. The following the sample usage --------- Co-authored-by: Pranav <pranav@chatwoot.com>
This commit is contained in:
@@ -151,8 +151,15 @@ export const actions = {
|
||||
}
|
||||
},
|
||||
|
||||
updateAvailability: async ({ commit, dispatch }, params) => {
|
||||
updateAvailability: async (
|
||||
{ commit, dispatch, getters: _getters },
|
||||
params
|
||||
) => {
|
||||
const previousStatus = _getters.getCurrentUserAvailability;
|
||||
|
||||
try {
|
||||
// optimisticly update current status
|
||||
commit(types.SET_CURRENT_USER_AVAILABILITY, params.availability);
|
||||
const response = await authAPI.updateAvailability(params);
|
||||
const userData = response.data;
|
||||
const { id } = userData;
|
||||
@@ -162,16 +169,23 @@ export const actions = {
|
||||
availabilityStatus: params.availability,
|
||||
});
|
||||
} catch (error) {
|
||||
// Ignore error
|
||||
// revert back to previous status if update fails
|
||||
commit(types.SET_CURRENT_USER_AVAILABILITY, previousStatus);
|
||||
}
|
||||
},
|
||||
|
||||
updateAutoOffline: async ({ commit }, { accountId, autoOffline }) => {
|
||||
updateAutoOffline: async (
|
||||
{ commit, getters: _getters },
|
||||
{ accountId, autoOffline }
|
||||
) => {
|
||||
const previousAutoOffline = _getters.getCurrentUserAutoOffline;
|
||||
|
||||
try {
|
||||
commit(types.SET_CURRENT_USER_AUTO_OFFLINE, autoOffline);
|
||||
const response = await authAPI.updateAutoOffline(accountId, autoOffline);
|
||||
commit(types.SET_CURRENT_USER, response.data);
|
||||
} catch (error) {
|
||||
// Ignore error
|
||||
commit(types.SET_CURRENT_USER_AUTO_OFFLINE, previousAutoOffline);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -212,6 +226,19 @@ export const mutations = {
|
||||
accounts,
|
||||
};
|
||||
},
|
||||
[types.SET_CURRENT_USER_AUTO_OFFLINE](_state, autoOffline) {
|
||||
const accounts = _state.currentUser.accounts.map(account => {
|
||||
if (account.id === _state.currentUser.account_id) {
|
||||
return { ...account, autoOffline: autoOffline };
|
||||
}
|
||||
return account;
|
||||
});
|
||||
|
||||
_state.currentUser = {
|
||||
..._state.currentUser,
|
||||
accounts,
|
||||
};
|
||||
},
|
||||
[types.CLEAR_USER](_state) {
|
||||
_state.currentUser = initialState.currentUser;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user