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
7 changes: 1 addition & 6 deletions frontend/main/src/app/quote.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Router } from '@angular/router';
import { type } from 'os';
import { catchError } from 'rxjs';
import { LoginserviceService } from './loginservice.service';
import { RctQtComponent } from './rct-qt/rct-qt.component';
import { ShipQtComponent } from './ship-qt/ship-qt.component';

@Injectable({
Expand Down Expand Up @@ -82,27 +83,21 @@ export class QuoteService {
this.http.post(this.APIBouncePut+this.login.idBounce, this.newBounce)
//FIM DO BOUNCE


this.http.post(this.apiURL2+'/recent',object)
.subscribe((response)=>{


console.log(response);

})


}

regPackage(object:any){
this.http.post(this.apiURL2+'/register',object)
.subscribe((response)=>{


console.log(response);



})
}
}
16 changes: 7 additions & 9 deletions frontend/main/src/app/rct-qt/rct-qt.component.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<table class="table table-bordered">
<thead>
<th>Ação</th>

<th>Preço do frete</th>
<th>Prazo</th>
<th>Transportadora</th>
Expand All @@ -12,19 +12,17 @@

</thead>
<tbody>
<tr *ngFor="let recQuote of recQuotes;let i = index;">
<td class="align-items-center"><button 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)">Criar pacote</button></td>
<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>R${{recQuote.price}}</td>
<td>{{recQuote.await}} dias úteis</td>
<td>{{recQuote.razaoTransportadora}}</td>
<td>{{recQuote.origin}}</td>
<td>{{recQuote.destiny}}</td>
<td>{{recQuote.cub_height}} kg</td>
<td>{{recQuote.nomePessoa}}</td>


<td>{{recQuote.cub_height}} kg</td>
<td>{{recQuote.nomePessoa}}</td>

</tr>
</tbody>
</table>
</table>
50 changes: 18 additions & 32 deletions frontend/main/src/app/rct-qt/rct-qt.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import { QuoteService } from '../quote.service';
})
export class RctQtComponent implements OnInit {


progress!:boolean
succeed:boolean = false
recQuotes!: Array<any>
id!: number
price!: number
Expand All @@ -25,8 +26,6 @@ export class RctQtComponent implements OnInit {
nomePessoa!: string
razaoTransportadora!: string
carrier!: any



constructor(private carrierService: CarrierService, private loginService: LoginserviceService, public quoteService: QuoteService, private router: Router, private http: HttpClient) { }

Expand All @@ -36,48 +35,34 @@ export class RctQtComponent implements OnInit {
this.quoteService.recQuote().pipe().subscribe((response: any) => {

console.log(response);

var count = Object.keys(response).length;

for (let i = 0; i < count; i++) {

this.id = response[i].id
this.price = response[i].price
this.await = response[i].await
this.origin = response[i].origin
this.destiny = response[i].destiny
this.cub_height = response[i].cub_height




this.carrierService.findName(response[i].carrier_id).subscribe((response:any) => {

this.recQuotes.push({id: this.id, price: this.price, await: this.await, origin: this.origin, destiny: this.destiny, cub_height: this.cub_height, razaoTransportadora: response.razao, carrier_id: response.id, nomePessoa: this.loginService.nome})


})




// this.id = response[i].id
// this.price = response[i].price
// this.await = response[i].await
// this.origin = response[i].origin
// this.destiny = response[i].destiny
// this.cub_height = response[i].cub_height

this.carrierService.findName(response[i].carrier_id).subscribe((resp:any) => {

this.recQuotes.push({id: response[i].id, price: response[i].price, await: response[i].await, origin: response[i].origin, destiny: response[i].destiny, cub_height: response[i].cub_height, razaoTransportadora: resp.razao, carrier_id: resp.id, nomePessoa: this.loginService.nome})

})

}

console.log();


})
})
}


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


this.progress = true

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

console.log(build);

this.quoteService.regPackage(build)


this.quoteService.regPackage(build)

setTimeout(()=>{
this.succeed = true
}, 1500)

}

Expand Down