calendartypes
This commit is contained in:
parent
5c2865a9e5
commit
762a9f2b8e
12 changed files with 523 additions and 11 deletions
58
src/stores/admin/calendarType.ts
Normal file
58
src/stores/admin/calendarType.ts
Normal file
|
@ -0,0 +1,58 @@
|
|||
import { defineStore } from "pinia";
|
||||
import type {
|
||||
CreateCalendarTypeViewModel,
|
||||
UpdateCalendarTypeViewModel,
|
||||
CalendarTypeViewModel,
|
||||
} from "@/viewmodels/admin/calendarType.models";
|
||||
import { http } from "@/serverCom";
|
||||
import type { AxiosResponse } from "axios";
|
||||
|
||||
export const useCalendarTypeStore = defineStore("calendarType", {
|
||||
state: () => {
|
||||
return {
|
||||
calendarTypes: [] as Array<CalendarTypeViewModel>,
|
||||
loading: "loading" as "loading" | "fetched" | "failed",
|
||||
loadingFields: "loading" as "loading" | "fetched" | "failed",
|
||||
};
|
||||
},
|
||||
actions: {
|
||||
fetchCalendarTypes() {
|
||||
this.loading = "loading";
|
||||
http
|
||||
.get("/admin/calendar/types")
|
||||
.then((result) => {
|
||||
this.calendarTypes = result.data;
|
||||
this.loading = "fetched";
|
||||
})
|
||||
.catch((err) => {
|
||||
this.loading = "failed";
|
||||
});
|
||||
},
|
||||
fetchCalendarTypeById(id: number): Promise<AxiosResponse<any, any>> {
|
||||
return http.get(`/admin/calendar/type/${id}`);
|
||||
},
|
||||
async createCalendarType(calendarType: CreateCalendarTypeViewModel): Promise<AxiosResponse<any, any>> {
|
||||
const result = await http.post(`/admin/calendar/type`, {
|
||||
type: calendarType.type,
|
||||
nscdr: calendarType.nscdr,
|
||||
color: calendarType.color,
|
||||
});
|
||||
this.fetchCalendarTypes();
|
||||
return result;
|
||||
},
|
||||
async updateActiveCalendarType(calendarType: UpdateCalendarTypeViewModel): Promise<AxiosResponse<any, any>> {
|
||||
const result = await http.patch(`/admin/calendar/type/${calendarType.id}`, {
|
||||
type: calendarType.type,
|
||||
nscdr: calendarType.nscdr,
|
||||
color: calendarType.color,
|
||||
});
|
||||
this.fetchCalendarTypes();
|
||||
return result;
|
||||
},
|
||||
async deleteCalendarType(calendarType: number): Promise<AxiosResponse<any, any>> {
|
||||
const result = await http.delete(`/admin/calendar/type/${calendarType}`);
|
||||
this.fetchCalendarTypes();
|
||||
return result;
|
||||
},
|
||||
},
|
||||
});
|
|
@ -87,9 +87,9 @@ export const useNavigationStore = defineStore("navigation", {
|
|||
mainTitle: "Verein",
|
||||
main: [
|
||||
...(abilityStore.can("read", "club", "member") ? [{ key: "member", title: "Mitglieder" }] : []),
|
||||
...(abilityStore.can("read", "club", "calendar") ? [{ key: "calendar", title: "Termine" }] : []),
|
||||
...(abilityStore.can("read", "club", "newsletter") ? [{ key: "newsletter", title: "Newsletter" }] : []),
|
||||
...(abilityStore.can("read", "club", "calendar") ? [{ key: "calendar", title: "Kalender" }] : []),
|
||||
...(abilityStore.can("read", "club", "protocoll") ? [{ key: "protocol", title: "Protokolle" }] : []),
|
||||
...(abilityStore.can("read", "club", "newsletter") ? [{ key: "newsletter", title: "Newsletter" }] : []),
|
||||
],
|
||||
},
|
||||
settings: {
|
||||
|
@ -108,6 +108,9 @@ export const useNavigationStore = defineStore("navigation", {
|
|||
...(abilityStore.can("read", "settings", "membership_status")
|
||||
? [{ key: "membership_status", title: "Mitgliedsstatus" }]
|
||||
: []),
|
||||
...(abilityStore.can("read", "settings", "calendar_type")
|
||||
? [{ key: "calendar_type", title: "Terminarten" }]
|
||||
: []),
|
||||
],
|
||||
},
|
||||
user: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue