Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TS migration] Migrate '[Components Group 1]' component to TypeScript #36764

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ function FocusModeNotification() {
<Text>
{translate('focusModeUpdateModal.prompt')}
<TextLinkWithRef
href={href}
style={styles.link}
onPress={() => {
User.clearFocusModeNotification();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {StyleSheet, View} from 'react-native';
import useLocalize from '@hooks/useLocalize';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import variables from '@styles/variables';
import Icon from './Icon';
import * as Expensicons from './Icon/Expensicons';
import * as Illustrations from './Icon/Illustrations';
Expand All @@ -23,8 +24,13 @@ function SAMLLoadingIndicator() {
/>
</View>
<Text style={[styles.textHeadline, styles.textXXLarge, styles.textAlignCenter]}>{translate('samlSignIn.launching')}</Text>
<View style={[styles.mt2, styles.mh2, styles.fontSizeNormal, styles.textAlignCenter]}>
<Text style={[styles.textAlignCenter]}>{translate('samlSignIn.oneMoment')}</Text>
<View style={[styles.mt2, styles.mh2, styles.textAlignCenter]}>
<Text
style={[styles.textAlignCenter]}
fontSize={variables.fontSizeNormal}
>
{translate('samlSignIn.oneMoment')}
</Text>
</View>
</View>
<View style={styles.deeplinkWrapperFooter}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,42 +1,34 @@
import PropTypes from 'prop-types';
import React from 'react';
import {View} from 'react-native';
import _ from 'underscore';
import Button from '@components/Button';
import * as Expensicons from '@components/Icon/Expensicons';
import Text from '@components/Text';
import type {StyleProp, ViewStyle} from 'react-native';
import useLocalize from '@hooks/useLocalize';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import * as NumberFormatUtils from '@libs/NumberFormatUtils';
import stylePropTypes from '@styles/stylePropTypes';
import Button from './Button';
import * as Expensicons from './Icon/Expensicons';
import Text from './Text';

const propTypes = {
type ShowMoreButtonProps = {
/** Additional styles for container */
containerStyle: stylePropTypes,
containerStyle?: StyleProp<ViewStyle>;

/** The number of currently shown items */
currentCount: PropTypes.number,
currentCount?: number;

/** The total number of items that could be shown */
totalCount: PropTypes.number,
totalCount?: number;

/** A handler that fires when button has been pressed */
onPress: PropTypes.func.isRequired,
onPress: () => void;
};

const defaultProps = {
containerStyle: {},
currentCount: undefined,
totalCount: undefined,
};

function ShowMoreButton({containerStyle, currentCount, totalCount, onPress}) {
function ShowMoreButton({containerStyle, currentCount, totalCount, onPress}: ShowMoreButtonProps) {
const {translate, preferredLocale} = useLocalize();
const theme = useTheme();
const styles = useThemeStyles();

const shouldShowCounter = _.isNumber(currentCount) && _.isNumber(totalCount);
const shouldShowCounter = !!(currentCount && totalCount);

return (
<View style={[styles.alignItemsCenter, containerStyle]}>
Expand Down Expand Up @@ -67,7 +59,5 @@ function ShowMoreButton({containerStyle, currentCount, totalCount, onPress}) {
}

ShowMoreButton.displayName = 'ShowMoreButton';
ShowMoreButton.propTypes = propTypes;
ShowMoreButton.defaultProps = defaultProps;

export default ShowMoreButton;
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
import lodashGet from 'lodash/get';
import React, {useMemo, useState} from 'react';
import _ from 'underscore';
import OptionsSelector from '@components/OptionsSelector';
import type {EdgeInsets} from 'react-native-safe-area-context';
import useLocalize from '@hooks/useLocalize';
import useStyleUtils from '@hooks/useStyleUtils';
import useThemeStyles from '@hooks/useThemeStyles';
import * as OptionsListUtils from '@libs/OptionsListUtils';
import type {PolicyTaxRateWithDefault} from '@libs/OptionsListUtils';
import * as TransactionUtils from '@libs/TransactionUtils';
import CONST from '@src/CONST';
import {defaultProps, propTypes} from './taxPickerPropTypes';
import OptionsSelector from './OptionsSelector';

function TaxPicker({selectedTaxRate, policyTaxRates, insets, onSubmit}) {
type TaxPickerProps = {
/** Collection of tax rates attached to a policy */
policyTaxRates: PolicyTaxRateWithDefault;

/** The selected tax rate of an expense */
selectedTaxRate?: string;

/** Safe area insets */
insets?: EdgeInsets;

/** Callback to fire when a tax is pressed */
onSubmit: () => void;
};

function TaxPicker({selectedTaxRate = '', policyTaxRates = {} as OptionsListUtils.PolicyTaxRateWithDefault, insets, onSubmit}: TaxPickerProps) {
const styles = useThemeStyles();
rayane-djouah marked this conversation as resolved.
Show resolved Hide resolved
const StyleUtils = useStyleUtils();
const {translate} = useLocalize();
Expand Down Expand Up @@ -58,11 +71,11 @@ function TaxPicker({selectedTaxRate, policyTaxRates, insets, onSubmit}) {
);
return policyTaxRatesOptions;
}, [policyTaxRates, searchValue, selectedOptions]);

const selectedOptionKey = lodashGet(_.filter(lodashGet(sections, '[0].data', []), (taxRate) => taxRate.searchText === selectedTaxRate)[0], 'keyForList');
const selectedOptionKey = sections?.[0]?.data?.find((taxRate) => taxRate.searchText === selectedTaxRate)?.keyForList;

return (
<OptionsSelector
// @ts-expect-error TODO: Remove this once OptionsSelector (https://github.com/Expensify/App/issues/25125) is migrated to TypeScript.
contentContainerStyles={[{paddingBottom: StyleUtils.getSafeAreaMargins(insets).marginBottom}]}
optionHoveredStyle={styles.hoveredComponentBG}
sectionHeaderStyle={styles.mt5}
Expand All @@ -84,7 +97,5 @@ function TaxPicker({selectedTaxRate, policyTaxRates, insets, onSubmit}) {
}

TaxPicker.displayName = 'TaxPicker';
TaxPicker.propTypes = propTypes;
TaxPicker.defaultProps = defaultProps;

export default TaxPicker;
21 changes: 0 additions & 21 deletions src/components/TaxPicker/taxPickerPropTypes.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2041,4 +2041,4 @@ export {
getShareLogOptions,
};

export type {MemberForList, CategorySection, GetOptions};
export type {MemberForList, CategorySection, GetOptions, PolicyTaxRateWithDefault};
Loading