Skip to content

Commit

Permalink
improve TypeSelector props
Browse files Browse the repository at this point in the history
  • Loading branch information
rezkiy37 committed Jun 20, 2024
1 parent 6a4342c commit 206f3d6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,9 @@ function CreatePolicyReportFieldPage({
/>
<InputWrapper
InputComponent={TypeSelector}
inputID={INPUT_IDS.TYPE}
label={translate('common.type')}
description={translate('common.type')}
rightLabel={translate('common.required')}
accessibilityLabel={translate('workspace.editor.typeInputLabel')}
inputID={INPUT_IDS.TYPE}
/>
<InputWrapper
InputComponent={TextPicker}
Expand Down
6 changes: 4 additions & 2 deletions src/pages/workspace/reportFields/TypeSelector/index.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import {Str} from 'expensify-common';
import React, {useState} from 'react';
import {View} from 'react-native';
import type {MenuItemBaseProps} from '@components/MenuItem';
import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription';
import type {ReportFieldItemType} from '@components/ReportFieldTypePicker';
import useLocalize from '@hooks/useLocalize';
import {getReportFieldTypeTranslationKey} from '@libs/WorkspaceReportFieldsUtils';
import type {PolicyReportFieldType} from '@src/types/onyx/Policy';
import TypeSelectorModal from './TypeSelectorModal';

type TypeSelectorProps = {
type TypeSelectorProps = Pick<MenuItemBaseProps, 'label' | 'rightLabel'> & {
/** Function to call when the user selects a type */
onInputChange?: (value: string) => void;

Expand All @@ -19,7 +20,7 @@ type TypeSelectorProps = {
label: string;
};

function TypeSelector({value, label, onInputChange}: TypeSelectorProps) {
function TypeSelector({value, label, rightLabel, onInputChange}: TypeSelectorProps) {
const {translate} = useLocalize();

const [isPickerVisible, setIsPickerVisible] = useState(false);
Expand All @@ -43,6 +44,7 @@ function TypeSelector({value, label, onInputChange}: TypeSelectorProps) {
shouldShowRightIcon
title={value ? Str.recapitalize(translate(getReportFieldTypeTranslationKey(value as PolicyReportFieldType))) : ''}
description={label}
rightLabel={rightLabel}
onPress={showPickerModal}
/>
<TypeSelectorModal
Expand Down

0 comments on commit 206f3d6

Please sign in to comment.