2019-03-29 08:12:41 +01:00
|
|
|
/**
|
2019-04-01 11:23:25 +02:00
|
|
|
* 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
|
2019-03-29 08:12:41 +01:00
|
|
|
*/
|
2021-09-18 01:43:08 +02:00
|
|
|
import React, { useState } from "react";
|
2019-03-29 08:12:41 +01:00
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
import { ApplyToJobButton } from "./ApplyToJobButton";
|
2019-03-29 08:12:41 +01:00
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
import { Locations } from "../Locations";
|
|
|
|
import { LocationName } from "../data/LocationNames";
|
2019-03-29 08:12:41 +01:00
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
import { Companies } from "../../Company/Companies";
|
|
|
|
import { CompanyPosition } from "../../Company/CompanyPosition";
|
|
|
|
import { CompanyPositions } from "../../Company/CompanyPositions";
|
|
|
|
import * as posNames from "../../Company/data/companypositionnames";
|
2019-04-01 11:23:25 +02:00
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
import { StdButton } from "../../ui/React/StdButton";
|
|
|
|
import { Reputation } from "../../ui/React/Reputation";
|
|
|
|
import { Favor } from "../../ui/React/Favor";
|
2021-09-13 00:03:07 +02:00
|
|
|
import { createPopup } from "../../ui/React/createPopup";
|
2021-09-18 01:43:08 +02:00
|
|
|
import { use } from "../../ui/Context";
|
2021-09-13 00:03:07 +02:00
|
|
|
import { QuitJobPopup } from "../../Company/ui/QuitJobPopup";
|
2021-04-29 02:07:26 +02:00
|
|
|
|
2019-03-29 08:12:41 +01:00
|
|
|
type IProps = {
|
2021-09-05 01:09:30 +02:00
|
|
|
locName: LocationName;
|
|
|
|
};
|
2021-03-31 06:45:21 +02:00
|
|
|
|
2021-09-18 01:43:08 +02:00
|
|
|
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);
|
|
|
|
}
|
2021-09-05 01:09:30 +02:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2021-09-18 01:43:08 +02:00
|
|
|
const company = Companies[props.locName];
|
|
|
|
if (company == null) throw new Error(`CompanyLocation component constructed with invalid company: ${props.locName}`);
|
2021-09-05 01:09:30 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Reference to the Location that this component is being rendered for
|
|
|
|
*/
|
2021-09-18 01:43:08 +02:00
|
|
|
const location = Locations[props.locName];
|
|
|
|
if (location == null) {
|
|
|
|
throw new Error(`CompanyLocation component constructed with invalid location: ${props.locName}`);
|
|
|
|
}
|
2021-09-05 01:09:30 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Name of company position that player holds, if applicable
|
|
|
|
*/
|
2021-09-18 01:43:08 +02:00
|
|
|
const jobTitle = p.jobs[props.locName] ? p.jobs[props.locName] : null;
|
2021-09-05 01:09:30 +02:00
|
|
|
|
2021-09-18 01:43:08 +02:00
|
|
|
/**
|
|
|
|
* CompanyPosition object for the job that the player holds at this company
|
|
|
|
* (if he has one)
|
|
|
|
*/
|
|
|
|
const companyPosition = jobTitle ? CompanyPositions[jobTitle] : null;
|
2021-09-05 01:09:30 +02:00
|
|
|
|
2021-09-18 01:43:08 +02:00
|
|
|
p.location = props.locName;
|
2021-09-05 01:09:30 +02:00
|
|
|
|
2021-09-18 01:43:08 +02:00
|
|
|
function applyForAgentJob(e: React.MouseEvent<HTMLElement>): void {
|
2021-09-05 01:09:30 +02:00
|
|
|
if (!e.isTrusted) {
|
|
|
|
return;
|
2019-03-29 08:12:41 +01:00
|
|
|
}
|
2021-09-18 01:43:08 +02:00
|
|
|
p.applyForAgentJob();
|
|
|
|
rerender();
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
2019-03-29 08:12:41 +01:00
|
|
|
|
2021-09-18 01:43:08 +02:00
|
|
|
function applyForBusinessConsultantJob(e: React.MouseEvent<HTMLElement>): void {
|
2021-09-05 01:09:30 +02:00
|
|
|
if (!e.isTrusted) {
|
|
|
|
return;
|
2019-03-29 08:12:41 +01:00
|
|
|
}
|
2021-09-18 01:43:08 +02:00
|
|
|
p.applyForBusinessConsultantJob();
|
|
|
|
rerender();
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
2019-03-29 08:12:41 +01:00
|
|
|
|
2021-09-18 01:43:08 +02:00
|
|
|
function applyForBusinessJob(e: React.MouseEvent<HTMLElement>): void {
|
2021-09-05 01:09:30 +02:00
|
|
|
if (!e.isTrusted) {
|
|
|
|
return;
|
2019-03-29 08:12:41 +01:00
|
|
|
}
|
2021-09-18 01:43:08 +02:00
|
|
|
p.applyForBusinessJob();
|
|
|
|
rerender();
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
2019-03-29 08:12:41 +01:00
|
|
|
|
2021-09-18 01:43:08 +02:00
|
|
|
function applyForEmployeeJob(e: React.MouseEvent<HTMLElement>): void {
|
2021-09-05 01:09:30 +02:00
|
|
|
if (!e.isTrusted) {
|
|
|
|
return;
|
2019-03-29 08:12:41 +01:00
|
|
|
}
|
2021-09-18 01:43:08 +02:00
|
|
|
p.applyForEmployeeJob();
|
|
|
|
rerender();
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
2019-03-29 08:12:41 +01:00
|
|
|
|
2021-09-18 01:43:08 +02:00
|
|
|
function applyForItJob(e: React.MouseEvent<HTMLElement>): void {
|
2021-09-05 01:09:30 +02:00
|
|
|
if (!e.isTrusted) {
|
|
|
|
return;
|
2019-03-29 08:12:41 +01:00
|
|
|
}
|
2021-09-18 01:43:08 +02:00
|
|
|
p.applyForItJob();
|
|
|
|
rerender();
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
2019-03-29 08:12:41 +01:00
|
|
|
|
2021-09-18 01:43:08 +02:00
|
|
|
function applyForPartTimeEmployeeJob(e: React.MouseEvent<HTMLElement>): void {
|
2021-09-05 01:09:30 +02:00
|
|
|
if (!e.isTrusted) {
|
|
|
|
return;
|
2019-03-29 08:12:41 +01:00
|
|
|
}
|
2021-09-18 01:43:08 +02:00
|
|
|
p.applyForPartTimeEmployeeJob();
|
|
|
|
rerender();
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
2019-03-29 08:12:41 +01:00
|
|
|
|
2021-09-18 01:43:08 +02:00
|
|
|
function applyForPartTimeWaiterJob(e: React.MouseEvent<HTMLElement>): void {
|
2021-09-05 01:09:30 +02:00
|
|
|
if (!e.isTrusted) {
|
|
|
|
return;
|
2019-03-29 08:12:41 +01:00
|
|
|
}
|
2021-09-18 01:43:08 +02:00
|
|
|
p.applyForPartTimeWaiterJob();
|
|
|
|
rerender();
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
2019-03-29 08:12:41 +01:00
|
|
|
|
2021-09-18 01:43:08 +02:00
|
|
|
function applyForSecurityJob(e: React.MouseEvent<HTMLElement>): void {
|
2021-09-05 01:09:30 +02:00
|
|
|
if (!e.isTrusted) {
|
|
|
|
return;
|
2019-03-29 08:12:41 +01:00
|
|
|
}
|
2021-09-18 01:43:08 +02:00
|
|
|
p.applyForSecurityJob();
|
|
|
|
rerender();
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
2019-03-29 08:12:41 +01:00
|
|
|
|
2021-09-18 01:43:08 +02:00
|
|
|
function applyForSoftwareConsultantJob(e: React.MouseEvent<HTMLElement>): void {
|
2021-09-05 01:09:30 +02:00
|
|
|
if (!e.isTrusted) {
|
|
|
|
return;
|
2019-03-29 08:12:41 +01:00
|
|
|
}
|
2021-09-18 01:43:08 +02:00
|
|
|
p.applyForSoftwareConsultantJob();
|
|
|
|
rerender();
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
2019-03-29 08:12:41 +01:00
|
|
|
|
2021-09-18 01:43:08 +02:00
|
|
|
function applyForSoftwareJob(e: React.MouseEvent<HTMLElement>): void {
|
2021-09-05 01:09:30 +02:00
|
|
|
if (!e.isTrusted) {
|
|
|
|
return;
|
2019-03-29 08:12:41 +01:00
|
|
|
}
|
2021-09-18 01:43:08 +02:00
|
|
|
p.applyForSoftwareJob();
|
|
|
|
rerender();
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
2019-03-29 08:12:41 +01:00
|
|
|
|
2021-09-18 01:43:08 +02:00
|
|
|
function applyForWaiterJob(e: React.MouseEvent<HTMLElement>): void {
|
2021-09-05 01:09:30 +02:00
|
|
|
if (!e.isTrusted) {
|
|
|
|
return;
|
|
|
|
}
|
2021-09-18 01:43:08 +02:00
|
|
|
p.applyForWaiterJob();
|
|
|
|
rerender();
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
2019-03-29 08:12:41 +01:00
|
|
|
|
2021-09-18 01:43:08 +02:00
|
|
|
function startInfiltration(e: React.MouseEvent<HTMLElement>): void {
|
2021-09-05 01:09:30 +02:00
|
|
|
if (!e.isTrusted) {
|
|
|
|
return;
|
|
|
|
}
|
2021-09-18 01:43:08 +02:00
|
|
|
const loc = location;
|
|
|
|
if (!loc.infiltrationData)
|
|
|
|
throw new Error(`trying to start infiltration at ${props.locName} but the infiltrationData is null`);
|
2019-03-30 00:13:58 +01:00
|
|
|
|
2021-09-18 10:01:07 +02:00
|
|
|
router.toInfiltration(loc);
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
2019-03-30 00:13:58 +01:00
|
|
|
|
2021-09-18 01:43:08 +02:00
|
|
|
function work(e: React.MouseEvent<HTMLElement>): void {
|
2021-09-05 01:09:30 +02:00
|
|
|
if (!e.isTrusted) {
|
|
|
|
return;
|
|
|
|
}
|
2019-04-04 02:08:11 +02:00
|
|
|
|
2021-09-18 01:43:08 +02:00
|
|
|
const pos = companyPosition;
|
2021-09-05 01:09:30 +02:00
|
|
|
if (pos instanceof CompanyPosition) {
|
2021-09-09 05:47:34 +02:00
|
|
|
if (pos.isPartTimeJob() || pos.isSoftwareConsultantJob() || pos.isBusinessConsultantJob()) {
|
2021-09-20 07:45:32 +02:00
|
|
|
p.startWorkPartTime(router, props.locName);
|
2021-09-05 01:09:30 +02:00
|
|
|
} else {
|
2021-09-20 07:45:32 +02:00
|
|
|
p.startWork(router, props.locName);
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
2021-09-18 01:43:08 +02:00
|
|
|
router.toWork();
|
2019-04-04 02:08:11 +02:00
|
|
|
}
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
2019-04-04 02:08:11 +02:00
|
|
|
|
2021-09-18 01:43:08 +02:00
|
|
|
function quit(e: React.MouseEvent<HTMLElement>): void {
|
2021-09-13 00:03:07 +02:00
|
|
|
if (!e.isTrusted) return;
|
|
|
|
const popupId = `quit-job-popup`;
|
|
|
|
createPopup(popupId, QuitJobPopup, {
|
2021-09-18 01:43:08 +02:00
|
|
|
locName: props.locName,
|
|
|
|
company: company,
|
|
|
|
player: p,
|
|
|
|
onQuit: rerender,
|
2021-09-13 00:03:07 +02:00
|
|
|
popupId: popupId,
|
2021-09-05 01:09:30 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-09-18 01:43:08 +02:00
|
|
|
const isEmployedHere = jobTitle != null;
|
|
|
|
const favorGain = company.getFavorGain();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
{isEmployedHere && (
|
|
|
|
<div>
|
|
|
|
<p>Job Title: {jobTitle}</p>
|
|
|
|
<br />
|
|
|
|
<p style={{ display: "block" }}>-------------------------</p>
|
|
|
|
<br />
|
|
|
|
<p className={"tooltip"}>
|
|
|
|
Company reputation: {Reputation(company.playerReputation)}
|
|
|
|
<span className={"tooltiptext"}>
|
|
|
|
You will earn {Favor(favorGain[0])} company favor upon resetting after installing Augmentations
|
|
|
|
</span>
|
|
|
|
</p>
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<p style={{ display: "block" }}>-------------------------</p>
|
|
|
|
<br />
|
|
|
|
<p className={"tooltip"}>
|
|
|
|
Company Favor: {Favor(company.favor)}
|
|
|
|
<span className={"tooltiptext"}>
|
|
|
|
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.
|
|
|
|
</span>
|
|
|
|
</p>
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<p style={{ display: "block" }}>-------------------------</p>
|
|
|
|
<br />
|
|
|
|
<StdButton onClick={work} text={"Work"} />
|
|
|
|
|
|
|
|
<StdButton onClick={quit} text={"Quit"} />
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
{company.hasAgentPositions() && (
|
|
|
|
<ApplyToJobButton
|
|
|
|
company={company}
|
|
|
|
entryPosType={CompanyPositions[posNames.AgentCompanyPositions[0]]}
|
|
|
|
onClick={applyForAgentJob}
|
|
|
|
p={p}
|
|
|
|
style={{ display: "block" }}
|
|
|
|
text={"Apply for Agent Job"}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
{company.hasBusinessConsultantPositions() && (
|
|
|
|
<ApplyToJobButton
|
|
|
|
company={company}
|
|
|
|
entryPosType={CompanyPositions[posNames.BusinessConsultantCompanyPositions[0]]}
|
|
|
|
onClick={applyForBusinessConsultantJob}
|
|
|
|
p={p}
|
|
|
|
style={{ display: "block" }}
|
|
|
|
text={"Apply for Business Consultant Job"}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
{company.hasBusinessPositions() && (
|
|
|
|
<ApplyToJobButton
|
|
|
|
company={company}
|
|
|
|
entryPosType={CompanyPositions[posNames.BusinessCompanyPositions[0]]}
|
|
|
|
onClick={applyForBusinessJob}
|
|
|
|
p={p}
|
|
|
|
style={{ display: "block" }}
|
|
|
|
text={"Apply for Business Job"}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
{company.hasEmployeePositions() && (
|
|
|
|
<ApplyToJobButton
|
|
|
|
company={company}
|
|
|
|
entryPosType={CompanyPositions[posNames.MiscCompanyPositions[1]]}
|
|
|
|
onClick={applyForEmployeeJob}
|
|
|
|
p={p}
|
|
|
|
style={{ display: "block" }}
|
|
|
|
text={"Apply to be an Employee"}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
{company.hasEmployeePositions() && (
|
|
|
|
<ApplyToJobButton
|
|
|
|
company={company}
|
|
|
|
entryPosType={CompanyPositions[posNames.PartTimeCompanyPositions[1]]}
|
|
|
|
onClick={applyForPartTimeEmployeeJob}
|
|
|
|
p={p}
|
|
|
|
style={{ display: "block" }}
|
|
|
|
text={"Apply to be a part-time Employee"}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
{company.hasITPositions() && (
|
|
|
|
<ApplyToJobButton
|
|
|
|
company={company}
|
|
|
|
entryPosType={CompanyPositions[posNames.ITCompanyPositions[0]]}
|
|
|
|
onClick={applyForItJob}
|
|
|
|
p={p}
|
|
|
|
style={{ display: "block" }}
|
|
|
|
text={"Apply for IT Job"}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
{company.hasSecurityPositions() && (
|
|
|
|
<ApplyToJobButton
|
|
|
|
company={company}
|
|
|
|
entryPosType={CompanyPositions[posNames.SecurityCompanyPositions[2]]}
|
|
|
|
onClick={applyForSecurityJob}
|
|
|
|
p={p}
|
|
|
|
style={{ display: "block" }}
|
|
|
|
text={"Apply for Security Job"}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
{company.hasSoftwareConsultantPositions() && (
|
|
|
|
<ApplyToJobButton
|
|
|
|
company={company}
|
|
|
|
entryPosType={CompanyPositions[posNames.SoftwareConsultantCompanyPositions[0]]}
|
|
|
|
onClick={applyForSoftwareConsultantJob}
|
|
|
|
p={p}
|
|
|
|
style={{ display: "block" }}
|
|
|
|
text={"Apply for Software Consultant Job"}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
{company.hasSoftwarePositions() && (
|
|
|
|
<ApplyToJobButton
|
|
|
|
company={company}
|
|
|
|
entryPosType={CompanyPositions[posNames.SoftwareCompanyPositions[0]]}
|
|
|
|
onClick={applyForSoftwareJob}
|
|
|
|
p={p}
|
|
|
|
style={{ display: "block" }}
|
|
|
|
text={"Apply for Software Job"}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
{company.hasWaiterPositions() && (
|
|
|
|
<ApplyToJobButton
|
|
|
|
company={company}
|
|
|
|
entryPosType={CompanyPositions[posNames.MiscCompanyPositions[0]]}
|
|
|
|
onClick={applyForWaiterJob}
|
|
|
|
p={p}
|
|
|
|
style={{ display: "block" }}
|
|
|
|
text={"Apply to be a Waiter"}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
{company.hasWaiterPositions() && (
|
|
|
|
<ApplyToJobButton
|
|
|
|
company={company}
|
|
|
|
entryPosType={CompanyPositions[posNames.PartTimeCompanyPositions[0]]}
|
|
|
|
onClick={applyForPartTimeWaiterJob}
|
|
|
|
p={p}
|
|
|
|
style={{ display: "block" }}
|
|
|
|
text={"Apply to be a part-time Waiter"}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
{location.infiltrationData != null && (
|
|
|
|
<StdButton onClick={startInfiltration} style={{ display: "block" }} text={"Infiltrate Company"} />
|
|
|
|
)}
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
</div>
|
|
|
|
);
|
2019-03-29 08:12:41 +01:00
|
|
|
}
|