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:
parent
0f58cba38c
commit
37cbbfa768
8
.replit
8
.replit
@ -19,6 +19,10 @@ externalPort = 80
|
|||||||
localPort = 33035
|
localPort = 33035
|
||||||
externalPort = 3001
|
externalPort = 3001
|
||||||
|
|
||||||
|
[[ports]]
|
||||||
|
localPort = 37459
|
||||||
|
externalPort = 5173
|
||||||
|
|
||||||
[[ports]]
|
[[ports]]
|
||||||
localPort = 41295
|
localPort = 41295
|
||||||
externalPort = 6000
|
externalPort = 6000
|
||||||
@ -35,10 +39,6 @@ externalPort = 4200
|
|||||||
localPort = 42175
|
localPort = 42175
|
||||||
externalPort = 3002
|
externalPort = 3002
|
||||||
|
|
||||||
[[ports]]
|
|
||||||
localPort = 42423
|
|
||||||
externalPort = 5173
|
|
||||||
|
|
||||||
[[ports]]
|
[[ports]]
|
||||||
localPort = 43169
|
localPort = 43169
|
||||||
externalPort = 5000
|
externalPort = 5000
|
||||||
|
|||||||
@ -49,6 +49,7 @@ export default function Sites() {
|
|||||||
defaultValues: {
|
defaultValues: {
|
||||||
name: "",
|
name: "",
|
||||||
address: "",
|
address: "",
|
||||||
|
customerId: undefined,
|
||||||
shiftType: "fixed_post",
|
shiftType: "fixed_post",
|
||||||
minGuards: 1,
|
minGuards: 1,
|
||||||
requiresArmed: false,
|
requiresArmed: false,
|
||||||
@ -67,6 +68,7 @@ export default function Sites() {
|
|||||||
defaultValues: {
|
defaultValues: {
|
||||||
name: "",
|
name: "",
|
||||||
address: "",
|
address: "",
|
||||||
|
customerId: undefined,
|
||||||
shiftType: "fixed_post",
|
shiftType: "fixed_post",
|
||||||
minGuards: 1,
|
minGuards: 1,
|
||||||
requiresArmed: false,
|
requiresArmed: false,
|
||||||
@ -139,6 +141,7 @@ export default function Sites() {
|
|||||||
editForm.reset({
|
editForm.reset({
|
||||||
name: site.name,
|
name: site.name,
|
||||||
address: site.address,
|
address: site.address,
|
||||||
|
customerId: site.customerId ?? undefined,
|
||||||
location: site.location,
|
location: site.location,
|
||||||
shiftType: site.shiftType,
|
shiftType: site.shiftType,
|
||||||
minGuards: site.minGuards,
|
minGuards: site.minGuards,
|
||||||
@ -237,15 +240,14 @@ export default function Sites() {
|
|||||||
name="customerId"
|
name="customerId"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Cliente</FormLabel>
|
<FormLabel>Cliente (opzionale)</FormLabel>
|
||||||
<Select onValueChange={field.onChange} value={field.value || undefined}>
|
<Select onValueChange={(value) => field.onChange(value || undefined)} value={field.value ?? undefined}>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<SelectTrigger data-testid="select-customer">
|
<SelectTrigger data-testid="select-customer">
|
||||||
<SelectValue placeholder="Seleziona cliente (opzionale)" />
|
<SelectValue placeholder="Nessun cliente" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectItem value="">Nessun cliente</SelectItem>
|
|
||||||
{customers?.map((customer) => (
|
{customers?.map((customer) => (
|
||||||
<SelectItem key={customer.id} value={customer.id}>
|
<SelectItem key={customer.id} value={customer.id}>
|
||||||
{customer.name}
|
{customer.name}
|
||||||
@ -524,15 +526,14 @@ export default function Sites() {
|
|||||||
name="customerId"
|
name="customerId"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Cliente</FormLabel>
|
<FormLabel>Cliente (opzionale)</FormLabel>
|
||||||
<Select onValueChange={field.onChange} value={field.value || undefined}>
|
<Select onValueChange={(value) => field.onChange(value || undefined)} value={field.value ?? undefined}>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<SelectTrigger data-testid="select-edit-customer">
|
<SelectTrigger data-testid="select-edit-customer">
|
||||||
<SelectValue placeholder="Seleziona cliente (opzionale)" />
|
<SelectValue placeholder="Nessun cliente" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectItem value="">Nessun cliente</SelectItem>
|
|
||||||
{customers?.map((customer) => (
|
{customers?.map((customer) => (
|
||||||
<SelectItem key={customer.id} value={customer.id}>
|
<SelectItem key={customer.id} value={customer.id}>
|
||||||
{customer.name}
|
{customer.name}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user