BuildingApartments.vue 1.94 KB
Newer Older
abergavenny's avatar
abergavenny committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<script setup>
import { ref } from 'vue'

import ApartmentList from '@/components/ApartmentList.vue'
import ContentPanel from '@/components/ContentPanel.vue'
import DataItem from '@/components/DataItem.vue'
import DataPage from '@/components/DataPage.vue'
import ModalContainer from '@/components/ModalContainer.vue'
import NoData from '@/components/NoData.vue'
import ApartmentForm from '@/components/forms/ApartmentForm.vue'
import { useApartmentStore } from '@/stores/apartments'
import { useBuildingStore } from '@/stores/buildings'

const showModal = ref(false)

const buildings = useBuildingStore()
const apartments = useApartmentStore()

function handleModal() {
  showModal.value = !showModal.value
}
</script>

<template>
  <ContentPanel label="Ihre Wohneinheiten">
    <DataPage>
      <div class="apartment-summary" v-if="buildings.active && apartments.count > 0">
        <div class="content stretched">
          <DataItem label="Wohneinheiten" :data="apartments.summary?.apartments" />
          <DataItem label="Fläche gesamt" :data="apartments.summary?.area" unit="m²" />
          <DataItem label="Fenster gesamt" :data="apartments.summary?.windows" />
        </div>
        <div class="content stretched">
          <DataItem label="Heizkörper" :data="apartments.summary?.heatingElements" />
          <DataItem label="Flächenheizung" :data="apartments.summary?.panelHeating" unit="m²" />
        </div>
      </div>
      <NoData v-else />
    </DataPage>
    <DataPage :stretch="true">
      <ApartmentList @on-create="() => showModal = true" />
    </DataPage>
  </ContentPanel>
  <ModalContainer v-if="showModal" label="Wohneinheit anlegen" @close-modal="handleModal">
    <ApartmentForm @close-modal="handleModal" />
  </ModalContainer>
</template>

<style scoped>
.apartment-summary {
  height: 100%;
  display: flex;
  flex-direction: column;
}

@media (min-width: 48em) {
  .apartment-summary {
    flex-direction: row;
    gap: var(--spacing);
  }
}
</style>