add:create restuarant endpoint for dmenu
This commit is contained in:
@@ -7,6 +7,7 @@ import { catchError, firstValueFrom, throwError } from "rxjs";
|
||||
import { IDmenuConfig } from "../../../configs/icons.config";
|
||||
import { DMENU_CONFIG } from "../constants";
|
||||
import { FindRestaurantsDto } from "../DTO/find-restaurants.dto";
|
||||
import { CreateRestaurantDto } from "../DTO/create-restaurant.dto";
|
||||
|
||||
@Injectable()
|
||||
export class RestaurantService {
|
||||
@@ -65,5 +66,26 @@ export class RestaurantService {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async createRestaurant(dto: CreateRestaurantDto) {
|
||||
try {
|
||||
const { data } = await firstValueFrom(
|
||||
this.httpService
|
||||
.post(`${this.config.baseUrl}/super-admin/restaurants`, dto, {
|
||||
headers: this.getHeaders(),
|
||||
})
|
||||
.pipe(
|
||||
catchError((err: AxiosError) => {
|
||||
this.logger.error(`Failed to create restaurant: ${err.message}`, err.stack);
|
||||
return throwError(() => err);
|
||||
}),
|
||||
),
|
||||
);
|
||||
return data;
|
||||
} catch (error: unknown) {
|
||||
this.logger.error(`Error creating restaurant: ${error instanceof Error ? error.message : "Unknown error"}`);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user