- Implemented TourProgressController to handle API endpoints for tracking guided tours seen by users. - Created UserTourProgress entity to store the highest version of tours seen by each user. - Developed UserTourProgressRepository for database interactions related to user tour progress. - Introduced TourProgressService to manage business logic for marking tours as seen and retrieving seen maps. - Added comprehensive tests for API endpoints and entity behavior to ensure functionality and data integrity.
15 lines
692 B
TypeScript
15 lines
692 B
TypeScript
import type { TourStep } from './types';
|
|
|
|
export function anchorSelector(anchor: string): string {
|
|
return `[data-tour="${anchor}"]`;
|
|
}
|
|
|
|
/**
|
|
* فقط استپهایی میمانند که المانشان همین حالا در DOM هست.
|
|
* صفحات پنل نقشمحورند: «افزودن نوبت» برای منشیِ بدون مجوز اصلاً رندر نمیشود و
|
|
* تور نباید روی المان غایب گیر کند یا شمارندهٔ اشتباه نشان بدهد.
|
|
*/
|
|
export function resolveSteps(steps: TourStep[], root: ParentNode = document): TourStep[] {
|
|
return steps.filter((s) => root.querySelector(anchorSelector(s.anchor)) !== null);
|
|
}
|