Skip to content

Commit

Permalink
fixup! Inventory search on the checklist page
Browse files Browse the repository at this point in the history
  • Loading branch information
Perdolique committed Aug 5, 2024
1 parent 3ead32e commit 12ae3f0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
21 changes: 11 additions & 10 deletions app/composables/use-checklist-items-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,31 @@ interface EquipmentItem {
readonly id: string;
readonly name: string;
readonly weight: number;
readonly createdAt: string;
}

export async function useChecklistItemsData(checklistId: string) {
const items = ref([])
interface ChecklistItem {
readonly id: string;
readonly equipment: EquipmentItem;
}

export async function useChecklistItemsData(checklistId: string) {
const items = ref<ChecklistItem[]>([])
const { data } = await useFetch(`/api/checklists/${checklistId}/items`)

if (data.value !== undefined) {
items.value = data.value
}

async function updateItems() {
try {
const response = await $fetch(`/api/checklists/${checklistId}/items`)

console.log('updateChecklist', response);

// items.value = response
items.value = response
} catch {
console.error('Failed to update equipment')
}
}

// if (data.value !== undefined) {
// equipment.value = data.value
// }

return {
items,
updateItems
Expand Down
2 changes: 1 addition & 1 deletion server/api/checklists/[id]/items.get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default defineEventHandler(async (event) => {
eq(tables.checklists.userId, userId)
)
)
.leftJoin(
.innerJoin(
tables.equipment,
eq(tables.checklistItems.equipmentId, tables.equipment.id)
)
Expand Down

0 comments on commit 12ae3f0

Please sign in to comment.