feat: add multi-tenant system with properties, organizations, and public booking
Implement complete multi-property architecture: - Properties (groups of spaces) with public/private visibility - Property managers (many-to-many) with role-based permissions - Organizations with member management - Anonymous/guest booking support via public API (/api/public/*) - Property-scoped spaces, bookings, and settings - Frontend: property selector, organization management, public booking views - Migration script and updated seed data Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,12 @@
|
||||
<div class="admin">
|
||||
<Breadcrumb :items="breadcrumbItems" />
|
||||
<div class="page-header">
|
||||
<h2>Space Management</h2>
|
||||
<div>
|
||||
<h2>Space Management</h2>
|
||||
<p v-if="authStore.isManager && propertyStore.currentProperty" class="property-context">
|
||||
Property: <strong>{{ propertyStore.currentProperty.name }}</strong>
|
||||
</p>
|
||||
</div>
|
||||
<button class="btn btn-primary" @click="openCreateModal">
|
||||
<Plus :size="16" />
|
||||
New Space
|
||||
@@ -73,6 +78,10 @@
|
||||
<UsersIcon :size="14" />
|
||||
{{ space.capacity }}
|
||||
</span>
|
||||
<span v-if="space.property_name" class="meta-badge meta-property" :title="'Property: ' + space.property_name">
|
||||
<Landmark :size="11" />
|
||||
{{ space.property_name }}
|
||||
</span>
|
||||
</div>
|
||||
<p v-if="space.description" class="space-card-desc">{{ space.description }}</p>
|
||||
</div>
|
||||
@@ -94,6 +103,15 @@
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="property">Property *</label>
|
||||
<select id="property" v-model.number="formData.property_id" required>
|
||||
<option v-for="prop in availableProperties" :key="prop.id" :value="prop.id">
|
||||
{{ prop.name }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="type">Type *</label>
|
||||
<select id="type" v-model="formData.type" required>
|
||||
@@ -201,10 +219,15 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { spacesApi, handleApiError } from '@/services/api'
|
||||
import { spacesApi, propertiesApi, handleApiError } from '@/services/api'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { usePropertyStore } from '@/stores/property'
|
||||
import Breadcrumb from '@/components/Breadcrumb.vue'
|
||||
import { Building2, Plus, Pencil, Power, Users as UsersIcon } from 'lucide-vue-next'
|
||||
import type { Space } from '@/types'
|
||||
import { Building2, Plus, Pencil, Power, Users as UsersIcon, Landmark } from 'lucide-vue-next'
|
||||
import type { Space, Property } from '@/types'
|
||||
|
||||
const authStore = useAuthStore()
|
||||
const propertyStore = usePropertyStore()
|
||||
|
||||
const breadcrumbItems = [
|
||||
{ label: 'Dashboard', to: '/dashboard' },
|
||||
@@ -212,6 +235,7 @@ const breadcrumbItems = [
|
||||
]
|
||||
|
||||
const spaces = ref<Space[]>([])
|
||||
const availableProperties = ref<Property[]>([])
|
||||
const loadingSpaces = ref(false)
|
||||
const activeCount = computed(() => spaces.value.filter(s => s.is_active).length)
|
||||
const inactiveCount = computed(() => spaces.value.filter(s => !s.is_active).length)
|
||||
@@ -226,12 +250,23 @@ const formData = ref({
|
||||
type: 'sala',
|
||||
capacity: 1,
|
||||
description: '',
|
||||
property_id: null as number | null,
|
||||
working_hours_start: null as number | null,
|
||||
working_hours_end: null as number | null,
|
||||
min_duration_minutes: null as number | null,
|
||||
max_duration_minutes: null as number | null
|
||||
})
|
||||
|
||||
const loadProperties = async () => {
|
||||
try {
|
||||
if (authStore.isSuperadmin) {
|
||||
availableProperties.value = await propertiesApi.listAll()
|
||||
} else {
|
||||
availableProperties.value = await propertiesApi.list()
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
|
||||
const loadSpaces = async () => {
|
||||
loadingSpaces.value = true
|
||||
error.value = ''
|
||||
@@ -274,6 +309,12 @@ const handleSubmit = async () => {
|
||||
|
||||
const openCreateModal = () => {
|
||||
resetForm()
|
||||
// Auto-select current property context or first available
|
||||
if (propertyStore.currentPropertyId) {
|
||||
formData.value.property_id = propertyStore.currentPropertyId
|
||||
} else if (availableProperties.value.length > 0) {
|
||||
formData.value.property_id = availableProperties.value[0].id
|
||||
}
|
||||
showModal.value = true
|
||||
}
|
||||
|
||||
@@ -284,6 +325,7 @@ const startEdit = (space: Space) => {
|
||||
type: space.type,
|
||||
capacity: space.capacity,
|
||||
description: space.description || '',
|
||||
property_id: space.property_id ?? null,
|
||||
working_hours_start: space.working_hours_start ?? null,
|
||||
working_hours_end: space.working_hours_end ?? null,
|
||||
min_duration_minutes: space.min_duration_minutes ?? null,
|
||||
@@ -307,7 +349,8 @@ const resetForm = () => {
|
||||
working_hours_start: null,
|
||||
working_hours_end: null,
|
||||
min_duration_minutes: null,
|
||||
max_duration_minutes: null
|
||||
max_duration_minutes: null,
|
||||
property_id: null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -333,6 +376,7 @@ const toggleStatus = async (space: Space) => {
|
||||
|
||||
onMounted(() => {
|
||||
loadSpaces()
|
||||
loadProperties()
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -353,6 +397,16 @@ onMounted(() => {
|
||||
color: var(--color-text-primary);
|
||||
}
|
||||
|
||||
.property-context {
|
||||
font-size: 14px;
|
||||
color: var(--color-text-secondary);
|
||||
margin: 4px 0 0;
|
||||
}
|
||||
|
||||
.property-context strong {
|
||||
color: var(--color-accent);
|
||||
}
|
||||
|
||||
/* Stats Pills */
|
||||
.stats-pills {
|
||||
display: flex;
|
||||
@@ -544,6 +598,14 @@ onMounted(() => {
|
||||
color: var(--color-accent);
|
||||
}
|
||||
|
||||
.meta-property {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
background: color-mix(in srgb, var(--color-warning) 12%, transparent);
|
||||
color: var(--color-warning);
|
||||
}
|
||||
|
||||
.meta-item {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
|
||||
Reference in New Issue
Block a user