Maison> interface Web> js tutoriel> le corps du texte

React Coding Challenge -City/Product Sales Browser using React

WBOY
Libérer: 2024-08-31 13:00:39
original
608 Les gens l'ont consulté

React Coding Challenge -City/Product Sales Browser using React

Assignment: City/Product Sales Browser using React

Company Name:Cytel

Result - Selected for Next Round

Objective

Develop a simple React application that displays city and product sales information with routing and dynamic data fetching. The app should allow users to navigate between different pages, and it should track how many cities and products have been visited. The data should be refreshed upon user request.

Requirements

  1. Application Overview:

    • Display two counters at the top of the page:
      • Cities Visited:0
      • Products Visited:0
    • Provide aRefreshbutton that resets the counters and reloads the data.
  2. Home Page:

    • URL: /
    • Display two lists:
      • List of city names fetched from the API.
      • List of product names fetched from the API.
    • Initialize theCities VisitedandProducts Visitedcounters to 0 when the app starts.
  3. API Endpoints:

    • To fetch all cities: https://assessments.reliscore.com/api/cities
    • To fetch all products: https://assessments.reliscore.com/api/sales/products
  4. City Details Page:

    • URL: /api/sales/ /
    • Clicking on a city name from the home page navigates to a city-specific page.
    • Fetch and display a list of product names and the quantity sold in the selected city using the following endpoint: https://assessments.reliscore.com/api/sales/ / (Replace with the actual city name.)
    • Increment theCities Visitedcounter by 1 whenever a city page is visited.
  5. Product Details Page:

    • URL: /sales/product/ /
    • Clicking on a product name from any page navigates to a product-specific page.
    • Fetch and display a list of all city names where the product has been sold and the amount sold in each city using the following endpoint: https://assessments.reliscore.com/api/sales/product/ / (Replace with the actual product name.)
    • Increment theProducts Visitedcounter by 1 whenever a product page is visited.
  6. Refresh Button:

    • Clicking theRefreshbutton on any page should:
      • Reload all data from the respective APIs.
      • Reset theCities VisitedandProducts Visitedcounters to 0.
  7. Single Page Application (SPA) with Routing:

    • Implement the application as a single-page application (SPA) using React.
    • Utilize routing to handle navigation between different pages (e.g., city details, product details) while ensuring that the browser’s back and forward buttons function correctly.
    • Ensure that users can navigate directly to any page using the appropriate URL.
  8. Evaluation Criteria:

    • Appropriate use of reusable React components.
    • Efficient use of React features such as hooks and state management.
    • Proper implementation of routing to simulate different pages.
    • Adherence to best practices in code structure and modularity.

Deliverables

  • A fully functional React application meeting the requirements outlined above.
  • The project should be structured, well-commented, and easy to navigate.
  • Ensure that the application handles edge cases, such as missing data or incorrect URLs.

Notes

  • Test your application thoroughly to ensure all features work as expected.
  • Make sure the app is responsive and works well on different screen sizes.

API Responses Overview

  1. Cities API Response:

    • Endpoint: https://assessments.reliscore.com/api/cities
    • Response Format:
    { "status": "success", "data": [ "Bombay", "Bangalore", "Pune", "Kolkata", "Chennai", "New Delhi" ] }
    Copier après la connexion

Description: This API returns a list of city names where sales data is available. The data array contains the names of these cities.

  1. Sales Data for a Specific City:

    • Endpoint: https://assessments.reliscore.com/api/sales/pune (Replace pune with any other city name as needed)
    • Response Format:
    { "status": "success", "data": { "product1": 137, "product2": 23, "product3": 77 } }
    Copier après la connexion
    Copier après la connexion
    Copier après la connexion

Description: This API returns sales data for a specific city. The data object contains key-value pairs where the key is the product name and the value is the number of items sold in that city.

  1. Products List API Response:

    • Endpoint: https://assessments.reliscore.com/api/sales/products
    • Response Format:
    { "status": "success", "data": { "product1": 137, "product2": 23, "product3": 77 } }
    Copier après la connexion
    Copier après la connexion
    Copier après la connexion

Description: This API returns a list of all products with their total sales figures. The data object contains key-value pairs where the key is the product name and the value is the total number of items sold across all cities.

  1. Product Detail API Response:

    • Endpoint: https://assessments.reliscore.com/api/sales/product/product1 (Replace product1 with any other product name as needed)
    • Response Format:
    { "status": "success", "data": { "product1": 137, "product2": 23, "product3": 77 } }
    Copier après la connexion
    Copier après la connexion
    Copier après la connexion

Description: This API returns the sales data for a specific product across different cities. The data object contains key-value pairs where the key is the city name and the value is the number of items sold for that product in that city.

Note:

Please ensure that you fully understand the requirements before starting the implementation. There’s a minor issue with the API response for the product/ endpoint, but it can be worked around with the provided data. Adding the API responses for reference above.

You are encouraged to implement the solution and make any necessary modifications to the APIs as needed to meet the requirements. If you need more details or are interested in similar assignments, you can refer to my E-Commerce Project.

Ce qui précède est le contenu détaillé de. pour plus d'informations, suivez d'autres articles connexes sur le site Web de PHP en chinois!

source:dev.to
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!