You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
1.5 KiB
JavaScript
80 lines
1.5 KiB
JavaScript
import Vue from 'vue'
|
|
import Vuex from 'vuex'
|
|
import { mapState } from 'vuex'
|
|
|
|
Vue.use(Vuex)
|
|
|
|
const upload ={
|
|
state: {
|
|
status: {},
|
|
options: {
|
|
request_payment: true,
|
|
request_payment_amount: 1,
|
|
payment_currency: 'SAT'
|
|
},
|
|
},
|
|
mutations:{
|
|
setPayAmount (state, val){
|
|
state.options.request_payment_amount = val
|
|
},
|
|
setUpStatus (state, status) {
|
|
state.status = status
|
|
},
|
|
setCurrency(state, val){
|
|
state.options.payment_currency = val
|
|
},
|
|
setRequestPay(state, val){
|
|
state.options.request_payment = val
|
|
}
|
|
}
|
|
}
|
|
|
|
const down = {
|
|
state: {
|
|
files: [],
|
|
},
|
|
mutations: {
|
|
setFiles(state, val){
|
|
state.files = val
|
|
}
|
|
}
|
|
}
|
|
|
|
const base = {
|
|
state: {
|
|
invoice: {
|
|
settled: false,
|
|
},
|
|
uploadId: 0
|
|
},
|
|
mutations: {
|
|
setUploadId (state, id) {
|
|
state.uploadId = id
|
|
},
|
|
setInvoice (state, invoice) {
|
|
state.invoice = invoice
|
|
}
|
|
},
|
|
getters: {
|
|
paid(state) {
|
|
return state.invoice.settled
|
|
},
|
|
expired (state){
|
|
return ((new Date(state.invoice.expires_at*1000) - new Date() <= 0) &&
|
|
!state.paid)
|
|
},
|
|
unpaid (state){
|
|
return !state.invoice.settled
|
|
}
|
|
}
|
|
}
|
|
|
|
export default new Vuex.Store({
|
|
modules: {
|
|
upload,
|
|
down,
|
|
base
|
|
},
|
|
strict: true
|
|
})
|