<template>
    <form class="add-project-form" @submit.prevent="submitProject">
        <h2>Ajouter un projet</h2>

        <div class="form-group">
            <label for="projectName">Nom du projet</label>
            <input
                id="projectName"
                v-model="project.projectName"
                type="text"
                required
            />
        </div>

        <div class="form-group">
            <label for="creationDate">Date de création</label>
            <input
                id="creationDate"
                v-model="project.creationDate"
                type="text"
                placeholder="JJ-MM-AAAA"
                required
            />
        </div>

        <div class="form-group">
            <label for="logo">Logo</label>
            <input
                id="logo"
                v-model="project.logo"
                type="text"
                placeholder="(à discuter)"
            />
        </div>

        <button type="submit">Ajouter</button>
    </form>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { postApi } from "@/services/api.ts";

const project = ref({
    projectName: "",
    creationDate: "",
    logo: "to be discussed not yet fixed",
});

function submitProject() {
    postApi("/admin/projects/add", project.value);
}
</script>

<style scoped>
h2 {
    font-size: 1.5rem;
    color: #333;
    margin-bottom: 1.2rem;
    border-bottom: 2px solid #ddd;
    padding-bottom: 0.5rem;
}

.add-project-form {
    max-width: 500px;
    margin: 0 auto;
    padding: 20px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

h2 {
    margin-bottom: 20px;
    font-size: 24px;
    color: #333;
}

.form-group {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}

label {
    font-weight: bold;
    margin-bottom: 5px;
}

input {
    padding: 8px;
    border-radius: 5px;
    border: 1px solid #ccc;
}

button {
    background-color: #4caf50;
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

button:hover {
    background-color: #45a049;
}
</style>
