Skip to content

Commit

Permalink
rm constructor variables and access prop directly
Browse files Browse the repository at this point in the history
  • Loading branch information
luacmartins committed Aug 17, 2022
1 parent b1bf398 commit 7c6d021
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/pages/RequestCallPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@ const defaultProps = {
class RequestCallPage extends Component {
constructor(props) {
super(props);
this.name = PersonalDetails.extractFirstAndLastNameFromAvailableDetails(props.currentUserPersonalDetails);
this.isWeekend = moment().day() === 0 || moment().day() === 6;
this.isBlockedFromConcierge = User.isBlockedFromConcierge(props.blockedFromConcierge);

this.onSubmit = this.onSubmit.bind(this);
this.getPhoneNumber = this.getPhoneNumber.bind(this);
Expand Down Expand Up @@ -131,7 +128,7 @@ class RequestCallPage extends Component {
* @param {Object} values - form input values passed by the Form component
*/
onSubmit(values) {
if (this.isBlockedFromConcierge) {
if (User.isBlockedFromConcierge(this.props.blockedFromConcierge)) {
return;
}

Expand Down Expand Up @@ -190,15 +187,19 @@ class RequestCallPage extends Component {

getWaitTimeMessage() {
let waitTimeKey = 'requestCallPage.waitTime.weekend';
if (!this.isWeekend) {
if (!this.isWeekend()) {
waitTimeKey = this.getWaitTimeMessageKey(this.props.inboxCallUserWaitTime);
}
return `${this.props.translate(waitTimeKey, {minutes: this.props.inboxCallUserWaitTime})} ${this.props.translate('requestCallPage.waitTime.guides')}`;
}

isWeekend() {
return moment().day() === 0 || moment().day() === 6;
}

fetchData() {
// If it is the weekend don't check the wait time
if (this.isWeekend) {
if (this.isWeekend()) {
return;
}

Expand Down Expand Up @@ -243,6 +244,8 @@ class RequestCallPage extends Component {
}

render() {
const {firstName, lastName} = PersonalDetails.extractFirstAndLastNameFromAvailableDetails(this.props.currentUserPersonalDetails);

return (
<ScreenWrapper>
<HeaderWithCloseButton
Expand Down Expand Up @@ -275,7 +278,7 @@ class RequestCallPage extends Component {
<View style={styles.flex1}>
<TextInput
inputID="firstName"
defaultValue={this.name.firstName}
defaultValue={firstName}
label={this.props.translate('common.firstName')}
name="fname"
placeholder={this.props.translate('profilePage.john')}
Expand All @@ -284,7 +287,7 @@ class RequestCallPage extends Component {
<View style={[styles.flex1, styles.ml2]}>
<TextInput
inputID="lastName"
defaultValue={this.name.lastName}
defaultValue={lastName}
label={this.props.translate('common.lastName')}
name="lname"
placeholder={this.props.translate('profilePage.doe')}
Expand All @@ -309,7 +312,7 @@ class RequestCallPage extends Component {
placeholder="100"
containerStyles={[styles.mt4]}
/>
{this.isBlockedFromConcierge ? (
{User.isBlockedFromConcierge(this.props.blockedFromConcierge) ? (
<View style={[styles.flexRow, styles.alignItemsCenter, styles.mt4]}>
<Icon src={Expensicons.Exclamation} fill={colors.yellow} />
<Text style={[styles.mutedTextLabel, styles.ml2, styles.flex1]}>{this.props.translate('requestCallPage.blockedFromConcierge')}</Text>
Expand Down

0 comments on commit 7c6d021

Please sign in to comment.