mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 00:10:57 +00:00
New logo-settings module (mirrors stamp-settings): single uploaded logo, stored via FilesService/MinIO, injected as a data URL into invoice/receipt, contract, warehouse, train-scheduling, and payment-receipt PDFs. Adds a matching backoffice settings page and settings:logo:view/manage permissions. >
40 lines
1.5 KiB
TypeScript
40 lines
1.5 KiB
TypeScript
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 { UpdateLogoSettingDto } from "./dto/update-logo-setting.dto";
|
|
import { LogoSettingsService } from "./logo-settings.service";
|
|
|
|
@ApiTags("logo-settings")
|
|
@ApiBearerAuth()
|
|
@Controller("logo-settings")
|
|
export class LogoSettingsController {
|
|
constructor(private readonly service: LogoSettingsService) {}
|
|
|
|
@Get()
|
|
@BookingStaff([FREIGHT_PERMS.settings.logo.view, FREIGHT_PERMS.admin])
|
|
@ApiOperation({ summary: "Current company logo used on every generated document" })
|
|
get() {
|
|
return this.service.getView();
|
|
}
|
|
|
|
@Put()
|
|
@BookingStaff([FREIGHT_PERMS.settings.logo.manage, FREIGHT_PERMS.admin])
|
|
@ApiOperation({ summary: "Replace the company logo" })
|
|
update(@Body() dto: UpdateLogoSettingDto, @CurrentUser() user: TCurrentUser) {
|
|
return this.service.setLogo(dto.logoImageBase64, user?.id ?? null);
|
|
}
|
|
|
|
@Delete()
|
|
@BookingStaff([FREIGHT_PERMS.settings.logo.manage, FREIGHT_PERMS.admin])
|
|
@ApiOperation({
|
|
summary: "Clear the company logo (documents fall back to their text mark)",
|
|
})
|
|
clear(@CurrentUser() user: TCurrentUser) {
|
|
return this.service.clearLogo(user?.id ?? null);
|
|
}
|
|
}
|