feat(checkout): implement authentication guard for checkout route and add bank account service

This commit is contained in:
2026-07-03 14:07:57 -03:00
parent 0a2d999c00
commit 3971970975
8 changed files with 81 additions and 6 deletions

View File

@@ -0,0 +1,23 @@
import { inject, Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { firstValueFrom } from 'rxjs';
import { environment } from '../../../environments/environment';
import { BankAccount } from './tenant.interface';
@Injectable({
providedIn: 'root'
})
export class CheckoutService {
private readonly http = inject(HttpClient);
async getSelectedBankAccount(tenantCode: string): Promise<BankAccount> {
const response = await firstValueFrom(
this.http.get<{ data: BankAccount }>(`${environment.url}tenants/${tenantCode}/bank-accounts/selected`)
);
if (!response?.data) {
throw new Error('No se encontraron los datos de la cuenta bancaria seleccionada.');
}
return response.data;
}
}

View File

@@ -1,5 +1,14 @@
import { ApiResponse } from './api-response.interface';
export interface BankAccount {
id: number;
tenant_code: string;
titular: string;
entidad: string;
alias: string;
cvu: string;
}
export interface Tenant {
id: number;
codigo: string;
@@ -13,6 +22,8 @@ export interface Tenant {
footer_bg_color: string;
header_logo: string;
footer_logo: string;
selected_bank_account_id?: number | null;
selected_bank_account?: BankAccount | null;
}
export type TenantBootstrapResponse = ApiResponse<Tenant>;