Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions frontend/main/src/app/quote.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,9 @@ export class QuoteService {

})
}

deleteRecentQuote(id:number){
this.http.delete(this.apiURL2+'/recent/'+id)
}

}
2 changes: 1 addition & 1 deletion frontend/main/src/app/rct-qt/rct-qt.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</thead>
<tbody>
<tr *ngFor="let recQuote of recQuotes;let i = index;">
<td class="align-items-center"><button [hidden]="succeed" class="btn btn-primary" (click)="regPackage(this.recQuote.price, this.recQuote.await, this.recQuote.origin, this.recQuote.destiny, this.recQuote.carrier_id, this.recQuote.cub_height)"><i [ngClass]="{'fas fa-circle-notch fa-spin':progress}"></i> Criar pacote</button><button disabled [hidden]="!succeed" class="btn btn-success"><i class="fas fa-check"></i> Added!</button></td>
<td class="align-items-center"><button [hidden]="succeed==this.recQuote.id" class="btn btn-primary" (click)="regPackage(this.recQuote.id ,this.recQuote.price, this.recQuote.await, this.recQuote.origin, this.recQuote.destiny, this.recQuote.carrier_id, this.recQuote.cub_height)"><i [ngClass]="{'fas fa-circle-notch fa-spin':progress==this.recQuote.id}"></i> Criar pacote</button><button disabled [hidden]="succeed!=this.recQuote.id" class="btn btn-success"><i class="fas fa-check"></i> Added!</button></td>

<td>R${{recQuote.price}}</td>
<td>{{recQuote.await}} dias úteis</td>
Expand Down
29 changes: 20 additions & 9 deletions frontend/main/src/app/rct-qt/rct-qt.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { QuoteService } from '../quote.service';
})
export class RctQtComponent implements OnInit {

progress!:boolean
succeed:boolean = false
progress:number = -1
succeed:number = -1
recQuotes!: Array<any>
id!: number
price!: number
Expand All @@ -32,7 +32,12 @@ export class RctQtComponent implements OnInit {
ngOnInit(): void {
this.recQuotes = new Array()

this.quoteService.recQuote().pipe().subscribe((response: any) => {
this.progress = -1
this.succeed = -1

this.quoteService.recQuote()
.pipe()
.subscribe((response: any) => {

console.log(response);

Expand All @@ -55,14 +60,13 @@ export class RctQtComponent implements OnInit {

}

console.log();

})

}

regPackage(price: number, time: number, origin: string, destiny: string, carrier_id: string, cub_height: number) {
regPackage(id:number, price: number, time: number, origin: string, destiny: string, carrier_id: string, cub_height: number) {

this.progress = true
this.progress = id

let build = {
"price": price,
Expand All @@ -75,11 +79,18 @@ export class RctQtComponent implements OnInit {
}

console.log(build);

this.quoteService.regPackage(build)

console.log(id);


this.http.delete('http://localhost:8080/quote/recent/'+id)

setTimeout(()=>{
this.succeed = true
this.succeed = id
setTimeout(() => {
this.ngOnInit()
}, 2000);
}, 1500)

}
Expand Down