diff --git a/frontend/src/app/Services/auth.service.ts b/frontend/src/app/Services/auth.service.ts index 4d0ed48..a4dff21 100644 --- a/frontend/src/app/Services/auth.service.ts +++ b/frontend/src/app/Services/auth.service.ts @@ -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 { 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 { return this.http.post( AUTH_API + '/register', diff --git a/frontend/src/app/Services/data.service.ts b/frontend/src/app/Services/data.service.ts index 412efb7..a11b78a 100644 --- a/frontend/src/app/Services/data.service.ts +++ b/frontend/src/app/Services/data.service.ts @@ -51,8 +51,8 @@ export class DataService { */ public createTransaction( symbol: string, - time: Date, - count: number, + time: string, + count: BigInt, price: number ): Observable { 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, }); } diff --git a/frontend/src/app/Services/token.service.ts b/frontend/src/app/Services/token.service.ts index f56b112..8460ed6 100644 --- a/frontend/src/app/Services/token.service.ts +++ b/frontend/src/app/Services/token.service.ts @@ -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) { diff --git a/frontend/src/app/Views/dashboard/dashboard.component.ts b/frontend/src/app/Views/dashboard/dashboard.component.ts index a04fd72..3cb280b 100644 --- a/frontend/src/app/Views/dashboard/dashboard.component.ts +++ b/frontend/src/app/Views/dashboard/dashboard.component.ts @@ -45,8 +45,8 @@ const ELEMENT_DATA: PeriodicElement[] = [ export interface TransactionData { symbol: string; - time: Date; - count: number; + time: string; + count: BigInt; price: number; } diff --git a/frontend/src/app/Views/dashboard/user-dialog/user-dialog.component.ts b/frontend/src/app/Views/dashboard/user-dialog/user-dialog.component.ts index ef4b05b..a777286 100644 --- a/frontend/src/app/Views/dashboard/user-dialog/user-dialog.component.ts +++ b/frontend/src/app/Views/dashboard/user-dialog/user-dialog.component.ts @@ -25,11 +25,17 @@ export class UserDialogComponent implements OnInit { onSubmit() { console.log(this.data); - this.dataService.createTransaction( - this.data.symbol, - this.data.time, - this.data.count, - this.data.price + 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(); }