Add blacklist payload type

This commit is contained in:
Matthias 2020-08-04 08:03:08 +02:00
parent c88308213d
commit faee161379
2 changed files with 33 additions and 31 deletions

View File

@ -1,5 +1,5 @@
import { api } from '@/shared/apiService';
import { BotState } from '@/store/types';
import { BotState, BlacklistPayload } from '@/store/types';
export default {
namespaced: true,
@ -220,12 +220,11 @@ export default {
console.error(error);
return Promise.reject(error);
},
addBlacklist({ commit, dispatch }, payload) {
async addBlacklist({ commit, dispatch }, payload: BlacklistPayload) {
console.log(`Adding ${payload} to blacklist`);
if (payload && payload.blacklist) {
return api
.post('/blacklist', payload)
.then((result) => {
try {
const result = await api.post('/blacklist', payload);
commit('updateBlacklist', result.data);
if (result.data.errors && Object.keys(result.data.errors).length !== 0) {
const { errors } = result.data;
@ -245,8 +244,8 @@ export default {
{ root: true },
);
}
})
.catch((error) => {
return Promise.resolve(result);
} catch (error) {
console.error(error.response);
dispatch(
'alerts/addAlert',
@ -256,14 +255,13 @@ export default {
},
{ root: true },
);
});
return Promise.reject(error);
}
}
// Error branchs
const error = 'Pair is empty';
console.error(error);
return new Promise((resolve, reject) => {
reject(error);
});
return Promise.reject(error);
},
},
};

View File

@ -4,6 +4,10 @@ export interface AuthPayload {
password: string;
}
export interface BlacklistPayload {
blacklist: Array<string>;
}
export interface DailyInterface {
timescale: number;
}