From f18e85e79ae2a3ab0e8ce6725dd740853f869c16 Mon Sep 17 00:00:00 2001 From: marco370 <48531002-marco370@users.noreply.replit.com> Date: Thu, 23 Oct 2025 09:16:27 +0000 Subject: [PATCH] Add customer selection to site creation and editing forms Update the `sites.tsx` page to fetch and display customer data, enabling users to associate sites with specific customers during creation and editing. This involves adding a new `Select` component for customer selection in both the site creation form and the edit site form, and updating the `InsertSite` schema to include `customerId`. 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/1nTItRR --- client/src/pages/sites.tsx | 58 +++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/client/src/pages/sites.tsx b/client/src/pages/sites.tsx index f4e4178..1cd0fa2 100644 --- a/client/src/pages/sites.tsx +++ b/client/src/pages/sites.tsx @@ -1,6 +1,6 @@ import { useState } from "react"; import { useQuery, useMutation } from "@tanstack/react-query"; -import { Site, InsertSite } from "@shared/schema"; +import { Site, InsertSite, Customer } from "@shared/schema"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog"; @@ -40,6 +40,10 @@ export default function Sites() { queryKey: ["/api/sites"], }); + const { data: customers } = useQuery({ + queryKey: ["/api/customers"], + }); + const form = useForm({ resolver: zodResolver(insertSiteSchema), defaultValues: { @@ -228,6 +232,32 @@ export default function Sites() { )} /> + ( + + Cliente + + + + )} + /> + + ( + + Cliente + + + + )} + /> +