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:
+17
-12
@@ -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> {
|
||||
|
||||
Reference in New Issue
Block a user