mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-27 00:52:50 +00:00
- Added parameter to and for server-side free-text search on contract reference, company name, and booking details. - Introduced new validation errors in for container clashes and space issues when creating bookings. - Implemented paginated dropdown settings retrieval in . - Updated to fetch active yards using a new method that handles pagination. - Enhanced with a method to fetch all records by walking through pages. - Refactored to support filtering and pagination in schedule listings. - Improved to return a paginated list of facilities. - Updated UI components in and to utilize debounced search inputs for better performance. - Added alerts in to inform users about booking constraints related to splits and capacity. - Enhanced to display notifications for split bookings and capacity usage.
86 lines
2.5 KiB
TypeScript
86 lines
2.5 KiB
TypeScript
import {
|
|
Body, Controller, Delete, Get, HttpCode, HttpStatus,
|
|
Param, ParseUUIDPipe, Patch, Post, Query,
|
|
} from '@nestjs/common';
|
|
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
|
|
import { CurrentUser } from '@edr/api-common';
|
|
import { RuleEngineManage, RuleEngineView } from '../../../common/rule-engine-guards';
|
|
import { CreateRateDto } from '../dto/create-rate.dto';
|
|
import { ListRatesQueryDto } from '../dto/list-rule-engine-query.dto';
|
|
import {
|
|
type AuthUserPayload,
|
|
resolveAuthUserId,
|
|
} from '../../../common/resolve-auth-user-id';
|
|
import { UpdateRateDto } from '../dto/update-rate.dto';
|
|
import { RatesService } from '../services/rates.service';
|
|
|
|
@ApiTags('rates')
|
|
@Controller('rates')
|
|
@ApiBearerAuth()
|
|
export class RatesController {
|
|
constructor(private readonly service: RatesService) {}
|
|
|
|
@Get()
|
|
@RuleEngineView('rates')
|
|
@ApiOperation({ summary: 'List rates' })
|
|
findAll(@Query() query: ListRatesQueryDto) {
|
|
return this.service.findAll(query);
|
|
}
|
|
|
|
@Get('live')
|
|
@RuleEngineView('rates')
|
|
@ApiOperation({ summary: 'List all LIVE rates effective now' })
|
|
findLive() {
|
|
return this.service.findLiveRates();
|
|
}
|
|
|
|
@Get(':id')
|
|
@RuleEngineView('rates')
|
|
@ApiOperation({ summary: 'Get a rate by ID' })
|
|
findOne(@Param('id', ParseUUIDPipe) id: string) {
|
|
return this.service.findById(id);
|
|
}
|
|
|
|
@Post()
|
|
@RuleEngineManage('rates')
|
|
@ApiOperation({ summary: 'Create a rate (DRAFT)' })
|
|
create(
|
|
@Body() dto: CreateRateDto,
|
|
@CurrentUser() user: AuthUserPayload,
|
|
) {
|
|
return this.service.create(dto, resolveAuthUserId(user));
|
|
}
|
|
|
|
@Patch(':id')
|
|
@RuleEngineManage('rates')
|
|
@ApiOperation({ summary: 'Update a DRAFT rate' })
|
|
update(@Param('id', ParseUUIDPipe) id: string, @Body() dto: UpdateRateDto) {
|
|
return this.service.update(id, dto);
|
|
}
|
|
|
|
@Post(':id/submit')
|
|
@RuleEngineManage('rates')
|
|
@ApiOperation({ summary: 'Submit rate for CEO approval' })
|
|
submit(@Param('id', ParseUUIDPipe) id: string) {
|
|
return this.service.submitForApproval(id);
|
|
}
|
|
|
|
@Post(':id/approve')
|
|
@RuleEngineManage('rates')
|
|
@ApiOperation({ summary: 'CEO approves a rate' })
|
|
approve(
|
|
@Param('id', ParseUUIDPipe) id: string,
|
|
@CurrentUser() user: AuthUserPayload,
|
|
) {
|
|
return this.service.approve(id, resolveAuthUserId(user));
|
|
}
|
|
|
|
@Delete(':id')
|
|
@RuleEngineManage('rates')
|
|
@HttpCode(HttpStatus.NO_CONTENT)
|
|
@ApiOperation({ summary: 'Soft-delete a rate' })
|
|
remove(@Param('id', ParseUUIDPipe) id: string) {
|
|
return this.service.remove(id);
|
|
}
|
|
}
|