Improve professional service listings and handle database errors gracefully

Updates professional service schema, adds error handling for service queries.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: c5f0c281-8dd8-4846-b452-4a07bcd21062
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/9777c70b-fc38-4831-8d6b-78dfffe041b0/77e3a9be-2270-44e5-9c08-420849b57e18.jpg
This commit is contained in:
ghaddaditw
2025-06-08 08:21:34 +00:00
parent a16fca481c
commit d0ccbf0a50
2 changed files with 25 additions and 22 deletions
+17 -12
View File
@@ -479,20 +479,25 @@ export class DatabaseStorage implements IStorage {
}
async getProfessionalServices(type?: string, location?: string): Promise<ProfessionalService[]> {
let query = db
.select()
.from(professionalServices)
.where(eq(professionalServices.isActive, true));
try {
let query = db
.select()
.from(professionalServices)
.where(eq(professionalServices.isActive, true));
if (type) {
query = query.where(eq(professionalServices.serviceType, type));
}
if (location) {
query = query.where(eq(professionalServices.location, location));
}
if (type) {
query = query.where(eq(professionalServices.type, type));
}
if (location) {
query = query.where(eq(professionalServices.location, location));
}
return await query.orderBy(desc(professionalServices.rating));
return await query.orderBy(desc(professionalServices.rating));
} catch (error) {
console.error('Database error in getProfessionalServices:', error);
return [];
}
}
async updateProfessionalService(id: number, userId: number, updates: Partial<ProfessionalService>): Promise<ProfessionalService | undefined> {