import { Body, Controller, Delete, Get, Put } from "@nestjs/common"; import { ApiBearerAuth, ApiOperation, ApiTags } from "@nestjs/swagger"; import { CurrentUser } from "@edr/api-common"; import type { TCurrentUser } from "@tria-plc/api-common/modules/auth/types/current-user.type"; import { BookingStaff } from "../../common/booking-guards"; import { FREIGHT_PERMS } from "../../seed/freight-permissions.registry"; import { UpdateStampSettingDto } from "./dto/update-stamp-setting.dto"; import { StampSettingsService } from "./stamp-settings.service"; @ApiTags("stamp-settings") @ApiBearerAuth() @Controller("stamp-settings") export class StampSettingsController { constructor(private readonly service: StampSettingsService) {} @Get() @BookingStaff([FREIGHT_PERMS.settings.stamp.view, FREIGHT_PERMS.admin]) @ApiOperation({ summary: "Current company stamp used on invoice/receipt PDFs" }) get() { return this.service.getView(); } @Put() @BookingStaff([FREIGHT_PERMS.settings.stamp.manage, FREIGHT_PERMS.admin]) @ApiOperation({ summary: "Replace the company stamp" }) update(@Body() dto: UpdateStampSettingDto, @CurrentUser() user: TCurrentUser) { return this.service.setStamp(dto.stampImageBase64, user?.id ?? null); } @Delete() @BookingStaff([FREIGHT_PERMS.settings.stamp.manage, FREIGHT_PERMS.admin]) @ApiOperation({ summary: "Clear the company stamp (invoices fall back to the plain seal)", }) clear(@CurrentUser() user: TCurrentUser) { return this.service.clearStamp(user?.id ?? null); } }