add pages
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
import { createFeature, createReducer, on } from '@ngrx/store';
|
||||
|
||||
import { GorodarActions } from './gorodar.actions';
|
||||
import type { ClaimState, GorodarState } from './gorodar.models';
|
||||
|
||||
const initialClaim: ClaimState = {
|
||||
landmarkId: null,
|
||||
photo: null,
|
||||
stage: 'idle',
|
||||
step: 1,
|
||||
};
|
||||
|
||||
export const initialState: GorodarState = {
|
||||
collectedIds: [],
|
||||
photos: {},
|
||||
collectedAt: {},
|
||||
claim: initialClaim,
|
||||
profile: {
|
||||
displayName: 'Иван Иванович',
|
||||
firstName: 'Иван',
|
||||
lastName: 'Иванов',
|
||||
city: 'Нижний Новгород',
|
||||
email: 'ivan.ivanovich@gorodar.app',
|
||||
phone: '+7 900 123-45-67',
|
||||
joinedLabel: 'Сентябрь 2026',
|
||||
},
|
||||
};
|
||||
|
||||
const gorodarReducer = createReducer(
|
||||
initialState,
|
||||
on(GorodarActions.photoCaptured, (state, { landmarkId, photo }): GorodarState => ({
|
||||
...state,
|
||||
claim: {
|
||||
landmarkId,
|
||||
photo,
|
||||
stage: 'check',
|
||||
step: 1,
|
||||
},
|
||||
})),
|
||||
on(GorodarActions.claimStepChanged, (state, { step }): GorodarState => ({
|
||||
...state,
|
||||
claim: {
|
||||
...state.claim,
|
||||
step,
|
||||
},
|
||||
})),
|
||||
on(GorodarActions.claimCompleted, (state, { landmarkId, photo, collectedAt }): GorodarState => ({
|
||||
...state,
|
||||
collectedIds: state.collectedIds.includes(landmarkId)
|
||||
? state.collectedIds
|
||||
: [...state.collectedIds, landmarkId],
|
||||
photos: {
|
||||
...state.photos,
|
||||
[landmarkId]: photo,
|
||||
},
|
||||
collectedAt: {
|
||||
...state.collectedAt,
|
||||
[landmarkId]: collectedAt,
|
||||
},
|
||||
claim: {
|
||||
landmarkId,
|
||||
photo,
|
||||
stage: 'success',
|
||||
step: 3,
|
||||
},
|
||||
})),
|
||||
on(GorodarActions.claimReset, (state): GorodarState => ({
|
||||
...state,
|
||||
claim: initialClaim,
|
||||
})),
|
||||
);
|
||||
|
||||
export const gorodarFeature = createFeature({
|
||||
name: 'gorodar',
|
||||
reducer: gorodarReducer,
|
||||
});
|
||||
Reference in New Issue
Block a user