<template>
  <q-card class="12">
    <q-card-section class="fit row justify-start content-center items-center">
      <div class="col-xs-12 col-sm-6 text-center text-h6">Neues Mitglied</div>
    </q-card-section>
    <q-card-section>
      <MainUserSettings :user="user" :new-user="true" @update:user="setUser" />
    </q-card-section>
  </q-card>
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue';
import MainUserSettings from './settings/MainUserSettings.vue';
import { useUserStore } from '@flaschengeist/api';

export default defineComponent({
  name: 'NewUser',
  components: { MainUserSettings },
  setup() {
    const userStore = useUserStore();
    const user = ref<FG.User>({
      userid: '',
      display_name: '',
      firstname: '',
      lastname: '',
      mail: '',
      roles: [],
    });

    async function setUser(value: FG.User) {
      await userStore.createUser(value);
    }
    return { user, setUser };
  },
});
</script>

<style scoped></style>
