business list
This commit is contained in:
@@ -7,6 +7,7 @@ import { SubscriptionsService } from "../subscriptions/providers/subscriptions.s
|
||||
import { IDPageConfig } from "../../configs/dpage.config";
|
||||
import { LoginDto } from './dto/login.dto';
|
||||
import { DPAGE_CONFIG } from "./constants";
|
||||
import { FindBusinessesDto } from "./dto/find-businesses.dto";
|
||||
// import { UsersService } from "../users/providers/users.service";
|
||||
// import { UpdateDpageDto } from './dto/update-dpage.dto';
|
||||
|
||||
@@ -28,8 +29,38 @@ export class DPageService {
|
||||
};
|
||||
}
|
||||
|
||||
findAll() {
|
||||
return `This action returns all dpage`;
|
||||
async findAll(dto: FindBusinessesDto) {
|
||||
|
||||
try {
|
||||
// 2. Login with userSubscriptionId
|
||||
const { data } = await firstValueFrom(
|
||||
this.httpService
|
||||
.get(`${this.config.baseUrl}/super-admin/business/list`,
|
||||
{
|
||||
params: dto,
|
||||
headers: this.getHeaders(),
|
||||
})
|
||||
.pipe(
|
||||
catchError((err: AxiosError) => {
|
||||
this.logger.error(`Failed to perform direct login: ${err.message}`, err.stack);
|
||||
return throwError(() => err);
|
||||
}),
|
||||
),
|
||||
);
|
||||
return data;
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof AxiosError && error.response) {
|
||||
this.logger.error(`External API error response:`, error.response.data);
|
||||
const errorResponse = {
|
||||
...error.response.data,
|
||||
message: error.response.data.error?.message || error.message,
|
||||
};
|
||||
throw new HttpException(errorResponse, error.response.status);
|
||||
}
|
||||
this.logger.error(`Error performing direct login: ${error instanceof Error ? error.message : "Unknown error"}`);
|
||||
throw error;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
findOne(id: number) {
|
||||
@@ -49,11 +80,11 @@ export class DPageService {
|
||||
// 1. validate userSubscription by id
|
||||
const userSubscription = await this.subscriptionService.findOneOrFail(userSubscriptionId)
|
||||
|
||||
|
||||
|
||||
if (userSubscription.user.id !== userId) {
|
||||
throw new BadRequestException("this subscription doesnt belongs to you")
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
// 2. Login with userSubscriptionId
|
||||
const { data } = await firstValueFrom(
|
||||
|
||||
Reference in New Issue
Block a user