Skip to content

Commit

Permalink
Merge pull request #33077 from VickyStash/ts-migration/optionRow-comp…
Browse files Browse the repository at this point in the history
…onent

[TS migration] Migrate 'OptionRow.js' component to TypeScript
  • Loading branch information
mountiny authored Dec 29, 2023
2 parents 48a0c82 + f178a82 commit 38bb94e
Show file tree
Hide file tree
Showing 8 changed files with 139 additions and 134 deletions.
6 changes: 3 additions & 3 deletions src/components/OfflineWithFeedback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ import MessagesRow from './MessagesRow';

type OfflineWithFeedbackProps = ChildrenProps & {
/** The type of action that's pending */
pendingAction: OnyxCommon.PendingAction;
pendingAction?: OnyxCommon.PendingAction;

/** Determine whether to hide the component's children if deletion is pending */
shouldHideOnDelete?: boolean;

/** The errors to display */
errors?: OnyxCommon.Errors;
errors?: OnyxCommon.Errors | null;

/** Whether we should show the error messages */
shouldShowErrorMessages?: boolean;
Expand Down Expand Up @@ -56,7 +56,7 @@ type OfflineWithFeedbackProps = ChildrenProps & {

type StrikethroughProps = Partial<ChildrenProps> & {style: Array<ViewStyle | TextStyle | ImageStyle>};

function omitBy<T>(obj: Record<string, T> | undefined, predicate: (value: T) => boolean) {
function omitBy<T>(obj: Record<string, T> | undefined | null, predicate: (value: T) => boolean) {
// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-unused-vars
return Object.fromEntries(Object.entries(obj ?? {}).filter(([_, value]) => !predicate(value)));
}
Expand Down
246 changes: 119 additions & 127 deletions src/components/OptionRow.js → src/components/OptionRow.tsx

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export default {
add: 'Add',
resend: 'Resend',
save: 'Save',
select: 'Select',
saveChanges: 'Save changes',
submit: 'Submit',
rotate: 'Rotate',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export default {
new: 'Nuevo',
search: 'Buscar',
searchWithThreeDots: 'Buscar...',
select: 'Seleccionar',
next: 'Siguiente',
previous: 'Anterior',
goBack: 'Volver',
Expand Down
13 changes: 12 additions & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,14 +310,25 @@ type OptimisticIOUReport = Pick<
>;
type DisplayNameWithTooltips = Array<Pick<PersonalDetails, 'accountID' | 'pronouns' | 'displayName' | 'login' | 'avatar'>>;

type CustomIcon = {
src: IconAsset;
color?: string;
};

type OptionData = {
text: string;
alternateText?: string | null;
allReportErrors?: Errors | null;
brickRoadIndicator?: typeof CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR | '' | null;
tooltipText?: string | null;
alternateTextMaxLines?: number;
boldStyle?: boolean;
customIcon?: CustomIcon;
descriptiveText?: string;
subtitle?: string | null;
login?: string | null;
accountID?: number | null;
pronouns?: string;
status?: string | null;
phoneNumber?: string | null;
isUnread?: boolean | null;
Expand Down Expand Up @@ -1449,7 +1460,7 @@ function getDisplayNameForParticipant(accountID?: number, shouldUseShortForm = f
}

function getDisplayNamesWithTooltips(
personalDetailsList: PersonalDetails[] | PersonalDetailsList,
personalDetailsList: PersonalDetails[] | PersonalDetailsList | OptionData[],
isMultipleParticipantReport: boolean,
shouldFallbackToHidden = true,
): DisplayNameWithTooltips {
Expand Down
1 change: 1 addition & 0 deletions src/libs/SidebarUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ function getOptionData(
}

const result: ReportUtils.OptionData = {
text: '',
alternateText: null,
allReportErrors: null,
brickRoadIndicator: null,
Expand Down
2 changes: 1 addition & 1 deletion src/styles/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ function getWidthStyle(width: number): ViewStyle {
/**
* Returns a style with backgroundColor and borderColor set to the same color
*/
function getBackgroundAndBorderStyle(backgroundColor: string): ViewStyle {
function getBackgroundAndBorderStyle(backgroundColor: string | undefined): ViewStyle {
return {
backgroundColor,
borderColor: backgroundColor,
Expand Down
3 changes: 1 addition & 2 deletions src/types/onyx/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ type Report = {
nonReimbursableTotal?: number;
isHidden?: boolean;
isChatRoom?: boolean;
participantsList?: Array<Partial<PersonalDetails>>;
text?: string;
participantsList?: PersonalDetails[];
privateNotes?: Record<number, Note>;
isLoadingPrivateNotes?: boolean;

Expand Down

0 comments on commit 38bb94e

Please sign in to comment.