<script setup>
import { ref } from 'vue'
import { useAuthStore } from '@/stores/authStore.js'

const store = useAuthStore()

const email = ref('')
const password = ref('')

const onSignIn = () => {
  store.login(email.value, password.value)
}

const onSignUp = () => {
  console.log('Sign up placeholder')
}
</script>

<template>
  <n-card class="my-card">
    <n-tabs
      class="card-tabs"
      default-value="signin"
      size="large"
      animated
      pane-wrapper-style="margin: 0 -4px"
      pane-style="padding-left: 4px; padding-right: 4px; box-sizing: border-box;"
    >
      <n-tab-pane name="signin" tab="Sign in">
        <n-form @submit.prevent="onSignIn">
          <n-form-item-row label="Email">
            <n-input v-model:value="email"/>
          </n-form-item-row>
          <n-form-item-row label="Password">
            <n-input v-model:value="password" type="password" show-password-on="click" />
          </n-form-item-row>
        </n-form>
        <n-button type="primary" block secondary strong @click="onSignIn"> Sign In</n-button>
      </n-tab-pane>

      <n-tab-pane name="signup" tab="Sign up">
        <n-form @submit.prevent="onSignUp" @keydown.enter.prevent="onSignUp">
          <n-form-item-row label="Email">
            <n-input />
          </n-form-item-row>
          <n-form-item-row label="Password">
            <n-input type="password" show-password-on="click" />
          </n-form-item-row>
          <n-form-item-row label="Reenter Password">
            <n-input type="password" show-password-on="click" />
          </n-form-item-row>
        </n-form>
        <n-button type="primary" block secondary strong @click="onSignUp">Sign up</n-button>
      </n-tab-pane>
    </n-tabs>
  </n-card>
</template>

<style scoped>
.card-tabs .n-tabs-nav--bar-type {
  padding-left: 4px;
}

.my-card {
  max-width: 500px;
  width: 90%;
}
</style>
