import { ChangeDetectionStrategy, Component, computed, input, output } from '@angular/core'; import { PiActionButtonComponent, PiCardBottomContentDirective, PiCardCenterContentDirective, PiCardComponent, PiCardTopContentDirective, PiChipComponent, PiTextColorDirective, PiTextSmallDirective, PiTextWeightBoldDirective, PiTextXSmallDirective, } from '@pi/ui'; import type { Copy } from '../core/copy'; import type { Locale } from '../core/api'; import type { PublicCall } from '../core/api.types'; import { TechnologyChip } from './technology-chip'; import { LinkButton } from './link-button'; @Component({ selector: 'app-call-card', changeDetection: ChangeDetectionStrategy.OnPush, imports: [ PiCardComponent, PiCardTopContentDirective, PiCardCenterContentDirective, PiCardBottomContentDirective, PiChipComponent, PiActionButtonComponent, PiTextSmallDirective, PiTextXSmallDirective, PiTextColorDirective, PiTextWeightBoldDirective, TechnologyChip, LinkButton, ], template: `
@if (hours(); as label) { } @if (weeks(); as label) { } @if (call().seniority; as seniority) { }

@if (call().path; as path) { {{ call().title }} } @else { {{ call().title }} }

@if (call().project?.title; as project) {

{{ project }}

} @if (call().description; as description) {

{{ description }}

} @if (call().technologies?.length) { }
`, }) export class CallCard { readonly call = input.required(); readonly copy = input.required(); readonly locale = input.required(); readonly apply = output(); // `pi-chip-value` renders the number and its unit as adjacent spans with no // separation, so "4h/semana" comes out as one word. Built here instead. protected readonly hours = computed(() => { const hours = this.call().hours_per_week; return hours ? `${hours} ${this.copy().labels.hoursPerWeek}` : null; }); protected readonly weeks = computed(() => { const weeks = this.call().duration_weeks; return weeks ? `${weeks} ${this.copy().labels.weeks}` : null; }); protected readonly closesAt = computed(() => { const value = this.call().closes_at; if (!value) { return null; } return new Intl.DateTimeFormat(this.locale(), { day: 'numeric', month: 'long', }).format(new Date(value)); }); }