diff --git a/frontend/angular.json b/frontend/angular.json
index 1e82ada..d0023de 100644
--- a/frontend/angular.json
+++ b/frontend/angular.json
@@ -51,7 +51,13 @@
"development": {
"optimization": false,
"extractLicenses": false,
- "sourceMap": true
+ "sourceMap": true,
+ "fileReplacements": [
+ {
+ "replace": "src/environments/environment.ts",
+ "with": "src/environments/environment.development.ts"
+ }
+ ]
}
},
"defaultConfiguration": "production"
diff --git a/frontend/src/app/app.config.ts b/frontend/src/app/app.config.ts
index a1e7d6f..f570fce 100644
--- a/frontend/src/app/app.config.ts
+++ b/frontend/src/app/app.config.ts
@@ -1,8 +1,9 @@
-import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
-import { provideRouter } from '@angular/router';
+import {ApplicationConfig, provideZoneChangeDetection} from '@angular/core';
+import {provideRouter} from '@angular/router';
-import { routes } from './app.routes';
+import {routes} from './app.routes';
+import {provideHttpClient} from "@angular/common/http";
export const appConfig: ApplicationConfig = {
- providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes)]
+ providers: [provideZoneChangeDetection({eventCoalescing: true}), provideRouter(routes), provideHttpClient()]
};
diff --git a/frontend/src/app/model/util.ts b/frontend/src/app/model/util.ts
index a663d5e..f4e952b 100644
--- a/frontend/src/app/model/util.ts
+++ b/frontend/src/app/model/util.ts
@@ -1,5 +1,5 @@
export const EMAIL_REGEX = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
export function verify_email(email: string): boolean {
- return EMAIL_REGEX.test(email);
+ return email.length > 0 && EMAIL_REGEX.test(email);
}
diff --git a/frontend/src/app/page/onboarding/registration/registration.component.html b/frontend/src/app/page/onboarding/registration/registration.component.html
index 76a282e..f358850 100644
--- a/frontend/src/app/page/onboarding/registration/registration.component.html
+++ b/frontend/src/app/page/onboarding/registration/registration.component.html
@@ -9,7 +9,7 @@
diff --git a/frontend/src/app/page/onboarding/registration/registration.component.ts b/frontend/src/app/page/onboarding/registration/registration.component.ts
index e559b48..c1e593a 100644
--- a/frontend/src/app/page/onboarding/registration/registration.component.ts
+++ b/frontend/src/app/page/onboarding/registration/registration.component.ts
@@ -5,6 +5,7 @@ import {Router, RouterLink} from "@angular/router";
import {TextButtonComponent} from "../../../atomic/text-button/text-button.component";
import {Onboarding} from "../../../model/onboarding";
import {verify_email} from "../../../model/util";
+import {ApiService} from "../../../service/api.service";
@Component({
selector: 'app-registration',
@@ -20,7 +21,7 @@ import {verify_email} from "../../../model/util";
export class RegistrationComponent implements OnInit {
mail: string = '';
- constructor(private router: Router) {
+ constructor(private router: Router, private api: ApiService) {
}
ngOnInit() {
@@ -35,7 +36,7 @@ export class RegistrationComponent implements OnInit {
return verify_email(this.mail);
}
- set_mail() {
+ register() {
const focusedElement = document.activeElement as HTMLElement;
if (focusedElement) {
focusedElement.blur();
@@ -62,7 +63,17 @@ export class RegistrationComponent implements OnInit {
onboarding.mail = this.mail;
}
localStorage.setItem('onboarding', JSON.stringify(onboarding));
- this.router.navigateByUrl('/onboarding/verification').then(_ => {
- });
+ this.api.register(this.mail).subscribe(
+ {
+ next: (resp: any) => {
+ console.info(resp);
+ this.router.navigateByUrl('/onboarding/verification').then(_ => {
+ });
+ },
+ error: (error) => {
+ console.error(error);
+ }
+ }
+ );
}
}
diff --git a/frontend/src/app/service/api.service.spec.ts b/frontend/src/app/service/api.service.spec.ts
new file mode 100644
index 0000000..c0310ae
--- /dev/null
+++ b/frontend/src/app/service/api.service.spec.ts
@@ -0,0 +1,16 @@
+import { TestBed } from '@angular/core/testing';
+
+import { ApiService } from './api.service';
+
+describe('ApiService', () => {
+ let service: ApiService;
+
+ beforeEach(() => {
+ TestBed.configureTestingModule({});
+ service = TestBed.inject(ApiService);
+ });
+
+ it('should be created', () => {
+ expect(service).toBeTruthy();
+ });
+});
diff --git a/frontend/src/app/service/api.service.ts b/frontend/src/app/service/api.service.ts
new file mode 100644
index 0000000..a5d0247
--- /dev/null
+++ b/frontend/src/app/service/api.service.ts
@@ -0,0 +1,19 @@
+import {Injectable} from '@angular/core';
+import {HttpClient} from "@angular/common/http";
+import {environment} from "../../environments/environment";
+import {Observable} from "rxjs";
+
+@Injectable({
+ providedIn: 'root'
+})
+export class ApiService {
+
+ constructor(private http: HttpClient) {
+ }
+
+ register(mail: string): Observable {
+ return this.http.post(`${environment.apiUrl}/api/v1/onboarding/register`, JSON.stringify({"email_address": mail}), {
+ headers: {'Content-Type': 'application/json'}
+ });
+ }
+}
diff --git a/frontend/src/environments/environment.development.ts b/frontend/src/environments/environment.development.ts
new file mode 100644
index 0000000..02c3b74
--- /dev/null
+++ b/frontend/src/environments/environment.development.ts
@@ -0,0 +1,4 @@
+export const environment = {
+ production: false,
+ apiUrl: 'http://127.0.0.1:8000'
+};
diff --git a/frontend/src/environments/environment.ts b/frontend/src/environments/environment.ts
new file mode 100644
index 0000000..7a47566
--- /dev/null
+++ b/frontend/src/environments/environment.ts
@@ -0,0 +1,4 @@
+export const environment = {
+ production: true,
+ apiUrl: '',
+};
diff --git a/frontend/src/main.ts b/frontend/src/main.ts
index 35b00f3..dd0f460 100644
--- a/frontend/src/main.ts
+++ b/frontend/src/main.ts
@@ -1,6 +1,16 @@
-import { bootstrapApplication } from '@angular/platform-browser';
-import { appConfig } from './app/app.config';
-import { AppComponent } from './app/app.component';
+import {bootstrapApplication} from '@angular/platform-browser';
+import {appConfig} from './app/app.config';
+import {AppComponent} from './app/app.component';
+import {environment} from "./environments/environment";
+import {enableProdMode} from "@angular/core";
+
+environment.apiUrl = `${window.location.protocol}//${window.location.host}`;
+
+if (environment.production) {
+ enableProdMode();
+} else {
+ environment.apiUrl += '8000';
+}
bootstrapApplication(AppComponent, appConfig)
- .catch((err) => console.error(err));
+ .catch((err) => console.error(err));