<script lang="ts">
import type { key_val } from '$lib/stores/ae_stores';

interface Props {
    event_obj: key_val;
    onsave?: (data: key_val) => void;
}

let { event_obj = $bindable(), onsave }: Props = $props();

function save() {
    if (onsave) onsave(event_obj);
}
</script>

<div class="space-y-4">
    <div>
        <label class="label">
            <span>Name</span>
            <input type="text" class="input" bind:value={event_obj.name} />
        </label>
    </div>
    <div>
        <label class="label">
            <span>Code</span>
            <input type="text" class="input" bind:value={event_obj.code} />
        </label>
    </div>
    <div>
        <label class="label">
            <input
                type="checkbox"
                class="checkbox"
                bind:checked={event_obj.conference} />
            <span>Conference</span>
        </label>
    </div>
    <div>
        <label class="label">
            <span>Summary</span>
            <textarea class="textarea" bind:value={event_obj.summary}
            ></textarea>
        </label>
    </div>
    <div>
        <label class="label">
            <span>Description</span>
            <textarea class="textarea" bind:value={event_obj.description}
            ></textarea>
        </label>
    </div>
    <div>
        <label class="label">
            <span>Timezone</span>
            <input type="text" class="input" bind:value={event_obj.timezone} />
        </label>
    </div>
    <div>
        <label class="label">
            <span>Start Datetime</span>
            <input
                type="datetime-local"
                class="input"
                bind:value={event_obj.start_datetime} />
        </label>
    </div>
    <div>
        <label class="label">
            <span>End Datetime</span>
            <input
                type="datetime-local"
                class="input"
                bind:value={event_obj.end_datetime} />
        </label>
    </div>
    <div>
        <label class="label">
            <span>Notes</span>
            <textarea class="textarea" bind:value={event_obj.notes}></textarea>
        </label>
    </div>
    <button type="button" class="btn preset-tonal-primary" onclick={save}
        >Save</button>
</div>
