2019-04-01 11:23:25 +02:00
|
|
|
/**
|
|
|
|
* React Component for a button that's used to apply for a job
|
|
|
|
*/
|
|
|
|
import * as React from "react";
|
|
|
|
|
|
|
|
import { Company } from "../../Company/Company";
|
|
|
|
import { CompanyPosition } from "../../Company/CompanyPosition";
|
|
|
|
import { getJobRequirementText } from "../../Company/GetJobRequirementText";
|
|
|
|
import { IPlayer } from "../../PersonObjects/IPlayer";
|
|
|
|
|
|
|
|
import { StdButton } from "../../ui/React/StdButton";
|
|
|
|
|
|
|
|
type IProps = {
|
|
|
|
company: Company;
|
|
|
|
entryPosType: CompanyPosition;
|
|
|
|
onClick: (e: React.MouseEvent<HTMLElement>) => void;
|
|
|
|
p: IPlayer;
|
2019-04-04 02:08:11 +02:00
|
|
|
style?: object;
|
2019-04-01 11:23:25 +02:00
|
|
|
text: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class ApplyToJobButton extends React.Component<IProps, any> {
|
|
|
|
constructor(props: IProps) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this.getJobRequirementTooltip = this.getJobRequirementTooltip.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
getJobRequirementTooltip(): string {
|
|
|
|
const pos = this.props.p.getNextCompanyPosition(this.props.company, this.props.entryPosType);
|
2021-04-30 05:52:56 +02:00
|
|
|
if (pos == null) { return "" }
|
2019-04-01 11:23:25 +02:00
|
|
|
|
|
|
|
if (!this.props.company.hasPosition(pos)) { return ""; }
|
|
|
|
|
|
|
|
return getJobRequirementText(this.props.company, pos, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<StdButton
|
|
|
|
onClick={this.props.onClick}
|
2019-04-04 02:08:11 +02:00
|
|
|
style={this.props.style}
|
2019-04-01 11:23:25 +02:00
|
|
|
text={this.props.text}
|
|
|
|
tooltip={this.getJobRequirementTooltip()}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|