diff --git a/src/app/core/services/form-errors.service.ts b/src/app/core/services/form-errors.service.ts index 4c1444d..a2f7997 100644 --- a/src/app/core/services/form-errors.service.ts +++ b/src/app/core/services/form-errors.service.ts @@ -68,6 +68,11 @@ export class FormErrorsService { const info = errors['invalidUsername']; out.push({ key: 'invalidUsername', message: info.message ?? `${label} معتبر نیست.` }); } + + if (errors['invalidFiscalId']) { + const info = errors['invalidFiscalId']; + out.push({ key: 'invalidFiscalId', message: info.message ?? `${label} معتبر نیست.` }); + } // fallback: include any other error keys Object.keys(errors).forEach((k) => { if ( @@ -80,6 +85,7 @@ export class FormErrorsService { 'max', 'email', 'pattern', + 'invalidFiscalId', ].indexOf(k) === -1 ) { try { diff --git a/src/app/core/validators/fiscal-code.validator.ts b/src/app/core/validators/fiscal-code.validator.ts deleted file mode 100644 index 5c45867..0000000 --- a/src/app/core/validators/fiscal-code.validator.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { ValidatorFn } from '@angular/forms'; - -export function fiscalCodeValidator(): ValidatorFn { - return (control) => { - if (control.value === null || control.value === undefined || control.value === '') { - return null; - } - return null; - return control.value.length === 11 && /^[0-9]{11}$/.test(control.value) - ? null - : { fiscalCode: 'معتبر نیست' }; - }; -} diff --git a/src/app/core/validators/fiscal-id.validator.ts b/src/app/core/validators/fiscal-id.validator.ts new file mode 100644 index 0000000..48286d7 --- /dev/null +++ b/src/app/core/validators/fiscal-id.validator.ts @@ -0,0 +1,30 @@ +import { ValidatorFn } from '@angular/forms'; + +export function fiscalIdValidator(): ValidatorFn { + return (control) => { + if (control.value === null || control.value === undefined || control.value === '') { + return null; + } + + if (control.value.length < 6) { + return { + minlength: { + requiredLength: 6, + actualLength: control.value.length, + }, + }; + } + + const pattern = /^[a-zA-Z0-9]*$/; + + if (!pattern.test(control.value)) { + return { + invalidFiscalId: { + value: control.value, + message: 'شناسه مالی فقط میتواند شامل حروف انگلیسی و اعداد باشد', + }, + }; + } + return null; + }; +} diff --git a/src/app/core/validators/index.ts b/src/app/core/validators/index.ts index a484f07..a0cb048 100644 --- a/src/app/core/validators/index.ts +++ b/src/app/core/validators/index.ts @@ -1,4 +1,4 @@ -export * from './fiscal-code.validator'; +export * from './fiscal-id.validator'; export * from './greater.validator'; export * from './iban.validator'; export * from './mobile.validator'; diff --git a/src/app/core/validators/password.validator.ts b/src/app/core/validators/password.validator.ts index ed520a4..a852857 100644 --- a/src/app/core/validators/password.validator.ts +++ b/src/app/core/validators/password.validator.ts @@ -1,16 +1,21 @@ import { ValidatorFn } from '@angular/forms'; -// Password must be minimum 8 characters, include at least one uppercase, -// one lowercase, one number and one special character -// export const PASSWORD_PATTERN = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^A-Za-z0-9]).{8,}$/; -export const PASSWORD_PATTERN = /^[0-9]{6,}$/; +// const PASSWORD_PATTERN = /^[a-zA-Z0-9_-]*$/; -// Validator factory named `password` as requested. Returns `null` for empty -// values so `Validators.required` can be used alongside it when needed. export function password(): ValidatorFn { return (control) => { const value = control?.value; if (value === null || value === undefined || String(value).length === 0) return null; - return PASSWORD_PATTERN.test(String(value)) ? null : { password: 'معتبر نیست' }; + + if (value.length < 6) { + return { + minlength: { + requiredLength: 6, + actualLength: value.length, + }, + }; + } + return null; + // return PASSWORD_PATTERN.test(String(value)) ? null : { password: 'معتبر نیست' }; }; } diff --git a/src/app/domains/consumer/constants/menuItems.const.ts b/src/app/domains/consumer/constants/menuItems.const.ts index f822ed6..a179cde 100644 --- a/src/app/domains/consumer/constants/menuItems.const.ts +++ b/src/app/domains/consumer/constants/menuItems.const.ts @@ -9,28 +9,28 @@ export const CONSUMER_MENU_ITEMS = [ }, { label: 'فعالیت اقتصادی', - icon: 'pi pi-fw pi-home', + icon: 'pi pi-fw pi-shop', routerLink: ['/consumer/business_activities'], }, { - label: 'پایانههای فروش', - icon: 'pi pi-fw pi-home', + label: 'پایانهی فروش', + icon: 'pi pi-fw pi-tablet', routerLink: ['/consumer/poses'], }, { label: 'فاکتورها', - icon: 'pi pi-fw pi-home', + icon: 'pi pi-fw pi-receipt', routerLink: ['/consumer/sale_invoices'], }, { label: 'مشتریها', - icon: 'pi pi-fw pi-home', + icon: 'pi pi-fw pi-users', routerLink: ['/consumer/customers'], }, { label: 'حسابهای کاربری', - icon: 'pi pi-fw pi-home', + icon: 'pi pi-fw pi-user', routerLink: ['/consumer/accounts'], }, ], diff --git a/src/app/domains/consumer/modules/businessActivities/components/form.component.html b/src/app/domains/consumer/modules/businessActivities/components/form.component.html index 5bc388e..73dc803 100644 --- a/src/app/domains/consumer/modules/businessActivities/components/form.component.html +++ b/src/app/domains/consumer/modules/businessActivities/components/form.component.html @@ -9,7 +9,7 @@