Skip to content
README.md 1.6 KiB
Newer Older
jmagm4@umsystem.edu's avatar
jmagm4@umsystem.edu committed

# Day List Component
jmagm4@umsystem.edu's avatar
jmagm4@umsystem.edu committed

This component is designed to fetch and display a list of days from a RESTful API. It includes functionality for filtering the data based on user input.
jmagm4@umsystem.edu's avatar
jmagm4@umsystem.edu committed

## Technologies Used
jmagm4@umsystem.edu's avatar
jmagm4@umsystem.edu committed

- React.js
- Axios (for API calls)
jmagm4@umsystem.edu's avatar
jmagm4@umsystem.edu committed

## How to Use
jmagm4@umsystem.edu's avatar
jmagm4@umsystem.edu committed

1. Install dependencies:
   ```bash
   npm install axios
   ```
jmagm4@umsystem.edu's avatar
jmagm4@umsystem.edu committed

2. Import the DayList component into your React application:
   ```javascript
   import React, { useState, useEffect } from 'react';
   import axios from 'axios';
   ```
jmagm4@umsystem.edu's avatar
jmagm4@umsystem.edu committed

3. Use the DayList component in your application where needed:
   ```javascript
   <DayList />
   ```
jmagm4@umsystem.edu's avatar
jmagm4@umsystem.edu committed

4. Customize the API endpoint:
   - Update the URL in the `fetchData` function to match your API endpoint.
   - Adjust the query parameters based on your API requirements.
jmagm4@umsystem.edu's avatar
jmagm4@umsystem.edu committed

5. Filter Data:
   - Enter filter criteria in the input fields provided (field, op, value).
   - Click the "Clear Filters" button to reset the filters.
jmagm4@umsystem.edu's avatar
jmagm4@umsystem.edu committed

## Component Overview
jmagm4@umsystem.edu's avatar
jmagm4@umsystem.edu committed

- **States:**
  - `days`: Stores the fetched day data.
  - `filter`: Stores the filter criteria for data fetching.
  - `error`: Stores error messages, if any.
jmagm4@umsystem.edu's avatar
jmagm4@umsystem.edu committed

- **Effects:**
  - Fetches data from the API when the filter criteria changes.
  - Clears error messages on successful data fetch.
jmagm4@umsystem.edu's avatar
jmagm4@umsystem.edu committed

- **Functions:**
  - `fetchData`: Fetches data from the API based on filter criteria.
  - `handleFilterChange`: Updates the filter state based on user input.
jmagm4@umsystem.edu's avatar
jmagm4@umsystem.edu committed

- **Rendering:**
  - Displays filter input fields and a clear filters button.
  - Displays a list of days with their date, max temperature, min temperature, and precipitation.
jmagm4@umsystem.edu's avatar
jmagm4@umsystem.edu committed

## Error Handling
jmagm4@umsystem.edu's avatar
jmagm4@umsystem.edu committed

- Displays error messages if data fetching fails.
jmagm4@umsystem.edu's avatar
jmagm4@umsystem.edu committed