Standardize new vs update
This commit is contained in:
@@ -156,7 +156,11 @@
|
||||
</div>
|
||||
<div class="content-frame">
|
||||
<button type="button" (click)="prevStep()">Back</button>
|
||||
@if(isNewCompany){
|
||||
<button type="submit">CREATE COMPANY</button>
|
||||
}@else{
|
||||
<button type="submit">UPDATE COMPANY</button>
|
||||
}
|
||||
</div>
|
||||
<div class="footer-frame">
|
||||
<span>Does everything look good</span><br />
|
||||
|
||||
@@ -19,6 +19,7 @@ export class CompanyEditorComponent {
|
||||
currentStep: number = 0;
|
||||
|
||||
public newListing: Company = new Company();
|
||||
public isNewCompany: boolean = true;
|
||||
public ErrorMsg: string = "";
|
||||
MaxFileMB: number = 3;
|
||||
|
||||
@@ -36,6 +37,7 @@ export class CompanyEditorComponent {
|
||||
this.http.get<Company>("api/company?CompanyID=" + CompanyID).subscribe({
|
||||
next: data => {
|
||||
this.newListing = data;
|
||||
this.isNewCompany = false;
|
||||
},
|
||||
error: err => {
|
||||
this.ErrorMsg = err.error;
|
||||
@@ -169,9 +171,9 @@ export class CompanyEditorComponent {
|
||||
return;
|
||||
}
|
||||
|
||||
this.http.post("api/company?newCompany=true", company).subscribe({
|
||||
this.http.post("api/company", company).subscribe({
|
||||
next: data => {
|
||||
this.router.navigate([""]);
|
||||
this.router.navigate(["/company"]);
|
||||
},
|
||||
error: err => {
|
||||
this.ErrorMsg = err.error;
|
||||
|
||||
@@ -108,7 +108,11 @@
|
||||
<div class="center">
|
||||
<div class="content-frame">
|
||||
<button type="button" (click)="prevStep()">Back</button>
|
||||
<button type="submit">CREATE JOB LISTING</button>
|
||||
@if (isNewListing){
|
||||
<button type="submit">CREATE LISTING</button>
|
||||
}@else{
|
||||
<button type="submit">UPDATE LISTING</button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -20,9 +20,9 @@ export class JobEditorComponent {
|
||||
currentStep: number = 0;
|
||||
|
||||
public Listing: JobListing = new JobListing();
|
||||
public isNewListing: boolean = true;
|
||||
|
||||
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");
|
||||
@@ -39,10 +39,11 @@ export class JobEditorComponent {
|
||||
this.router.navigate([""]);
|
||||
}else if (CompanyID !== null ){
|
||||
this.mode = "new";
|
||||
this.modeID = CompanyID;
|
||||
this.Listing.companyID = CompanyID;
|
||||
}else if(JobID !== null){
|
||||
this.mode = "edit";
|
||||
this.modeID = JobID;
|
||||
this.Listing.id = JobID;
|
||||
this.isNewListing = false;
|
||||
}else if (CompanyID === null && JobID === null){
|
||||
this.router.navigate([""]);
|
||||
}
|
||||
@@ -90,14 +91,9 @@ export class JobEditorComponent {
|
||||
}
|
||||
|
||||
SubmitForm(jobListing: JobListing){
|
||||
if (this.mode === "new"){
|
||||
jobListing.companyID = this.modeID;
|
||||
} else if (this.mode === "edit"){
|
||||
jobListing.id = this.modeID;
|
||||
}
|
||||
this.http.post("api/joblisting", jobListing).subscribe({
|
||||
next: data => {
|
||||
this.router.navigate([""]);
|
||||
this.router.navigate(["/company"]);
|
||||
},
|
||||
error: err => {
|
||||
this.ErrorMsg = err.error;
|
||||
|
||||
Reference in New Issue
Block a user