add form to create new event

This commit is contained in:
j3d1 2024-11-02 22:12:00 +01:00
parent f9409bb823
commit dffd3531fa
5 changed files with 132 additions and 11 deletions

View file

@ -48,6 +48,7 @@ const store = createStore({
afterInitHandlers: [],
showAddBoxModal: false,
showAddEventModal: false,
shippingVoucherTypes: {
'2kg-de': '2kg Paket (DE)',
@ -172,6 +173,12 @@ const store = createStore({
closeAddBoxModal(state) {
state.showAddBoxModal = false;
},
openAddEventModal(state) {
state.showAddEventModal = true;
},
closeAddEventModal(state) {
state.showAddEventModal = false;
},
createToast(state, {title, message, color}) {
var toast = {title, message, color, key: state.keyIncrement}
state.toasts.push(toast);
@ -300,6 +307,18 @@ const store = createStore({
if (data && success)
commit('replaceEvents', data);
},
async createEvent({commit, dispatch, state}, event) {
const {data, success} = await http.post('/2/events/', event, state.user.token);
if (data && success)
commit('replaceEvents', [...state.events, data]);
},
async deleteEvent({commit, dispatch, state}, event_id) {
const {data, success} = await http.delete(`/2/events/${event_id}/`, state.user.token);
if (success) {
await dispatch('loadEvents')
commit('replaceEvents', [...state.events.filter(e => e.eid !== event_id)])
}
},
async fetchTicketStates({commit, state}) {
if (!state.user.token) return;
if (state.fetchedData.states > Date.now() - 1000 * 60 * 60 * 24) return;