<script setup lang="ts">
import { usePocketBase } from '@/pocketbase';
import { ref } from 'vue';
import { useRouter } from 'vue-router';

const pb = usePocketBase();
const router = useRouter();

const username = ref("");
const password = ref("");

const login = async () => {
    await pb.collection('users').authWithPassword(username.value, password.value);
    await router.push('/');
}
</script>

<template>
    <div class="p-4 mx-auto mt-10 grid justify-center gap-2 w-64">
        <div class="grid">
            Login:
            <input type="text" autocomplete="username" v-model="username" />
        </div>
        <div class="grid">
            Password:
            <input type="password" autocomplete="password" v-model="password" />
        </div>
        <button class="justify-self-end" @click="login" >Login</button>
    </div>
</template>
