Skip to content

Commit

Permalink
refactor: apply pull request feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
pac-guerreiro committed Dec 1, 2023
1 parent 4bd7929 commit 044cf0a
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/components/IFrame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@ import {OnyxEntry, withOnyx} from 'react-native-onyx';
import ONYXKEYS from '@src/ONYXKEYS';
import {Session} from '@src/types/onyx';

function getNewDotURL(url: string | URL) {
type OldDotIFrameOnyxProps = {
session: OnyxEntry<Session>;
};

type OldDotIFrameProps = OldDotIFrameOnyxProps;

type Url = string | URL;

function getNewDotURL(url: Url): string {
const urlObj = new URL(url);
const paramString = urlObj.searchParams.get('param') ?? '';
const pathname = urlObj.pathname.slice(1);
Expand Down Expand Up @@ -47,7 +55,7 @@ function getNewDotURL(url: string | URL) {
return pathname;
}

function getOldDotURL(url: string | URL) {
function getOldDotURL(url: Url): string {
const urlObj = new URL(url);
const pathname = urlObj.pathname;
const paths = pathname.slice(1).split('/');
Expand Down Expand Up @@ -85,19 +93,13 @@ function getOldDotURL(url: string | URL) {
return pathname;
}

type OldDotIFrameOnyxProps = {
session: OnyxEntry<Session>;
};

type OldDotIFrameProps = OldDotIFrameOnyxProps;

function OldDotIFrame({session}: OldDotIFrameProps) {
const [oldDotURL, setOldDotURL] = useState('https://staging.expensify.com');

useEffect(() => {
setOldDotURL(`https://expensify.com.dev/${getOldDotURL(window.location.href)}`);

window.addEventListener('message', (event) => {
window.addEventListener('message', (event: MessageEvent<string>) => {
const url = event.data;
// TODO: use this value to navigate to a new path
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand Down

0 comments on commit 044cf0a

Please sign in to comment.