From c722495fdd8cc407fdd926bfe1e22e25279c48cc Mon Sep 17 00:00:00 2001
From: Hayden <64056131+hay-kot@users.noreply.github.com>
Date: Mon, 31 Oct 2022 19:07:01 -0800
Subject: [PATCH] feat: redirect to item on create (#121)
* redirect on create
* change to text area
---
frontend/components/Item/CreateModal.vue | 6 ++++--
frontend/components/Label/CreateModal.vue | 3 ++-
frontend/components/Location/CreateModal.vue | 1 +
3 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/frontend/components/Item/CreateModal.vue b/frontend/components/Item/CreateModal.vue
index b2ed85e..42bb6b7 100644
--- a/frontend/components/Item/CreateModal.vue
+++ b/frontend/components/Item/CreateModal.vue
@@ -10,7 +10,7 @@
:autofocus="true"
label="Item Name"
/>
-
+
@@ -81,13 +81,14 @@
}
const out: ItemCreate = {
+ parentId: undefined,
name: form.name,
description: form.description,
locationId: form.location.id as string,
labelIds: form.labels.map(l => l.id) as string[],
};
- const { error } = await api.items.create(out);
+ const { error, data } = await api.items.create(out);
if (error) {
toast.error("Couldn't create item");
return;
@@ -95,5 +96,6 @@
toast.success("Item created");
reset();
+ navigateTo(`/item/${data.id}`);
}
diff --git a/frontend/components/Label/CreateModal.vue b/frontend/components/Label/CreateModal.vue
index 99bfaa9..829ce8c 100644
--- a/frontend/components/Label/CreateModal.vue
+++ b/frontend/components/Label/CreateModal.vue
@@ -54,7 +54,7 @@
const toast = useNotifier();
async function create() {
- const { error } = await api.labels.create(form);
+ const { error, data } = await api.labels.create(form);
if (error) {
toast.error("Couldn't create label");
return;
@@ -62,5 +62,6 @@
toast.success("Label created");
reset();
+ navigateTo(`/label/${data.id}`);
}
diff --git a/frontend/components/Location/CreateModal.vue b/frontend/components/Location/CreateModal.vue
index 5d9713a..3503a0d 100644
--- a/frontend/components/Location/CreateModal.vue
+++ b/frontend/components/Location/CreateModal.vue
@@ -64,5 +64,6 @@
toast.success("Location created");
}
reset();
+ navigateTo(`/location/${data.id}`);
}