route issues fixed
This commit is contained in:
@@ -33,7 +33,7 @@
|
||||
"src/assets/scss/black-dashboard.scss",
|
||||
"src/assets/css/nucleo-icons.css"
|
||||
],
|
||||
"scripts": [],
|
||||
"scripts": []
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
|
||||
15987
package-lock.json
generated
15987
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
54
src/app/app-routing.module copy.ts
Normal file
54
src/app/app-routing.module copy.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import { NgModule } from "@angular/core";
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { BrowserModule } from "@angular/platform-browser";
|
||||
import { Routes, RouterModule } from "@angular/router";
|
||||
import { LoginComponent } from "./pages/login/login.component";
|
||||
import { AdminLayoutComponent } from "./layouts/admin-layout/admin-layout.component";
|
||||
import { AuthLayoutComponent } from './layouts/auth-layout/auth-layout.component';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: "login",
|
||||
component: LoginComponent
|
||||
},
|
||||
{
|
||||
path: "",
|
||||
redirectTo: "login",
|
||||
pathMatch: "full"
|
||||
},
|
||||
{
|
||||
path: "",
|
||||
component: AdminLayoutComponent,
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
loadChildren: () => import ("./layouts/admin-layout/admin-layout.module").then(m => m.AdminLayoutModule)
|
||||
}
|
||||
]
|
||||
}, {
|
||||
path: "",
|
||||
component: AuthLayoutComponent,
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
loadChildren: () => import ("./layouts/auth-layout/auth-layout.module").then(m => m.AuthLayoutModule)
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: "**",
|
||||
redirectTo: "login"
|
||||
}
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
BrowserModule,
|
||||
RouterModule.forRoot(routes, {
|
||||
useHash: true
|
||||
})
|
||||
],
|
||||
exports: [RouterModule]
|
||||
})
|
||||
export class AppRoutingModule {}
|
||||
@@ -1,20 +1,21 @@
|
||||
import { NgModule } from "@angular/core";
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { BrowserModule } from "@angular/platform-browser";
|
||||
import { Routes, RouterModule } from "@angular/router";
|
||||
import { Routes, RouterModule, Router } from "@angular/router";
|
||||
import { LoginComponent } from "./pages/login/login.component";
|
||||
import { AdminLayoutComponent } from "./layouts/admin-layout/admin-layout.component";
|
||||
import { AuthLayoutComponent } from './layouts/auth-layout/auth-layout.component';
|
||||
import { AuthLayoutComponent } from "./layouts/auth-layout/auth-layout.component";
|
||||
import { AuthService } from "./services/auth.service";
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: "login",
|
||||
component: LoginComponent
|
||||
component: LoginComponent,
|
||||
},
|
||||
{
|
||||
path: "",
|
||||
redirectTo: "company-information",
|
||||
pathMatch: "full"
|
||||
redirectTo: "login",
|
||||
pathMatch: "full",
|
||||
},
|
||||
{
|
||||
path: "",
|
||||
@@ -22,23 +23,30 @@ const routes: Routes = [
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
loadChildren: () => import ("./layouts/admin-layout/admin-layout.module").then(m => m.AdminLayoutModule)
|
||||
}
|
||||
]
|
||||
}, {
|
||||
loadChildren: () =>
|
||||
import("./layouts/admin-layout/admin-layout.module").then(
|
||||
(m) => m.AdminLayoutModule
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "",
|
||||
component: AuthLayoutComponent,
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
loadChildren: () => import ("./layouts/auth-layout/auth-layout.module").then(m => m.AuthLayoutModule)
|
||||
}
|
||||
]
|
||||
loadChildren: () =>
|
||||
import("./layouts/auth-layout/auth-layout.module").then(
|
||||
(m) => m.AuthLayoutModule
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "**",
|
||||
redirectTo: "company-information"
|
||||
}
|
||||
redirectTo: "login",
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
@@ -46,9 +54,23 @@ const routes: Routes = [
|
||||
CommonModule,
|
||||
BrowserModule,
|
||||
RouterModule.forRoot(routes, {
|
||||
useHash: true
|
||||
})
|
||||
useHash: true,
|
||||
}),
|
||||
],
|
||||
exports: [RouterModule]
|
||||
exports: [RouterModule],
|
||||
})
|
||||
export class AppRoutingModule {}
|
||||
export class AppRoutingModule {
|
||||
companyLocalStorage: any;
|
||||
|
||||
constructor(private router: Router, private authService: AuthService) {
|
||||
this.companyLocalStorage = localStorage.getItem("companyData");
|
||||
|
||||
console.log("this.companyLocalStorage, ", this.companyLocalStorage);
|
||||
|
||||
if (this.companyLocalStorage !== null) {
|
||||
this.router.navigate(["company-information"]);
|
||||
} else {
|
||||
this.router.navigate(["login"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,20 +7,18 @@ import { Router } from "@angular/router";
|
||||
styleUrls: ["./app.component.scss"],
|
||||
})
|
||||
export class AppComponent implements OnInit {
|
||||
title = "black-dashboard-angular";
|
||||
title = "Talenttic Tech Hub CRM";
|
||||
companyLocalStorage: any;
|
||||
|
||||
constructor(private router: Router) {
|
||||
this.companyLocalStorage = JSON.parse(
|
||||
localStorage.getItem("companyData") || "{}"
|
||||
);
|
||||
this.companyLocalStorage = localStorage.getItem("companyData");
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
if (this.companyLocalStorage) {
|
||||
this.router.navigate(["/company-information"]);
|
||||
if (this.companyLocalStorage !== null) {
|
||||
this.router.navigate(["company-information"]);
|
||||
} else {
|
||||
this.router.navigate(["/login"]);
|
||||
this.router.navigate(["login"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,7 +224,7 @@ export class NavbarComponent implements OnInit, OnDestroy {
|
||||
this.toastr.success("Logout Successfully");
|
||||
|
||||
setTimeout(() => {
|
||||
this.router.navigate(["login"]);
|
||||
this.router.navigate(["/login"]);
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,10 +8,8 @@
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div style="text-align: center; margin-bottom: 3rem;">
|
||||
<h1>
|
||||
TALENTTIC TECH HUB CRM
|
||||
</h1>
|
||||
<div style="text-align: center; margin-bottom: 3rem">
|
||||
<h1>TALENTTIC TECH HUB CRM</h1>
|
||||
</div>
|
||||
|
||||
<ng-container *ngIf="loginSuccess">
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Component, OnInit } from "@angular/core";
|
||||
import { FormGroup, FormBuilder, Validators } from "@angular/forms";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { CompanyService } from "../../services/company.service";
|
||||
import { AuthService } from "../../services/auth.service";
|
||||
|
||||
@Component({
|
||||
selector: "app-login",
|
||||
@@ -21,6 +22,7 @@ export class LoginComponent implements OnInit {
|
||||
constructor(
|
||||
private fb: FormBuilder,
|
||||
private companyService: CompanyService,
|
||||
private authService: AuthService,
|
||||
private router: Router,
|
||||
private route: ActivatedRoute
|
||||
) {
|
||||
@@ -49,14 +51,14 @@ export class LoginComponent implements OnInit {
|
||||
}
|
||||
|
||||
signin() {
|
||||
const email = this.company.email;
|
||||
const password = this.company.password;
|
||||
|
||||
if (this.loginForm.invalid) {
|
||||
console.log("Form error");
|
||||
return;
|
||||
}
|
||||
|
||||
const email = this.company.email;
|
||||
const password = this.company.password;
|
||||
|
||||
if (
|
||||
this.loginForm.value.companyEmail !== email ||
|
||||
this.loginForm.value.password !== password
|
||||
@@ -74,10 +76,17 @@ export class LoginComponent implements OnInit {
|
||||
localStorage.getItem("companyData") || "{}"
|
||||
);
|
||||
|
||||
if (this.companyLocalStorage) {
|
||||
const isLoggedIn = this.authService.login(
|
||||
this.loginForm.value.companyEmail,
|
||||
this.loginForm.value.password
|
||||
);
|
||||
|
||||
if (isLoggedIn) {
|
||||
setTimeout(() => {
|
||||
this.router.navigate(["/company-information"]);
|
||||
this.router.navigate(["company-information"]);
|
||||
}, 1000);
|
||||
|
||||
console.log(true);
|
||||
} else {
|
||||
this.router.navigate(["/login"]);
|
||||
}
|
||||
|
||||
40
src/app/services/auth.service.ts
Normal file
40
src/app/services/auth.service.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { Injectable } from "@angular/core";
|
||||
|
||||
@Injectable({
|
||||
providedIn: "root",
|
||||
})
|
||||
export class AuthService {
|
||||
private isLoggedIn: boolean = false;
|
||||
companyLocalStorage: any;
|
||||
|
||||
constructor() {
|
||||
this.companyLocalStorage = JSON.parse(
|
||||
localStorage.getItem("companyData") || "{}"
|
||||
);
|
||||
}
|
||||
|
||||
login(email: string, password: string): boolean {
|
||||
// Implement login logic here
|
||||
// Sets isLoggedIn to true if email and password satisfy conditions
|
||||
if (email.length > 6 && email.includes("@") && password.length > 4) {
|
||||
this.isLoggedIn = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
logout(): void {
|
||||
// Implement your logout logic here
|
||||
this.isLoggedIn = false;
|
||||
}
|
||||
|
||||
isLoggedInMethod(): boolean {
|
||||
if (this.companyLocalStorage) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
// return this.isLoggedIn;
|
||||
}
|
||||
}
|
||||
@@ -163,7 +163,7 @@
|
||||
}
|
||||
.form-control[disabled], .form-control[readonly], fieldset[disabled] .form-control {
|
||||
background-color: $black-states;
|
||||
color: $default;
|
||||
color: #999;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user