Files
front/src/app/claim/photo-check/photo-check.ts
T
2026-10-07 17:32:25 +03:00

49 lines
1.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { ChangeDetectionStrategy, Component, computed, input } from '@angular/core';
import { Icon } from '../../shared/icon/icon';
type StepState = 'done' | 'active' | 'wait';
@Component({
selector: 'app-photo-check',
imports: [Icon],
templateUrl: './photo-check.html',
styleUrl: './photo-check.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class PhotoCheck {
readonly photo = input.required<string>();
readonly title = input.required<string>();
readonly step = input(0);
protected readonly items = computed(() => {
const step = this.step();
return [
{
title: 'Фото отправлено',
text: step >= 1 ? 'Снимок получен сервисом' : 'Готовим снимок',
state: stepState(step, 0),
},
{
title: 'Сравниваем с эталонами',
text: `Ищем совпадение с ${this.title()}`,
state: stepState(step, 1),
},
{
title: 'Добавляем в коллекцию',
text: 'Объект появится в вашей коллекции',
state: stepState(step, 2),
},
];
});
}
function stepState(step: number, index: number): StepState {
if (step > index) {
return 'done';
}
return step === index ? 'active' : 'wait';
}