-
+
-
+
@@ -113,7 +94,7 @@
-
+
diff --git a/src/Client/src/app/pages/main/jobs/editor/jobeditor.component.ts b/src/Client/src/app/pages/main/jobs/editor/jobeditor.component.ts
index 63b61bc..b5522dc 100644
--- a/src/Client/src/app/pages/main/jobs/editor/jobeditor.component.ts
+++ b/src/Client/src/app/pages/main/jobs/editor/jobeditor.component.ts
@@ -15,31 +15,46 @@ import { Company, Employee } from 'app/models/Company';
imports: [ FormsModule, CommonModule, RouterModule ]
})
export class JobEditorComponent {
+ public ErrorMsg: string = "";
@ViewChildren('step') formSteps!: QueryList
>;
currentStep: number = 0;
- public employeeOfList: Employee[] = [];
- public selectedCompany: Company = new Company;
+ public Listing: JobListing = new JobListing();
- public newListing: JobListing = new JobListing();
- public ErrorMsg: string = "";
+ public mode: string = "";
+ public modeID: number = 0;
constructor( private http: HttpClient, private router: Router, private route: ActivatedRoute, private title: Title, public auth: Authentication ) {
this.title.setTitle("Jobs - Editor | 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;
+ this.route.queryParams.subscribe(params => {
+ const CompanyID = params['CompanyID'] ? +params['CompanyID'] : null;
+ const JobID = params['JobID'] ? +params['JobID'] : null;
+ if (CompanyID !== null && JobID !== null){
+ this.router.navigate([""]);
+ }else if (CompanyID !== null ){
+ this.mode = "new";
+ this.modeID = CompanyID;
+ }else if(JobID !== null){
+ this.mode = "edit";
+ this.modeID = JobID;
+ }else if (CompanyID === null && JobID === null){
+ this.router.navigate([""]);
+ }
+
+ if (this.mode === "edit") {
+ this.http.get("api/joblisting/" + JobID).subscribe({
+ next: data => {
+ this.Listing = data;
+ },
+ error: err => {
+ this.ErrorMsg = err.error;
+ }
+ });
}
});
- };
+ }
ngAfterViewInit(){
this.formSteps.changes.subscribe(() => {
@@ -70,8 +85,8 @@ export class JobEditorComponent {
this.updateUI();
}
- PostJobListing(jobListing: JobListing){
- jobListing.companyID = this.selectedCompany.id!;
+ PostNewJob(jobListing: JobListing){
+ jobListing.companyID = this.modeID;
this.http.post("api/joblisting", jobListing).subscribe({
next: data => {
this.router.navigate([""]);
@@ -82,4 +97,23 @@ export class JobEditorComponent {
});
}
+ PostEditJob(jobListing: JobListing){
+ this.http.post("api/joblisting", jobListing).subscribe({
+ next: data => {
+ this.router.navigate([""]);
+ },
+ error: err => {
+ this.ErrorMsg = err.error;
+ }
+ });
+ }
+
+ SubmitForm(job: JobListing){
+ if (this.mode === "new"){
+ this.PostNewJob(job);
+ }else if (this.mode === "edit"){
+ this.PostEditJob(job);
+ }
+ }
+
}
\ No newline at end of file