modificacion PayPal y agregacion de correo

This commit is contained in:
Paola 2021-08-11 01:30:33 -06:00
parent 3ef698c0d3
commit cd2ee8803b
11 changed files with 452 additions and 10 deletions

View File

@ -318,6 +318,12 @@
<groupId>org.springframework.security</groupId> <groupId>org.springframework.security</groupId>
<artifactId>spring-security-messaging</artifactId> <artifactId>spring-security-messaging</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>4.0.0-2</version>
</dependency>
<!-- jhipster-needle-maven-add-dependency --> <!-- jhipster-needle-maven-add-dependency -->
</dependencies> </dependencies>

View File

@ -4,6 +4,7 @@ import java.nio.charset.StandardCharsets;
import java.util.Locale; import java.util.Locale;
import javax.mail.MessagingException; import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeMessage;
import org.datasurvey.domain.Factura;
import org.datasurvey.domain.User; import org.datasurvey.domain.User;
import org.datasurvey.domain.UsuarioEncuesta; import org.datasurvey.domain.UsuarioEncuesta;
import org.datasurvey.domain.UsuarioExtra; import org.datasurvey.domain.UsuarioExtra;
@ -33,6 +34,8 @@ public class MailService {
private static final String CONTRASENNA = "contrasenna"; private static final String CONTRASENNA = "contrasenna";
private static final String FACTURA = "factura";
private static final String BASE_URL = "baseUrl"; private static final String BASE_URL = "baseUrl";
private final JHipsterProperties jHipsterProperties; private final JHipsterProperties jHipsterProperties;
@ -128,6 +131,22 @@ public class MailService {
sendEmail(user.getEmail(), subject, content, false, true); sendEmail(user.getEmail(), subject, content, false, true);
} }
@Async
public void sendEmailFromTemplateFactura(User user, Factura factura, String templateName, String titleKey) {
if (user.getEmail() == null) {
log.debug("Email doesn't exist for user '{}'", user.getLogin());
return;
}
Locale locale = Locale.forLanguageTag(user.getLangKey());
Context context = new Context(locale);
context.setVariable(USER, user);
context.setVariable(FACTURA, factura);
context.setVariable(BASE_URL, jHipsterProperties.getMail().getBaseUrl());
String content = templateEngine.process(templateName, context);
String subject = messageSource.getMessage(titleKey, null, locale);
sendEmail(user.getEmail(), subject, content, false, true);
}
@Async @Async
public void sendActivationEmail(User user) { public void sendActivationEmail(User user) {
log.debug("Sending activation email to '{}'", user.getEmail()); log.debug("Sending activation email to '{}'", user.getEmail());
@ -203,4 +222,10 @@ public class MailService {
"email.deleteColaborator.title" "email.deleteColaborator.title"
); );
} }
@Async
public void sendReceiptUser(UsuarioExtra user, Factura factura) {
log.debug("Sending paypal receipt mail to '{}'", user.getUser().getEmail());
sendEmailFromTemplateFactura(user.getUser(), factura, "mail/facturaPayPalEmail", "email.receipt.title");
}
} }

View File

