<script setup>
import {useI18n} from 'vue-i18n';

const {t} = useI18n({useScope: 'local'});
</script>

<template>
  <form class='chat-box' v-on:submit='onSubmit($event)'>
    <input
        v-model='text'
        type='text'
    />
    <button :disabled='text === ""'>{{ t('pwa.send') }}</button>
  </form>
</template>



<script>
export default {
  name: 'ChatBox',
  data: () => ({
    text: ''
  }),
  methods: {

    onSubmit(event) {
      this.$emit("submit", event, this.text);
      this.text = '';
    }
  }
}
</script>

<style scoped>
.chat-box {
  width: 100%;
  display: flex;
}

input {
  width: min(100%, 20rem);
  flex-grow: 1;
}

button:disabled {
  opacity: 0.5;
}
</style>

<i18n lang="json" locale="en" src="./locale/en.json"/>
<i18n lang="json" locale="fr" src="./locale/fr.json"/>