Skip to content

Commit

Permalink
refactor: replace withOnyx usage with useOnyx
Browse files Browse the repository at this point in the history
  • Loading branch information
pac-guerreiro committed Sep 17, 2024
1 parent 225304f commit 347ec96
Showing 1 changed file with 6 additions and 20 deletions.
26 changes: 6 additions & 20 deletions src/pages/ReportDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {Str} from 'expensify-common';
import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react';
import {View} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import {useOnyx, withOnyx} from 'react-native-onyx';
import {useOnyx} from 'react-native-onyx';
import type {ValueOf} from 'type-fest';
import AvatarWithImagePicker from '@components/AvatarWithImagePicker';
import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView';
Expand Down Expand Up @@ -64,14 +64,7 @@ type ReportDetailsPageMenuItem = {
shouldShowRightIcon?: boolean;
};

type ReportDetailsPageOnyxProps = {
/** Personal details of all the users */
personalDetails: OnyxEntry<OnyxTypes.PersonalDetailsList>;

/** Session info for the currently logged in user. */
session: OnyxEntry<OnyxTypes.Session>;
};
type ReportDetailsPageProps = ReportDetailsPageOnyxProps & WithReportOrNotFoundProps & StackScreenProps<ReportDetailsNavigatorParamList, typeof SCREENS.REPORT_DETAILS.ROOT>;
type ReportDetailsPageProps = WithReportOrNotFoundProps & StackScreenProps<ReportDetailsNavigatorParamList, typeof SCREENS.REPORT_DETAILS.ROOT>;

const CASES = {
DEFAULT: 'default',
Expand All @@ -81,7 +74,7 @@ const CASES = {

type CaseID = ValueOf<typeof CASES>;

function ReportDetailsPage({policies, report, session, personalDetails}: ReportDetailsPageProps) {
function ReportDetailsPage({policies, report}: ReportDetailsPageProps) {
const {translate} = useLocalize();
const {isOffline} = useNetwork();
const styles = useThemeStyles();
Expand All @@ -101,6 +94,8 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD

const [transactionThreadReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID}`);
const [isDebugModeEnabled] = useOnyx(ONYXKEYS.USER, {selector: (user) => !!user?.isDebugModeEnabled});
const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST);
const [session] = useOnyx(ONYXKEYS.SESSION);

const [isLastMemberLeavingGroupModalVisible, setIsLastMemberLeavingGroupModalVisible] = useState(false);
const [isDeleteModalVisible, setIsDeleteModalVisible] = useState(false);
Expand Down Expand Up @@ -861,13 +856,4 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD

ReportDetailsPage.displayName = 'ReportDetailsPage';

export default withReportOrNotFound()(
withOnyx<ReportDetailsPageProps, ReportDetailsPageOnyxProps>({
personalDetails: {
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
},
session: {
key: ONYXKEYS.SESSION,
},
})(ReportDetailsPage),
);
export default withReportOrNotFound()(ReportDetailsPage);

0 comments on commit 347ec96

Please sign in to comment.