Merge pull request #602 from ente-io/open-family-new-window
open family page in new tab
This commit is contained in:
commit
a5f093456f
|
@ -9,6 +9,7 @@ import { CustomError } from '../error';
|
||||||
import { logError } from '../sentry';
|
import { logError } from '../sentry';
|
||||||
import { getFamilyPortalRedirectURL } from 'services/userService';
|
import { getFamilyPortalRedirectURL } from 'services/userService';
|
||||||
import { FamilyData, FamilyMember, User } from 'types/user';
|
import { FamilyData, FamilyMember, User } from 'types/user';
|
||||||
|
import { openLink } from 'utils/common';
|
||||||
|
|
||||||
const PAYMENT_PROVIDER_STRIPE = 'stripe';
|
const PAYMENT_PROVIDER_STRIPE = 'stripe';
|
||||||
const PAYMENT_PROVIDER_APPSTORE = 'appstore';
|
const PAYMENT_PROVIDER_APPSTORE = 'appstore';
|
||||||
|
@ -253,15 +254,16 @@ export async function manageFamilyMethod(
|
||||||
try {
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const url = await getFamilyPortalRedirectURL();
|
const url = await getFamilyPortalRedirectURL();
|
||||||
window.location.href = url;
|
openLink(url, true);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logError(error, 'failed to redirect to family portal');
|
logError(error, 'failed to redirect to family portal');
|
||||||
setLoading(false);
|
|
||||||
setDialogMessage({
|
setDialogMessage({
|
||||||
title: constants.ERROR,
|
title: constants.ERROR,
|
||||||
content: constants.UNKNOWN_ERROR,
|
content: constants.UNKNOWN_ERROR,
|
||||||
close: { variant: 'danger' },
|
close: { variant: 'danger' },
|
||||||
});
|
});
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,3 +69,13 @@ export const promiseWithTimeout = async (
|
||||||
rejectOnTimeout,
|
rejectOnTimeout,
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export function openLink(href: string, newTab?: boolean) {
|
||||||
|
const a = document.createElement('a');
|
||||||
|
a.href = href;
|
||||||
|
if (newTab) {
|
||||||
|
a.target = '_blank';
|
||||||
|
}
|
||||||
|
a.rel = 'noreferrer noopener';
|
||||||
|
a.click();
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue