Skip to content

Commit 7c6d021

Browse files
committed
rm constructor variables and access prop directly
1 parent b1bf398 commit 7c6d021

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/pages/RequestCallPage.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,6 @@ const defaultProps = {
100100
class RequestCallPage extends Component {
101101
constructor(props) {
102102
super(props);
103-
this.name = PersonalDetails.extractFirstAndLastNameFromAvailableDetails(props.currentUserPersonalDetails);
104-
this.isWeekend = moment().day() === 0 || moment().day() === 6;
105-
this.isBlockedFromConcierge = User.isBlockedFromConcierge(props.blockedFromConcierge);
106103

107104
this.onSubmit = this.onSubmit.bind(this);
108105
this.getPhoneNumber = this.getPhoneNumber.bind(this);
@@ -131,7 +128,7 @@ class RequestCallPage extends Component {
131128
* @param {Object} values - form input values passed by the Form component
132129
*/
133130
onSubmit(values) {
134-
if (this.isBlockedFromConcierge) {
131+
if (User.isBlockedFromConcierge(this.props.blockedFromConcierge)) {
135132
return;
136133
}
137134

@@ -190,15 +187,19 @@ class RequestCallPage extends Component {
190187

191188
getWaitTimeMessage() {
192189
let waitTimeKey = 'requestCallPage.waitTime.weekend';
193-
if (!this.isWeekend) {
190+
if (!this.isWeekend()) {
194191
waitTimeKey = this.getWaitTimeMessageKey(this.props.inboxCallUserWaitTime);
195192
}
196193
return `${this.props.translate(waitTimeKey, {minutes: this.props.inboxCallUserWaitTime})} ${this.props.translate('requestCallPage.waitTime.guides')}`;
197194
}
198195

196+
isWeekend() {
197+
return moment().day() === 0 || moment().day() === 6;
198+
}
199+
199200
fetchData() {
200201
// If it is the weekend don't check the wait time
201-
if (this.isWeekend) {
202+
if (this.isWeekend()) {
202203
return;
203204
}
204205

@@ -243,6 +244,8 @@ class RequestCallPage extends Component {
243244
}
244245

245246
render() {
247+
const {firstName, lastName} = PersonalDetails.extractFirstAndLastNameFromAvailableDetails(this.props.currentUserPersonalDetails);
248+
246249
return (
247250
<ScreenWrapper>
248251
<HeaderWithCloseButton
@@ -275,7 +278,7 @@ class RequestCallPage extends Component {
275278
<View style={styles.flex1}>
276279
<TextInput
277280
inputID="firstName"
278-
defaultValue={this.name.firstName}
281+
defaultValue={firstName}
279282
label={this.props.translate('common.firstName')}
280283
name="fname"
281284
placeholder={this.props.translate('profilePage.john')}
@@ -284,7 +287,7 @@ class RequestCallPage extends Component {
284287
<View style={[styles.flex1, styles.ml2]}>
285288
<TextInput
286289
inputID="lastName"
287-
defaultValue={this.name.lastName}
290+
defaultValue={lastName}
288291
label={this.props.translate('common.lastName')}
289292
name="lname"
290293
placeholder={this.props.translate('profilePage.doe')}
@@ -309,7 +312,7 @@ class RequestCallPage extends Component {
309312
placeholder="100"
310313
containerStyles={[styles.mt4]}
311314
/>
312-
{this.isBlockedFromConcierge ? (
315+
{User.isBlockedFromConcierge(this.props.blockedFromConcierge) ? (
313316
<View style={[styles.flexRow, styles.alignItemsCenter, styles.mt4]}>
314317
<Icon src={Expensicons.Exclamation} fill={colors.yellow} />
315318
<Text style={[styles.mutedTextLabel, styles.ml2, styles.flex1]}>{this.props.translate('requestCallPage.blockedFromConcierge')}</Text>

0 commit comments

Comments
 (0)