Overview
The CV builder uses form components with client-side state management through React hooks and persistent storage using cookies. Forms handle various data types including text inputs, textareas, selects, and implement validation patterns for structured data like DNI and phone numbers.Core Form Pattern
All forms in the application follow a consistent pattern:- Client-side rendering with
"use client"directive - State management using React
useStatehooks - Persistent storage using
js-cookielibrary - Auto-initialization from cookies on component mount
- Manual save with user feedback
Personal Information Form
The primary form example fromsrc/app/perfil/info-personal/page.jsx demonstrates the complete pattern:
State Management
Cookie Initialization
Forms initialize from cookies on mount and create default structure if not present:Data Loading
ThecargarDatos function hydrates state from cookie data:
Save Functionality
Saving collects current state and persists to cookies with user feedback:Input Types
Text Input
Standard text inputs with controlled state:src/app/perfil/info-personal/page.jsx:120-128
Textarea
Multi-line text input for longer content:src/app/perfil/info-personal/page.jsx:99-105
Email Input
Email-specific input with browser validation:src/app/perfil/info-personal/page.jsx:176-184
Select Dropdown
Dropdown for predefined options:src/app/perfil/info-personal/page.jsx:222-238
Validation Patterns
DNI Pattern
DNI input with pattern validation and max length:\d{4}-\d{4}-\d{5} (4 digits, dash, 4 digits, dash, 5 digits)
Reference: src/app/perfil/info-personal/page.jsx:190-200
Phone Number Pattern
Phone input with pattern validation:[0-9]{4}-[0-9]{4} (4 digits, dash, 4 digits)
Reference: src/app/perfil/info-personal/page.jsx:206-216
Form Layout
Forms use a flex-based layout with responsive widths:src/app/perfil/info-personal/page.jsx:115-129
Save Button & Feedback
Save Button
Buttons usetype="button" to prevent form submission and trigger manual save:
src/app/perfil/info-personal/page.jsx:242-250
Success Message
Conditional success message with animation:src/app/perfil/info-personal/page.jsx:252-256
Cookie Storage Details
Storage Key Convention
Each form section uses a unique cookie key:InformacionPersonal- Personal information- Similar pattern for other sections (academic, experience, etc.)
Expiration
All cookies are set with 10-year expiration:Data Format
Data is stored as JSON-stringified objects:Integration Pattern
To create a new form section:- Define state variables for each field
- Create cookie key following naming convention
- Implement
useEffectfor initialization - Implement
cargarDatosfunction - Implement
nuevofunction to collect current state - Implement
guardarfunction with feedback - Build form UI with controlled inputs
- Add save button with success message
Best Practices
- Use
autoComplete="off"to prevent browser autofill interference - Provide clear placeholder text for expected format
- Use pattern validation for structured data (DNI, phone)
- Implement maxLength to prevent overflow
- Show success feedback with animations
- Use undefined checks when building data objects
- Set long cookie expiration for persistent data
- Structure data as flat JSON objects for easy serialization
