Skip to content

Commit

Permalink
Currency account troubleshooting
Browse files Browse the repository at this point in the history
  • Loading branch information
brozanski committed Apr 17, 2024
1 parent d652c2f commit 912cfa4
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
@NoArgsConstructor
public class ForeignCurrencyAccountDto {
private Long id;
private String curencyCode;
private String curencyName;
private String curencyCode; //!TODO zmienić na currencyCode
private String curencyName; //!TODO zmienić na currencyName
private String balance;
private Long userId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,22 @@ <h5 class="card-title">{{ account.curencyName }}</h5>
</div>
</div>
</div>


<h3>Create Currency Account</h3>

<form #createAccountForm="ngForm" (ngSubmit)="createCurrencyAccount(createAccountForm.value)">
<div class="form-group">
<label for="currencyCode">Currency Code</label>
<input type="text" class="form-control" id="currencyCode" name="currencyCode" ngModel>
</div>
<div class="form-group">
<label for="balance">Balance</label>
<input type="number" class="form-control" id="balance" name="balance" ngModel>
</div>
<div class="form-group">
<label for="userId">User ID</label>
<input type="number" class="form-control" id="userId" name="userId" ngModel>
</div>
<button type="submit" class="btn btn-primary">Create Account</button>
</form>
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,48 @@ export class CurrencyAccountComponent implements OnInit {

constructor(private axiosService: AxiosService) { }

ngOnInit(): void {
this.axiosService.requestWithOutData(
"POST",
"/api/ForeignCurrencyAccount/getCurrencyAccounts"
).then((response) => {
this.axiosService.getAuthTocken();
getCurrencyAccounts(): void {
this.axiosService.request("POST",
"/api/ForeignCurrencyAccount/getCurrencyAccounts",
{}).then((response) => {
this.accounts = response.data;
console.log(this.accounts);
});
}

createCurrencyAccount(newAccount: { curencyCode: string, balance: number, userId: number }): void {
this.axiosService.request("POST", "/api/ForeignCurrencyAccount/createCurrencyAccount", newAccount).then((response) => {
console.log(response.data);
this.getCurrencyAccounts(); // Refresh the accounts list after creating a new account
});
}

// createCurrencyAccount(): void {
// let newAccount = {
// curencyCode: 'USD',
// balance: 1000,
// userId: 2
// };
//
// this.axiosService.request("POST", "/api/ForeignCurrencyAccount/createCurrencyAccount", newAccount).then((response) => {
// console.log(response.data);
// });
// }

ngOnInit(): void {
this.getCurrencyAccounts();
// this.createCurrencyAccount()


// this.axiosService.requestWithOutData(
// "POST",
// "/api/ForeignCurrencyAccount/getCurrencyAccounts"
// ).then((response) => {
// this.axiosService.getAuthTocken();
// this.accounts = response.data;
// console.log(this.accounts);
//
// });

}
}

0 comments on commit 912cfa4

Please sign in to comment.