- Implemented CompanyLogoUseCases for retrieving, saving, and removing company logos. - Created CompanyLogoError class for error handling related to logo operations. - Developed CompanyLogoProcessor to optimize and validate logo images. - Added HTTP routes for logo management, including GET and POST endpoints. - Created Sequelize-based repository for logo persistence. - Implemented migration for adding logoVersion to companies and creating company_logos table. - Added frontend components for displaying and managing company logos, including avatar and logo upload fields. - Wrote tests for logo processing and avatar components to ensure functionality and correctness.
43 lines
1.4 KiB
TypeScript
43 lines
1.4 KiB
TypeScript
import { z } from "zod/v4";
|
|
|
|
import { CompanyLogoVersionSchema } from "../../company-logo";
|
|
|
|
import {
|
|
DepartmentAssignmentSchema,
|
|
DepartmentSchema,
|
|
PersonFieldsSchema,
|
|
PersonSchema,
|
|
} from "./people.dto";
|
|
|
|
const RequiredTextSchema = z
|
|
.string()
|
|
.min(1)
|
|
.max(100)
|
|
.refine((value) => value.trim().length > 0);
|
|
export const CompanyFieldsSchema = z.strictObject({
|
|
name: RequiredTextSchema,
|
|
active: z.boolean(),
|
|
});
|
|
export const ContactFieldsSchema = PersonFieldsSchema.omit({ isContact: true });
|
|
export const SiteFieldsSchema = z.strictObject({
|
|
name: RequiredTextSchema,
|
|
address: z.string().max(10000).nullable(),
|
|
});
|
|
export const CompanySummarySchema = CompanyFieldsSchema.extend({
|
|
id: z.uuid(),
|
|
logoVersion: CompanyLogoVersionSchema.nullable().optional(),
|
|
});
|
|
export type CompanySummaryDTO = z.infer<typeof CompanySummarySchema>;
|
|
export const ContactSchema = PersonSchema;
|
|
export type ContactDTO = z.infer<typeof ContactSchema>;
|
|
export const SiteSchema = SiteFieldsSchema.extend({ id: z.uuid(), companyId: z.uuid() });
|
|
export type SiteDTO = z.infer<typeof SiteSchema>;
|
|
export const CompanySchema = CompanySummarySchema.extend({
|
|
contacts: z.array(ContactSchema),
|
|
sites: z.array(SiteSchema),
|
|
people: z.array(PersonSchema),
|
|
departments: z.array(DepartmentSchema),
|
|
assignments: z.array(DepartmentAssignmentSchema),
|
|
});
|
|
export type CompanyDTO = z.infer<typeof CompanySchema>;
|