diff --git a/backend/app/routers/sites.py b/backend/app/routers/sites.py index f789cef..17cd89b 100644 --- a/backend/app/routers/sites.py +++ b/backend/app/routers/sites.py @@ -83,7 +83,7 @@ async def create_site( """Create a new site. Requires operator role or above.""" await _check_tenant_access(current_user, tenant_id, db) return await site_service.create_site( - db=db, tenant_id=tenant_id, data=data, user_id=current_user.id + db=db, tenant_id=tenant_id, data=data, user_id=current_user.user_id ) @@ -103,7 +103,7 @@ async def update_site( """Update a site. Requires operator role or above.""" await _check_tenant_access(current_user, tenant_id, db) return await site_service.update_site( - db=db, tenant_id=tenant_id, site_id=site_id, data=data, user_id=current_user.id + db=db, tenant_id=tenant_id, site_id=site_id, data=data, user_id=current_user.user_id ) @@ -122,7 +122,7 @@ async def delete_site( """Delete a site. Requires tenant_admin or above.""" await _check_tenant_access(current_user, tenant_id, db) await site_service.delete_site( - db=db, tenant_id=tenant_id, site_id=site_id, user_id=current_user.id + db=db, tenant_id=tenant_id, site_id=site_id, user_id=current_user.user_id ) diff --git a/frontend/src/components/sites/SiteFormDialog.tsx b/frontend/src/components/sites/SiteFormDialog.tsx index 5303178..75dbf40 100644 --- a/frontend/src/components/sites/SiteFormDialog.tsx +++ b/frontend/src/components/sites/SiteFormDialog.tsx @@ -1,6 +1,7 @@ import { useState } from 'react' import { useMutation, useQueryClient } from '@tanstack/react-query' import { sitesApi, type SiteResponse, type SiteCreate, type SiteUpdate } from '@/lib/api' +import { toast } from '@/components/ui/toast' import { Dialog, DialogContent, @@ -36,6 +37,11 @@ export function SiteFormDialog({ open, onOpenChange, tenantId, site }: SiteFormD onSuccess: () => { void queryClient.invalidateQueries({ queryKey: ['sites', tenantId] }) onOpenChange(false) + toast({ title: 'Site created' }) + }, + onError: (err: unknown) => { + const e = err as { response?: { data?: { detail?: string } } } + toast({ title: 'Failed to create site', description: e.response?.data?.detail || 'Unknown error', variant: 'destructive' }) }, }) @@ -44,6 +50,11 @@ export function SiteFormDialog({ open, onOpenChange, tenantId, site }: SiteFormD onSuccess: () => { void queryClient.invalidateQueries({ queryKey: ['sites', tenantId] }) onOpenChange(false) + toast({ title: 'Site updated' }) + }, + onError: (err: unknown) => { + const e = err as { response?: { data?: { detail?: string } } } + toast({ title: 'Failed to update site', description: e.response?.data?.detail || 'Unknown error', variant: 'destructive' }) }, })