import { Company } from '../entities/company.entity'; import { ExternalProfile, } from '../entities/external-profile.entity'; import { ProfileType } from '../entities/company-profile.entity'; export class ResponseExternalProfileDto { id: string; userId: string; companyId: string; firstName: string; lastName: string; nationalId?: string | null; jobTitle?: string | null; isPrimaryContact: boolean; /** The active operational mode (importer/exporter/forwarder). */ activeProfileType?: ProfileType | null; /** * The id of the company_profile matching activeProfileType, resolved * server-side so the client never re-derives it. Null until a company * (with profiles) is loaded and a matching profile exists. */ activeCompanyProfileId?: string | null; onboardingStep?: string | null; onboardingCompleted: boolean; createdAt: Date; updatedAt: Date; constructor(profile: ExternalProfile, company?: Company) { this.id = profile.id; this.userId = profile.userId; this.companyId = profile.companyId; this.firstName = profile.firstName; this.lastName = profile.lastName; this.nationalId = profile.nationalId; this.jobTitle = profile.jobTitle; this.isPrimaryContact = profile.isPrimaryContact; this.activeProfileType = profile.activeProfileType ?? null; this.onboardingStep = profile.onboardingStep ?? null; this.onboardingCompleted = profile.onboardingCompleted ?? false; this.activeCompanyProfileId = company?.companyProfiles?.find( (p) => p.type === profile.activeProfileType, )?.id ?? null; this.createdAt = profile.createdAt; this.updatedAt = profile.updatedAt; } }