<template>
  <join-form
    :value="code"
    :error="error"
    title="Einem Team beitreten"
    ok-text="Team beitreten"
    cancel-text="Abbrechen"
    @input="updateCode"
    @cancel="cancel"
    @confirm="joinTeam"/>
</template>

<script>
  import JoinForm from '@/components/profile/JoinForm';
  import {MY_TEAM} from '@/router/me.names';

  export default {
    components: {
      JoinForm,
    },

    data() {
      return {
        code: '',
        error: '',
        teamRoute: {
          name: MY_TEAM
        }
      };
    },

    methods: {
      updateCode(event) {
        this.code = event.target.value;
        this.error = '';
      },
      cancel() {
        this.$router.push(this.teamRoute);
      },
      joinTeam(code) {
        // todo
        console.log('joinTeam', code);
      },
    },
  };
</script>

<style scoped lang="scss">
  @import '~styles/helpers';

</style>
