<script setup lang="ts">
import { ref } from 'vue';
import { Form } from 'vee-validate';

/*Social icons*/
import google from '@/assets/images/svgs/google-icon.svg';
import facebook from '@/assets/images/svgs/facebook-icon.svg';

const checkbox = ref(false);
const valid = ref(false);
const show1 = ref(false);
const password = ref('admin123');
const username = ref('info@wrappixel.com');
const passwordRules = ref([
    (v: string) => !!v || 'Password is required',
    (v: string) => (v && v.length <= 10) || 'Password must be less than 10 characters'
]);
const emailRules = ref([(v: string) => !!v || 'E-mail is required', (v: string) => /.+@.+\..+/.test(v) || 'E-mail must be valid']);
const { signIn, getProviders } = useAuth()
const providers = await getProviders()
const login = () => {
    console.log(providers)
}
</script>

<template>
    <!-- <v-row class="d-flex mb-3">
        <v-col cols="6" sm="6" class="pr-2">
            <v-btn variant="outlined" size="large"  class="border text-subtitle-1 hover-link-primary" block>
                <img :src="google" height="16" class="mr-2" alt="google" />
                Google
            </v-btn>
        </v-col>
        <v-col cols="6" sm="6" class="pl-2">
            <v-btn variant="outlined" size="large" class="border text-subtitle-1  hover-link-primary" block>
                <img :src="facebook" width="20" class="mr-1" alt="facebook" />
                Facebook
            </v-btn>
        </v-col>
    </v-row>
    <div class="d-flex align-center text-center mb-6">
        <div class="text-h6 w-100 px-5 font-weight-regular auth-divider position-relative">
            <span class="bg-surface px-5 py-3 position-relative">or sign in with</span>
        </div>  
    </div> -->
    <Form class="mt-5">
        <v-label class="font-weight-semibold pb-2 ">Username</v-label>
        <VTextField v-model="username" :rules="emailRules" class="mb-8" required hide-details="auto"></VTextField>
        <v-label class="font-weight-semibold pb-2 ">Password</v-label>
        <VTextField v-model="password" :rules="passwordRules" required hide-details="auto" type="password"
            class="pwdInput"></VTextField>
        <div class="d-flex flex-wrap align-center my-3 ml-n2">
            <v-checkbox class="pe-2" v-model="checkbox" :rules="[(v: any) => !!v || 'You must agree to continue!']"
                required hide-details color="primary">
                <template v-slot:label class="font-weight-medium">Remeber this Device</template>
            </v-checkbox>
            <div class="ml-sm-auto">
                <RouterLink to="" class="text-primary text-decoration-none font-weight-medium">Forgot Password ?
                </RouterLink>
            </div>
        </div>
        <!-- <v-btn size="large" color="primary" :disabled="valid" block flat @click="login">Sign In</v-btn> -->
        <v-btn v-for="provider in providers" :key="provider" @click="signIn(provider.id)" color="primary" size="large"
            block flat>Sign in with {{ provider.name }}</v-btn>
        <!-- <div class="mt-2">
            <v-alert color="error"></v-alert>
        </div> -->
    </Form>
</template>
