Get New Job Listing Functional

This commit is contained in:
2025-07-20 22:08:41 -07:00
parent 2bf8909930
commit d2536c1749
4 changed files with 42 additions and 3 deletions
@@ -1,3 +1,9 @@
.full-width {
display: block;
width: 100%;
column-count: 2;
}
.tile-frame { .tile-frame {
column-count: 4; column-count: 4;
column-gap: 20px; column-gap: 20px;
@@ -19,7 +19,7 @@
<button (click)="RemoveJobListing(cur.id)">DELETE</button> <button (click)="RemoveJobListing(cur.id)">DELETE</button>
</div> </div>
<div> <div>
<button [routerLink]="['/jobs/new']">NEW</button> <button [routerLink]="['/jobs/new']">POST JOB</button>
</div> </div>
</div> </div>
@@ -2,12 +2,28 @@
<h1>POST A NEW JOB</h1> <h1>POST A NEW JOB</h1>
</div> </div>
<form (ngSubmit)="PostJobListing(newListing)"> <form (ngSubmit)="PostJobListing(newListing)">
<!-- Attach To Company -->
<div #step class="sub-frame">
<div class="center">
<div class="content-frame">
<label>For What Company</label>
<select name="company" [(ngModel)]="selectedCompany">
<option value="">-- Select Company --</option>
<option *ngFor="let cur of employeeOfList" [ngValue]="cur.company">{{ cur.company.name }}</option>
</select>
<button type="button" (click)="nextStep()">Next</button>
</div>
</div>
</div>
<!-- Title --> <!-- Title -->
<div #step class="sub-frame"> <div #step class="sub-frame">
<div class="center"> <div class="center">
<div class="content-frame"> <div class="content-frame">
<label>Job Title</label> <label>Job Title</label>
<input name="title" [(ngModel)]="newListing.title" type="text" /> <input name="title" [(ngModel)]="newListing.title" type="text" />
<button type="button" (click)="prevStep()">Back</button>
<button type="button" (click)="nextStep()">Next</button> <button type="button" (click)="nextStep()">Next</button>
</div> </div>
</div> </div>
@@ -6,6 +6,7 @@ import { Title } from '@angular/platform-browser';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { JobListing } from 'app/models/JobListing'; import { JobListing } from 'app/models/JobListing';
import { Authentication } from 'app/services/Authentication'; import { Authentication } from 'app/services/Authentication';
import { Company, Employee } from 'app/models/Company';
@Component({ @Component({
selector: 'main-jobs-new', selector: 'main-jobs-new',
@@ -18,11 +19,26 @@ export class JobNewComponent {
@ViewChildren('step') formSteps!: QueryList<ElementRef<HTMLDivElement>>; @ViewChildren('step') formSteps!: QueryList<ElementRef<HTMLDivElement>>;
currentStep: number = 0; currentStep: number = 0;
public employeeOfList: Employee[] = [];
public selectedCompany: Company = new Company;
public newListing: JobListing = new JobListing(); public newListing: JobListing = new JobListing();
public ErrorMsg: string = ""; public ErrorMsg: string = "";
constructor( private http: HttpClient, private router: Router, private route: ActivatedRoute, private title: Title, public auth: Authentication ) { constructor( private http: HttpClient, private router: Router, private route: ActivatedRoute, private title: Title, public auth: Authentication ) {
this.title.setTitle("Jobs - new | BoredCareers"); this.title.setTitle("Jobs - new | BoredCareers");
this.http.get<Employee[]>("api/employee").subscribe({
next: empOf => {
if (empOf.length === 0){
router.navigate(["company/connect"]);
}
this.employeeOfList = empOf;
},
error: err => {
this.ErrorMsg = err.error;
}
});
}; };
ngAfterViewInit(){ ngAfterViewInit(){
@@ -64,12 +80,13 @@ export class JobNewComponent {
} }
PostJobListing(jobListing: JobListing){ PostJobListing(jobListing: JobListing){
jobListing.companyID = this.selectedCompany.id;
this.http.post("api/joblisting", jobListing).subscribe({ this.http.post("api/joblisting", jobListing).subscribe({
next: data => { next: data => {
this.router.navigate([""]);
}, },
error: err => { error: err => {
alert("Failed to create the job listing. Try again"); this.ErrorMsg = err.error;
} }
}); });
} }