<template>
    <UiContainer v-if="!userStore.vCodeVerify" class="flex py-20 sm:py-14">
        <div class="hidden xl:block rounded-2xl min-w-[60%] h-[830px]" :style="{
            backgroundImage: `url('/api/public/file/${component.img[0]}_l.webp')`,
            backgroundSize: 'cover',
            backgroundPosition: 'center',
        }" />
        <div class="w-full sm:w-[80%] mx-auto my-auto xl:w-full xl:px-12 ">
            <div class="space-25-55">
                <div class="flex flex-wrap-reverse gap-y-4 justify-between">
                    <h2 class="h2-bold-bounded">{{ $t('login') }}</h2>
                    <button @click="menuStore.navigateToItem()"
                        class="h-[40px] sm:h-[43px] px-[10px] sm:px-[17px] border border-gray dark:border-button-disabled text-gray dark:text-button-disabled hover:bg-gray transition-all hover:text-white rounded-[8px] cursor-pointer">{{
                            $t('back_to_home') }}</button>
                </div>
                <div class="space-y-[15px]">
                    <p class="pl-6">{{ $t('email') }}</p>
                    <input v-model="userStore.email" :placeholder="$t('email')" type="text"
                        class="border-2 border-block placeholder:text-gray dark:placeholder:text-button-disabled text-bg-dark dark:text-bg-light rounded-lg px-6 h-[50px] sm:h-[67px] w-full focus:outline-none focus:ring-0 focus:border-2" />
                </div>
                <div class="space-y-[15px]">
                    <p class="pl-6">{{ $t('password') }}</p>
                    <input v-model="userStore.password" :placeholder="$t('placeholder_password')" type="text"
                        class="border-2 border-block placeholder:text-gray dark:placeholder:text-button-disabled text-bg-dark dark:text-bg-light rounded-lg px-6 h-[50px] sm:h-[67px] w-full focus:outline-none focus:ring-0 focus:border-2" />
                </div>
            </div>
            <p class="text-button hover:text-button-hover transition-all font-medium mt-[30px] cursor-pointer">{{
                $t('forgot_password_question')
            }}</p>
            <div class="py-[25px] sm:py-12 border-b border-gray flex justify-center w-full">
                <UiButtonArrow @click="userStore.logIn()" type="fill" :arrow="true">{{ $t('login') }}</UiButtonArrow>
            </div>
            <div class="mt-[25px] sm:mt-[30px] w-full flex justify-center gap-3">
                <p class="cursor-pointer hover:underline transition-all">{{
                    $t('no_account')
                }}</p>
                <p class="text-button cursor-pointer hover:text-button-hover">{{
                    $t('sign_up_now')
                }}</p>
            </div>
        </div>
    </UiContainer>

    <UiContainer v-if="!userStore.vCodeVerify" class="flex py-20 sm:py-14">
        <div class="hidden xl:block rounded-2xl min-w-[50%] h-[830px]" :style="{
            backgroundImage: `url('/api/public/file/${component.img[0]}_l.webp')`,
            backgroundSize: 'cover',
            backgroundPosition: 'center',
        }" />
        <div class="w-full sm:w-[80%] mx-auto my-auto xl:w-full xl:px-12 ">
            <div class="space-25-55">
                <div class="space-y-[15px]">
                    <div class="flex flex-wrap-reverse gap-y-4 justify-between">
                        <h2 class="h2-bold-bounded">{{ $t('verify_login') }}</h2>
                        <button @click="menuStore.navigateToItem()"
                            class="h-[40px] sm:h-[43px] px-[10px] sm:px-[17px] border border-gray dark:border-button-disabled text-gray dark:text-button-disabled hover:bg-gray transition-all hover:text-white rounded-[8px] cursor-pointer">{{
                                $t('back_to_home') }}</button>
                    </div>
                    <p>{{ $t('send_code') }} <span class="text-button font-semibold">test@ma-al.com</span> {{
                        $t('by_email') }}
                    </p>
                </div>
                <div class="space-y-[15px]">
                    <p class="pl-6">{{ $t('code') }}</p>
                    <input v-model="userStore.vCode" :placeholder="$t('code')" type="text"
                        class="border-2 border-block placeholder:text-gray dark:placeholder:text-button-disabled text-bg-dark dark:text-bg-light rounded-lg px-6 h-[50px] sm:h-[67px] w-full focus:outline-none focus:ring-0 focus:border-2" />
                </div>
            </div>
            <div class="py-[25px] sm:py-12 flex justify-center w-full">
                <UiButtonArrow @click="userStore.logIn()" type="fill" :arrow="true">{{ $t('confirm') }}</UiButtonArrow>
            </div>
        </div>
    </UiContainer>

    <!-- v-if="store.vCodeVerify" -->
    <div class="max-w-[590px] w-full">
        <h3 class="mb-1 text-2xl font-bold">
            {{ $t("FrontTranslations", "Verify your login") }}
        </h3>
        <span class="text-sm font-bold text-black">
            {{ $t("FrontTranslations", "We send code to") }} <span class="text-yellow"> {{ userStore.vEmail }}</span>
            {{ $t("FrontTranslations", "by") }} e-mail.</span>
        <!-- <form
            @submit.prevent="useUserStore().sendFormCode(`${vCode}`, vEmail, useRoute().query.to ? (useRoute().query.to as string) : undefined)">
            <div class="flex flex-col w-full gap-10 mt-6">
                <BaseInput v-model="vCode" :id="1"> {{ $t("FrontTranslations", "Code") }}</BaseInput>
            </div>
            <div class="flex flex-col">
                <div class="flex">
                    <BaseButtonLogin id="2" type="submit">
                        {{ $t("FrontTranslations", "Confirm") }}
                    </BaseButtonLogin>
                </div>
            </div>
        </form> -->
    </div>
</template>

<script lang="ts" setup>
defineProps<{
    component: {
        id: number
        name: string
        img: string[]
        component_name: string
        is_no_lang: boolean
        page_name: string
        front_section_lang: {
            data: {
            }
            id_front_section: number
            id_lang: number
        }[]
    }
}>();
const store = useStore()
const userStore = useUserStore()
const menuStore = useMenuStore()
</script>