Overview
TheCreateIncidentForm component provides a complete incident creation interface for guest users. It includes form fields for title, description, priority selection, and area type with validation and submission handling.
Features
- Multi-field incident form (title, description, priority, area)
- Animated modal sheets for priority and area selection
- Real-time area loading from Supabase
- Guest session integration via SecureStore
- Form validation and error handling
- Loading states during submission
Usage
Props
This component does not accept any props. It manages all state internally.Types
Priority
- baja - Low priority (green badge)
- media - Medium priority (orange badge)
- alta - High priority (red badge)
Area
Internal State
The component manages the following internal state:The incident title entered by the user
Detailed description of the incident
Selected priority level (baja, media, or alta)
ID of the selected area/department
List of available areas loaded from the database
Indicates whether the form is submitting
Controls visibility of the priority selection modal
Controls visibility of the area selection modal
Methods
loadAreas()
Fetches available areas from the Supabaseareas table:
handleSubmit()
Validates and submits the incident form:Form Fields
Title Input
Single-line text input for the incident title:Priority Selector
Opens a modal sheet with three priority options:- Baja: Green badge (#10B981, background #ECFDF5)
- Media: Orange badge (#F59E0B, background #FEF3C7)
- Alta: Red badge (#EF4444, background #FEE2E2)
Area Selector
Opens a modal sheet with dynamically loaded areas:Description Input
Multi-line text area for detailed incident description:Dependencies
@/components/settings/ModalSheet- Animated bottom sheet for selections@/components/AppText- Styled text component@/src/services/supabase- Supabase client for data operationsexpo-secure-store- Secure storage for guest session datalucide-react-native- Icons (Check, ChevronDown)react-native- Core UI components and animations
Database Requirements
Tables
areasSecureStore Data
guest_sessionExample Integration
Error Handling
The component handles the following error cases:- Missing fields: Alert shown if any required field is empty
- No guest session: Error thrown if SecureStore lacks guest_session
- Area loading failure: Alert shown if areas cannot be fetched
- Submission failure: Alert shown with error message from Supabase
Accessibility
- Form dismisses keyboard when tapping outside inputs
- Touch targets meet minimum size requirements (44x44 points)
- Visual feedback on all interactive elements (opacity changes)
- Clear placeholder text for all inputs
- Loading state prevents double submissions