mirror of
https://github.com/Dvorinka/Bookra.git
synced 2026-10-28 07:41:16 +00:00
feat(catalog): add service and staff management end-to-end
Services and staff existed as schema + booking FK targets but had no management surface. Adds full CRUD: repository (pgx + in-memory with matching FK semantics), catalog service validation with tenant isolation, MaxStaff entitlement enforcement, protected API routes, OpenAPI schemas, and dashboard screens for both entities. Dashboard summary now resolves staff names on bookings and computes setup completion from real configured state. Booking modal selects from the tenant's actual services; blocked days can be scoped per staff member. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
7a6223c07b
commit
09f780e7a6
21 files changed
+2422
-15
No files matched your search
@@ -355,6 +355,12 @@ func (s *Service) DashboardSummary(ctx context.Context, principal domain.Princip
|
||||
locationNames[location.ID] = location.Name
|
||||
}
|
||||
}
|
||||
staffNames := map[string]string{}
|
||||
if staff, err := s.repo.ListStaffByTenant(ctx, membership.Tenant.ID); err == nil {
|
||||
for _, member := range staff {
|
||||
staffNames[member.ID] = member.DisplayName
|
||||
}
|
||||
}
|
||||
toDomain := func(booking db.BookingRecord) domain.UpcomingBooking {
|
||||
out := domain.UpcomingBooking{
|
||||
ID: booking.ID,
|
||||
@@ -372,6 +378,9 @@ func (s *Service) DashboardSummary(ctx context.Context, principal domain.Princip
|
||||
if booking.LocationID != nil {
|
||||
out.Location = locationNames[*booking.LocationID]
|
||||
}
|
||||
if booking.StaffID != nil {
|
||||
out.StaffName = staffNames[*booking.StaffID]
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
@@ -408,6 +417,15 @@ func (s *Service) DashboardSummary(ctx context.Context, principal domain.Princip
|
||||
allBookings = append(allBookings, toDomain(booking))
|
||||
}
|
||||
|
||||
brandName := membership.Tenant.Name
|
||||
if brand, err := s.repo.GetBrandProfile(ctx, membership.Tenant.ID); err == nil && strings.TrimSpace(brand.Name) != "" {
|
||||
brandName = brand.Name
|
||||
}
|
||||
scheduleCount := 0
|
||||
if rules, err := s.repo.ListAvailabilityRulesByTenant(ctx, membership.Tenant.ID); err == nil {
|
||||
scheduleCount = len(rules)
|
||||
}
|
||||
|
||||
return domain.DashboardSummary{
|
||||
TenantName: membership.Tenant.Name,
|
||||
TenantSlug: membership.Tenant.Slug,
|
||||
@@ -415,7 +433,7 @@ func (s *Service) DashboardSummary(ctx context.Context, principal domain.Princip
|
||||
Timezone: membership.Tenant.Timezone,
|
||||
PlanCode: shared.NormalizePlanCode(membership.Tenant.PlanCode),
|
||||
PublicBookingURL: "/book/" + membership.Tenant.Slug,
|
||||
SetupCompletion: 100,
|
||||
SetupCompletion: setupCompletion(brandName, len(locationNames), len(serviceNames), len(staffNames), scheduleCount),
|
||||
KPIs: []domain.DashboardKPI{
|
||||
{Code: "bookings_this_week", Label: "Bookings this week", Value: fmt.Sprintf("%d", metrics.BookingsCount)},
|
||||
{Code: "cancellations", Label: "Cancellations", Value: fmt.Sprintf("%d", metrics.CancellationsCount)},
|
||||
@@ -428,6 +446,28 @@ func (s *Service) DashboardSummary(ctx context.Context, principal domain.Princip
|
||||
}, nil
|
||||
}
|
||||
|
||||
// setupCompletion scores onboarding readiness across five equal-weight checks:
|
||||
// brand profile, location, service catalog, staff roster, and schedule rules.
|
||||
func setupCompletion(brandName string, locationCount, serviceCount, staffCount, scheduleCount int) int {
|
||||
score := 0
|
||||
if strings.TrimSpace(brandName) != "" {
|
||||
score += 20
|
||||
}
|
||||
if locationCount > 0 {
|
||||
score += 20
|
||||
}
|
||||
if serviceCount > 0 {
|
||||
score += 20
|
||||
}
|
||||
if staffCount > 0 {
|
||||
score += 20
|
||||
}
|
||||
if scheduleCount > 0 {
|
||||
score += 20
|
||||
}
|
||||
return score
|
||||
}
|
||||
|
||||
func widgetSnippets(tenant db.TenantRecord) []domain.WidgetSnippet {
|
||||
path := "/book/" + tenant.Slug
|
||||
return []domain.WidgetSnippet{
|
||||
|
||||
Reference in new issue
Block a user