Advertisement
AngelKejov

Untitled

Nov 27th, 2022
619
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { getById } from '../api/data.js';
  2. import { html, render } from '../lib.js';
  3.  
  4. const detailsTemplate = (pet) => html `
  5.  
  6. <section id="detailsPage">
  7.             <div class="details">
  8.                 <div class="animalPic">
  9.                     <img src="">
  10.                 </div>
  11.                 <div>
  12.                     <div class="animalInfo">
  13.                          <h1>Name: ${pet.name}</h1>
  14.                          <h3>Breed: ${pet.breed}</h3>
  15.                          <h4>Age: ${pet.age}</h4>
  16.                          <h4>Weight: ${pet.weight}</h4>
  17.                          <h4 class="donation">Donation: 0$</h4>
  18.                     </div>
  19.                     <!-- if there is no registered user, do not display div-->
  20.                     <div class="actionBtn">
  21.                         <!-- Only for registered user and creator of the pets-->
  22.                         <a href="#" class="edit">Edit</a>
  23.                         <a href="#" class="remove">Delete</a>
  24.                         <!--(Bonus Part) Only for no creator and user-->
  25.                         <a href="#" class="donate">Donate</a>
  26.                     </div>
  27.                 </div>
  28.             </div>
  29.         </section>
  30.  
  31. `;
  32.  
  33. export async function showDetails(ctx) {
  34.     const id = ctx.params.id;
  35.     const pet = await getById(id);
  36.  
  37.     console.log(pet)
  38.     ctx.render(detailsTemplate());
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement