<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Url Shortener</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
    <link rel="stylesheet" href="/style.css">
</head>

<body class="bg-dark" >
    <div class="container">
        <div class="row">
            <div class="col-12 mt-2 m-auto">
                <h3 class="text-center text-info" >Fgr Link Shortener</h3>
            </div>
            <div class="col-8 m-auto mt-5">
                <form action="/shortlink" class="form" method="post">
                    <label for="url">Url</label>
                    <input type="text" class="form-control" id="url" name="fullLink" placeholder="Enter url">
                    <button type="submit" class="btn btn-outline-info">Shrink</button>
                </form>
            </div>
            <div class="col-8 m-auto ">
                <table class="table table-info table-striped">
                    <thead>
                      <tr>
                        <th scope="col" colspan="2">Original Url</th>
                        <th scope="col">Shorten Url</th>
                        <th scope="col">Click</th>
                      </tr>
                    </thead>
                    <tbody>
                        <% shortlinks.forEach(urls => { %>
                            <tr>
                                <td colspan="2">
                                    <a href="<%= urls.fullLink%>" target="_blank">
                                      <%= urls.fullLink%>
                                    </a>    
                                </td>
                                <td>
                                    <a href="<%= urls.shortLink%>" target="_blank">
                                        <%=urls.shortLink%>
                                    </a>
                                </td>
                                <td>
                                    <%= urls.clicks%>
                                </td>
                              </tr>
                         <%   }); %> 
                    </tbody>
                  </table>
            </div>
        </div>

    </div>

</body>

</html>
