Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let newState = updateOperationsMap(state, u.omit(account.operationIds));
// Then remove the account from the access.
newState = updateAccessFields(newState, account.accessId, {
accountIds: u.reject(id => id === accountId)
});
// Remove access if no more accounts in the access.
newState =
accountIdsByAccessId(newState, account.accessId).length === 0
? removeAccess(newState, account.accessId)
: newState;
// Reset the defaultAccountId if we just deleted it.
if (getDefaultAccountId(newState) === accountId) {
newState = u({ defaultAccountId: DefaultSettings.get('default-account-id') }, newState);
}
// Reset the current account id if we just deleted it.
if (getCurrentAccountId(newState) === accountId) {
newState = setCurrentAccessAndAccount(newState);
}
// Remove alerts attached to the account.
newState = u.updateIn('alerts', u.reject(alert => alert.accountId === accountId), newState);
// Finally, remove the account from the accounts map.
return updateAccountsMap(newState, u.omit(accountId));
}
export function initialState(external, allAccesses, allAccounts, allOperations, allAlerts) {
// Retrieved from outside.
let { defaultCurrency, defaultAccountId } = external;
if (defaultAccountId !== DefaultSettings.get('default-account-id')) {
defaultAccountId = parseInt(defaultAccountId, 10);
}
let banks = StaticBanks.map(b => new Bank(b));
sortBanks(banks);
let newState = u(
{
banks,
constants: {
defaultCurrency
},
defaultAccountId
},
INITIAL_STATE
);
newState = addAccesses(newState, allAccesses, allAccounts, allOperations);
newState = setCurrentAccessAndAccount(newState);
let alerts = allAlerts.map(al => new Alert(al));
return u(
export function setMapping(state, action) {
return u(
{
[action.payload.feature]: {
param: action.payload.param
}
},
state
);
}
export default function (state = [], {type, payload}) {
switch (type) {
case SELECT_TAG:
return u(
u.ifElse(
contains(payload.tagId),
without([payload.tagId]),
append(payload.tagId)
),
state
);
case `${DELETE_TAG}_PENDING`:
return reject(equals(payload.tagId), state);
case REMOVE_FILTER:
return without([payload.tagId], state);
default:
return state;
}
}
return function(state, action) {
let { status } = action;
if (status === FAIL || status === SUCCESS) {
return u({ processingReason: null }, state);
}
return u({ processingReason }, state);
};
}
function reduceUpdateAlert(state, action) {
let { status } = action;
if (status === SUCCESS) {
let { attributes, alertId } = action;
return u.updateIn('alerts', updateMapIf('id', alertId, u(attributes)), state);
}
return state;
}
let { status } = action;
if (status === SUCCESS) {
return u(
{
budgetsByPeriod: {
[`${action.year}${action.month}`]: action.budgets.map(b => new Budget(b))
}
},
state
);
}
if (status === FAIL) {
genericErrorHandler(action.error);
return u(
{
budgetsByPeriod: {
[`${action.year}${action.month}`]: null
}
},
state
);
}
return state;
}
async request({ dispatch, rootGetters }, config) {
const accessToken = rootGetters['auth/getAccessToken'];
return dispatch(
'api/request',
u(config, {
headers: {
Authorization: `Bearer ${accessToken}`
}
}),
{ root: true }
);
}
};
function reduceGetWeboobVersion(state, action) {
let { status } = action;
if (status === SUCCESS) {
let stateUpdates = { map: { 'weboob-version': action.version } };
if (typeof action.isInstalled === 'boolean') {
if (!action.isInstalled) {
notify.error($t('client.sync.weboob_not_installed'));
}
stateUpdates.map['weboob-installed'] = action.isInstalled.toString();
}
return u(stateUpdates, state);
}
if (status === FAIL) {
if (action.error.code === Errors.WEBOOB_NOT_INSTALLED) {
notify.error($t('client.sync.weboob_not_installed'));
return u({ map: { 'weboob-installed': 'false' } }, state);
}
genericErrorHandler(action.error);
return u({ map: { 'weboob-version': null } }, state);
}
return state;
}
export function initialState(isDemoEnabled) {
let search = initialSearch();
return u(
{
search,
displaySearchDetails: false,
processingReason: 'client.general.loading_assets',
updatingWeboob: false,
sendingTestEmail: false,
isDemoMode: isDemoEnabled,
isExporting: false,
isSmallScreen: computeIsSmallScreen(),
modal: {
slug: null,
state: null
},
isMenuHidden: computeIsSmallScreen()
},
{}