added action to update other account

This commit is contained in:
Nouman Tahir 2023-06-14 18:59:48 +05:00
parent 905c39707d
commit 1f97de29da
3 changed files with 19 additions and 0 deletions

View File

@ -7,6 +7,7 @@ import {
SET_GLOBAL_PROPS,
UPDATE_CURRENT_ACCOUNT,
UPDATE_UNREAD_ACTIVITY_COUNT,
UPDATE_OTHER_ACCOUNT,
} from '../constants/constants';
export const fetchGlobalProperties = () => (dispatch) =>
@ -27,6 +28,11 @@ export const addOtherAccount = (data) => ({
payload: data,
});
export const updateOtherAccount = (accountObj) => ({
type: UPDATE_OTHER_ACCOUNT,
payload: accountObj
})
export const failedAccount = (data) => ({
type: FETCH_ACCOUNT_FAIL,
payload: data,

View File

@ -41,6 +41,7 @@ export const SET_ENC_UNLOCK_PIN = 'SET_ENC_UNLOCK_PIN';
// Accounts
export const ADD_OTHER_ACCOUNT = 'ADD_OTHER_ACCOUNT';
export const UPDATE_OTHER_ACCOUNT = 'UPDATE_OTHER_ACCOUNT';
export const FETCH_ACCOUNT_FAIL = 'FETCH_ACCOUNT_FAIL';
export const FETCHING_ACCOUNT = 'FETCHING_ACCOUNT';
export const REMOVE_OTHER_ACCOUNT = 'REMOVE_OTHER_ACCOUNT';

View File

@ -4,6 +4,7 @@ import {
FETCH_ACCOUNT_FAIL,
FETCHING_ACCOUNT,
ADD_OTHER_ACCOUNT,
UPDATE_OTHER_ACCOUNT,
UPDATE_CURRENT_ACCOUNT,
UPDATE_UNREAD_ACTIVITY_COUNT,
REMOVE_OTHER_ACCOUNT,
@ -78,6 +79,17 @@ export default function (state = initialState, action) {
errorMessage: null,
};
case UPDATE_OTHER_ACCOUNT:
return {
...state,
otherAccounts: [
...state.otherAccounts.filter(
(item) => item.username !== action.payload.username),
action.payload
],
}
case REMOVE_OTHER_ACCOUNT:
return {
...state,