Changed Backend to Supabase
This commit is contained in:
@@ -4,14 +4,51 @@
|
||||
|
||||
<UButton @click="showCreateProject = true">+ Projekt</UButton>
|
||||
<UModal v-model="showCreateProject">
|
||||
<UCard :ui="{ ring: '', divide: 'divide-y divide-gray-100 dark:divide-gray-800' }">
|
||||
<UCard>
|
||||
<template #header>
|
||||
Projekt erstellen
|
||||
</template>
|
||||
|
||||
<UFormGroup
|
||||
label="Name:"
|
||||
>
|
||||
<UInput
|
||||
v-model="createProjectData.name"
|
||||
/>
|
||||
</UFormGroup>
|
||||
<UFormGroup
|
||||
label="Kunde:"
|
||||
>
|
||||
<USelectMenu
|
||||
v-model="createProjectData.customer"
|
||||
:options="customers"
|
||||
option-attribute="name"
|
||||
value-attribute="id"
|
||||
searchable
|
||||
:search-attributes="['name']"
|
||||
/>
|
||||
</UFormGroup>
|
||||
<UFormGroup
|
||||
label="Notizen:"
|
||||
>
|
||||
<UTextarea
|
||||
v-model="createProjectData.notes"
|
||||
/>
|
||||
</UFormGroup>
|
||||
|
||||
<template #footer>
|
||||
<UButton
|
||||
@click="createProject"
|
||||
>
|
||||
Erstellen
|
||||
</UButton>
|
||||
</template>
|
||||
</UCard>
|
||||
</UModal>
|
||||
|
||||
<router-link v-for="item in projects" :to="`/projects/${item.id}`">
|
||||
<UCard class="listItem">
|
||||
<UBadge>{{item.id}}</UBadge> {{item.attributes.name}}
|
||||
<UBadge>{{item.id}}</UBadge> {{item.name}}
|
||||
</UCard>
|
||||
</router-link>
|
||||
|
||||
@@ -21,14 +58,14 @@
|
||||
{{selectedItem}}
|
||||
<UCard v-if="selectedItem.id">
|
||||
<template #header>
|
||||
<UBadge>{{selectedItem.id}}</UBadge> {{selectedItem.attributes.name}}
|
||||
<UBadge>{{selectedItem.id}}</UBadge> {{selectedItem.name}}
|
||||
</template>
|
||||
|
||||
Kunde:<br>
|
||||
{{selectedItem.attributes.customer.data.attributes.name}}<br>
|
||||
{{selectedItem.customer.data.name}}<br>
|
||||
|
||||
Notizen: <br>
|
||||
{{selectedItem.attributes.notes}}
|
||||
{{selectedItem.notes}}
|
||||
|
||||
<!-- Lieferantenrechnungen: <br>
|
||||
<UTable :rows="dataStore.getVendorInvoicesByProjectId(selectedItem.id)"></UTable>
|
||||
@@ -50,11 +87,15 @@ definePageMeta({
|
||||
middleware: "auth"
|
||||
})
|
||||
|
||||
const {find,create} = useStrapi4()
|
||||
const projects = (await find('projects',{populate: "*"})).data
|
||||
const supabase = useSupabaseClient()
|
||||
|
||||
const projects = (await supabase.from("projects").select()).data
|
||||
const customers = (await supabase.from("customers").select()).data
|
||||
|
||||
const showCreateProject = ref(false)
|
||||
const projectData = ref({})
|
||||
const createProjectData = ref({
|
||||
phases: []
|
||||
})
|
||||
|
||||
let selectedItem = ref({})
|
||||
|
||||
@@ -63,6 +104,19 @@ const selectItem = (item) => {
|
||||
console.log(item)
|
||||
}
|
||||
|
||||
const createProject = async () => {
|
||||
const {data,error} = await supabase
|
||||
.from("projects")
|
||||
.insert([createProjectData.value])
|
||||
.select()
|
||||
|
||||
if(error) console.log(error)
|
||||
|
||||
showCreateProject.value = false
|
||||
createProjectData.value = {phases: []}
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
Reference in New Issue
Block a user