Overview
ThePago component is the core building block for displaying individual payment items in Pagosapp. It provides a comprehensive interface for managing payment status, due dates, and payment details through an interactive list item.
Features
- Visual Status Indicators: Color-coded styling based on payment status and due date proximity
- Payment Toggle: Quick switch to mark payments as paid/unpaid
- Date Management: Integrated date picker for setting due dates
- Payment Details Modal: Full payment information accessible via click
- Smart State Management: Leverages the
usePagohook for state and localStorage persistence
Location
Props
The payment object containing payment informationProperties:
nombre(string): The payment name/titlemensual(boolean): Whether this is a monthly recurring paymentmeses(array): Specific months when this payment applies
The month identifier for this payment instance (e.g., “Enero”, “Febrero”)
Status Styling
The component applies dynamic CSS classes based on payment status:| Class | Condition | Meaning |
|---|---|---|
item-green | checked === true | Payment completed |
item-gray | No due date OR dateDifference > 3 | Not urgent or no date set |
item-red | dateDifference < 0 | Overdue payment |
item-orange | dateDifference <= 3 | Due soon (within 3 days) |
The
dateDifference value is calculated by the usePago hook and represents days until the due date.Usage Example
Component Structure
The component renders a list item (<li>) with the following child elements:
- Payment Name: Displays
pago.nombre - Switch Element: Toggle for marking payment as paid/unpaid
- Date Picker Button: Pencil icon button to open date selector
- Date Picker: Conditional rendering when
openDatePickeris true - Start Date Display: Shows the current due date
- Payment Modal: Opens on item click for detailed information
Hook Integration
The component uses theusePago hook which provides:
Event Handling
Item Click
Clicking the list item opens the payment modal:Date Picker Toggle
The pencil icon button toggles the date picker:Dependencies
usePagohook - State management and persistenceSwitchElement- Payment status toggleDatePickerElement- Due date selectionStartDateElement- Due date displayPaymentModal- Detailed payment information@chakra-ui/react- Modal disclosure management@fortawesome/react-fontawesome- Edit icon
Styling
The component imports../styles/Pago.css for styling. The main visual feedback comes from the dynamic itemStyle class applied to the <li> element.
Related Components
- Mes Component - Container that renders multiple Pago components
- SwitchElement - Payment toggle control
- DatePickerElement - Due date selector
Source Code Reference
Key implementation atsrc/components/Pago.jsx:13-70
Status styling logic at src/components/Pago.jsx:16-25