fix and add documents view
This commit is contained in:
@@ -68,33 +68,14 @@
|
||||
</section>
|
||||
}
|
||||
|
||||
@if (collected()) {
|
||||
<section>
|
||||
<h2>Ваше фото</h2>
|
||||
<button class="owned-photo" type="button" (click)="openPhoto()">
|
||||
<img
|
||||
[src]="userPhoto() ?? '/assets/illustrations/photo-day.svg'"
|
||||
alt="Ваше фото объекта"
|
||||
/>
|
||||
<span class="owned-photo__badge">
|
||||
<app-icon name="check" [size]="14" />
|
||||
Подтверждено
|
||||
</span>
|
||||
</button>
|
||||
<p class="object__hint">
|
||||
Этот объект уже в вашей коллекции. Повторно его получить нельзя.
|
||||
</p>
|
||||
</section>
|
||||
} @else {
|
||||
<section>
|
||||
<h2>Как забрать</h2>
|
||||
<ol class="steps">
|
||||
<li>Приезжайте на место и найдите объект</li>
|
||||
<li>Нажмите «Забрать» и сфотографируйте объект</li>
|
||||
<li>Получите объект в свою коллекцию</li>
|
||||
</ol>
|
||||
</section>
|
||||
}
|
||||
<section>
|
||||
<h2>Как забрать</h2>
|
||||
<ol class="steps">
|
||||
<li>Приезжайте на место и найдите объект</li>
|
||||
<li>Нажмите «Забрать» и сфотографируйте объект</li>
|
||||
<li>Получите объект в свою коллекцию</li>
|
||||
</ol>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
@if (!collected()) {
|
||||
@@ -108,22 +89,6 @@
|
||||
}
|
||||
</article>
|
||||
}
|
||||
|
||||
@if (photoOpen()) {
|
||||
@if (userPhoto(); as image) {
|
||||
<div class="photo-viewer" (click)="closePhoto()">
|
||||
<button
|
||||
class="photo-viewer__close"
|
||||
type="button"
|
||||
aria-label="Закрыть"
|
||||
(click)="closePhoto()"
|
||||
>
|
||||
<app-icon name="chevron-left" [size]="22" />
|
||||
</button>
|
||||
<img [src]="image" alt="Ваше фото объекта" (click)="$event.stopPropagation()" />
|
||||
</div>
|
||||
}
|
||||
}
|
||||
} @else if (status() === 'loading') {
|
||||
<section class="object object--empty">
|
||||
<p>Загружаем…</p>
|
||||
|
||||
@@ -13,12 +13,7 @@ import { MatButton } from '@angular/material/button';
|
||||
import { Router } from '@angular/router';
|
||||
import { Store } from '@ngrx/store';
|
||||
|
||||
import {
|
||||
areaOpenedCount,
|
||||
areaTotalCount,
|
||||
isObtained,
|
||||
type AreaDetails,
|
||||
} from '../../areas/area.models';
|
||||
import { areaOpenedCount, areaTotalCount, type AreaDetails } from '../../areas/area.models';
|
||||
import { ClaimFlow } from '../../claim/claim-flow/claim-flow';
|
||||
import { AudioGuide } from '../../shared/audio-guide/audio-guide';
|
||||
import { Icon } from '../../shared/icon/icon';
|
||||
@@ -32,7 +27,6 @@ import {
|
||||
selectAuthenticated,
|
||||
selectClaim,
|
||||
selectCollectedAt,
|
||||
selectCollectedIdSet,
|
||||
selectPhotos,
|
||||
} from '../../state';
|
||||
|
||||
@@ -63,28 +57,19 @@ export class MapItemPage {
|
||||
(): AreaDetails | null => this.details()[this.areaId()] ?? null,
|
||||
);
|
||||
protected readonly landmark = computed(() => this.attractions()[this.id()] ?? null);
|
||||
protected readonly collectedIds = this.store.selectSignal(selectCollectedIdSet);
|
||||
protected readonly photos = this.store.selectSignal(selectPhotos);
|
||||
protected readonly collectedAtMap = this.store.selectSignal(selectCollectedAt);
|
||||
protected readonly claim = this.store.selectSignal(selectClaim);
|
||||
protected readonly openedCount = computed(() => {
|
||||
const area = this.area();
|
||||
return area ? areaOpenedCount(area, this.collectedIds()) : 0;
|
||||
return area ? areaOpenedCount(area) : 0;
|
||||
});
|
||||
protected readonly totalCount = computed(() => {
|
||||
const area = this.area();
|
||||
return area ? areaTotalCount(area) : 0;
|
||||
});
|
||||
|
||||
protected readonly collected = computed(() => {
|
||||
const item = this.landmark();
|
||||
return item ? isObtained(item, this.collectedIds()) : false;
|
||||
});
|
||||
|
||||
protected readonly userPhoto = computed(() => {
|
||||
const item = this.landmark();
|
||||
return item ? (this.photos()[item.id] ?? null) : null;
|
||||
});
|
||||
protected readonly collected = computed(() => this.landmark()?.visited ?? false);
|
||||
|
||||
protected readonly collectedLabel = computed(() => {
|
||||
if (!this.collected()) {
|
||||
@@ -111,8 +96,6 @@ export class MapItemPage {
|
||||
return claim.landmarkId === this.id() && claim.stage !== 'idle';
|
||||
});
|
||||
|
||||
protected readonly photoOpen = signal(false);
|
||||
|
||||
constructor() {
|
||||
effect(() => {
|
||||
const areaId = this.areaId();
|
||||
@@ -147,19 +130,4 @@ export class MapItemPage {
|
||||
|
||||
this.store.dispatch(GorodarActions.authSheetOpened({ intent: 'claim', landmarkId: this.id() }));
|
||||
}
|
||||
|
||||
protected openPhoto(): void {
|
||||
if (this.userPhoto()) {
|
||||
this.photoOpen.set(true);
|
||||
}
|
||||
}
|
||||
|
||||
protected closePhoto(): void {
|
||||
this.photoOpen.set(false);
|
||||
}
|
||||
|
||||
@HostListener('document:keydown.escape')
|
||||
protected onEscape(): void {
|
||||
this.closePhoto();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import { inject } from '@angular/core';
|
||||
import { type CanActivateFn, Router } from '@angular/router';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { filter, map, take } from 'rxjs';
|
||||
|
||||
import { findAttraction } from '../../areas/area.models';
|
||||
import { GorodarActions, selectAreaDetails } from '../../state';
|
||||
|
||||
export const visitedItemGuard: CanActivateFn = (route) => {
|
||||
const store = inject(Store);
|
||||
const router = inject(Router);
|
||||
const areaId = route.paramMap.get('areaId') ?? '';
|
||||
const id = route.paramMap.get('id') ?? '';
|
||||
|
||||
store.dispatch(GorodarActions.areaRequested({ id: areaId }));
|
||||
|
||||
return store.select(selectAreaDetails).pipe(
|
||||
map((details) => {
|
||||
const area = details[areaId];
|
||||
return area ? findAttraction(area, id) : undefined;
|
||||
}),
|
||||
filter((item) => item !== undefined),
|
||||
take(1),
|
||||
map((item) => (item?.visited ? router.createUrlTree(['/city', areaId]) : true)),
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user