<template>
    <div class="container-xxl flex-grow-1 container-p-y">
        <div class="card">
            <div class="pb-4 rounded-top">
                <div class="container py-12 px-xl-10 px-4" style="padding-bottom: 0px !important">
                    <h3 class="text-center mb-2 mt-4">글 작성</h3>
                </div>
            </div>

            <div class="col-xl-12">
                <div class="card-body">
                    <FormInput title="제목" name="title" :is-essential="true" @update:data="title = $event" />

                    <FormSelect title="카테고리" name="cate" :is-essential="true" :data="categoryList" @update:data="category = $event" />

                    <FormInput title="비밀번호" name="pw" type="password" :is-essential="true" @update:data="password = $event" />

                    <FormFile title="첨부파일" name="files" @update:data="attachFiles = $event" />

                    <div class="mb-4">
                        <label for="html5-tel-input" class="col-md-2 col-form-label">
                            내용
                            <span class="text-red">*</span>
                        </label>
                        <div class="col-md-12">
                            <!-- <TEditor @update:data="content = $event"/> -->
                            <QEditor/>
                        </div>
                    </div>

                    <div class="mb-4 d-flex justify-content-end">
                        <button type="button" class="btn btn-info right" @click="goList">목록</button>
                        <button type="button" class="btn btn-primary ms-1" @click="write">작성</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup>
import QEditor from '@c/editor/QEditor.vue';
import TEditor from '@c/editor/TEditor.vue';
import FormInput from '@c/input/FormInput.vue';
import FormSelect from '@c/input/FormSelect.vue';
import FormFile from '@c/input/FormFile.vue';
import { ref } from 'vue';
import router from '@/router';

const categoryList = ['자유', '익명', '공지사항'];

const title = ref('');
const password = ref('');
const category = ref('');
const content = ref('');
const attachFiles = ref(null);

const goList = () => {
    // 목록으로 이동 나중엔 페이지 정보 ,검색 정보도 붙여야됨
    router.push('/board');
};

const write = () => {
    console.log("작성");
};
</script>

<style>
.text-red {
    color: red;
    text-align: center;
}
</style>
