/** * React Subcomponent for displaying a location's UI, when that location is a company * * This subcomponent renders all of the buttons for applying to jobs at a company */ import React, { useState } from "react"; import { ApplyToJobButton } from "./ApplyToJobButton"; import { Locations } from "../Locations"; import { LocationName } from "../data/LocationNames"; import { Companies } from "../../Company/Companies"; import { CompanyPosition } from "../../Company/CompanyPosition"; import { CompanyPositions } from "../../Company/CompanyPositions"; import * as posNames from "../../Company/data/companypositionnames"; import { StdButton } from "../../ui/React/StdButton"; import { Reputation } from "../../ui/React/Reputation"; import { Favor } from "../../ui/React/Favor"; import { createPopup } from "../../ui/React/createPopup"; import { use } from "../../ui/Context"; import { QuitJobPopup } from "../../Company/ui/QuitJobPopup"; type IProps = { locName: LocationName; }; export function CompanyLocation(props: IProps): React.ReactElement { const p = use.Player(); const router = use.Router(); const setRerender = useState(false)[1]; function rerender(): void { setRerender((old) => !old); } /** * We'll keep a reference to the Company that this component is being rendered for, * so we don't have to look it up every time */ const company = Companies[props.locName]; if (company == null) throw new Error(`CompanyLocation component constructed with invalid company: ${props.locName}`); /** * Reference to the Location that this component is being rendered for */ const location = Locations[props.locName]; if (location == null) { throw new Error(`CompanyLocation component constructed with invalid location: ${props.locName}`); } /** * Name of company position that player holds, if applicable */ const jobTitle = p.jobs[props.locName] ? p.jobs[props.locName] : null; /** * CompanyPosition object for the job that the player holds at this company * (if he has one) */ const companyPosition = jobTitle ? CompanyPositions[jobTitle] : null; p.location = props.locName; function applyForAgentJob(e: React.MouseEvent): void { if (!e.isTrusted) { return; } p.applyForAgentJob(); rerender(); } function applyForBusinessConsultantJob(e: React.MouseEvent): void { if (!e.isTrusted) { return; } p.applyForBusinessConsultantJob(); rerender(); } function applyForBusinessJob(e: React.MouseEvent): void { if (!e.isTrusted) { return; } p.applyForBusinessJob(); rerender(); } function applyForEmployeeJob(e: React.MouseEvent): void { if (!e.isTrusted) { return; } p.applyForEmployeeJob(); rerender(); } function applyForItJob(e: React.MouseEvent): void { if (!e.isTrusted) { return; } p.applyForItJob(); rerender(); } function applyForPartTimeEmployeeJob(e: React.MouseEvent): void { if (!e.isTrusted) { return; } p.applyForPartTimeEmployeeJob(); rerender(); } function applyForPartTimeWaiterJob(e: React.MouseEvent): void { if (!e.isTrusted) { return; } p.applyForPartTimeWaiterJob(); rerender(); } function applyForSecurityJob(e: React.MouseEvent): void { if (!e.isTrusted) { return; } p.applyForSecurityJob(); rerender(); } function applyForSoftwareConsultantJob(e: React.MouseEvent): void { if (!e.isTrusted) { return; } p.applyForSoftwareConsultantJob(); rerender(); } function applyForSoftwareJob(e: React.MouseEvent): void { if (!e.isTrusted) { return; } p.applyForSoftwareJob(); rerender(); } function applyForWaiterJob(e: React.MouseEvent): void { if (!e.isTrusted) { return; } p.applyForWaiterJob(); rerender(); } function startInfiltration(e: React.MouseEvent): void { if (!e.isTrusted) { return; } const loc = location; if (!loc.infiltrationData) throw new Error(`trying to start infiltration at ${props.locName} but the infiltrationData is null`); router.toInfiltration(loc); } function work(e: React.MouseEvent): void { if (!e.isTrusted) { return; } const pos = companyPosition; if (pos instanceof CompanyPosition) { if (pos.isPartTimeJob() || pos.isSoftwareConsultantJob() || pos.isBusinessConsultantJob()) { p.startWorkPartTime(props.locName); } else { p.startWork(props.locName); } router.toWork(); } } function quit(e: React.MouseEvent): void { if (!e.isTrusted) return; const popupId = `quit-job-popup`; createPopup(popupId, QuitJobPopup, { locName: props.locName, company: company, player: p, onQuit: rerender, popupId: popupId, }); } const isEmployedHere = jobTitle != null; const favorGain = company.getFavorGain(); return (
{isEmployedHere && (

Job Title: {jobTitle}


-------------------------


Company reputation: {Reputation(company.playerReputation)} You will earn {Favor(favorGain[0])} company favor upon resetting after installing Augmentations



-------------------------


Company Favor: {Favor(company.favor)} Company favor increases the rate at which you earn reputation for this company by 1% per favor. Company favor is gained whenever you reset after installing Augmentations. The amount of favor you gain depends on how much reputation you have with the comapny.



-------------------------


    
)} {company.hasAgentPositions() && ( )} {company.hasBusinessConsultantPositions() && ( )} {company.hasBusinessPositions() && ( )} {company.hasEmployeePositions() && ( )} {company.hasEmployeePositions() && ( )} {company.hasITPositions() && ( )} {company.hasSecurityPositions() && ( )} {company.hasSoftwareConsultantPositions() && ( )} {company.hasSoftwarePositions() && ( )} {company.hasWaiterPositions() && ( )} {company.hasWaiterPositions() && ( )} {location.infiltrationData != null && ( )}




); }