feat: finish company profile in the backoffice

This commit is contained in:
Nathnael
2026-06-23 06:45:29 +00:00
parent f7cbb6af6f
commit a6f3fd5643
24 changed files with 690 additions and 938 deletions

View File

@@ -136,6 +136,14 @@ export class BookingsController {
return this.bookingsService.findAll(filter, companyId);
}
@Get('by-company/:companyId/customer-view')
@ApiOperation({ summary: 'List bookings for a company (customer-view shape, backoffice)' })
findByCompanyCustomerView(
@Param('companyId', ParseUUIDPipe) companyId: string,
) {
return this.bookingsService.findCustomerBookings(companyId);
}
@Get('list-summary')
@ApiOperation({ summary: 'Booking list metrics and tab counts (backoffice)' })
@ApiOkResponse({ type: BookingListSummaryDto })

View File

@@ -1036,4 +1036,37 @@ export class BookingsService {
return this.findById(id);
}
async findCustomerBookings(companyId: string): Promise<{
id: string;
reference: string;
status: string;
tradeDirection: string;
freightType: string;
originLabel: string;
destinationLabel: string;
totalAmount: number;
currency: string;
scheduledDate: Date | null;
createdAt: Date;
}[]> {
const { items } = await this.bookingsRepository.findAllPaginated({
page: 1,
pageSize: 500,
companyId,
});
return items.map((b) => ({
id: b.id,
reference: b.reference,
status: b.status,
tradeDirection: b.tradeDirection,
freightType: b.freightType,
originLabel: b.originYard?.label ?? '',
destinationLabel: b.destinationYard?.label ?? '',
totalAmount: Number(b.totalAmount),
currency: b.paymentCurrency,
scheduledDate: b.scheduledDate ?? null,
createdAt: b.createdAt,
}));
}
}