Git Product home page Git Product logo

phase-2-flatapets-lab's Introduction

Flatapets Lab

There is a new website called Flatapets dedicated to helping pets find new homes, but they need our help! Our job is to implement a React application to help organize their data!

Setup

  1. Run npm install in your terminal.
  2. Run npm run server. This will run your backend on port 4000.
  3. In a new terminal, run npm start. This will run your React app on port 5000.

In our React application, the data about the Pets is in the db.json file. This file will mimic an API that follows RESTful conventions.

Make sure to open http://localhost:4000/pets in the browser to verify that your backend is working before you proceed!

What You Already Have

The App component holds two children: Header and PetPage. The PetPage component holds three children: NewPetForm, Search and PetList. These components have some starter code in them already. The PetList component will render all Pet components.

All of the code to style the page has been written for you, meaning that you should be adding to the code rather than editing it; however, if your finished product has some styling issues, don't worry too much about it.

Core Deliverables

As a user, I should be able to:

  • See list of pets on the page, using the Pet component. The Pet component should display the pet's image, name, and conditionally render whether it is from a pet shop or from the wild. If the pet is from a pet shop, the component should say "From a Pet Shop", otherwise it should say "From the wild".
  • Click on the image of the pet in the Pet component and see the animal_type in place of the name. If I click on the image again, the animal_type should again be replaced with the name. If I click on another pet's image, it toggles that pet's name independent of any other pet's.
  • Submit the form in the NewPetForm component to add a new pet. This should add the new pet in your React app by updating the appropriate state and should additionally persist the added pet to the JSON Server database.
  • Type in the Search component and see the list of pets whose name or animal_type match the text in the search bar. If there's no text in the search bar, all the pets should be rendered.

Endpoints for Core Deliverables

GET /pets

Example Response:

[
  {
    "id": 1,
    "name": "Fido",
    "fromPetShop": true,
    "image": "./images/dog.jpeg",
    "animal_type": "Dog"
  },
  {
    "id": 2,
    "name": "Kitty",
    "fromPetShop": true,
    "image": "./images/cat.png",
    "animal_type": "Cat"
  }
]

POST /pets

Required Headers:

{
  "Content-Type": "application/json"
}

Request Object:

{
  "name": "string",
  "fromPetShop": boolean,
  "image": "string",
  "animal_type": "string"
}

Example Response:

{
  "id": 7,
  "name": "Goldie",
  "fromPetShop": true,
  "image": "./images/fish.jpeg",
  "animal_type": "Fish"
}

Advanced Deliverables

If you have the extra time, these Advanced Deliverables are a great way to stretch your skills.

You may have to add additional elements for these features. Feel free to style them however you see fit!

As a user:

  1. I can update the name of a pet and still see the updated name after refreshing the page.
  2. I can delete a pet when clicking the "Adopt Pet" button and it is still gone when I refresh the page.

Endpoints for Advanced Deliverables

PATCH /pets/:id

Required Headers:

{
  "Content-Type": "application/json"
}

Request Object:

{
  "name": "string"
}

Example Response:

{
  "id": 1,
  "name": "Frank",
  "fromPetShop": true,
  "image": "./images/dog.jpeg",
  "animal_type": "Dog"
}

DELETE /pets/:id

Example Response:

{}

phase-2-flatapets-lab's People

Contributors

rikkux491 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.