GithubHelp home page GithubHelp logo

hotelpirates's Introduction

Hotel finder App ☠️

alt text

Overview

Build a small web app that lists hotels from api call and filters based on stars or price. Suggest back end flight data structure for.

Context

  • HTML
  • CSS
  • JavaScript

1. Task

We need for our next trip with the whole ☠️-crew a hotel and what we get from our backend-🐵 was only this.

Present us the hotels that we can choose the right one for our next trip. To make it easier for us to find the right hotel, we want to have a filter for hotel ⭐ (stars) and hotel 💰 (price).

To get to our hotel, we also need a flight.

Proposed Solution

API call Async call to API. coherse data into JSON. Catch no data and call API again. return the API results and populate the DOM.

Flight API Solution For the flight finder backend API I have written a small function to send a get request call similar to the provided fake hotels api. In a small modal a user enters flight details. The desitantion city is bound to the selected hotel. This function returns an object with four keys: flights = { departure: "city", destination: "cityStr", departureDate: "xx.xx.xx", returnDate: "xx.xx.xx" }

The url for a heroku backend would respond to : "http://fake-hotel-api.herokuapp.com/api/flights/departure/desitnation/departureDate/returnDate

The backend would scrap for results returning many results. These results could be filtered and handled in the fronted by price, length, layover sorting.

Challenges

sort data API data. I mapped all of the API results to populate the DOM inside the callback as Im
handling the API async. I am not satisfied with how messy my drawRes() became. There are two promise
callbacks. I honeslty wish I was writing this in React. Since I am using JS to handle the DOM
React is much faster, safer to handle bugs etc.

I am not satisfied with hotels review callback. This became messy passing the hotel id to an ascync
function and writing DOM elements in a nested callback! 

I found writing tests simulating the DOM with JEST & puppeteer to be difficult to test for. Often
I was testing if the DOM element existed rather then the data inside of it. I would restructure my
functions to seperate DOM handling and data handling to do more unit testing before integrating them.

TODOS

  • write Modular CSS and JS components. Import these for clarity of code.
  • Clean up Async API promises so there is not nested callbacks populating DOM. This is too messy solution. Im not satisfied.
  • Toggle review comments hide/display
  • write catches for the filter sorting data
  • handle flight details into a purchase portal
  • handle flight details API response
  • find flight modal only works in dev.
  • build importing style and JS resources errors

Instructions

To start, you must only install the dependencies.

open ./build/index.html

***** for find flight modal you must run the dev code.

open ./src/index.html

hotelpirates's People

Contributors

colinrosati avatar juniordev4life avatar dependabot[bot] 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.