From d8762408d4d89aa547be6b3f809a23405f1beb5a Mon Sep 17 00:00:00 2001 From: Derek Holloway Date: Fri, 18 Jul 2025 19:55:53 -0700 Subject: [PATCH] Start work on Company New --- src/Client/src/app/app.routes.ts | 4 + .../connect/companyconnect.component.css | 93 +++++++++++ .../connect/companyconnect.component.html | 147 ++++++++++++++++++ .../connect/companyconnect.component.ts | 77 +++++++++ src/Server/Controllers/CompanyController.cs | 26 +++- 5 files changed, 340 insertions(+), 7 deletions(-) create mode 100644 src/Client/src/app/pages/main/company/connect/companyconnect.component.css create mode 100644 src/Client/src/app/pages/main/company/connect/companyconnect.component.html create mode 100644 src/Client/src/app/pages/main/company/connect/companyconnect.component.ts diff --git a/src/Client/src/app/app.routes.ts b/src/Client/src/app/app.routes.ts index 7fec6b3..9a9b176 100644 --- a/src/Client/src/app/app.routes.ts +++ b/src/Client/src/app/app.routes.ts @@ -14,6 +14,7 @@ import { JobsComponent } from './pages/main/jobs/jobs.component'; import { ResumesComponent } from './pages/main/resumes/resumes.component'; import { JobNewComponent } from './pages/main/jobs/new/jobnew.component'; import { JobEditComponent } from './pages/main/jobs/edit/jobedit.component'; +import { CompanyConnectComponent } from './pages/main/company/connect/companyconnect.component'; export const routes: Routes = [ @@ -26,6 +27,9 @@ export const routes: Routes = [ { path: "jobs/new", component: JobNewComponent }, { path: "jobs/edit", component: JobEditComponent }, + // Company + { path: "company/connect", component: CompanyConnectComponent }, + // Account stuff { path: "account/forgotpassword", component: ForgotPasswordComponent }, { path: "account/resetpassword", component: ResetPasswordComponent }, diff --git a/src/Client/src/app/pages/main/company/connect/companyconnect.component.css b/src/Client/src/app/pages/main/company/connect/companyconnect.component.css new file mode 100644 index 0000000..4203dc9 --- /dev/null +++ b/src/Client/src/app/pages/main/company/connect/companyconnect.component.css @@ -0,0 +1,93 @@ +.title-text { + width: 100%; + text-align: center; +} + +form { + display: grid; + grid-template-areas: "stack"; + position: relative; + width: 100%; + overflow: hidden; + transition: 0.5s; +} + +.center { + width: 100%; + display: grid; + justify-content: center; +} + +.sub-frame { + position: relative; + grid-area: stack; + transition: 0.5s; + width: 100%; + text-align: center; +} + +.content-frame { + background-color: #00000088; + border-radius: 10px; + padding: 40px; + break-inside: avoid; + margin-bottom: 20px; +} + +.footer-frame { + background-color: #00000044; + border-radius: 10px; + padding: 10px; + break-inside: avoid; + margin-bottom: 20px; +} + +.split { + column-count: 2; +} + +.half-frame { + width: 400px; + break-inside: avoid; +} + +.content-frame label { + color: #FFF; +} + +.content-frame textarea { + width: calc(100% - 40px); + margin: 0 20px; + height: 200px; + resize: none; +} + +.content-frame input { + width: calc(50% - 24px); + margin: 0 calc(25% + 10px); + margin-bottom: 20px; + appearance: textfield; +} + +.content-frame input:focus ~ label { + color: green; +} + +.content-frame select { + width: calc(50% - 24px); + margin: 0 calc(25% + 10px); + margin-bottom: 20px; +} + +.tile-frame { + column-count: 4; + column-gap: 20px; + padding: 20px; + width: calc(100% - 40px); +} + +.tile{ + background-color: var(--Mistox-Dark)\); + height: 40px; + break-inside: avoid; +} \ No newline at end of file diff --git a/src/Client/src/app/pages/main/company/connect/companyconnect.component.html b/src/Client/src/app/pages/main/company/connect/companyconnect.component.html new file mode 100644 index 0000000..12111ca --- /dev/null +++ b/src/Client/src/app/pages/main/company/connect/companyconnect.component.html @@ -0,0 +1,147 @@ +
+

Connect To Company

+
+
+ +
+
+
+ + + +
+ +
+
+ + +
+
+
+ + + + +
+ +
+
+ + +
+
+
+ + + + +
+ +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+

Job Location

+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ + +
+
+
+ + +
+
+
+ + + + +
+
+
+ + +
+
+
+ {{ newListing.name }} + +
+
+
+ city: {{ newListing.city }} +
+
+ country: {{ newListing.country }} +
+
+
+
+ state: {{ newListing.stateOrRegion }} +
+
+ postal code: {{ newListing.postalCode }} +
+
+
+ {{ newListing.description }} +
+
+
+ + +
+
+
+
\ No newline at end of file diff --git a/src/Client/src/app/pages/main/company/connect/companyconnect.component.ts b/src/Client/src/app/pages/main/company/connect/companyconnect.component.ts new file mode 100644 index 0000000..2bb7cb7 --- /dev/null +++ b/src/Client/src/app/pages/main/company/connect/companyconnect.component.ts @@ -0,0 +1,77 @@ +import { Component, ElementRef, QueryList, ViewChildren } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { FormsModule } from '@angular/forms'; +import { Router, ActivatedRoute, RouterModule } from '@angular/router'; +import { Title } from '@angular/platform-browser'; +import { CommonModule } from '@angular/common'; +import { Authentication } from 'app/services/Authentication'; +import { Company } from 'app/models/Company'; + +@Component({ + selector: 'main-company-connect', + templateUrl: './companyconnect.component.html', + styleUrls: [ './companyconnect.component.css' ], + imports: [ FormsModule, CommonModule, RouterModule ] +}) +export class CompanyConnectComponent { + + @ViewChildren('step') formSteps!: QueryList>; + currentStep: number = 0; + + public newListing: Company = new Company(); + public ErrorMsg: string = ""; + + constructor( private http: HttpClient, private router: Router, private route: ActivatedRoute, private title: Title, public auth: Authentication ) { + this.title.setTitle("Company - Connect | BoredCareers"); + }; + + ngAfterViewInit(){ + this.formSteps.forEach((step: ElementRef, i: number) => { + if (i === this.currentStep) { + step.nativeElement.style.left = '0%'; + } else if (i < this.currentStep) { + step.nativeElement.style.left = '-100%'; + } else { + step.nativeElement.style.left = '100%'; + } + }); + } + + nextStep(){ + this.currentStep += 1; + this.formSteps.forEach((step: ElementRef, i: number) => { + if (i === this.currentStep) { + step.nativeElement.style.left = '0%'; + } else if (i < this.currentStep) { + step.nativeElement.style.left = '-100%'; + } else { + step.nativeElement.style.left = '100%'; + } + }); + } + + prevStep(){ + this.currentStep -= 1; + this.formSteps.forEach((step: ElementRef, i: number) => { + if (i === this.currentStep) { + step.nativeElement.style.left = '0%'; + } else if (i < this.currentStep) { + step.nativeElement.style.left = '-100%'; + } else { + step.nativeElement.style.left = '100%'; + } + }); + } + + PostNewCompany(company: Company){ + this.http.post("api/company?newCompany=true", company).subscribe({ + next: data => { + this.router.navigate([""]); + }, + error: err => { + alert("Failed to create the job listing. Err: " + err.error); + } + }); + } + +} \ No newline at end of file diff --git a/src/Server/Controllers/CompanyController.cs b/src/Server/Controllers/CompanyController.cs index cb644a2..2424d44 100644 --- a/src/Server/Controllers/CompanyController.cs +++ b/src/Server/Controllers/CompanyController.cs @@ -17,19 +17,30 @@ namespace BoredCareers.Controllers { if (company != null) { return Ok(company); } + return NotFound("Company doesn't exist"); } - return NotFound(); + return NotFound("Not logged in"); } [HttpPost] - public async Task SetCompany([FromBody] Company company) { + public async Task SetCompany([FromBody] Company company, [FromQuery] bool newCompany = false) { if (isLoggedIn()) { - if (await isLoggedInUserEmployeeOf(company.ID)) { - await _databaseService.SetCompany(company); - return Ok(); + if (newCompany) { + Company? test = await _databaseService.GetCompany(company.ID); + if (test == null) { + await _databaseService.SetCompany(company); + return Ok(); + } + return NotFound("The company already exists"); + } else { + if (await isLoggedInUserEmployeeOf(company.ID)) { + await _databaseService.SetCompany(company); + return Ok(); + } + return NotFound("You are not an employee of company"); } } - return NotFound(); + return NotFound("Not logged in"); } [HttpDelete] @@ -39,8 +50,9 @@ namespace BoredCareers.Controllers { await _databaseService.DeleteCompany(CompanyID); return Ok(); } + return NotFound("You are not an employee of company"); } - return NotFound(); + return NotFound("Not logged in"); } }