<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" @update:user="setUser" :new-user="true" />
    </q-card-section>
  </q-card>
</template>

<script lang="ts">
import { defineComponent, ref } from '@vue/composition-api';
import MainUserSettings from 'src/plugins/user/components/settings/MainUserSettings.vue';
import { Store } from 'vuex';
import { StateInterface } from 'src/store';
export default defineComponent({
  name: 'NewUser',
  components: { MainUserSettings },
  setup(_, { root }) {
    const store = <Store<StateInterface>>root.$store;
    const user = ref<FG.User>({
      userid: '',
      display_name: '',
      firstname: '',
      lastname: '',
      mail: '',
      roles: [],
    });
    function setUser(value: FG.User) {
      store.dispatch('user/setUser', value).catch((error) => {
        console.warn(error);
      });
    }
    return { user, setUser };
  },
});
</script>

<style scoped></style>
