<script>
const api = require('./api')
export default {
  data() {
    return {
      error: null,
      model: {
        url: null
      }
    }
  },
  methods: {
    async submit() {
      const result = await api.post('feeds', this.model)
      if (result.error) {
        this.error = result.error
      } else {
        this.$router.push(`/feeds/${result.id}`)
      }
    }
  }
}
</script>
<template>
  <div>
    <h1>New RSS Feed</h1>
    <v-text-field v-model="model.url" label="URL to rss feed" />
    <v-btn @click="submit">Continue...</v-btn>
    <v-alert :value="true" v-if="error" type="error" dismissible>{{error}}</v-alert>
  </div>
</template>
