<script setup>
  useHead({
    title: 'Create account | crbtc.org',
    meta: [
      { 
        name: 'description', 
        content: `` 
      },      
    ],
  })

  import { Field, Form } from 'vee-validate';

  function required(value) {
    return value ? true : 'This field is required';
  }

  const { createUser } = useDirectusAuth();

  const onSubmit = async (values) => {
    try {
      const newUser = await createUser({
        email: values.email,
        password: values.password
      });
    } catch (e) {}
  };

</script>

<template>
  <div class="register">
    <h3>Create your account</h3>
    <h4 class="policy">By continuing, you agree to our <NuxtLink href="terms">Terms of 
      use</NuxtLink> and <NuxtLink href="privacy">Privacy policy</NuxtLink>.</h4>

    <Form v-slot="{ errors }" @submit="onSubmit" >
      <div class="input">
        <label>Username</label>
        <Field name="username" placeholder="Choose a username" />
      </div>

      <div class="input">
        <label>Email</label>
        <Field name="email" placeholder="Enter your email" />
      </div>

      <div class="input">
        <label>Password</label>
        <Field name="password" placeholder="********" type="password" />
      </div>

      <button>Create account</button>
    </form>

    <p class="newbie">Already have an account? <NuxtLink href="/login">Sign in</NuxtLink></p>

  </div>
</template>