diff --git a/server/storage.ts b/server/storage.ts index 25ab012..2cc6207 100644 --- a/server/storage.ts +++ b/server/storage.ts @@ -479,20 +479,25 @@ export class DatabaseStorage implements IStorage { } async getProfessionalServices(type?: string, location?: string): Promise { - 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): Promise { diff --git a/shared/schema.ts b/shared/schema.ts index d568508..8c0910c 100644 --- a/shared/schema.ts +++ b/shared/schema.ts @@ -359,20 +359,18 @@ export const messageStatuses = pgTable("message_statuses", { // Professional services table export const professionalServices = pgTable("professional_services", { id: serial("id").primaryKey(), - providerId: integer("provider_id").notNull().references(() => users.id, { onDelete: "cascade" }), - name: text("name").notNull(), + userId: integer("user_id").notNull().references(() => users.id, { onDelete: "cascade" }), + providerId: integer("provider_id").references(() => users.id, { onDelete: "cascade" }), + name: text("name"), + title: text("title"), description: text("description"), - type: professionalTypeEnum("type").notNull(), + serviceType: professionalTypeEnum("service_type").notNull(), specializations: text("specializations").array(), - hourlyRate: numeric("hourly_rate", { precision: 10, scale: 2 }), - currency: varchar("currency", { length: 3 }).default("OMR"), - availability: json("availability").$type<{ - [key: string]: { start: string; end: string; available: boolean }[] - }>(), + priceRange: text("price_range"), + availabilitySchedule: text("availability_schedule"), location: text("location"), - isOnline: boolean("is_online").default(false), rating: numeric("rating", { precision: 3, scale: 2 }), - reviewCount: integer("review_count").default(0), + totalReviews: integer("total_reviews").default(0), isVerified: boolean("is_verified").default(false), isActive: boolean("is_active").default(true), createdAt: timestamp("created_at").defaultNow(),