Add new createTransaction method
This commit is contained in:
parent
c5e66b4720
commit
9de1258f7f
@ -11,12 +11,25 @@ const httpOptions = {
|
||||
})
|
||||
export class AuthService {
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
/**
|
||||
* @param {string} email
|
||||
* @param {string} password
|
||||
* @returns Observable
|
||||
*/
|
||||
login(email: string, password: string): Observable<any> {
|
||||
return this.http.post(AUTH_API + '/login', {
|
||||
email,
|
||||
password,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} email
|
||||
* @param {string} username
|
||||
* @param {string} password
|
||||
* @returns Observable
|
||||
*/
|
||||
register(email: string, username: string, password: string): Observable<any> {
|
||||
return this.http.post(
|
||||
AUTH_API + '/register',
|
||||
|
@ -51,8 +51,8 @@ export class DataService {
|
||||
*/
|
||||
public createTransaction(
|
||||
symbol: string,
|
||||
time: Date,
|
||||
count: number,
|
||||
time: string,
|
||||
count: BigInt,
|
||||
price: number
|
||||
): Observable<any> {
|
||||
return this.http.post(API_URL + 'transactions', {
|
||||
@ -60,10 +60,11 @@ export class DataService {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: 'Bearer ' + this.tokenStorage.getToken(),
|
||||
}),
|
||||
symbol,
|
||||
time,
|
||||
responseType: 'text',
|
||||
count,
|
||||
price,
|
||||
symbol,
|
||||
time,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -6,20 +6,42 @@ const USER_KEY = 'auth-user';
|
||||
})
|
||||
export class TokenStorageService {
|
||||
constructor() {}
|
||||
|
||||
/**
|
||||
* @returns void
|
||||
*/
|
||||
signOut(): void {
|
||||
window.sessionStorage.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} token
|
||||
* @returns void
|
||||
*/
|
||||
public saveToken(token: string): void {
|
||||
window.sessionStorage.removeItem(TOKEN_KEY);
|
||||
window.sessionStorage.setItem(TOKEN_KEY, token);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns string
|
||||
*/
|
||||
public getToken(): string | null {
|
||||
return window.sessionStorage.getItem(TOKEN_KEY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} user
|
||||
* @returns void
|
||||
*/
|
||||
public saveUser(user: any): void {
|
||||
window.sessionStorage.removeItem(USER_KEY);
|
||||
window.sessionStorage.setItem(USER_KEY, JSON.stringify(user));
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns any
|
||||
*/
|
||||
public getUser(): any {
|
||||
const user = window.sessionStorage.getItem(USER_KEY);
|
||||
if (user) {
|
||||
|
@ -45,8 +45,8 @@ const ELEMENT_DATA: PeriodicElement[] = [
|
||||
|
||||
export interface TransactionData {
|
||||
symbol: string;
|
||||
time: Date;
|
||||
count: number;
|
||||
time: string;
|
||||
count: BigInt;
|
||||
price: number;
|
||||
}
|
||||
|
||||
|
@ -25,11 +25,17 @@ export class UserDialogComponent implements OnInit {
|
||||
|
||||
onSubmit() {
|
||||
console.log(this.data);
|
||||
this.dataService.createTransaction(
|
||||
console.log(
|
||||
this.dataService
|
||||
.createTransaction(
|
||||
this.data.symbol,
|
||||
this.data.time,
|
||||
this.data.count,
|
||||
this.data.price
|
||||
)
|
||||
.subscribe((data) => {
|
||||
console.log(data);
|
||||
})
|
||||
);
|
||||
this.dialog.closeAll();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user