(false);
+
+ readonly loading = computed(() => this.store.loading());
+ readonly customer = computed(() => this.store.entity());
+ readonly customerBreadcrumb = computed(() => this.store.breadcrumbItems());
+
+ constructor() {
+ effect(() => {
+ if (this.customer()?.id) {
+ this.setBreadcrumb();
+ }
+ });
+ }
+
+ getData() {
+ this.store.getData(this.customerId());
+ }
+
+ setBreadcrumb() {
+ this.breadcrumbService.setItems(this.customerBreadcrumb());
+ }
+}
diff --git a/src/app/domains/partner/modules/dashboard/views/index.component.html b/src/app/domains/partner/modules/dashboard/views/index.component.html
index bcac5c5..541972f 100644
--- a/src/app/domains/partner/modules/dashboard/views/index.component.html
+++ b/src/app/domains/partner/modules/dashboard/views/index.component.html
@@ -1,3 +1 @@
-
- به پنل کسب و کار خوش آمدید
-
+به پنل مدیریتی شریک تجاری خوش آمدید.
diff --git a/src/app/domains/partner/modules/dashboard/views/index.component.ts b/src/app/domains/partner/modules/dashboard/views/index.component.ts
index 4ad28f7..8428f5a 100644
--- a/src/app/domains/partner/modules/dashboard/views/index.component.ts
+++ b/src/app/domains/partner/modules/dashboard/views/index.component.ts
@@ -4,6 +4,4 @@ import { Component } from '@angular/core';
selector: 'partner-dashboard',
templateUrl: './index.component.html',
})
-export class DashboardComponent {
- constructor() {}
-}
+export class DashboardComponent {}
diff --git a/src/app/domains/partner/routes.ts b/src/app/domains/partner/routes.ts
index 94a6969..72120ea 100644
--- a/src/app/domains/partner/routes.ts
+++ b/src/app/domains/partner/routes.ts
@@ -1,13 +1,17 @@
import { Route } from '@angular/router';
+import { PARTNER_ACCOUNTS_ROUTES } from './modules/accounts/constants';
+import { PARTNER_CUSTOMERS_ROUTES } from './modules/customers/constants';
export const PARTNER_ROUTES = {
path: 'partner',
- component: undefined,
+ loadComponent: () => import('./layouts/layout.component').then((m) => m.LayoutComponent),
children: [
{
path: '',
loadComponent: () =>
import('./modules/dashboard/views/index.component').then((m) => m.DashboardComponent),
},
+ ...PARTNER_ACCOUNTS_ROUTES,
+ ...PARTNER_CUSTOMERS_ROUTES,
],
} as Route;
diff --git a/src/app/domains/partner/services/main.service.ts b/src/app/domains/partner/services/main.service.ts
new file mode 100644
index 0000000..5e91166
--- /dev/null
+++ b/src/app/domains/partner/services/main.service.ts
@@ -0,0 +1,16 @@
+import { HttpClient } from '@angular/common/http';
+import { Injectable } from '@angular/core';
+import { Observable } from 'rxjs';
+import { PARTNER_API_ROUTES } from '../constants';
+import { IPartnerInfoRawResponse, IPartnerInfoResponse } from '../models';
+
+@Injectable({ providedIn: 'root' })
+export class PartnerService {
+ constructor(private http: HttpClient) {}
+
+ private apiRoutes = PARTNER_API_ROUTES;
+
+ getInfo(): Observable {
+ return this.http.get(this.apiRoutes.info());
+ }
+}
diff --git a/src/app/domains/partner/store/main.store.ts b/src/app/domains/partner/store/main.store.ts
new file mode 100644
index 0000000..0a41df2
--- /dev/null
+++ b/src/app/domains/partner/store/main.store.ts
@@ -0,0 +1,57 @@
+import { EntityState, EntityStore } from '@/core/state';
+import { LayoutService } from '@/layout/service/layout.service';
+import { inject, Injectable } from '@angular/core';
+import { catchError, finalize } from 'rxjs';
+import { IPartnerInfoResponse } from '../models';
+import { PartnerService } from '../services/main.service';
+
+interface PartnerState extends EntityState {}
+
+@Injectable({
+ providedIn: 'root',
+})
+export class PartnerStore extends EntityStore {
+ private readonly service = inject(PartnerService);
+ private readonly layoutService = inject(LayoutService);
+
+ constructor() {
+ super({
+ loading: false,
+ error: null,
+ entity: null,
+ initialized: false,
+ isRefreshing: false,
+ });
+ }
+
+ 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: `پنل مدیریتی ${entity.name}`,
+ });
+ this.setEntity(entity);
+ });
+ }
+
+ override reset(): void {
+ this.setState({
+ loading: false,
+ error: null,
+ entity: null,
+ initialized: false,
+ isRefreshing: false,
+ });
+ }
+}