refactor: remove change password form and related service, update root component to use tabs
This commit is contained in:
@@ -1,9 +1,11 @@
|
|||||||
import { ToastService } from '@/core/services/toast.service';
|
import { ToastService } from '@/core/services/toast.service';
|
||||||
import { AbstractDialog } from '@/shared/abstractClasses/abstract-dialog';
|
import { AbstractDialog } from '@/shared/abstractClasses/abstract-dialog';
|
||||||
import { ChangePasswordFormDialogComponent } from '@/shared/components';
|
import {
|
||||||
|
ChangePasswordFormDialogComponent,
|
||||||
|
IChangePasswordSubmitPayload,
|
||||||
|
} from '@/shared/components';
|
||||||
import { Component, inject, signal } from '@angular/core';
|
import { Component, inject, signal } from '@angular/core';
|
||||||
import { finalize } from 'rxjs';
|
import { finalize } from 'rxjs';
|
||||||
import { IChangePasswordSubmitPayload } from '../modules/configs/components/changePassword/model';
|
|
||||||
import { PosChangePasswordService } from '../services/password';
|
import { PosChangePasswordService } from '../services/password';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
<app-card-data cardTitle="تغییر گذرواژه" class="w-full">
|
|
||||||
<form [formGroup]="form" (submit)="submit()" class="flex flex-col gap-4">
|
|
||||||
<shared-password-input
|
|
||||||
[passwordControl]="form.controls.password"
|
|
||||||
[confirmPasswordControl]="form.controls.confirmPassword" />
|
|
||||||
|
|
||||||
<div class="flex w-full justify-end">
|
|
||||||
<button pButton label="ذخیره گذرواژه" [loading]="submitLoading()" class="w-full max-w-40"></button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</app-card-data>
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
import { MustMatch } from '@/core/validators';
|
|
||||||
import { AbstractForm } from '@/shared/abstractClasses';
|
|
||||||
import { AppCardComponent } from '@/shared/components';
|
|
||||||
import { SharedPasswordInputComponent } from '@/shared/components/passwordInput/password-input.component';
|
|
||||||
import { fieldControl } from '@/shared/constants';
|
|
||||||
import { CommonModule } from '@angular/common';
|
|
||||||
import { Component, inject } from '@angular/core';
|
|
||||||
import { ReactiveFormsModule } from '@angular/forms';
|
|
||||||
import { ButtonDirective } from 'primeng/button';
|
|
||||||
import { tap } from 'rxjs';
|
|
||||||
import { IChangePasswordSubmitPayload } from './model';
|
|
||||||
import { PosChangePasswordService } from './services/main.service';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'pos-change-password-form',
|
|
||||||
templateUrl: './form.component.html',
|
|
||||||
imports: [
|
|
||||||
ReactiveFormsModule,
|
|
||||||
SharedPasswordInputComponent,
|
|
||||||
CommonModule,
|
|
||||||
ButtonDirective,
|
|
||||||
AppCardComponent,
|
|
||||||
],
|
|
||||||
})
|
|
||||||
export class PosChangePasswordFormDialogComponent extends AbstractForm<
|
|
||||||
IChangePasswordSubmitPayload,
|
|
||||||
any
|
|
||||||
> {
|
|
||||||
private readonly changePasswordService = inject(PosChangePasswordService);
|
|
||||||
|
|
||||||
form = this.fb.group(
|
|
||||||
{
|
|
||||||
password: fieldControl.password(),
|
|
||||||
confirmPassword: fieldControl.confirmPassword(),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
validators: [MustMatch('password', 'confirmPassword')],
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
override submitForm() {
|
|
||||||
const payload = this.form.getRawValue().password!;
|
|
||||||
return this.changePasswordService.changePassword({ password: payload }).pipe(
|
|
||||||
tap({
|
|
||||||
next: (res) => {
|
|
||||||
this.form.reset();
|
|
||||||
},
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
export interface IChangePasswordSubmitPayload {
|
|
||||||
password: string;
|
|
||||||
}
|
|
||||||
-15
@@ -1,15 +0,0 @@
|
|||||||
import { HttpClient } from '@angular/common/http';
|
|
||||||
import { Injectable } from '@angular/core';
|
|
||||||
import { Observable } from 'rxjs';
|
|
||||||
import { IChangePasswordSubmitPayload } from '../model';
|
|
||||||
|
|
||||||
@Injectable({
|
|
||||||
providedIn: 'root',
|
|
||||||
})
|
|
||||||
export class PosChangePasswordService {
|
|
||||||
constructor(private readonly http: HttpClient) {}
|
|
||||||
|
|
||||||
changePassword(payload: IChangePasswordSubmitPayload): Observable<unknown> {
|
|
||||||
return this.http.put('/api/v1/pos/update-password', payload);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,11 @@
|
|||||||
<div class="flex h-full w-full flex-col items-center justify-center gap-6 p-4">
|
<div class="bg-surface-card flex h-full w-full flex-col gap-4 rounded-b-2xl p-4">
|
||||||
<app-card-data cardTitle="تنظیمات صدور صورتحساب" class="w-full">
|
<p-tabs value="0">
|
||||||
|
<p-tablist>
|
||||||
|
<p-tab value="0">تنظیمات صدور صورتحساب</p-tab>
|
||||||
|
<p-tab value="1">تنظیمات پرینت</p-tab>
|
||||||
|
</p-tablist>
|
||||||
|
<p-tabpanels class="mt-4">
|
||||||
|
<p-tabpanel value="0">
|
||||||
<div class="flex w-full flex-col gap-4">
|
<div class="flex w-full flex-col gap-4">
|
||||||
@if (info()?.guild!.code.toLocaleLowerCase() === 'gold') {
|
@if (info()?.guild!.code.toLocaleLowerCase() === 'gold') {
|
||||||
<pos-config-gold-price-form class="w-full" />
|
<pos-config-gold-price-form class="w-full" />
|
||||||
@@ -9,11 +15,14 @@
|
|||||||
<hr />
|
<hr />
|
||||||
<pos-config-send-to-fiscal-activation-form class="w-full" />
|
<pos-config-send-to-fiscal-activation-form class="w-full" />
|
||||||
</div>
|
</div>
|
||||||
</app-card-data>
|
</p-tabpanel>
|
||||||
<app-card-data cardTitle="تنظیمات پرینت صورتحساب" class="w-full">
|
|
||||||
|
<p-tabpanel value="1">
|
||||||
<p-message variant="text" severity="info" icon="pi pi-info-circle">
|
<p-message variant="text" severity="info" icon="pi pi-info-circle">
|
||||||
هریک از موارد زیر را که میخواهید در چاپ صورتحساب نمایش داده شوند را انتخاب کنید
|
هریک از موارد زیر را که میخواهید در چاپ صورتحساب نمایش داده شوند را انتخاب کنید
|
||||||
</p-message>
|
</p-message>
|
||||||
<pos-config-print-form class="mt-6 block w-full" (onClose)="returnToMainPage()" />
|
<pos-config-print-form class="mt-6 block w-full" (onClose)="returnToMainPage()" />
|
||||||
</app-card-data>
|
</p-tabpanel>
|
||||||
|
</p-tabpanels>
|
||||||
|
</p-tabs>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { PosInfoStore } from '@/domains/pos/store';
|
import { PosInfoStore } from '@/domains/pos/store';
|
||||||
import { AppCardComponent } from '@/shared/components';
|
|
||||||
import { Component, computed, inject } from '@angular/core';
|
import { Component, computed, inject } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { Message } from 'primeng/message';
|
import { Message } from 'primeng/message';
|
||||||
|
import { TabsModule } from 'primeng/tabs';
|
||||||
import { PosConfigGoldPriceFormComponent } from '../components/goldPrice/form.component';
|
import { PosConfigGoldPriceFormComponent } from '../components/goldPrice/form.component';
|
||||||
import { PosConfigPrintFormComponent } from '../components/print/form.component';
|
import { PosConfigPrintFormComponent } from '../components/print/form.component';
|
||||||
import { PosConfigRapidInvoiceFormComponent } from '../components/rapidInvoice/form.component';
|
import { PosConfigRapidInvoiceFormComponent } from '../components/rapidInvoice/form.component';
|
||||||
@@ -13,8 +13,8 @@ import { PosConfigSendToFiscalActivationFormComponent } from '../components/send
|
|||||||
templateUrl: './root.component.html',
|
templateUrl: './root.component.html',
|
||||||
imports: [
|
imports: [
|
||||||
PosConfigPrintFormComponent,
|
PosConfigPrintFormComponent,
|
||||||
AppCardComponent,
|
|
||||||
Message,
|
Message,
|
||||||
|
TabsModule,
|
||||||
PosConfigGoldPriceFormComponent,
|
PosConfigGoldPriceFormComponent,
|
||||||
PosConfigRapidInvoiceFormComponent,
|
PosConfigRapidInvoiceFormComponent,
|
||||||
PosConfigSendToFiscalActivationFormComponent,
|
PosConfigSendToFiscalActivationFormComponent,
|
||||||
@@ -25,6 +25,7 @@ export class PosConfigPageComponent {
|
|||||||
private readonly posInfoStore = inject(PosInfoStore);
|
private readonly posInfoStore = inject(PosInfoStore);
|
||||||
|
|
||||||
readonly info = computed(() => this.posInfoStore.entity());
|
readonly info = computed(() => this.posInfoStore.entity());
|
||||||
|
activeTabIndex = 0;
|
||||||
|
|
||||||
returnToMainPage() {
|
returnToMainPage() {
|
||||||
this.router.navigateByUrl('/');
|
this.router.navigateByUrl('/');
|
||||||
|
|||||||
Reference in New Issue
Block a user