Components Overview
Pagosapp’s component library is built with React and Chakra UI, providing a modular and reusable architecture for managing payment tracking. The components are organized into categories based on their functionality.Component Categories
Pago Component
Individual payment item with status, toggle, and date picker
Mes Component
Month container that displays payments for a specific month
Date Picker
Interactive date selection component for setting due dates
Switch Element
Toggle switch for marking payments as paid or unpaid
Modal Components
Add New Item Modal
Modal dialog for creating new payment items
Payment Modal
Modal for viewing and editing payment details
Component Library
Core Components
These are the primary components that form the backbone of Pagosapp’s payment management interface.HomeHeader
Location:src/components/HomeHeader.jsx
The main header component displayed at the top of the application. It includes the application title and a floating action button for adding new payment items.
Features:
- Displays “PAGOS PENDIENTES” heading
- Add button to open the new item modal
- Responsive design with Chakra UI
Pago
Location:src/components/Pago.jsx
Represents an individual payment item with full interactive functionality.
Features:
- Visual status indicators (color-coded by payment status)
- Toggle switch for marking payments as complete
- Inline date picker for setting due dates
- Click to view detailed payment information
- Automatic color coding:
- Green: Payment completed
- Red: Payment overdue
- Orange: Payment due within 3 days
- Gray: Payment due in more than 3 days
Mes
Location:src/components/Mes.jsx
Renders all payments for a specific month, grouping related payment items together.
Features:
- Displays month name as heading
- Lists all payments associated with that month
- Filters payments based on monthly recurrence or specific month assignment
Form Elements
Interactive input components that handle user interactions and data entry.DatePickerElement
Location:src/components/DatePickerElement.jsx
A wrapper component for the React DatePicker library with custom styling.
Props:
startDate: Currently selected datehandleDateChange: Callback for date changesopenDatePicker: Boolean controlling visibilitysetOpenDatePicker: Function to toggle picker visibility
- Custom calendar styling
- Click-outside to close
- Positioned absolutely for overlay functionality
SwitchElement
Location:src/components/SwitchElement.jsx
A toggle switch component for marking payments as paid or unpaid.
Props:
checked: Current state of the switchhandleChange: Callback when switch is toggled
- Uses react-switch library
- Accessible with proper ARIA labels
- Visually hidden label for screen readers
StartDateElement
Location:src/components/StartDateElement.jsx
Displays the due date for unpaid payments in a localized format.
Props:
checked: Payment completion statusstartDate: Due date to display
- Conditionally renders based on payment status
- Formats date using locale settings
- Only shows for unchecked (unpaid) items
Modal Components
Dialog components that provide focused interfaces for specific tasks.AddNewItemModal
Location:src/components/modals/AddNewItemModal.jsx
Modal dialog for creating new payment items with month selection.
Features:
- Form validation for required fields
- Month selection with checkboxes
- Option for monthly recurring payments
- Disables individual month selection when “Mensual” is selected
- Error messaging for incomplete forms
- Integrates with ItemsContext for state management
- Payment name (text input)
- Month selection (multi-select with checkboxes)
- Monthly recurring option
PaymentModal
Location:src/components/modals/PaymentModal.jsx
Modal dialog displaying detailed payment information and allowing payment date entry.
Features:
- Shows payment name and due date
- Displays payment date for completed payments
- Inline date picker for setting actual payment date
- Read-only view for unpaid items
- Edit capability for paid items
- Payment name
- Due date (fecha de vencimiento)
- Payment date (fecha de pago) - only for completed payments
Component Dependencies
External Libraries
-
Chakra UI: Primary UI component library
- Modal, Button, Input, Checkbox, Menu components
- Layout components (Flex, Box)
- Icons (AddIcon)
- react-datepicker: Date selection functionality
- react-switch: Toggle switch component
- FontAwesome: Icon library (faPencilAlt for edit actions)
Internal Dependencies
- usePago Hook: Custom hook managing payment state and interactions
- ItemsContext: Context provider for global payment state management
Styling Approach
Components use a combination of:- Chakra UI props: For layout and theming
- Custom CSS files: Component-specific styles
DatePicker.cssHomeHeader.cssPago.css
Component Architecture
Best Practices
When working with Pagosapp components:- State Management: Use the ItemsContext for payment data
- Date Handling: Always use Date objects for consistency
- Accessibility: Maintain ARIA labels and keyboard navigation
- Styling: Follow Chakra UI theming conventions
- Prop Validation: Components use prop-types (disabled via eslint comments)
Next Steps
Pago Component
Deep dive into the payment item component
Mes Component
Learn about the month container component
Add New Item Modal
Understand how to create new payments
State Management
Learn about custom hooks like usePago and useItems