Skip to content

Commit 66683d6

Browse files
committed
feat: add dialog
1 parent 064db8c commit 66683d6

4 files changed

Lines changed: 31 additions & 5 deletions

File tree

src/app/afip/afip.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</div>
1313
</div>
1414

15-
<button mat-raised-button color="primary" class="w-100" (click)="test()">TEST</button>
15+
<!--button mat-raised-button color="primary" class="w-100" (click)="test()">TEST</button-->
1616

1717
<div *ngIf="invoices.length > 0" class="row">
1818
<div class="col-12">

src/app/afip/afip.component.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { Component, OnInit, ViewChild } from '@angular/core';
1+
import { Component, OnInit, ViewChild, Inject } from '@angular/core';
22
import {animate, state, style, transition, trigger} from '@angular/animations';
33
import { MatTable } from '@angular/material/table';
4+
import { MatDialog, MAT_DIALOG_DATA } from '@angular/material/dialog';
45
import { BarcodeScanner } from '@awesome-cordova-plugins/barcode-scanner/ngx';
56

67
export interface InvoiceElement {
@@ -32,7 +33,7 @@ export class AfipComponent implements OnInit {
3233
expandedElement: InvoiceElement | null | undefined;
3334
@ViewChild(MatTable) table: MatTable<InvoiceElement> | undefined;
3435

35-
constructor(private barcodeScanner: BarcodeScanner) { }
36+
constructor(private barcodeScanner: BarcodeScanner, public dialog: MatDialog) { }
3637

3738
ngOnInit(): void {
3839
let inv = localStorage.getItem('invoices');
@@ -80,7 +81,7 @@ export class AfipComponent implements OnInit {
8081
this.table!.renderRows();
8182
}
8283
} else {
83-
alert('El QR escaneado no es de AFIP');
84+
this.openDialog('El QR escaneado no es de AFIP');
8485
}
8586
}
8687

@@ -181,4 +182,20 @@ export class AfipComponent implements OnInit {
181182
link.click();
182183
}
183184

185+
openDialog(msg: string) {
186+
const dialogRef = this.dialog.open(DialogContent, {
187+
data: msg,
188+
});
189+
190+
dialogRef.afterClosed().subscribe(result => {});
191+
}
192+
184193
}
194+
195+
@Component({
196+
selector: 'dialog-data',
197+
templateUrl: './dialog.html',
198+
})
199+
export class DialogContent {
200+
constructor(@Inject(MAT_DIALOG_DATA) public data: string) {}
201+
}

src/app/afip/dialog.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<h2 mat-dialog-title>Advertencia</h2>
2+
<mat-dialog-content class="mat-typography">
3+
{{data}}
4+
</mat-dialog-content>
5+
<mat-dialog-actions>
6+
<button mat-button [mat-dialog-close]="true" cdkFocusInitial>Aceptar</button>
7+
</mat-dialog-actions>

src/app/app.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { MatIconModule } from '@angular/material/icon';
2020
import { MatDialogModule } from '@angular/material/dialog';
2121

2222
import { AfipComponent } from './afip/afip.component';
23+
import { DialogContent } from './afip/afip.component';
2324

2425
const routes: Routes = [
2526
{ path: 'home', component: AfipComponent },
@@ -32,7 +33,8 @@ const routes: Routes = [
3233
@NgModule({
3334
declarations: [
3435
AppComponent,
35-
AfipComponent
36+
AfipComponent,
37+
DialogContent
3638
],
3739
imports: [
3840
BrowserModule,

0 commit comments

Comments
 (0)