<template>
  <meta-head title="Написать нам"></meta-head>

  <div class="xl:container xl:mx-auto px-2 md:px-3">
    <div class="mt-16 shadow-classic rounded-md bg-indigo-200">
      <div class="flex flex-col md:grid grid-cols-6 lg:grid-cols-5">
        <settings-menu />

        <div class="col-span-4">
          <div class="mx-4 2xl:mx-28 my-8">
            <form class="flex flex-col gap-4" @submit.prevent="submit">
              <div class="flex flex-col">
                <text-input v-model="form.title" :error="form.errors.title"
                            type="text" class="focus:ring-4 focus:ring-offset-1 focus:ring-orange focus:ring-opacity-20 focus:ring-offset-orange focus:border-transparent text-gray border border-indigo-300 bg-indigo-200 rounded-md placeholder-gray-light"
                            label="Тема"
                />
              </div>
              <div class="flex flex-col">
                <textarea-input v-model="form.body" :error="form.errors.body"
                                class="focus:ring-4 focus:ring-offset-1 focus:ring-orange focus:ring-opacity-20 focus:ring-offset-orange focus:border-transparent text-gray border border-indigo-300 bg-indigo-200 rounded-md" cols="30"
                                rows="4" label="Сообщение"
                />
              </div>
              <div>
                <loading-button :loading="form.processing" class="my-1 transition shadow-none hover:shadow-classic2 inline-flex items-center px-8 py-3 justify-center  text-base rounded-md text-white bg-orange focus:outline-none"
                                type="submit"
                >
                  Отправить
                </loading-button>
              </div>
            </form>

            <!-- <div class="mt-10">
              <div class="flex flex-col text-white">
                <a href="/company/about" class="hover:underline">О компании</a>
                <a href="/company/offer" class="hover:underline">Оферта</a>
                <a href="/company/terms-payment" class="hover:underline">Условия оплаты</a>
                <a href="/company/terms-service" class="hover:underline">Условия предоставления услуг</a>
                <a href="/company/cookies" class="hover:underline">Cookies</a>
                <a href="/company/privacy-policy" class="hover:underline">Privacy Policy</a>
              </div>
            </div> -->
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import TextInput from '@/Shared/Form/TextInput.vue'
import { Inertia } from '@inertiajs/inertia'
import { useForm, usePage } from '@inertiajs/inertia-vue3'
import LoadingButton from '@/Shared/Form/LoadingButton.vue'
import Layout from '@/Shared/Layout.vue'
import SettingsMenu from '@/Shared/LayoutParts/SettingsMenu.vue'
import MetaHead from '@/Shared/MetaHead.vue'
import TextareaInput from '@/Shared/Form/TextareaInput.vue'

export default {
    components: {
        MetaHead,
        SettingsMenu,
        LoadingButton,
        TextInput,
        TextareaInput,
    },
    layout: Layout,
    props: {

    },
    setup(props) {
        const form = useForm({
            title: null,
            body: null,
        })

        const submit = () => {
            form.post(route('common.write-to-us'), {
                onSuccess: () => form.reset(),
            })
        }

        return {
            form,
            submit
        }
    }
}
</script>
