Commit 6b447bc1 authored by vtduong0912's avatar vtduong0912

refactor: optimized

parent 41d4ff00
...@@ -19,7 +19,7 @@ export class JobManagerService { ...@@ -19,7 +19,7 @@ export class JobManagerService {
} }
jobsGetOne(id: string) { jobsGetOne(id: string) {
return this._http.get<ResponseResult<JobApi.Response>>('jobs/' + id); return this._http.get<ResponseResult<JobApi.Response>>(`jobs/${id}`);
} }
jobsPost(request: JobApi.Request) { jobsPost(request: JobApi.Request) {
...@@ -27,10 +27,10 @@ export class JobManagerService { ...@@ -27,10 +27,10 @@ export class JobManagerService {
} }
jobsPut(id: string, request: JobApi.Request) { jobsPut(id: string, request: JobApi.Request) {
return this._http.put<ResponseResult<JobApi.Request>>('jobs/' + id, request); return this._http.put<ResponseResult<JobApi.Request>>(`jobs/${id}`, request);
} }
jobsDelete(id: string) { jobsDelete(id: string) {
return this._http.delete<ResponseResult<JobApi.Request>>('jobs/' + id); return this._http.delete<ResponseResult<JobApi.Request>>(`jobs/${id}`);
} }
} }
\ No newline at end of file
...@@ -51,7 +51,7 @@ import { catchError, of, tap } from 'rxjs'; ...@@ -51,7 +51,7 @@ import { catchError, of, tap } from 'rxjs';
` `
}) })
export class JobFormComponent implements OnInit, OnDestroy { export class JobFormComponent implements OnInit {
isCreate: boolean = false; isCreate: boolean = false;
...@@ -75,10 +75,6 @@ export class JobFormComponent implements OnInit, OnDestroy { ...@@ -75,10 +75,6 @@ export class JobFormComponent implements OnInit, OnDestroy {
} }
ngOnDestroy() {
}
onCreateSubmit() { onCreateSubmit() {
const data = this.jobCreatingFormGroup.value; const data = this.jobCreatingFormGroup.value;
if (!this.jobCreatingFormGroup.valid) { if (!this.jobCreatingFormGroup.valid) {
......
...@@ -228,7 +228,6 @@ export class JobListComponent implements OnInit { ...@@ -228,7 +228,6 @@ export class JobListComponent implements OnInit {
tap((response: ResponseResult<JobApi.Request>) => { tap((response: ResponseResult<JobApi.Request>) => {
this.getAllJobs(); this.getAllJobs();
this.isEdit = false; this.isEdit = false;
console.log(response);
}), }),
catchError((err) => { catchError((err) => {
console.log(err); console.log(err);
...@@ -245,7 +244,7 @@ export class JobListComponent implements OnInit { ...@@ -245,7 +244,7 @@ export class JobListComponent implements OnInit {
.pipe( .pipe(
tap((response: ResponseResult<JobApi.Response>) => { tap((response: ResponseResult<JobApi.Response>) => {
this.jobEdittingFormGroup = this._fb.group({ this.jobEdittingFormGroup = this._fb.group({
type: [response.responseData?.type, Validators.required], type: ['', Validators.required],
company: [response.responseData?.company, Validators.required], company: [response.responseData?.company, Validators.required],
company_url: [response.responseData?.company_url, Validators.required], company_url: [response.responseData?.company_url, Validators.required],
location: [response.responseData?.location, Validators.required], location: [response.responseData?.location, Validators.required],
......
...@@ -11,7 +11,7 @@ export class AuthGuard implements CanActivate { ...@@ -11,7 +11,7 @@ export class AuthGuard implements CanActivate {
const isLoggedIn = this._service.isLoggedIn(); const isLoggedIn = this._service.isLoggedIn();
const isAdmin = this._service.isAdmin(); const isAdmin = this._service.isAdmin();
if (!isLoggedIn || !isAdmin) { if (!isLoggedIn || !isAdmin) {
this._router.navigate(['/']); this._router.navigate(['/home']);
return false; return false;
} }
return true; return true;
......
...@@ -8,6 +8,10 @@ import { AuthService } from '../service/auth.service'; ...@@ -8,6 +8,10 @@ import { AuthService } from '../service/auth.service';
export class LoginGuard implements CanActivate { export class LoginGuard implements CanActivate {
constructor(private _service: AuthService, private _router: Router) {} constructor(private _service: AuthService, private _router: Router) {}
canActivate(): boolean { canActivate(): boolean {
return !this._service.isLoggedIn(); if (this._service.isLoggedIn()) {
this._router.navigate(['/home']);
return false;
}
return true;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment