Skip to content

Commit

Permalink
Merge pull request Expensify#32411 from shubham1206agra/rename-newdat…
Browse files Browse the repository at this point in the history
…epicker

Renamed NewDatePicker to DatePicker
  • Loading branch information
mountiny authored Dec 4, 2023
2 parents 90cda7c + 958c431 commit f5ec979
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const datePickerDefaultProps = {
value: undefined,
};

function NewDatePicker({containerStyles, defaultValue, disabled, errorText, inputID, isSmallScreenWidth, label, maxDate, minDate, onInputChange, onTouched, placeholder, translate, value}) {
function DatePicker({containerStyles, defaultValue, disabled, errorText, inputID, isSmallScreenWidth, label, maxDate, minDate, onInputChange, onTouched, placeholder, translate, value}) {
const styles = useThemeStyles();
const [selectedDate, setSelectedDate] = useState(value || defaultValue || undefined);

Expand Down Expand Up @@ -99,8 +99,8 @@ function NewDatePicker({containerStyles, defaultValue, disabled, errorText, inpu
);
}

NewDatePicker.propTypes = propTypes;
NewDatePicker.defaultProps = datePickerDefaultProps;
NewDatePicker.displayName = 'NewDatePicker';
DatePicker.propTypes = propTypes;
DatePicker.defaultProps = datePickerDefaultProps;
DatePicker.displayName = 'DatePicker';

export default withLocalize(NewDatePicker);
export default withLocalize(DatePicker);
4 changes: 2 additions & 2 deletions src/pages/EditRequestCreatedPage.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import PropTypes from 'prop-types';
import React from 'react';
import DatePicker from '@components/DatePicker';
import FormProvider from '@components/Form/FormProvider';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import NewDatePicker from '@components/NewDatePicker';
import ScreenWrapper from '@components/ScreenWrapper';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@styles/useThemeStyles';
Expand Down Expand Up @@ -34,7 +34,7 @@ function EditRequestCreatedPage({defaultCreated, onSubmit}) {
submitButtonText={translate('common.save')}
enabledWhenOffline
>
<NewDatePicker
<DatePicker
inputID="created"
label={translate('common.date')}
defaultValue={defaultCreated}
Expand Down
4 changes: 2 additions & 2 deletions src/pages/EnablePayments/AdditionalDetailsStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import React from 'react';
import {View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import _ from 'underscore';
import DatePicker from '@components/DatePicker';
import FormProvider from '@components/Form/FormProvider';
import InputWrapper from '@components/Form/InputWrapper';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import NewDatePicker from '@components/NewDatePicker';
import ScreenWrapper from '@components/ScreenWrapper';
import Text from '@components/Text';
import TextInput from '@components/TextInput';
Expand Down Expand Up @@ -230,7 +230,7 @@ function AdditionalDetailsStep({walletAdditionalDetails, translate, currentUserP
placeholder={translate('common.phoneNumberPlaceholder')}
shouldSaveDraft
/>
<NewDatePicker
<DatePicker
inputID="dob"
containerStyles={[styles.mt4]}
label={translate(fieldNameTranslationKeys.dob)}
Expand Down
4 changes: 2 additions & 2 deletions src/pages/ReimbursementAccount/CompanyStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import _ from 'underscore';
import CheckboxWithLabel from '@components/CheckboxWithLabel';
import DatePicker from '@components/DatePicker';
import FormProvider from '@components/Form/FormProvider';
import InputWrapper from '@components/Form/InputWrapper';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import NewDatePicker from '@components/NewDatePicker';
import Picker from '@components/Picker';
import ScreenWrapper from '@components/ScreenWrapper';
import StatePicker from '@components/StatePicker';
Expand Down Expand Up @@ -241,7 +241,7 @@ function CompanyStep({reimbursementAccount, reimbursementAccountDraft, getDefaul
/>
</View>
<View style={styles.mt4}>
<NewDatePicker
<DatePicker
inputID="incorporationDate"
label={translate('companyStep.incorporationDate')}
placeholder={translate('companyStep.incorporationDatePlaceholder')}
Expand Down
4 changes: 2 additions & 2 deletions src/pages/ReimbursementAccount/IdentityForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import PropTypes from 'prop-types';
import React from 'react';
import {View} from 'react-native';
import _ from 'underscore';
import DatePicker from '@components/DatePicker';
import InputWrapper from '@components/Form/InputWrapper';
import NewDatePicker from '@components/NewDatePicker';
import TextInput from '@components/TextInput';
import useThemeStyles from '@styles/useThemeStyles';
import CONST from '@src/CONST';
Expand Down Expand Up @@ -171,7 +171,7 @@ function IdentityForm(props) {
/>
</View>
</View>
<NewDatePicker
<DatePicker
inputID={props.inputKeys.dob}
shouldSaveDraft={props.shouldSaveDraft}
label={`${props.translate('common.dob')}`}
Expand Down
4 changes: 2 additions & 2 deletions src/pages/iou/MoneyRequestDatePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import PropTypes from 'prop-types';
import React, {useEffect} from 'react';
import {withOnyx} from 'react-native-onyx';
import _ from 'underscore';
import DatePicker from '@components/DatePicker';
import FormProvider from '@components/Form/FormProvider';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import NewDatePicker from '@components/NewDatePicker';
import ScreenWrapper from '@components/ScreenWrapper';
import useLocalize from '@hooks/useLocalize';
import * as MoneyRequestUtils from '@libs/MoneyRequestUtils';
Expand Down Expand Up @@ -99,7 +99,7 @@ function MoneyRequestDatePage({iou, route, selectedTab}) {
submitButtonText={translate('common.save')}
enabledWhenOffline
>
<NewDatePicker
<DatePicker
inputID="moneyRequestCreated"
label={translate('common.date')}
defaultValue={iou.created}
Expand Down
4 changes: 2 additions & 2 deletions src/pages/settings/Profile/PersonalDetails/DateOfBirthPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import lodashGet from 'lodash/get';
import PropTypes from 'prop-types';
import React, {useCallback} from 'react';
import {withOnyx} from 'react-native-onyx';
import DatePicker from '@components/DatePicker';
import FormProvider from '@components/Form/FormProvider';
import FullscreenLoadingIndicator from '@components/FullscreenLoadingIndicator';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import NewDatePicker from '@components/NewDatePicker';
import ScreenWrapper from '@components/ScreenWrapper';
import withLocalize, {withLocalizePropTypes} from '@components/withLocalize';
import usePrivatePersonalDetails from '@hooks/usePrivatePersonalDetails';
Expand Down Expand Up @@ -81,7 +81,7 @@ function DateOfBirthPage({translate, privatePersonalDetails}) {
submitButtonText={translate('common.save')}
enabledWhenOffline
>
<NewDatePicker
<DatePicker
inputID="dob"
label={translate('common.date')}
defaultValue={privatePersonalDetails.dob || ''}
Expand Down
7 changes: 7 additions & 0 deletions src/stories/Form.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, {useState} from 'react';
import {View} from 'react-native';
import AddressSearch from '@components/AddressSearch';
import CheckboxWithLabel from '@components/CheckboxWithLabel';
import DatePicker from '@components/DatePicker';
import FormProvider from '@components/Form/FormProvider';
import InputWrapper from '@components/Form/InputWrapper';
import Picker from '@components/Picker';
Expand Down Expand Up @@ -29,6 +30,7 @@ const story = {
CheckboxWithLabel,
Picker,
StatePicker,
DatePicker,
},
};

Expand Down Expand Up @@ -67,6 +69,11 @@ function Template(args) {
containerStyles={[styles.mt4]}
hint="No PO box"
/>
<DatePicker
inputID="dob"
label="Date of Birth"
containerStyles={[styles.mt4]}
/>
<View>
<InputWrapper
InputComponent={Picker}
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/CalendarPickerTest.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {fireEvent, render, within} from '@testing-library/react-native';
import {addMonths, addYears, subYears} from 'date-fns';
import CalendarPicker from '../../src/components/NewDatePicker/CalendarPicker';
import CalendarPicker from '../../src/components/DatePicker/CalendarPicker';
import CONST from '../../src/CONST';
import DateUtils from '../../src/libs/DateUtils';

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/generateMonthMatrixTest.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import generateMonthMatrix from '../../src/components/NewDatePicker/CalendarPicker/generateMonthMatrix';
import generateMonthMatrix from '../../src/components/DatePicker/CalendarPicker/generateMonthMatrix';

describe('generateMonthMatrix', () => {
it('returns the correct matrix for January 2022', () => {
Expand Down

0 comments on commit f5ec979

Please sign in to comment.