feat: add refresh functionality to various components
- Implemented refresh event emission in multiple list components across partner and superAdmin modules. - Updated consumers and customers list components to handle refresh actions. - Enhanced dashboard component to fetch partner info on initialization. - Introduced new API method in PartnerService to retrieve current partner data. - Modified PartnerStore to utilize the new API method for fetching partner information. - Updated UI elements to reflect changes in partner and license management, including new fields for license renewals. - Added a new POS display component for better presentation of POS terminal information. - Updated layout service and top bar to reflect new titles and improve user experience. - Refactored existing components to ensure consistency and maintainability.
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import { defaultBaseStateData, EntityState, EntityStore } from '@/core/state';
|
||||
import { IPartnerInfoResponse } from '@/domains/partner/models';
|
||||
import { PartnerService } from '@/domains/partner/services/main.service';
|
||||
import { LayoutService } from '@/layout/service/layout.service';
|
||||
import { inject, Injectable } from '@angular/core';
|
||||
import { catchError, finalize } from 'rxjs';
|
||||
|
||||
interface PartnerInfoState extends EntityState<IPartnerInfoResponse> {}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class PartnerInfoStore extends EntityStore<IPartnerInfoResponse, PartnerInfoState> {
|
||||
private readonly service = inject(PartnerService);
|
||||
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.setEntity(entity);
|
||||
});
|
||||
}
|
||||
|
||||
override reset(): void {
|
||||
this.setState({ ...defaultBaseStateData });
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,18 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { Component, computed, inject } from '@angular/core';
|
||||
import { PartnerInfoStore } from '../store/main.store';
|
||||
|
||||
@Component({
|
||||
selector: 'partner-dashboard',
|
||||
templateUrl: './index.component.html',
|
||||
})
|
||||
export class DashboardComponent {}
|
||||
export class DashboardComponent {
|
||||
private readonly store = inject(PartnerInfoStore);
|
||||
|
||||
readonly loading = computed(() => this.store.loading());
|
||||
readonly entity = computed(() => this.store.entity());
|
||||
readonly error = computed(() => this.store.error());
|
||||
|
||||
ngOnInit() {
|
||||
this.store.getData();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user