alert on bad url

This commit is contained in:
Hayden 2021-01-03 12:07:01 -09:00
parent 5769e9336a
commit b1390b5fec

View File

@ -8,6 +8,11 @@
<v-form> <v-form>
<v-text-field v-model="recipeURL" label="Recipe URL"></v-text-field> <v-text-field v-model="recipeURL" label="Recipe URL"></v-text-field>
</v-form> </v-form>
<v-alert v-if="error" color="red" outlined type="success">
Looks like there was an error parsing the URL. Check the log and
debug/last_recipe.json to see what went wrong.
</v-alert>
</v-card-text> </v-card-text>
<v-divider></v-divider> <v-divider></v-divider>
@ -37,6 +42,7 @@ import api from "../api";
export default { export default {
data() { data() {
return { return {
error: false,
fab: false, fab: false,
addRecipe: false, addRecipe: false,
recipeURL: "", recipeURL: "",
@ -47,9 +53,16 @@ export default {
methods: { methods: {
async createRecipe() { async createRecipe() {
this.processing = true; this.processing = true;
await api.recipes.createByURL(this.recipeURL); let response = await api.recipes.createByURL(this.recipeURL);
if (response.status !== 201) {
this.error = true;
this.processing = false;
return;
}
this.addRecipe = false; this.addRecipe = false;
this.processing = false; this.processing = false;
this.$router.push(`/recipe/${response.data}`);
}, },
navCreate() { navCreate() {