Advertisement
ErolKZ

Untitled

Apr 1st, 2022
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1.  
  2. import { getById } from '../api/data.js';
  3. import { html, until } from '../lib.js';
  4.  
  5. const detailsTemplate = (itemPromise) => html`
  6. <div class="row space-top">
  7. <div class="col-md-12">
  8. <h1>Furniture Details</h1>
  9. </div>
  10. </div>
  11. <div class="row space-top">
  12. <div class="col-md-4">
  13. ${until(itemPromise, html`<p>Loading &hellip;</p>`)}
  14. </div>
  15. </div>`;
  16.  
  17. const itemTemplate = (item) => html`
  18. <div class="card text-white bg-primary">
  19. <div class="card-body">
  20. <img src=${item.img} />
  21. </div>
  22. </div>
  23. </div>
  24. <div class="col-md-4">
  25. <p>Make: <span>${item.make}</span></p>
  26. <p>Model: <span>${item.model}</span></p>
  27. <p>Year: <span>${item.year}</span></p>
  28. <p>Description: <span>${item.description}</span></p>
  29. <p>Price: <span>${item.price}</span></p>
  30. <p>Material: <span>${item.material}</span></p>
  31. <div>
  32. <a href=${`/edit/${item._id}`} class="btn btn-info">Edit</a>
  33. <a href="javascript:void(0)" class="btn btn-red">Delete</a>
  34. </div>`;
  35.  
  36. export function detailsPage(ctx) {
  37. ctx.render(detailsTemplate(loadItem(ctx.params.id)));
  38. }
  39.  
  40. async function loadItem(id) {
  41. const item = await getById(id);
  42.  
  43. return itemTemplate(item);
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement