Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. import React, { useEffect, useState } from 'react'
  2. import { Link } from 'react-router-dom'
  3. import api from '../../services/api'
  4. import './style.css'
  5.  
  6.  
  7. export default function Dashboard() {
  8. const [Spots, setSpots] = useState([])
  9. useEffect(() => {
  10. async function LoadSpots() {
  11. const user_id = localStorage.getItem('user')
  12. const response = await api.get('/dashboard', {
  13. headers: { user_id }
  14. })
  15. setSpots(response.data)
  16. }
  17. LoadSpots()
  18. }, [])
  19.  
  20. return (
  21. <>
  22. <ul className="spotList">
  23. {Spots.map(Spot => (
  24. <li key={Spot._id}>
  25. <header style={{ backgroundImage: `url(${Spot.thumbnail_url})` }} />
  26. <strong>{Spot.company}</strong>
  27. <span>{Spot.price ? `$${Spot.price}/day` : 'FREE'}</span>
  28. </li>
  29. ))}
  30. </ul>
  31. <Link to="/new">
  32. Cadastrar novo spot
  33. </Link>
  34. </>
  35. )
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement