extend damageReport with noteByWorker

This commit is contained in:
Julian Krauser 2025-07-17 10:37:26 +02:00
parent a208cdd158
commit c02487ad3c
8 changed files with 18 additions and 8 deletions

View file

@ -1,7 +1,7 @@
export interface CreateDamageReportCommand { export interface CreateDamageReportCommand {
description: string; description: string;
location: string; location: string;
note: string; noteByReporter: string;
reportedBy: string; reportedBy: string;
images: string[]; images: string[];
affectedId?: string; affectedId?: string;
@ -11,6 +11,7 @@ export interface CreateDamageReportCommand {
export interface UpdateDamageReportCommand { export interface UpdateDamageReportCommand {
id: string; id: string;
status: string; status: string;
noteByWorker: string;
done: boolean; done: boolean;
} }

View file

@ -23,7 +23,7 @@ export default abstract class DamageReportCommandHandler {
status: "eingereicht", status: "eingereicht",
description: createDamageReport.description, description: createDamageReport.description,
location: createDamageReport.location, location: createDamageReport.location,
note: createDamageReport.note, noteByReporter: createDamageReport.noteByReporter,
reportedBy: createDamageReport.reportedBy, reportedBy: createDamageReport.reportedBy,
images: createDamageReport.images, images: createDamageReport.images,
equipmentId: createDamageReport.affected == "equipment" ? createDamageReport.affectedId : null, equipmentId: createDamageReport.affected == "equipment" ? createDamageReport.affectedId : null,
@ -50,6 +50,7 @@ export default abstract class DamageReportCommandHandler {
.update(damageReport) .update(damageReport)
.set({ .set({
status: updateDamageReport.status, status: updateDamageReport.status,
noteByWorker: updateDamageReport.noteByWorker,
done: updateDamageReport.done, done: updateDamageReport.done,
}) })
.where("id = :id", { id: updateDamageReport.id }) .where("id = :id", { id: updateDamageReport.id })

View file

@ -108,7 +108,7 @@ export async function createDamageReport(req: Request, res: Response): Promise<a
let createDamageReport: CreateDamageReportCommand = { let createDamageReport: CreateDamageReportCommand = {
description, description,
location, location,
note, noteByReporter: note,
reportedBy, reportedBy,
images: images.map((i) => i.filename), images: images.map((i) => i.filename),
affectedId, affectedId,
@ -128,11 +128,13 @@ export async function createDamageReport(req: Request, res: Response): Promise<a
export async function updateDamageReportById(req: Request, res: Response): Promise<any> { export async function updateDamageReportById(req: Request, res: Response): Promise<any> {
const damageReportId = req.params.id; const damageReportId = req.params.id;
const status = req.body.status; const status = req.body.status;
const noteByWorker = req.body.noteByWorker;
const done = req.body.done; const done = req.body.done;
let updateDamageReport: UpdateDamageReportCommand = { let updateDamageReport: UpdateDamageReportCommand = {
id: damageReportId, id: damageReportId,
status, status,
noteByWorker,
done, done,
}; };
await DamageReportCommandHandler.update(updateDamageReport); await DamageReportCommandHandler.update(updateDamageReport);

View file

@ -129,7 +129,7 @@ export async function createDamageReport(req: Request, res: Response): Promise<a
let createDamageReport: CreateDamageReportCommand = { let createDamageReport: CreateDamageReportCommand = {
description: description, description: description,
location: location, location: location,
note: note, noteByReporter: note,
reportedBy: reportedBy, reportedBy: reportedBy,
images: images.map((i) => i.filename), images: images.map((i) => i.filename),
affectedId: related ? related.id : undefined, affectedId: related ? related.id : undefined,

View file

@ -25,7 +25,10 @@ export class damageReport {
location: string; location: string;
@Column({ type: "text" }) @Column({ type: "text" })
note: string; noteByReporter: string;
@Column({ type: "text" })
noteByWorker: string;
@Column({ @Column({
type: "text", type: "text",

View file

@ -46,7 +46,8 @@ export default abstract class DamageReportFactory {
done: record.done, done: record.done,
description: record.description, description: record.description,
location: record.location, location: record.location,
note: record.note, noteByReporter: record.noteByReporter,
noteByWorker: record.noteByWorker,
images: record.images, images: record.images,
reportedBy: record?.reportedBy, reportedBy: record?.reportedBy,
...assigned, ...assigned,

View file

@ -10,7 +10,8 @@ export const damage_report_table = new Table({
{ name: "done", ...getTypeByORM("boolean"), default: getDefaultByORM("boolean", false) }, { name: "done", ...getTypeByORM("boolean"), default: getDefaultByORM("boolean", false) },
{ name: "description", ...getTypeByORM("text") }, { name: "description", ...getTypeByORM("text") },
{ name: "location", ...getTypeByORM("text") }, { name: "location", ...getTypeByORM("text") },
{ name: "note", ...getTypeByORM("text") }, { name: "noteByReporter", ...getTypeByORM("text") },
{ name: "noteByWorker", ...getTypeByORM("text") },
{ name: "reportedBy", ...getTypeByORM("varchar") }, { name: "reportedBy", ...getTypeByORM("varchar") },
{ name: "imageCount", ...getTypeByORM("int"), default: getDefaultByORM("number", 0) }, { name: "imageCount", ...getTypeByORM("int"), default: getDefaultByORM("number", 0) },
{ name: "equipmentId", ...getTypeByORM("uuid", true) }, { name: "equipmentId", ...getTypeByORM("uuid", true) },

View file

@ -27,7 +27,8 @@ export type DamageReportViewModel = {
done: boolean; done: boolean;
description: string; description: string;
location: string; location: string;
note: string; noteByReporter: string;
noteByWorker: string;
images: string[]; images: string[];
reportedBy: string; reportedBy: string;
maintenance?: MaintenanceViewModel; maintenance?: MaintenanceViewModel;