diff --git a/angular.json b/angular.json index 028588d..c235ae2 100644 --- a/angular.json +++ b/angular.json @@ -116,6 +116,10 @@ } ], "fileReplacements": [ + { + "replace": "src/config.ts", + "with": "src/tenants/tis/config.ts" + }, { "replace": "src/assets/images/brandingAssets.ts", "with": "src/tenants/tis/brandingAssets.ts" diff --git a/ngsw-config.json b/ngsw-config.json index 9e4c54b..9ff9b73 100644 --- a/ngsw-config.json +++ b/ngsw-config.json @@ -2,7 +2,7 @@ "$schema": "./node_modules/@angular/service-worker/config/schema.json", "appData": { "appVersion": "0.0.0", - "buildDate": "2026-05-11T09:56:45.724Z" + "buildDate": "2026-05-11T10:08:38.776Z" }, "assetGroups": [ { diff --git a/scripts/tis/update-tis-ngsw-appdata.js b/scripts/tis/update-tis-ngsw-appdata.js index 9af3fab..8be5001 100644 --- a/scripts/tis/update-tis-ngsw-appdata.js +++ b/scripts/tis/update-tis-ngsw-appdata.js @@ -10,11 +10,20 @@ const ngswConfig = JSON.parse(fs.readFileSync(ngswConfigPath, 'utf8')); const now = new Date(); const buildDate = process.env.TIS_BUILD_DATE || now.toISOString(); -const appVersion = process.env.TIS_APP_VERSION || packageJson.version || '0.0.0'; +const previousAppVersion = ngswConfig.appData?.appVersion || packageJson.version || '0.0.0'; +const appVersion = + process.env.TIS_APP_VERSION || + previousAppVersion.replace( + /^(\d+)\.(\d+)\.(\d+)$/, + (_, major, minor, patch) => `${major}.${minor}.${Number(patch) + 1}`, + ); +const previousBuildNumber = Number(ngswConfig.appData?.buildNumber || 0); +const buildNumber = Number(process.env.TIS_BUILD_NUMBER || previousBuildNumber + 1); ngswConfig.appData = { ...(ngswConfig.appData || {}), appVersion, + buildNumber, buildDate, }; diff --git a/scripts/update-ngsw-appdata.js b/scripts/update-ngsw-appdata.js index a357ea3..6c867a8 100644 --- a/scripts/update-ngsw-appdata.js +++ b/scripts/update-ngsw-appdata.js @@ -10,11 +10,20 @@ const ngswConfig = JSON.parse(fs.readFileSync(ngswConfigPath, 'utf8')); const now = new Date(); const buildDate = process.env.BUILD_DATE || now.toISOString(); -const appVersion = process.env.APP_VERSION || packageJson.version || '0.0.0'; +const previousAppVersion = ngswConfig.appData?.appVersion || packageJson.version || '0.0.0'; +const appVersion = + process.env.APP_VERSION || + previousAppVersion.replace( + /^(\d+)\.(\d+)\.(\d+)$/, + (_, major, minor, patch) => `${major}.${minor}.${Number(patch) + 1}`, + ); +const previousBuildNumber = Number(ngswConfig.appData?.buildNumber || 0); +const buildNumber = Number(process.env.BUILD_NUMBER || previousBuildNumber + 1); ngswConfig.appData = { ...(ngswConfig.appData || {}), appVersion, + buildNumber, buildDate, }; diff --git a/src/app/domains/pos/modules/about/constants/routes/index.ts b/src/app/domains/pos/modules/about/constants/routes/index.ts index 7c6a058..5ca3e29 100644 --- a/src/app/domains/pos/modules/about/constants/routes/index.ts +++ b/src/app/domains/pos/modules/about/constants/routes/index.ts @@ -1,7 +1,9 @@ import { NamedRoutes } from '@/core'; import { Routes } from '@angular/router'; +import config from 'src/config'; export type TPosAboutRouteNames = 'about'; +const baseRoute = `${config.isPosApplication ? '' : '/pos'}/about`; export const posAboutNamedRoutes: NamedRoutes = { about: { @@ -9,7 +11,7 @@ export const posAboutNamedRoutes: NamedRoutes = { loadComponent: () => import('../../views/root.component').then((m) => m.PosAboutPageComponent), meta: { title: 'درباره سیستم', - pagePath: () => '/pos/about', + pagePath: () => baseRoute, }, }, }; diff --git a/src/app/domains/pos/modules/saleInvoices/constants/routes/index.ts b/src/app/domains/pos/modules/saleInvoices/constants/routes/index.ts index fa1ea02..f19c1e1 100644 --- a/src/app/domains/pos/modules/saleInvoices/constants/routes/index.ts +++ b/src/app/domains/pos/modules/saleInvoices/constants/routes/index.ts @@ -1,23 +1,28 @@ import { NamedRoutes } from '@/core'; import { Routes } from '@angular/router'; +import config from 'src/config'; export type TPosSaleInvoicesRouteNames = 'saleInvoices' | 'saleInvoice'; +const baseRoute = `${config.isPosApplication ? '' : '/pos'}/sale_invoices`; + export const posSaleInvoicesNamedRoutes: NamedRoutes = { saleInvoices: { path: 'sale_invoices', - loadComponent: () => import('../../views/list.component').then((m) => m.PosSaleInvoicesComponent), + loadComponent: () => + import('../../views/list.component').then((m) => m.PosSaleInvoicesComponent), meta: { title: 'فاکتورها', - pagePath: () => `/pos/sale_invoices`, + pagePath: () => baseRoute, }, }, saleInvoice: { path: 'sale_invoices/:invoiceId', - loadComponent: () => import('../../views/single.component').then((m) => m.PosSaleInvoiceComponent), + loadComponent: () => + import('../../views/single.component').then((m) => m.PosSaleInvoiceComponent), meta: { title: 'جزئیات فاکتور', - pagePath: (invoiceId: string) => `/pos/sale_invoices/${invoiceId}`, + pagePath: (invoiceId: string) => `${baseRoute}/${invoiceId}`, }, }, }; diff --git a/src/app/domains/pos/modules/support/constants/routes/index.ts b/src/app/domains/pos/modules/support/constants/routes/index.ts index 446511f..ac814b8 100644 --- a/src/app/domains/pos/modules/support/constants/routes/index.ts +++ b/src/app/domains/pos/modules/support/constants/routes/index.ts @@ -1,7 +1,9 @@ import { NamedRoutes } from '@/core'; import { Routes } from '@angular/router'; +import config from 'src/config'; export type TPosSupportRouteNames = 'support'; +const baseRoute = `${config.isPosApplication ? '' : '/pos'}/support`; export const posSupportNamedRoutes: NamedRoutes = { support: { @@ -10,7 +12,7 @@ export const posSupportNamedRoutes: NamedRoutes = { import('../../views/root.component').then((m) => m.PosSupportPageComponent), meta: { title: 'پشتیبانی', - pagePath: () => '/pos/support', + pagePath: () => baseRoute, }, }, }; diff --git a/src/app/layout/default/app.layout.component.ts b/src/app/layout/default/app.layout.component.ts index 35c9a59..5f56b42 100644 --- a/src/app/layout/default/app.layout.component.ts +++ b/src/app/layout/default/app.layout.component.ts @@ -5,6 +5,7 @@ import { CommonModule } from '@angular/common'; import { Component, computed, ContentChild, inject, Renderer2, TemplateRef } from '@angular/core'; import { NavigationEnd, Router, RouterModule } from '@angular/router'; import { filter, Subscription } from 'rxjs'; +import config from 'src/config'; import { LayoutService } from '../service/layout.service'; import { AppFooter } from './app.footer.component'; import { AppSidebar } from './app.sidebar.component'; @@ -137,29 +138,33 @@ export class AppLayout { this.layoutService.topbarCenterSlot$.subscribe((tpl) => (this.topBarCenterAction = tpl)); this.layoutService.topbarEndSlot$.subscribe((tpl) => (this.topBarEndAction = tpl)); - // if (window.location.pathname === '/') { - // if (!this.authService.currentAccount()) { - // this.router.navigateByUrl('auth'); - // } - // switch (this.authService.currentAccount()?.type) { - // case 'ADMIN': - // this.router.navigateByUrl('super_admin'); - // break; - // case 'CONSUMER': - // if (this.authService.currentAccount()?.role === 'OWNER') - // this.router.navigateByUrl('consumer'); - // // else { - // // this.router.navigateByUrl('pos'); - // // } - // break; - // case 'PARTNER': - // this.router.navigateByUrl('partner'); - // break; - // case 'PROVIDER': - // this.router.navigateByUrl('provider'); - // break; - // } - // } + if (window.location.pathname === '/') { + if (!this.authService.currentAccount()) { + this.router.navigateByUrl('auth'); + } + + let redirectUrl = ''; + + switch (this.authService.currentAccount()?.type) { + case 'ADMIN': + redirectUrl = '/super_admin'; + break; + case 'PROVIDER': + redirectUrl = '/provider'; + break; + case 'PARTNER': + redirectUrl = '/partner'; + break; + case 'CONSUMER': + if (this.authService.currentAccount()?.role === 'OWNER') { + redirectUrl = '/consumer'; + } else { + redirectUrl = config.isPosApplication ? '/' : '/pos'; + } + break; + } + this.router.navigateByUrl(redirectUrl); + } } ngOnDestroy() { diff --git a/src/app/modules/auth/pages/auth.component.ts b/src/app/modules/auth/pages/auth.component.ts index 0284402..47403ee 100644 --- a/src/app/modules/auth/pages/auth.component.ts +++ b/src/app/modules/auth/pages/auth.component.ts @@ -3,6 +3,7 @@ import { ToastService } from '@/core/services/toast.service'; import { Component, EventEmitter, inject, Input, Output, signal } from '@angular/core'; import { Router } from '@angular/router'; import images from 'src/assets/images'; +import config from 'src/config'; import { LoginComponent } from './login/login.component'; type TSteps = 'login' | 'otp' | 'modifyLoginInfo' | 'signup'; @@ -74,7 +75,7 @@ export class AuthComponent { break; case 'CONSUMER': if (this.accountRole() === 'OPERATOR') { - redirectUrl = '/pos'; + redirectUrl = config.isPosApplication ? '/' : '/pos'; } else { redirectUrl = '/consumer'; } diff --git a/src/app/modules/auth/pages/login/login.component.html b/src/app/modules/auth/pages/login/login.component.html index 388f3ce..37eb9b8 100644 --- a/src/app/modules/auth/pages/login/login.component.html +++ b/src/app/modules/auth/pages/login/login.component.html @@ -1,4 +1,4 @@ -
+ - -
- - -
+
-
diff --git a/src/config.ts b/src/config.ts new file mode 100644 index 0000000..f854dd2 --- /dev/null +++ b/src/config.ts @@ -0,0 +1,3 @@ +export default { + isPosApplication: false, +}; diff --git a/src/tenants/tis/config.ts b/src/tenants/tis/config.ts new file mode 100644 index 0000000..52a9020 --- /dev/null +++ b/src/tenants/tis/config.ts @@ -0,0 +1,3 @@ +export default { + isPosApplication: true, +};