mirror of
https://github.com/crater-invoice/crater.git
synced 2026-02-07 19:21:42 -05:00
Add New SweetAlert & Notification Components
This commit is contained in:
committed by
Mohit Panjwani
parent
3f7db2793f
commit
c3d3e5e35f
27
resources/assets/js/store/modules/notification/actions.js
Normal file
27
resources/assets/js/store/modules/notification/actions.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import * as types from './mutation-types'
|
||||
|
||||
export const showNotification = ({ commit, dispatch, state }, payload) => {
|
||||
commit(types.SHOW_NOTIFICATION, true)
|
||||
|
||||
if (payload.type) {
|
||||
commit(types.SET_NOTIFICATION_TYPE, payload.type)
|
||||
}
|
||||
if (payload.title) {
|
||||
commit(types.SET_TITLE, payload.title)
|
||||
}
|
||||
if (payload.autoHide) {
|
||||
commit(types.SET_AUTO_HIDE, payload.autoHide)
|
||||
}
|
||||
if (payload.message) {
|
||||
commit(types.SET_MESSAGE, payload.message)
|
||||
}
|
||||
}
|
||||
|
||||
export const hideNotification = ({ commit, dispatch, state }) => {
|
||||
commit(types.RESET_DATA)
|
||||
commit(types.HIDE_NOTIFICATION, false)
|
||||
}
|
||||
|
||||
export const resetNotificationData = ({ commit, dispatch, state }) => {
|
||||
commit(types.RESET_DATA)
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
export const notificationActive = (state) => state.active
|
||||
export const notificationTitle = (state) => state.title
|
||||
export const notificationMessage = (state) => state.message
|
||||
export const notificationAutoHide = (state) => state.autoHide
|
||||
export const notificationType = (state) => state.type
|
||||
23
resources/assets/js/store/modules/notification/index.js
Normal file
23
resources/assets/js/store/modules/notification/index.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import mutations from './mutations'
|
||||
import * as actions from './actions'
|
||||
import * as getters from './getters'
|
||||
|
||||
const initialState = {
|
||||
active: false,
|
||||
autoHide: true,
|
||||
title: '',
|
||||
message: '',
|
||||
type: '',
|
||||
}
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
|
||||
state: initialState,
|
||||
|
||||
getters: getters,
|
||||
|
||||
actions: actions,
|
||||
|
||||
mutations: mutations,
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
export const SHOW_NOTIFICATION = 'SHOW_NOTIFICATION'
|
||||
export const HIDE_NOTIFICATION = 'HIDE_NOTIFICATION'
|
||||
export const SET_TITLE = 'SET_TITLE'
|
||||
export const SET_AUTO_HIDE = 'SET_AUTO_HIDE'
|
||||
export const SET_MESSAGE = 'SET_MESSAGE'
|
||||
export const SET_NOTIFICATION_TYPE = 'SET_NOTIFICATION_TYPE'
|
||||
export const RESET_DATA = 'RESET_DATA'
|
||||
33
resources/assets/js/store/modules/notification/mutations.js
Normal file
33
resources/assets/js/store/modules/notification/mutations.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import * as types from './mutation-types'
|
||||
|
||||
export default {
|
||||
[types.SHOW_NOTIFICATION](state, data) {
|
||||
state.active = data
|
||||
},
|
||||
|
||||
[types.HIDE_NOTIFICATION](state, data) {
|
||||
state.active = data
|
||||
},
|
||||
|
||||
[types.SET_TITLE](state, data) {
|
||||
state.title = data
|
||||
},
|
||||
|
||||
[types.SET_AUTO_HIDE](state, data) {
|
||||
state.autoHide = data
|
||||
},
|
||||
|
||||
[types.SET_MESSAGE](state, data) {
|
||||
state.message = data
|
||||
},
|
||||
|
||||
[types.SET_NOTIFICATION_TYPE](state, data) {
|
||||
state.type = data
|
||||
},
|
||||
|
||||
[types.RESET_DATA](state) {
|
||||
state.active = false
|
||||
state.description = ''
|
||||
state.title = ''
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user