-
+
{{ name }}
@@ -7,7 +10,7 @@
{{ formattedWeight }}
-
+
+
+
diff --git a/app/pages/inventory.vue b/app/pages/inventory.vue
index b296853..ae3d0ad 100644
--- a/app/pages/inventory.vue
+++ b/app/pages/inventory.vue
@@ -22,9 +22,12 @@
:columns="columns"
>
-
+
{{ rowData.name }}
-
+
@@ -60,6 +63,7 @@
import EmptyState from '~/components/EmptyState.vue';
import PerdTable from '~/components/PerdTable/PerdTable.vue';
import PerdButton from '~/components/PerdButton.vue';
+ import PerdLink from '~/components/PerdLink.vue';
interface EquipmentItem {
readonly id: number;
@@ -154,7 +158,7 @@
}
}
- .name {
+ .nameLink {
font-weight: var(--font-weight-medium);
}
diff --git a/app/pages/manager/equipment/index.vue b/app/pages/manager/equipment/index.vue
index 4271ade..04ad12e 100644
--- a/app/pages/manager/equipment/index.vue
+++ b/app/pages/manager/equipment/index.vue
@@ -83,7 +83,7 @@
const router = useRouter()
const page = ref(1)
- const { data, error } = await useFetch('/api/equipment/drafts', {
+ const { data, error } = await useFetch('/api/search/equipment-drafts', {
query: {
page
},
diff --git a/public/equipment-item-placeholder.webp b/public/equipment-item-placeholder.webp
new file mode 100644
index 0000000..1a43992
Binary files /dev/null and b/public/equipment-item-placeholder.webp differ
diff --git a/server/api/equipment/items/[itemId].get.ts b/server/api/equipment/items/[itemId].get.ts
new file mode 100644
index 0000000..f64e3a3
--- /dev/null
+++ b/server/api/equipment/items/[itemId].get.ts
@@ -0,0 +1,57 @@
+import { eq } from 'drizzle-orm'
+import * as v from 'valibot'
+
+const paramsSchema = v.object({
+ itemId: stringToIntegerValidator
+})
+
+function validateParams(params: unknown) {
+ return v.parse(paramsSchema, params)
+}
+
+export default defineEventHandler(async (event) => {
+ const { itemId } = await getValidatedRouterParams(event, validateParams)
+
+ const item = await event.context.db
+ .select({
+ equipment: {
+ id: tables.equipment.id,
+ name: tables.equipment.name,
+ description: tables.equipment.description,
+ weight: tables.equipment.weight
+ },
+
+ group: {
+ id: tables.equipmentTypes.id,
+ name: tables.equipmentTypes.name
+ },
+
+ type: {
+ id: tables.equipmentGroups.id,
+ name: tables.equipmentGroups.name
+ }
+ })
+ .from(tables.equipment)
+ .where(
+ eq(tables.equipment.id, itemId)
+ )
+ .leftJoin(
+ tables.equipmentTypes,
+ eq(tables.equipment.equipmentTypeId, tables.equipmentTypes.id)
+ )
+ .leftJoin(
+ tables.equipmentGroups,
+ eq(tables.equipment.equipmentGroupId, tables.equipmentGroups.id)
+ )
+
+ const foundItem = item[0]
+
+ if (foundItem === undefined) {
+ throw createError({
+ statusCode: 404,
+ message: 'Item not found'
+ })
+ }
+
+ return foundItem
+})
diff --git a/server/api/equipment/index.get.ts b/server/api/equipment/items/index.get.ts
similarity index 100%
rename from server/api/equipment/index.get.ts
rename to server/api/equipment/items/index.get.ts
diff --git a/server/api/equipment/index.post.ts b/server/api/equipment/items/index.post.ts
similarity index 100%
rename from server/api/equipment/index.post.ts
rename to server/api/equipment/items/index.post.ts
diff --git a/server/api/equipment/drafts.get.ts b/server/api/search/equipment-drafts.get.ts
similarity index 100%
rename from server/api/equipment/drafts.get.ts
rename to server/api/search/equipment-drafts.get.ts