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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
Expand Down Expand Up @@ -42,5 +43,10 @@ public Carriers register(@RequestBody Carriers dados) {
return carriersRepository.save(dados);

}

@DeleteMapping("/{id}")
public void deleteCarrier(@PathVariable("id") int id){
carriersRepository.deleteById(id);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,7 @@ private void setMaturidadeNivel3(Pessoa pessoa) {
}

}



}
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,6 @@ public int goingPackages() {

}



}
12 changes: 6 additions & 6 deletions frontend/main/src/app/carriers/carriers.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ <h2 class="text-uppercase">New Carrier</h2>
<table class="table table-bordered">
<thead>

<th>ID</th>
<th>Razão social</th>
<th>Taxa</th>
<th>Item</th>
<th>Carrier name</th>
<th>Tax of transport</th>
<th>E-mail</th>
<th>Cnpj</th>
<th>Ação</th>
<th>Action</th>


</thead>
Expand All @@ -113,8 +113,8 @@ <h2 class="text-uppercase">New Carrier</h2>
<td>{{carrier.email}}</td>
<td>{{carrier.cnpj}}</td>
<td>
<button class="btn btn-danger mr-2" (click)="deletar()">Deletar</button>
<button class="btn btn-primary mr-2" (click)="alterar()">Alterar</button>
<button class="btn btn-danger mr-2" (click)="deletar(carrier.id)">Delet</button>
<button class="btn btn-primary mr-2" (click)="alterar()">Edit</button>
</td>

</tr>
Expand Down
17 changes: 14 additions & 3 deletions frontend/main/src/app/carriers/carriers.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export class CarriersComponent implements OnInit {
email!: string
razao!: string
taxa!: string
id!: number

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

Expand All @@ -37,12 +38,14 @@ export class CarriersComponent implements OnInit {

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


this.id = response[i].id;
this.razao = response[i].razao;
this.taxa = response[i].taxa;
this.email = response[i].email;
this.cnpj = response[i].cnpj;

this.carriers.push({ razao: this.razao, taxa: this.taxa, email: this.email, cnpj: this.cnpj});
this.carriers.push({id: this.id, razao: this.razao, taxa: this.taxa, email: this.email, cnpj: this.cnpj});

}

Expand All @@ -57,7 +60,6 @@ export class CarriersComponent implements OnInit {

adicionar(razao: string, taxa: string, email: string, cnpj: string) {


let build ={
"razao":razao,
"taxa":taxa,
Expand All @@ -75,8 +77,15 @@ export class CarriersComponent implements OnInit {
// this.carriers.push({razao:this.razao, taxa:this.taxa, email:this.email, cnpj:this.cnpj});
}

deletar(){
deletar(id:number){

console.log(id);

this.http.delete('http://localhost:8080/carriers/'+id).subscribe();

setTimeout(() => {
this.ngOnInit();
}, 500);

}

Expand Down Expand Up @@ -107,4 +116,6 @@ export class CarriersComponent implements OnInit {

}



}
2 changes: 1 addition & 1 deletion frontend/main/src/app/users/users.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ <h2 class="text-uppercase">New User</h2>
<hr>
<table class="table table-bordered">
<thead>
<th>ID</th>
<th>Item</th>
<th>Name</th>
<th>E-mail</th>
<th>CPF</th>
Expand Down