App: [HOLD for payment 2023-08-21] [$250] Migrate AdditionalDetailsStep.js to function component
Class Component Migration
Filenames
Task
- We currently have some class components in our codebase that we would like to refactor to a function component.
- Here’s a link with some general advice on how to refactor a class component to a function component: https://react.dev/reference/react/Component#alternatives
- If you need additional guidance, please ask in #expensify-open-source
- Test for any regressions and verify that there are no breaking changes
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~01ddb468a7b05692a6
- Upwork Job ID: 1687529728271044608
- Last Price Increase: 2023-08-04
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 58 (16 by maintainers)
GENERATED BY GPT : (Its the draft of functional component)
“In PR i will provide you complete code with full functionality”
`import _ from ‘underscore’; import React, { useState } from ‘react’; import PropTypes from ‘prop-types’; import { withOnyx } from ‘react-native-onyx’; import { View } from ‘react-native’; import moment from ‘moment/moment’; import { parsePhoneNumber } from ‘awesome-phonenumber’; import IdologyQuestions from ‘./IdologyQuestions’; import ScreenWrapper from ‘…/…/components/ScreenWrapper’; import HeaderWithBackButton from ‘…/…/components/HeaderWithBackButton’; import withLocalize, { withLocalizePropTypes } from ‘…/…/components/withLocalize’; import styles from ‘…/…/styles/styles’; import Text from ‘…/…/components/Text’; import CONST from ‘…/…/CONST’; import compose from ‘…/…/libs/compose’; import ONYXKEYS from ‘…/…/ONYXKEYS’; import TextLink from ‘…/…/components/TextLink’; import TextInput from ‘…/…/components/TextInput’; import * as Wallet from ‘…/…/libs/actions/Wallet’; import * as ValidationUtils from ‘…/…/libs/ValidationUtils’; import * as ErrorUtils from ‘…/…/libs/ErrorUtils’; import AddressForm from ‘…/ReimbursementAccount/AddressForm’; import DatePicker from ‘…/…/components/DatePicker’; import Form from ‘…/…/components/Form’; import withCurrentUserPersonalDetails, { withCurrentUserPersonalDetailsPropTypes, withCurrentUserPersonalDetailsDefaultProps } from ‘…/…/components/withCurrentUserPersonalDetails’; import * as PersonalDetails from ‘…/…/libs/actions/PersonalDetails’; import OfflineIndicator from ‘…/…/components/OfflineIndicator’;
const propTypes = { …withLocalizePropTypes, …withCurrentUserPersonalDetailsPropTypes,
};
const defaultProps = { walletAdditionalDetails: { errorFields: {}, isLoading: false, errors: {}, questions: [], idNumber: ‘’, errorCode: ‘’, }, …withCurrentUserPersonalDetailsDefaultProps, };
const INPUT_IDS = { // Rest of the INPUT_IDS };
const AdditionalDetailsStep = (props) => { const [minDate] = useState(moment().subtract(CONST.DATE_BIRTH.MAX_AGE, ‘Y’).toDate()); const [maxDate] = useState(moment().subtract(CONST.DATE_BIRTH.MIN_AGE_FOR_PAYMENT, ‘Y’).toDate());
};
AdditionalDetailsStep.propTypes = propTypes; AdditionalDetailsStep.defaultProps = defaultProps;
export default compose( withLocalize, withCurrentUserPersonalDetails, withOnyx({ walletAdditionalDetails: { key: ONYXKEYS.WALLET_ADDITIONAL_DETAILS, }, }), )(AdditionalDetailsStep); `
I think we’re all set here? Gonna close. Feel free to reopen if there’s anything left!
@allroundexperts Do you mean that Anshu should do this issue? I’m already assigned and working on a PR.
Let’s go with @AnshuAgarwal24 since they were the first to express there interest.
🎀 👀 🎀 C+ reviewed