Skip to content

SinisaJO/Invoice-creator-vanilla-JS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Welcome to Invoice Creator APP 👋

Screenshoot

Inovice-Generator

    Requirements:

  1. Array to hold services requested
  2. Buttons to add service to array
  3. Place to display data from array - updated every time the array changes
  4. Once for same service
  5. Total costs stays updated
  6. Button to remove item from array
  7. Button to submit/send invoice

    Key learnings:

    1. Array methods - forEach(), find(), findIndex()
    services.forEach(service => {
      const {id, name, price} = service
      servicesBox.innerHTML += 
      `
          <button class="services-btn" id=${id}>${name}: $${price}</button>
      `
    
      const item = services.find(service => service.id === target.id)
    
      const item = services.findIndex(service => service.id === target.id)
    
    1. Event Object
    box.addEventListener("click", (e) => {
      const target = e.target
      if(target.tagName === "BUTTON") {
          const item = servicesCart.find(service => service.id === target.id)
          servicesCart.splice(item, 1)
          renderService(servicesCart)
      }
    })
    
    1. Localstorage
      localStorage.setItem("services", JSON.stringify(servicesCart))
    
      servicesCart = (JSON.parse(localStorage.getItem("services")))
    

    Author: Sinisa Jovanovic(https://github.com/SinisaJO)