@ -8,9 +8,12 @@ import java.util.Optional;
import javax.validation.Valid; import javax.validation.Valid;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import org.datasurvey.domain.Factura; import org.datasurvey.domain.Factura;
import org.datasurvey.domain.UsuarioExtra;
import org.datasurvey.repository.FacturaRepository; import org.datasurvey.repository.FacturaRepository;
import org.datasurvey.service.FacturaQueryService; import org.datasurvey.service.FacturaQueryService;
import org.datasurvey.service.FacturaService; import org.datasurvey.service.FacturaService;
import org.datasurvey.service.MailService;
import org.datasurvey.service.UsuarioExtraService;
import org.datasurvey.service.criteria.FacturaCriteria; import org.datasurvey.service.criteria.FacturaCriteria;
import org.datasurvey.web.rest.errors.BadRequestAlertException; import org.datasurvey.web.rest.errors.BadRequestAlertException;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -41,10 +44,22 @@ public class FacturaResource {
private final FacturaQueryService facturaQueryService; private final FacturaQueryService facturaQueryService;
public FacturaResource(FacturaService facturaService, FacturaRepository facturaRepository, FacturaQueryService facturaQueryService) { private final UsuarioExtraService userExtraService;
private final MailService mailService;
public FacturaResource(
FacturaService facturaService,
FacturaRepository facturaRepository,
FacturaQueryService facturaQueryService,
UsuarioExtraService userExtraService,
MailService mailService
) {
this.facturaService = facturaService; this.facturaService = facturaService;
this.facturaRepository = facturaRepository; this.facturaRepository = facturaRepository;
this.facturaQueryService = facturaQueryService; this.facturaQueryService = facturaQueryService;
this.userExtraService = userExtraService;
this.mailService = mailService;
} }
/** /**
@ -60,11 +75,22 @@ public class FacturaResource {
if (factura.getId() != null) { if (factura.getId() != null) {
throw new BadRequestAlertException("A new factura cannot already have an ID", ENTITY_NAME, "idexists"); throw new BadRequestAlertException("A new factura cannot already have an ID", ENTITY_NAME, "idexists");
} }
Optional<UsuarioExtra> usuarioExtra = userExtraService.findOne(Long.parseLong(factura.getNombreUsuario()));
factura.setNombreUsuario(usuarioExtra.get().getNombre());
Factura result = facturaService.save(factura); Factura result = facturaService.save(factura);
mailService.sendReceiptUser(usuarioExtra.get(), factura);
return ResponseEntity return ResponseEntity
.created(new URI("/api/facturas/" + result.getId())) .created(new URI("/api/facturas/" + result.getId()))
.headers(HeaderUtil.createEntityCreationAlert(applicationName, true, ENTITY_NAME, result.getId().toString())) .headers(HeaderUtil.createEntityCreationAlert(applicationName, true, ENTITY_NAME, result.getId().toString()))
.body(result); .body(result);
//retrieve yser
//Enviar el correo
} }
/** /**

View File

@ -64,3 +64,11 @@ email.deleteColaborator.title=Se le ha expulsado de una encuesta como colaborado
email.deleteColaborator.greeting=¡Se le ha expulsado, {0}! email.deleteColaborator.greeting=¡Se le ha expulsado, {0}!
email.deleteColaborator.text1=Fue expulsado de la encuesta {0}(#{1})" email.deleteColaborator.text1=Fue expulsado de la encuesta {0}(#{1})"
email.deleteColaborator.text2=Saludos, email.deleteColaborator.text2=Saludos,
email.receipt.title=Comprobante de pago
email.receipt.user={0}
email.receipt.fecha={0}
email.receipt.plantilla={0}
email.receipt.precio=${0}

View File

@ -0,0 +1,262 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" th:lang="${#locale.language}" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width" />
<!-- Forcing initial-scale shouldn't be necessary -->
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!-- Use the latest (edge) version of IE rendering engine -->
<meta name="x-apple-disable-message-reformatting" />
<!-- Disable auto-scale in iOS 10 Mail entirely -->
<title th:text="#{email.receipt.title}">JHipster activation</title>
<link rel="icon" th:href="@{|${baseUrl}/favicon.ico|}" />
<link href="https://fonts.googleapis.com/css?family=NotoSansSP:300,400,700" rel="stylesheet" />
<link rel="manifest" href="manifest.webapp" />
<link
href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk"
crossorigin="anonymous"
/>
<style>
body {
margin-top: 20px;
color: #484b51;
}
.brc-default-l1 {
border-color: #dce9f0 !important;
}
.ml-n1,
.mx-n1 {
margin-left: -0.25rem !important;
}
.mr-n1,
.mx-n1 {
margin-right: -0.25rem !important;
}
.mb-4,
.my-4 {
margin-bottom: 1.5rem !important;
}
hr {
margin-top: 1rem;
margin-bottom: 1rem;
border: 0;
border-top: 1px solid rgba(0, 0, 0, 0.1);
}
.text-grey-m2 {
color: #888a8d !important;
}
.font-bolder,
.text-600 {
font-weight: 600 !important;
}
.text-110 {
font-size: 110% !important;
}
.text-blue {
color: #478fcc !important;
}
.pb-25,
.py-25 {
padding-bottom: 0.75rem !important;
}
.pt-25,
.py-25 {
padding-top: 0.75rem !important;
}
.bgc-default-tp1 {
background-color: rgba(121, 169, 197, 0.92) !important;
}
.page-header .page-tools {
-ms-flex-item-align: end;
align-self: flex-end;
}
.text-blue-m2 {
color: #68a3d5 !important;
}
.text-150 {
font-size: 150% !important;
}
</style>
</head>
<body width="100%" style="margin: 0; padding: 0 !important; mso-line-height-rule: exactly; background-color: #f1f1f1">
<center style="width: 100%; background-color: #f1f1f1">
<div
style="
display: none;
font-size: 1px;
max-height: 0px;
max-width: 0px;
opacity: 0;
overflow: hidden;
mso-hide: all;
font-family: sans-serif;
"
>
&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;
</div>
<div style="max-width: 600px; margin: 0 auto" class="email-container">
<!-- BEGIN BODY -->
<table align="center" role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%" style="margin: auto">
<tr>
<td valign="top" class="bg_white" style="padding: 1em 2.5em 0 2.5em">
<table role="presentation" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td class="logo" style="text-align: center">
<h1>
<a href="#"
><img
src="https://res.cloudinary.com/marielascloud/image/upload/v1626333881/DataSurveyLogo2_smr2ok.png"
alt=""
width="300"
/></a>
</h1>
</td>
</tr>
</table>
</td>
</tr>
<!-- end tr -->
<!-- end tr -->
<div class="page-content container">
<div class="container px-0">
<div class="row mt-4">
<div class="col-12 col-lg-10 offset-lg-1">
<!-- .row -->
<hr class="row brc-default-l1 mx-n1 mb-4" />
<div class="row">
<div class="col-sm-6">
<div>
<span class="text-sm text-grey-m2 align-middle">Usuario:</span>
<span
class="text-600 text-110 text-blue align-middle"
th:text="#{email.receipt.user(${factura.getNombreUsuario()})}"
></span>
</div>
</div>
<!-- /.col -->
<div class="text-95 col-sm-6 align-self-start d-sm-flex justify-content-end">
<hr class="d-sm-none" />
<div class="text-grey-m2">
<div class="my-2">
<i class="fa fa-circle text-blue-m2 text-xs mr-1"></i>
<span class="text-600 text-90" th:text="#{email.receipt.fecha(${factura.getFecha()}, 'dd-MM-yyyy HH:mm' )}"
>Fecha:</span
>
</div>
</div>
</div>
<!-- /.col -->
</div>
<div class="mt-4">
<div class="row text-600 text-white bgc-default-tp1 py-25">
<div class="col-9 col-sm-5">Plantilla</div>
<div class="d-none d-sm-block col-4 col-sm-2">Cantidad</div>
<div class="d-none d-sm-block col-sm-2">Precio</div>
</div>
<div class="text-95 text-secondary-d3">
<div class="row mb-2 mb-sm-0 py-25">
<div class="col-9 col-sm-5" th:text="#{email.receipt.plantilla(${factura.getNombrePlantilla()})}"></div>
<div class="d-none d-sm-block col-2">1</div>
<div class="d-none d-sm-block col-2 text-95" th:text="#{email.receipt.precio(${factura.getCosto()})}"></div>
</div>
</div>
</div>
<div class="row mt-3">
<div class="col-12 col-sm-5 text-grey text-90 order-first order-sm-last">
<div class="row my-2 align-items-center bgc-primary-l3 p-2">
<div class="col-7 text-right">Monto total</div>
<div class="col-5">
<span class="text-150 text-success-d3 opacity-2" th:text="#{email.receipt.precio(${factura.getCosto()})}"></span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- end tr -->
<!-- 1 Column Text + Button : END -->
</table>
<table align="center" role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%" style="margin: auto">
<tr>
<td valign="middle" class="bg_light footer email-section">
<table>
<tr>
<td valign="top" width="33.333%" style="padding-top: 20px">
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td style="text-align: left; padding-right: 10px">
<h3 class="heading">Acerca de</h3>
<p>DataSurvey es su compañero más cercano para poder recolectar información valiosa para usted</p>
</td>
</tr>
</table>
</td>
<td valign="top" width="33.333%" style="padding-top: 20px">
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td style="text-align: left; padding-left: 5px; padding-right: 5px">
<h3 class="heading">Información de contacto</h3>
<ul>
<li><span href="mailto:datasurveyapp@gmail.com" class="text">datasurveyapp@gmail.com</span></li>
</ul>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<!-- end: tr -->
<tr>
<td class="bg_light" style="text-align: center">
<p><a href="https://datasurvey.org" style="color: rgba(0, 0, 0, 0.8)">DataSurvey.org</a></p>
</td>
</tr>
</table>
</div>
</center>
<script
src="https://code.jquery.com/jquery-3.5.1.min.js"
integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0="
crossorigin="anonymous"
></script>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/2.4.1/cjs/popper.min.js"
integrity="sha256-T3bYsIPyOLpEfeZOX4M7J59ZoDMzuYFUsPiSN3Xcc2M="
crossorigin="anonymous"
></script>
<script
src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"
integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI"
crossorigin="anonymous"
></script>
</body>
</html>

View File

@ -19,6 +19,7 @@ export class FacturaService {
constructor(protected http: HttpClient, protected applicationConfigService: ApplicationConfigService) {} constructor(protected http: HttpClient, protected applicationConfigService: ApplicationConfigService) {}
create(factura: IFactura): Observable<EntityResponseType> { create(factura: IFactura): Observable<EntityResponseType> {
debugger;
const copy = this.convertDateFromClient(factura); const copy = this.convertDateFromClient(factura);
return this.http return this.http
.post<IFactura>(this.resourceUrl, copy, { observe: 'response' }) .post<IFactura>(this.resourceUrl, copy, { observe: 'response' })

View File

@ -17,13 +17,37 @@
<div class="input-group-addon"><i class="glyphicon glyphicon-search"></i></div> <div class="input-group-addon"><i class="glyphicon glyphicon-search"></i></div>
<input class="form-control" type="text" name="searchString" placeholder="Buscar por nombre..." [(ngModel)]="searchString" /> <input class="form-control" type="text" name="searchString" placeholder="Buscar por nombre..." [(ngModel)]="searchString" />
</div> </div>
<div class="ds-filter"> <!--<div class="ds-filter">
<select name="searchCategoria" class="form-control" [(ngModel)]="searchCategoria" style="width: 200px"> <select name="searchCategoria" class="form-control" [(ngModel)]="searchCategoria" style="width: 200px">
<option value="" selected="selected" disabled="disabled">Filtrar por categoría</option> <option value="" selected="selected" disabled="disabled">Filtrar por categoría</option>
<option value="">Todas las categorías</option> <option value="">Todas las categorías</option>
<option *ngFor="let categoria of categorias" [value]="categoria.nombre">{{ categoria.nombre }}</option> <option *ngFor="let categoria of categorias" [value]="categoria.nombre">{{ categoria.nombre }}</option>
</select> </select>
</div> </div>-->
<!--<div class="ds-filter">
<div class="form-check pl-0 mb-3">
<input type="radio" class="form-check-input" id="under25" name="materialExampleRadios" [value]="0">
<label for="under25" [(ngModel)]="searchPrecio">GRATIS</label>
</div>
<div class="form-check pl-0 mb-3">
<input type="radio" class="form-check-input" id="2550" name="materialExampleRadios" [value]="">
<label for="2550" [(ngModel)]="searchPrecio"> $5 - $10</label>
</div>
<div class="form-check pl-0 mb-3">
<input type="radio" class="form-check-input" id="50100" name="materialExampleRadios">
<label for="50100" [(ngModel)]="searchPrecio">$10 - $20</label>
</div>
<div class="form-check pl-0 mb-3">
<input type="radio" class="form-check-input" id="100200" name="materialExampleRadios">
<label for="100200" [(ngModel)]="searchPrecio">$20 - $30</label>
</div>
<div class="form-check pl-0 mb-3">
<input type="radio" class="form-check-input" id="200above" name="materialExampleRadios">
<label [(ngModel)]="searchPrecio">Más de $30 </label>
</div>
</div>-->
</div> </div>
<hr /> <hr />
@ -45,7 +69,10 @@
<div <div
class="col-xl-4 col-lg-4 col-md-6 mb-5" class="col-xl-4 col-lg-4 col-md-6 mb-5"
*ngFor=" *ngFor="
let plantilla of plantillas | filter: 'nombre':searchString | filter: 'categoria.nombre':searchCategoria; let plantilla of plantillas
| filter: 'nombre':searchString
| filter: 'categoria.nombre':searchCategoria
| filter: 'precio':searchPrecio;
trackBy: trackId trackBy: trackId
" "
> >

View File

@ -27,6 +27,7 @@ import { PaypalDialogComponent } from '../paypal-dialog/paypal-dialog.component'
export class ListarTiendaPlantillaComponent implements OnInit { export class ListarTiendaPlantillaComponent implements OnInit {
public searchString: string; public searchString: string;
public searchCategoria: string; public searchCategoria: string;
public searchPrecio: string;
categorias?: ICategoria[]; categorias?: ICategoria[];
account: Account | null = null; account: Account | null = null;
public searchEncuestaPublica: string; public searchEncuestaPublica: string;
@ -58,6 +59,7 @@ export class ListarTiendaPlantillaComponent implements OnInit {
this.searchEncuestaPublica = ''; this.searchEncuestaPublica = '';
this.searchString = ''; this.searchString = '';
this.searchCategoria = ''; this.searchCategoria = '';
this.searchPrecio = '';
} }
ngOnInit(): void { ngOnInit(): void {

View File

@ -9,7 +9,13 @@
<h2 class="ds-title--small">Total: ${{ plantilla!.precio }}</h2> <h2 class="ds-title--small">Total: ${{ plantilla!.precio }}</h2>
<hr /> <hr />
<ngx-paypal [config]="payPalConfig"></ngx-paypal>
<h2 class="entity-body--row m-2">La plantilla ha comprar no tiene costo alguno</h2>
<button type="button" class="ds-btn btn-outline-success fc-center" data-dismiss="modal" (click)="freePurchase()">
<fa-icon [icon]="faCheck"></fa-icon>&nbsp;<span>Finalizar compra</span>
</button>
<ngx-paypal [config]="payPalConfig" *ngIf="plantilla!.precio != 0"></ngx-paypal>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">

View File

@ -5,6 +5,16 @@ import { EncuestaService } from '../../encuesta/service/encuesta.service';
import { FormBuilder } from '@angular/forms'; import { FormBuilder } from '@angular/forms';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { IPlantilla } from '../../plantilla/plantilla.model'; import { IPlantilla } from '../../plantilla/plantilla.model';
import { faCreditCard, faCheck } from '@fortawesome/free-solid-svg-icons';
import { Account } from '../../../core/auth/account.model';
import { UsuarioExtra } from '../../usuario-extra/usuario-extra.model';
import { UsuarioExtraService } from '../../usuario-extra/service/usuario-extra.service';
import { IFactura } from '../../factura/factura.model';
import { takeUntil } from 'rxjs/operators';
import { AccountService } from '../../../core/auth/account.service';
import { Subject } from 'rxjs';
import * as dayjs from 'dayjs';
import { FacturaService } from '../../factura/service/factura.service';
@Component({ @Component({
selector: 'jhi-paypal-dialog', selector: 'jhi-paypal-dialog',
@ -15,18 +25,44 @@ export class PaypalDialogComponent implements OnInit {
public payPalConfig?: IPayPalConfig; public payPalConfig?: IPayPalConfig;
showSuccess = false; showSuccess = false;
plantilla?: IPlantilla; plantilla?: IPlantilla;
account: Account | null = null;
usuarioExtra: UsuarioExtra | null = null;
factura?: IFactura;
notAccount: boolean = true;
private readonly destroy$ = new Subject<void>();
constructor(protected activeModal: NgbActiveModal) {} faCreditCard = faCreditCard;
faCheck = faCheck;
constructor(
protected facturaService: FacturaService,
protected usuarioExtraService: UsuarioExtraService,
protected activeModal: NgbActiveModal,
protected accountService: AccountService
) {}
ngOnInit(): void { ngOnInit(): void {
this.accountService
.getAuthenticationState()
.pipe(takeUntil(this.destroy$))
.subscribe(account => {
if (account !== null) {
this.account = account;
this.notAccount = false;
} else {
this.notAccount = true;
}
});
this.getUser();
this.initConfig(); this.initConfig();
} }
private initConfig(): void { private initConfig(): void {
debugger;
this.payPalConfig = { this.payPalConfig = {
currency: 'USD', currency: 'USD',
clientId: 'sb', clientId: 'AUIxW_mYvd_h3mMqTtHdrSNMJ9yPmJkpiOCkNq454vDxXCN6hgadgPHIX_9PTeQn1Qv8m-ozcQUQkUjZ',
createOrderOnClient: data => createOrderOnClient: data =>
<ICreateOrderRequest>{ <ICreateOrderRequest>{
intent: 'CAPTURE', intent: 'CAPTURE',
@ -63,7 +99,6 @@ export class PaypalDialogComponent implements OnInit {
layout: 'vertical', layout: 'vertical',
}, },
onApprove: (data, actions) => { onApprove: (data, actions) => {
debugger;
console.log('onApprove - transaction was approved, but not authorized', data, actions); console.log('onApprove - transaction was approved, but not authorized', data, actions);
actions.order.get().then((details: any) => { actions.order.get().then((details: any) => {
//calls baxkend //calls baxkend
@ -71,8 +106,10 @@ export class PaypalDialogComponent implements OnInit {
}); });
}, },
onClientAuthorization: data => { onClientAuthorization: data => {
debugger;
console.log('onClientAuthorization - you should probably inform your server about completed transaction at this point', data); console.log('onClientAuthorization - you should probably inform your server about completed transaction at this point', data);
this.showSuccess = true; this.updateUser();
this.sendReceipt();
}, },
}; };
} }
@ -80,4 +117,45 @@ export class PaypalDialogComponent implements OnInit {
cancel(): void { cancel(): void {
this.activeModal.dismiss(); this.activeModal.dismiss();
} }
getUser(): void {
debugger;
// Get jhi_user and usuario_extra information
if (this.account !== null) {
this.usuarioExtraService.find(this.account.id).subscribe(usuarioExtra => {
this.usuarioExtra = usuarioExtra.body;
});
}
}
updateUser(): void {
this.usuarioExtra?.plantillas?.push(this.plantilla!);
this.usuarioExtraService.update(this.usuarioExtra!).subscribe(() => {
this.showSuccess = true;
});
}
sendReceipt(): void {
const now = dayjs();
debugger;
this.factura = {
nombreUsuario: String(this.usuarioExtra?.id!),
nombrePlantilla: this.plantilla?.nombre!,
costo: this.plantilla?.precio,
fecha: now,
};
this.facturaService.create(this.factura).subscribe(() => {
this.showSuccess = true;
this.cancel();
});
//send
}
freePurchase(): void {
this.getUser();
this.sendReceipt();
}
} }

View File

@ -6,6 +6,7 @@ import { Pipe, PipeTransform, Injectable } from '@angular/core';
@Injectable() @Injectable()
export class FilterPipe implements PipeTransform { export class FilterPipe implements PipeTransform {
transform(items: any[], field: string, value: string): any[] { transform(items: any[], field: string, value: string): any[] {
debugger;
if (!items) { if (!items) {
return []; return [];
} }