Skip to content

Commit

Permalink
feat: display only active items in search
Browse files Browse the repository at this point in the history
  • Loading branch information
Perdolique committed Nov 24, 2024
1 parent 95e2fc0 commit de3f91a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions server/api/search/equipment.get.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { and, asc, eq, isNull, like } from 'drizzle-orm'
import { equipmentTypes } from '~~/shared/models/equipment';

interface ReturnData {
readonly id: number;
Expand Down Expand Up @@ -33,6 +34,7 @@ export default defineEventHandler(async (event) : Promise<ReturnData[]> => {
)
.where(
and(
eq(tables.equipment.status, equipmentTypes.active),
like(tables.equipment.name, `%${searchString}%`),
isNull(tables.userEquipment.userId),
)
Expand Down
5 changes: 5 additions & 0 deletions shared/models/equipment.ts
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
export type EquipmentStatus = 'draft' | 'active'

export const equipmentTypes : Record<EquipmentStatus, EquipmentStatus> = {
draft: 'draft',
active: 'active'
} as const

0 comments on commit de3f91a

Please sign in to comment.