From 652780c238be48214a7f7189988cad9e77d4c5e7 Mon Sep 17 00:00:00 2001 From: morteza-mortezai Date: Sat, 27 Dec 2025 16:48:52 +0330 Subject: [PATCH] fix : get restuarant by user sub id --- .../dmenu/providers/restaurant.service.ts | 36 ++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/src/modules/dmenu/providers/restaurant.service.ts b/src/modules/dmenu/providers/restaurant.service.ts index a3018c6..7235f79 100644 --- a/src/modules/dmenu/providers/restaurant.service.ts +++ b/src/modules/dmenu/providers/restaurant.service.ts @@ -104,24 +104,36 @@ export class RestaurantService { ); return data; } catch (error: unknown) { + // Return validation errors or other error types from external API + if (error instanceof AxiosError && error.response?.data) { + this.logger.error(`External API error response:`, error.response.data); + return error.response.data; + } + this.logger.error(`Error creating restaurant: ${error instanceof Error ? error.message : "Unknown error"}`); throw error; } } async getRestaurantSubscription(subscriptionId: string) { - // TODO: Implement the business logic to get restaurant subscription - // This could involve querying the database, making external API calls, etc. - - this.logger.log(`Getting restaurant subscription for ID: ${subscriptionId}`); - - // For now, return a placeholder response - // You should implement the actual logic based on your business requirements - return { - subscriptionId, - message: "Restaurant subscription endpoint created successfully", - // Add actual data structure based on your requirements - }; + try { + const { data } = await firstValueFrom( + this.httpService + .get(`${this.config.baseUrl}/super-admin/restaurants/subscription/${subscriptionId}`, { + headers: this.getHeaders(), + }) + .pipe( + catchError((err: AxiosError) => { + this.logger.error(`Failed to get restaurant subscription: ${err.message}`, err.stack); + return throwError(() => err); + }), + ), + ); + return data; + } catch (error: unknown) { + this.logger.error(`Error getting restaurant subscription: ${error instanceof Error ? error.message : "Unknown error"}`); + throw error; + } } async getSmsCountByRestaurant(page: number, limit: number) {