Improve site management interface to correctly assign customers

Update the `sites.tsx` page to correctly handle `customerId` when creating or editing sites, ensuring the customer selection works as expected.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: e5565357-90e1-419f-b9a8-6ee8394636df
Replit-Commit-Checkpoint-Type: intermediate_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/6d543d2c-20b9-4ea6-93fe-70fe9b1d9f80/e5565357-90e1-419f-b9a8-6ee8394636df/IcLh7if
This commit is contained in:
marco370 2025-10-23 09:35:46 +00:00
parent 0f58cba38c
commit 37cbbfa768
2 changed files with 13 additions and 12 deletions

View File

@ -19,6 +19,10 @@ externalPort = 80
localPort = 33035
externalPort = 3001
[[ports]]
localPort = 37459
externalPort = 5173
[[ports]]
localPort = 41295
externalPort = 6000
@ -35,10 +39,6 @@ externalPort = 4200
localPort = 42175
externalPort = 3002
[[ports]]
localPort = 42423
externalPort = 5173
[[ports]]
localPort = 43169
externalPort = 5000

View File

@ -49,6 +49,7 @@ export default function Sites() {
defaultValues: {
name: "",
address: "",
customerId: undefined,
shiftType: "fixed_post",
minGuards: 1,
requiresArmed: false,
@ -67,6 +68,7 @@ export default function Sites() {
defaultValues: {
name: "",
address: "",
customerId: undefined,
shiftType: "fixed_post",
minGuards: 1,
requiresArmed: false,
@ -139,6 +141,7 @@ export default function Sites() {
editForm.reset({
name: site.name,
address: site.address,
customerId: site.customerId ?? undefined,
location: site.location,
shiftType: site.shiftType,
minGuards: site.minGuards,
@ -237,15 +240,14 @@ export default function Sites() {
name="customerId"
render={({ field }) => (
<FormItem>
<FormLabel>Cliente</FormLabel>
<Select onValueChange={field.onChange} value={field.value || undefined}>
<FormLabel>Cliente (opzionale)</FormLabel>
<Select onValueChange={(value) => field.onChange(value || undefined)} value={field.value ?? undefined}>
<FormControl>
<SelectTrigger data-testid="select-customer">
<SelectValue placeholder="Seleziona cliente (opzionale)" />
<SelectValue placeholder="Nessun cliente" />
</SelectTrigger>
</FormControl>
<SelectContent>
<SelectItem value="">Nessun cliente</SelectItem>
{customers?.map((customer) => (
<SelectItem key={customer.id} value={customer.id}>
{customer.name}
@ -524,15 +526,14 @@ export default function Sites() {
name="customerId"
render={({ field }) => (
<FormItem>
<FormLabel>Cliente</FormLabel>
<Select onValueChange={field.onChange} value={field.value || undefined}>
<FormLabel>Cliente (opzionale)</FormLabel>
<Select onValueChange={(value) => field.onChange(value || undefined)} value={field.value ?? undefined}>
<FormControl>
<SelectTrigger data-testid="select-edit-customer">
<SelectValue placeholder="Seleziona cliente (opzionale)" />
<SelectValue placeholder="Nessun cliente" />
</SelectTrigger>
</FormControl>
<SelectContent>
<SelectItem value="">Nessun cliente</SelectItem>
{customers?.map((customer) => (
<SelectItem key={customer.id} value={customer.id}>
{customer.name}