diff --git a/src/Client/src/app/pages/main/jobs/new/jobnew.component.ts b/src/Client/src/app/pages/main/jobs/new/jobnew.component.ts
index 0d8a586..793424d 100644
--- a/src/Client/src/app/pages/main/jobs/new/jobnew.component.ts
+++ b/src/Client/src/app/pages/main/jobs/new/jobnew.component.ts
@@ -6,6 +6,7 @@ import { Title } from '@angular/platform-browser';
import { CommonModule } from '@angular/common';
import { JobListing } from 'app/models/JobListing';
import { Authentication } from 'app/services/Authentication';
+import { Company, Employee } from 'app/models/Company';
@Component({
selector: 'main-jobs-new',
@@ -18,11 +19,26 @@ export class JobNewComponent {
@ViewChildren('step') formSteps!: QueryList
>;
currentStep: number = 0;
+ public employeeOfList: Employee[] = [];
+ public selectedCompany: Company = new Company;
+
public newListing: JobListing = new JobListing();
public ErrorMsg: string = "";
constructor( private http: HttpClient, private router: Router, private route: ActivatedRoute, private title: Title, public auth: Authentication ) {
this.title.setTitle("Jobs - new | BoredCareers");
+
+ this.http.get("api/employee").subscribe({
+ next: empOf => {
+ if (empOf.length === 0){
+ router.navigate(["company/connect"]);
+ }
+ this.employeeOfList = empOf;
+ },
+ error: err => {
+ this.ErrorMsg = err.error;
+ }
+ });
};
ngAfterViewInit(){
@@ -64,12 +80,13 @@ export class JobNewComponent {
}
PostJobListing(jobListing: JobListing){
+ jobListing.companyID = this.selectedCompany.id;
this.http.post("api/joblisting", jobListing).subscribe({
next: data => {
-
+ this.router.navigate([""]);
},
error: err => {
- alert("Failed to create the job listing. Try again");
+ this.ErrorMsg = err.error;
}
});
}