Component Hierarchy
The application follows a clear component hierarchy:Root Component: App
Location:src/App.jsx
The App component manages the month navigation and renders the main layout:
- Displays 3 months at a time
- Default start: current month - 1
- Navigation buttons to slide through months
- Reset button to clear localStorage
- Consumes
useItemshook for payment data
HomeHeader Component
Location:src/components/HomeHeader.jsx
Provides the application header with add functionality:
Mes Component
Location:src/components/Mes.jsx
Renders a month container with filtered payment items:
- Filters payments by month
- Shows payments marked as
mensual(monthly) in all months - Shows payments with specific months in
mesesarray - Uses payment name as unique key
Pago Component
Location:src/components/Pago.jsx
The most complex component, representing an individual payment item:
- Green (
item-green): Payment is marked as paid - Gray (
item-gray): No due date set or due date > 3 days away - Red (
item-red): Overdue (past due date) - Orange (
item-orange): Due soon (0-3 days)
- Status toggle switch
- Due date picker with edit button
- Click to open detailed modal
- Visual status indication
Form Elements
SwitchElement
Wraps react-switch for payment status toggle:DatePickerElement
Wraps react-datepicker for due date selection:StartDateElement
Displays formatted due date or payment status:Modal Components
AddNewItemModal
Location:src/components/modals/AddNewItemModal.jsx
Modal for adding new payment items:
- Input validation
- Month selection (individual or “mensual” for all months)
- Integrates with ItemsContext via
addItem
PaymentModal
Location:src/components/modals/PaymentModal.jsx
Displays detailed payment information when clicking a payment item.
Component Best Practices
Prop Types
Components use prop-types for runtime validation:Event Handling
Careful event propagation management:Accessibility
Buttons includearia-label attributes:
Styling Approach
- CSS Modules: Component-specific styles in separate CSS files
- Chakra UI: Theme-based styling for modals and forms
- CSS Classes: Dynamic classes based on payment status