Implemented Fullcalendar

This commit is contained in:
2023-12-02 17:06:39 +01:00
parent 45da05c9a4
commit f63bda171f
25 changed files with 213 additions and 20179 deletions

View File

@@ -4,11 +4,17 @@ import {createClient} from '@supabase/supabase-js'
const supabase = createClient('https://uwppvcxflrcsibuzsbil.supabase.co','eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InV3cHB2Y3hmbHJjc2lidXpzYmlsIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MDA5MzgxOTQsImV4cCI6MjAxNjUxNDE5NH0.CkxYSQH0uLfwx9GVUlO6AYMU2FMLAxGMrwEKvyPv7Oo')
// @ts-ignore
export const useDataStore = defineStore('data', {
state: () => ({
loaded: false,
ownTenant: {
calendarConfig: {
eventTypes: [] as any[]
}
},
profiles: [] as any[],
events: [] as any[],
customers: [] as any[],
tasks: [] as any[],
projects: [] as any[],
@@ -20,10 +26,14 @@ export const useDataStore = defineStore('data', {
movements: [] as any[],
forms: [] as any[],
formSubmits: [] as any[],
contact: [] as any[]
contacts: [] as any[],
vehicles: [] as any[],
}),
actions: {
async fetchData() {
await this.fetchOwnTenant()
await this.fetchProfiles()
await this.fetchEvents()
await this.fetchCustomers()
await this.fetchTasks()
await this.fetchForms()
@@ -34,8 +44,22 @@ export const useDataStore = defineStore('data', {
await this.fetchDocuments()
await this.fetchMovements()
await this.fetchSpaces()
await this.fetchVehicles()
this.loaded = true
},
async fetchOwnTenant() {
//TODO: Tenant ID Dynamisch machen
// @ts-ignore
this.ownTenant = (await supabase.from("tenants").select().eq('id', 1)).data[0]
},
async fetchProfiles() {
// @ts-ignore
this.profiles = (await supabase.from("profiles").select()).data
},
async fetchEvents() {
// @ts-ignore
this.events = (await supabase.from("events").select()).data
},
async fetchCustomers() {
// @ts-ignore
this.customers = (await supabase.from("customers").select().order('customerNumber', {ascending: true})).data
@@ -72,6 +96,10 @@ export const useDataStore = defineStore('data', {
// @ts-ignore
this.movements = (await supabase.from("movements").select()).data
},
async fetchVehicles() {
// @ts-ignore
this.vehicles = (await supabase.from("vehicles").select()).data
},
async fetchDocuments() {
// @ts-ignore
this.documents = (await supabase.from("documents").select()).data
@@ -87,6 +115,35 @@ export const useDataStore = defineStore('data', {
movementsBySpace: (state) => (spaceId:number) => state.movements.filter(move => move.spaceId === spaceId),
getProductById: (state) => (productId:number) => state.products.find(product => product.id === productId),
getProjectById: (state) => (projectId:number) => state.projects.find(project => project.id === projectId),
getFormSubmitsWithLabelProp: (state) => (state.formSubmits.map(submit => {return{...submit, label: submit.id}}))
getFormSubmitsWithLabelProp: (state) => (state.formSubmits.map(submit => {return{...submit, label: submit.id}})),
getResources: (state) => {
return [
...state.profiles.map(profile => {
return {
type: 'person',
title: profile.firstName + ' ' + profile.lastName,
id: profile.id
}
}),
...state.vehicles.map(vehicle => {
return {
type: 'vehicle',
title: vehicle.licensePlate,
id: vehicle.licensePlate
}
})
]
},
getEvents: (state) => {
return [
...state.events.map(event => {
return {
...event,
backgroundColor: state.ownTenant.calendarConfig.eventTypes.find(type => type.label === event.type).color
}
}),
]
},
getEventTypes: (state) => state.ownTenant.calendarConfig.eventTypes
}
})