Documentation Index
Fetch the complete documentation index at: https://mintlify.com/gcsconsultores/gcs-website/llms.txt
Use this file to discover all available pages before exploring further.
submitLead() is a Next.js Server Action defined in app/actions/lead-actions.ts that validates and processes contact form submissions for GCS’s free Orientación Estratégica offering. It runs exclusively on the server, enforces the same Zod schema used by the browser form (defence-in-depth), and delegates CRM delivery to the sendToCrm adapter — keeping the rest of the application decoupled from any particular CRM provider.
Return type
Every call tosubmitLead() resolves to a LeadResult discriminated union. The client reads the ok flag to decide whether to show a success message or inline field errors.
fieldErrors is a flat object mapping each invalid field name to a Spanish-language error string ready to display next to the form control.
Function signature
unknown deliberately — the function never trusts the caller. All type safety is established by leadSchema.safeParse(raw) at runtime.
Processing flow
Validate input with leadSchema.safeParse
The raw value is parsed against
leadSchema (defined in lib/schemas.ts). Because the schema is shared between the client form and this server action, any mutation of the payload in transit is caught immediately.Return field errors if validation fails
If
parsed.success is false, the action iterates over parsed.error.issues to build a fieldErrors map and returns early without touching the CRM.Call sendToCrm with the validated lead
The validated
parsed.data (typed as LeadInput) is passed to sendToCrm(). This is the single integration point — all CRM-specific logic lives inside that function.Return ok: false if the CRM call throws
If
sendToCrm rejects (network error, non-2xx response, etc.) the error is caught and a user-facing Spanish message is returned without exposing internal details.leadSchema field reference
leadSchema is a Zod object defined in lib/schemas.ts. All messages are in Spanish.
Full name of the contact. Minimum 2 characters, maximum 80. Whitespace is trimmed before validation.
Name of the contact’s organisation. Minimum 2 characters, maximum 120. Trimmed before validation.
Valid email address. Validated with Zod’s
.email() check after trimming. Minimum length 1 (to produce the correct “required” error rather than an “invalid email” error on an empty field).Colombian or international phone number. Must match
/^[+]?[\d\s().-]{7,18}$/ — between 7 and 18 characters, allowing digits, spaces, parentheses, dashes, dots, and an optional leading +. Trimmed before validation.Area of interest selected from the dropdown. Must be one of the following values:
| Value | Label displayed in the UI |
|---|---|
crecimiento | Crecimiento Estratégico |
riesgo | Riesgo & Cumplimiento |
estrategia | Estrategia Ejecutiva |
innovacion | Innovación & Tecnología |
talento | Talento & Capacitación |
calidad | Calidad & Mejoramiento |
otro | Otro / No estoy seguro |
Optional free-text message from the contact. Maximum 1000 characters. An empty string is also accepted (coerced to
undefined by .or(z.literal(''))).Must be the boolean literal
true. This field cannot be pre-checked or defaulted — it requires an explicit user action.interestOptions mapping
TheinterestOptions array exported from lib/schemas.ts is the single source of truth for both the <select> dropdown in the form and the interest enum in the schema. Add or remove entries here to keep both in sync.
sendToCrm adapter
sendToCrm is a private async function in the same file. It follows the adapter pattern — all CRM-specific details are confined here so that submitLead and the rest of the application never depend on a concrete provider.
Required environment variables
The full URL of the CRM’s lead or contact creation endpoint. Leave unset during local development — leads will be logged to the server console instead.
API key or Bearer token for the CRM. Sent as
Authorization: Bearer <CRM_API_KEY> on every request.When
CRM_API_URL is not set (or CRM_API_KEY is missing), sendToCrm logs the lead fields to the server console and returns without error. No lead data is lost — you can collect submissions safely before the CRM is connected.Fetch body structure
The function sends aPOST request with the following JSON body. Remap the property names inside sendToCrm to match the field names required by your CRM provider.