diff --git a/.gitignore b/.gitignore index 854acd5..9efe7dc 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,7 @@ __screenshots__/ # System files .DS_Store Thumbs.db + +# Sensetive files +.env +.env.local diff --git a/angular.json b/angular.json index 9fdcd90..77a0468 100644 --- a/angular.json +++ b/angular.json @@ -45,7 +45,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/src/app/app.ts b/src/app/app.ts index 3679258..780b269 100644 --- a/src/app/app.ts +++ b/src/app/app.ts @@ -6,7 +6,7 @@ import { Header } from "./core/layouts/header/header"; @Component({ selector: "app-root", - imports: [RouterOutlet, Products, Footer, Header], + imports: [RouterOutlet, Footer, Header], templateUrl: "./app.html", styleUrl: "./app.css", }) diff --git a/src/app/core/layouts/footer/footer.ts b/src/app/core/layouts/footer/footer.ts index 4e74772..a87d535 100644 --- a/src/app/core/layouts/footer/footer.ts +++ b/src/app/core/layouts/footer/footer.ts @@ -1,9 +1,8 @@ import { Component } from "@angular/core"; -import { DatePipe } from "@angular/common"; import { LucideAngularModule, Mail, Phone, MapPin } from "lucide-angular"; @Component({ selector: "app-footer", - imports: [DatePipe, LucideAngularModule], + imports: [LucideAngularModule], templateUrl: "./footer.html", styleUrl: "./footer.css", }) diff --git a/src/app/core/models/user.model.ts b/src/app/core/models/user.model.ts new file mode 100644 index 0000000..096b3cc --- /dev/null +++ b/src/app/core/models/user.model.ts @@ -0,0 +1,8 @@ +export interface RegisterUserRequest{ + name: string | null; + email: string | null; + mobile_number: string | null; + password: string | null; + password_confirmation: string | null; + city: string | null; +} diff --git a/src/app/core/tokens/api-url-tokens.ts b/src/app/core/tokens/api-url-tokens.ts new file mode 100644 index 0000000..854a927 --- /dev/null +++ b/src/app/core/tokens/api-url-tokens.ts @@ -0,0 +1,7 @@ +import { InjectionToken } from "@angular/core"; +import {environment} from '../../../environments/environment'; + +export const API_URL = new InjectionToken('API_URL', { + providedIn: "root", + factory: () => environment.apiUrl +}) diff --git a/src/app/features/auth/components/register/register.html b/src/app/features/auth/components/register/register.html index 3a0e6dd..60c0aee 100644 --- a/src/app/features/auth/components/register/register.html +++ b/src/app/features/auth/components/register/register.html @@ -4,36 +4,36 @@

Sign up with your
email address to get started

-
+
Name - +
Mobile Number - +
Email - +

your-email-address@email.com

Password - +
Confirm Password - +
City - +
diff --git a/src/app/features/auth/components/register/register.ts b/src/app/features/auth/components/register/register.ts index 630e501..d6e4f60 100644 --- a/src/app/features/auth/components/register/register.ts +++ b/src/app/features/auth/components/register/register.ts @@ -1,9 +1,30 @@ -import { Component } from "@angular/core"; +import { Component, inject } from "@angular/core"; +import { FormControl, FormGroup, ReactiveFormsModule } from "@angular/forms"; +import { AuthService } from "../../services/auth-service"; +import { RegisterUserRequest } from "../../../../core/models/user.model"; @Component({ selector: "app-register", - imports: [], + imports: [ReactiveFormsModule], templateUrl: "./register.html", styleUrl: "./register.css", }) -export class Register {} +export class Register { + + authService = inject(AuthService); + + registerForm = new FormGroup({ + name :new FormControl(''), + email :new FormControl(''), + mobile_number : new FormControl(''), + password : new FormControl(''), + password_confirmation : new FormControl(''), + city : new FormControl(''), + }); + + registerUser() { + this.authService.register(this.registerForm.value as RegisterUserRequest) + .subscribe(); + } + +} diff --git a/src/app/features/auth/services/auth-service.spec.ts b/src/app/features/auth/services/auth-service.spec.ts new file mode 100644 index 0000000..ef933a9 --- /dev/null +++ b/src/app/features/auth/services/auth-service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { AuthService } from './auth-service'; + +describe('AuthService', () => { + let service: AuthService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(AuthService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/features/auth/services/auth-service.ts b/src/app/features/auth/services/auth-service.ts new file mode 100644 index 0000000..e61b363 --- /dev/null +++ b/src/app/features/auth/services/auth-service.ts @@ -0,0 +1,19 @@ +import { Injectable, inject } from '@angular/core'; +import { RegisterUserRequest } from '../../../core/models/user.model'; +import { HttpClient } from '@angular/common/http'; +import { API_URL } from '../../../core/tokens/api-url-tokens'; + +@Injectable({ + providedIn: 'root', +}) +export class AuthService { + + private http: HttpClient = inject(HttpClient); + private apiUrl = inject(API_URL); + + register(userRequest: RegisterUserRequest) { + console.log(this.apiUrl); + return this.http.post(`${this.apiUrl}/register`, userRequest); + } + +} diff --git a/src/environments/environment.development.ts b/src/environments/environment.development.ts new file mode 100644 index 0000000..9449fd4 --- /dev/null +++ b/src/environments/environment.development.ts @@ -0,0 +1,4 @@ +export const environment = { + production: false, + apiUrl: 'http://localhost:8000/api', +}; diff --git a/src/environments/environment.ts b/src/environments/environment.ts new file mode 100644 index 0000000..562aa74 --- /dev/null +++ b/src/environments/environment.ts @@ -0,0 +1,4 @@ +export const environment = { + production: false, + apiUrl: 'http://my-dev-url', +};