Replaced sweet alert success alerts with my own toasts

This commit is contained in:
Roman Cervantes 2019-01-18 22:57:52 -07:00
parent 70932e614e
commit 0304bd7ed4
6 changed files with 12 additions and 35 deletions

View file

@ -109,7 +109,7 @@ import GameSearch from '@/components/GameSearch/GameSearch';
import { mapState, mapGetters } from 'vuex';
import firebase from 'firebase/app';
import 'firebase/firestore';
import { $success, $error } from '@/shared/modals';
import { $error } from '@/shared/modals';
const db = firebase.firestore();
@ -176,7 +176,7 @@ export default {
updateLists() {
db.collection('lists').doc(this.user.uid).set(this.gameLists, { merge: true })
.then(() => {
$success('List saved');
this.$bus.$emit('TOAST', { message: 'List saved' });
})
.catch(() => {
$error('Authentication error');

View file

@ -44,7 +44,7 @@
<script>
import GameRating from '@/components/GameDetail/GameRating';
import { mapState } from 'vuex';
import { $success, $error } from '@/shared/modals';
import { $error } from '@/shared/modals';
import firebase from 'firebase/app';
import 'firebase/firestore';
@ -131,7 +131,7 @@ export default {
db.collection('lists').doc(this.user.uid).set(this.gameLists, { merge: true })
.then(() => {
$success('List saved');
this.$bus.$emit('TOAST', { message: 'Game added to list' });
})
.catch(() => {
$error('Authentication error');
@ -148,7 +148,7 @@ export default {
db.collection('lists').doc(this.user.uid).set(this.gameLists, { merge: true })
.then(() => {
$success('List saved');
this.$bus.$emit('TOAST', { message: 'Game removed' });
})
.catch(() => {
$error('Authentication error');

View file

@ -179,14 +179,7 @@ export default {
this.$emit('scroll');
this.reset();
swal({
position: 'bottom-end',
title: 'List added',
type: 'success',
toast: true,
showConfirmButton: false,
timer: 1500,
});
this.$bus.$emit('TOAST', { message: 'List added' });
},
reset() {

View file

@ -33,7 +33,7 @@ import ListOptions from '@/components/Lists/ListOptions';
import GameBoardPlaceholder from '@/components/GameBoard/GameBoardPlaceholder';
import Onboard from '@/components/GameBoard/Onboard';
import Panel from '@/components/Panel/Panel';
import { $success, $error, swal } from '@/shared/modals';
import { $error, swal } from '@/shared/modals';
import List from '@/components/GameBoard/List';
import draggable from 'vuedraggable';
import { mapState, mapGetters } from 'vuex';
@ -127,20 +127,18 @@ export default {
deleteList(index) {
this.$store.commit('REMOVE_LIST', index);
this.updateLists();
$success('List deleted');
this.$bus.$emit('TOAST', { message: 'List deleted' });
},
dragEnd() {
this.dragging = false;
this.draggingId = null;
this.$bus.$emit('TOAST', { message: 'Collection updated' });
this.updateLists();
},
updateLists(force) {
db.collection('lists').doc(this.user.uid).set(this.gameLists, { merge: !force })
.then(() => {
$success('List saved');
})
.catch(() => {
$error('Authentication error');
});

View file

@ -107,7 +107,7 @@ import 'firebase/auth';
import Gravatar from 'vue-gravatar';
import Panel from '@/components/Panel/Panel';
import ToggleSwitch from '@/components/ToggleSwitch/ToggleSwitch';
import { $success, $error, swal } from '@/shared/modals';
import { $error, swal } from '@/shared/modals';
import moment from 'moment';
const db = firebase.firestore();
@ -180,12 +180,9 @@ export default {
// TODO: use async/await
db.collection('settings').doc(this.user.uid).delete()
.then(() => {
$success('Settings deleted');
db.collection('lists').doc(this.user.uid).delete()
.then(() => {
$success('Game lists deleted');
$success('Account deleted');
this.$bus.$emit('TOAST', { message: 'Account deleted' });
this.$store.commit('CLEAR_SESSION');
this.$router.push({ name: 'home' });
})
@ -215,7 +212,7 @@ export default {
db.collection('settings').doc(this.user.uid).set(this.localSettings, { merge: true })
.then(() => {
this.$store.commit('SET_SETTINGS', this.localSettings);
$success('Settings saved');
this.$bus.$emit('TOAST', { message: 'Settings saved' });
})
.catch(() => {
$error('There was an error saving your settings');

View file

@ -12,15 +12,4 @@ export function $error(title) {
});
}
export function $success(title) {
swal({
position: 'bottom-end',
title,
type: 'success',
toast: true,
showConfirmButton: false,
timer: 1500,
});
}
export { swal };