c135e1a85f
- Replaced individual state properties (loading, error, entity, initialized, isRefreshing) with a spread of defaultBaseStateData in various entity stores including AccountStore, BusinessActivityStore, ConsumerComplexStore, PosStore, and others. - Updated imports to include defaultBaseStateData in relevant store files. - Enhanced consistency in state management across multiple stores. feat: add partner profile management components and services - Introduced PartnerProfileFormComponent and PartnerResetPasswordCardComponent for profile editing and password reset functionalities. - Created ProfileService to handle API interactions for partner profile management. - Added routes and constants for partner profile API and navigation. - Implemented UI components for displaying and editing partner profile information in single.component.html and single.component.ts.
54 lines
1.5 KiB
TypeScript
54 lines
1.5 KiB
TypeScript
import { defaultBaseStateData, EntityState, EntityStore } from '@/core/state';
|
|
import { LayoutService } from '@/layout/service/layout.service';
|
|
import { inject, Injectable } from '@angular/core';
|
|
import { catchError, finalize } from 'rxjs';
|
|
import { IConsumerInfoResponse } from '../models';
|
|
import { consumerProfileNamedRoutes } from '../modules/profile/constants';
|
|
import { ConsumerService } from '../services/main.service';
|
|
|
|
interface ConsumerState extends EntityState<IConsumerInfoResponse> {}
|
|
|
|
@Injectable({
|
|
providedIn: 'root',
|
|
})
|
|
export class ConsumerStore extends EntityStore<IConsumerInfoResponse, ConsumerState> {
|
|
private readonly service = inject(ConsumerService);
|
|
private readonly layoutService = inject(LayoutService);
|
|
|
|
constructor() {
|
|
super({
|
|
...defaultBaseStateData,
|
|
});
|
|
}
|
|
|
|
getData() {
|
|
this.patchState({ loading: true });
|
|
this.service
|
|
.getInfo()
|
|
.pipe(
|
|
finalize(() => {
|
|
this.patchState({ loading: false });
|
|
}),
|
|
catchError((error) => {
|
|
this.setError(error);
|
|
throw error;
|
|
}),
|
|
)
|
|
.subscribe((entity) => {
|
|
this.layoutService.setPanelInfo({
|
|
title: 'پنل مدیریت صورتحسابهای مالیاتی',
|
|
});
|
|
this.layoutService.setProfilePageRoute(
|
|
consumerProfileNamedRoutes.profile.meta!.pagePath!(),
|
|
);
|
|
this.patchState({ entity });
|
|
});
|
|
}
|
|
|
|
override reset(): void {
|
|
this.setState({
|
|
...defaultBaseStateData,
|
|
});
|
|
}
|
|
}
|