{% load static %}

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

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Osina</title>

    <link rel="stylesheet" type="text/css" href='{% static "dist/output.css" %}'>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
</head>

<body class="font-poppinsLight">
    <div id="hiddenContent">
        <h1 class="text-secondosiblue text-2xl font-semibold text-center">Add File</h1>

        <form>
            <div class="w-full flex justify-center items-center">
                <input type="text" placeholder="File Name"
                    class="w-full p-3 border border-gray-300 rounded-md bg-transparent outline-none mt-4" required>
            </div>

            <input type="date" id="date" name="date"
                class="w-full md:w-[300px] p-3 border border-gray-300 rounded-md bg-transparent outline-none mt-4"
                required>

            <div class="inbox-box border border-gray-300 py-1 px-3 w-full rounded-md mt-3">
                <div class="flex items-center justify-between">
                    <input required name="cv" type="file" id="actual-btn" accept=".pdf,.docx" hidden required />
                    <span id="file-name" class="text-gray-500 text-base focus:outline-none outline-none">Upload
                        Document(s)</span>
                    <label for="actual-btn"
                        class="bg-transparent text-gray-500 border border-white  py-2 h-14 cursor-pointer flex items-center"><i
                            class="fa fa-upload"></i></label>
                </div>
            </div>

            <div class="w-full flex justify-center items-center mt-6">
                <button type="submit"
                    class="w-fit bg-osiblue border border-osiblue rounded-md text-white text-xl px-5 py-1 hover:bg-white hover:text-osiblue duration-300"
                    id="addfileclose">Save</button>
            </div>
        </form>
    </div>

    <!-- <script>
        const successMessage = document.getElementById('successMessage');
        const addfileclose = document.getElementById('addfileclose');
        const form = document.querySelector('form');

        addfileclose.addEventListener("click", () => {
            if (form.checkValidity()) {
                successMessage.classList.remove('hidden');
            }
        });

        // Add an event listener to prevent the form submission when the Enter key is pressed
        form.addEventListener("submit", (e) => {
            e.preventDefault();
        });


    </script> -->

    <!-- WHEN THE USER CHOOSE A FILE THE NAME OF THE FILE WILL APPEAR IN THE SPAN -->
    <script>
        const fileInput = document.getElementById('actual-btn');
        const fileNameSpan = document.getElementById('file-name');

        fileInput.addEventListener('change', (event) => {
            const selectedFiles = event.target.files;
            if (selectedFiles.length > 0) {
                const fileNames = Array.from(selectedFiles).map(file => file.name).join(', ');
                fileNameSpan.textContent = fileNames;
            } else {
                fileNameSpan.textContent = 'Upload Documents (PDF, docx)';
            }
        });
    </script>

</body>

</html>