diff --git a/web/src/components/AppHeader.vue b/web/src/components/AppHeader.vue
new file mode 100644
index 0000000..f3e6476
--- /dev/null
+++ b/web/src/components/AppHeader.vue
@@ -0,0 +1,117 @@
+
+
+ Inventory Manager
+
+
+ Add Storage Space
+
+
+
+
+
+ Add New Storage Space
+
+
+
+
+
+
+
+
+
+
+
+ {{ error }}
+
+
+
+
+
+ Cancel
+
+ Save
+
+
+
+
+
+
+
+
diff --git a/web/src/components/StorageHierarchy.vue b/web/src/components/StorageHierarchy.vue
index 85445b5..1c1e53c 100644
--- a/web/src/components/StorageHierarchy.vue
+++ b/web/src/components/StorageHierarchy.vue
@@ -196,6 +196,14 @@ async function fetchStorageData(storageId: number): Promise {
}
}
+// Watch for changes in storage spaces (e.g., when a new one is added)
+watch(() => storageStore.storageSpaces, (newSpaces) => {
+ // If we don't have a selected storage and spaces are available, select the first one
+ if (!selectedStorageId.value && newSpaces.length > 0) {
+ selectedStorageId.value = newSpaces[0].id;
+ }
+}, { deep: true });
+
onMounted(async () => {
loading.value = true;
error.value = null;
diff --git a/web/src/layouts/default.vue b/web/src/layouts/default.vue
index 651a9b0..ae805ca 100644
--- a/web/src/layouts/default.vue
+++ b/web/src/layouts/default.vue
@@ -1,4 +1,6 @@
+
+
@@ -7,5 +9,5 @@
diff --git a/web/src/stores/storage.ts b/web/src/stores/storage.ts
index d48da2c..0c75f68 100644
--- a/web/src/stores/storage.ts
+++ b/web/src/stores/storage.ts
@@ -43,6 +43,39 @@ export const useStorageStore = defineStore('storage', {
},
actions: {
+ async createStorageSpace(data: { location: string; parentId: number | null }): Promise {
+ this.loading = true;
+ this.error = null;
+
+ try {
+ const parentData = data.parentId ? { valid: true, int64: data.parentId } : null;
+
+ const response = await fetch('/api/v1/storageSpaces', {
+ method: 'POST',
+ headers: {
+ 'Authorization': `Bearer ${localStorage.getItem('auth_token')}`,
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify({
+ location: data.location,
+ parent: parentData
+ }),
+ });
+
+ if (!response.ok) {
+ throw new Error('Failed to create storage space');
+ }
+
+ // Refresh the storage spaces list
+ await this.fetchStorageSpaces();
+ } catch (error: any) {
+ this.error = error.message;
+ throw error;
+ } finally {
+ this.loading = false;
+ }
+ },
+
async fetchStorageSpaces(): Promise {
this.loading = true;
this.error = null;