refactor: remove get-current-user GQL query
This commit is contained in:
@@ -14,7 +14,8 @@ import useCurrentUser from 'hooks/useCurrentUser';
|
||||
function DeleteAccountDialog(props) {
|
||||
const [deleteCurrentUser] = useMutation(DELETE_CURRENT_USER);
|
||||
const formatMessage = useFormatMessage();
|
||||
const { data: currentUser } = useCurrentUser();
|
||||
const { data } = useCurrentUser();
|
||||
const currentUser = data?.data;
|
||||
|
||||
const authentication = useAuthentication();
|
||||
const navigate = useNavigate();
|
||||
@@ -24,7 +25,7 @@ function DeleteAccountDialog(props) {
|
||||
authentication.updateToken('');
|
||||
await apolloClient.clearStore();
|
||||
navigate(URLS.LOGIN);
|
||||
}, [deleteCurrentUser, currentUser?.data]);
|
||||
}, [deleteCurrentUser, currentUser]);
|
||||
|
||||
return (
|
||||
<ConfirmationDialog
|
||||
|
@@ -7,7 +7,8 @@ import useCurrentUser from 'hooks/useCurrentUser';
|
||||
|
||||
const Chatwoot = ({ ready }) => {
|
||||
const theme = useTheme();
|
||||
const { data: currentUser } = useCurrentUser();
|
||||
const { data } = useCurrentUser();
|
||||
const currentUser = data?.data;
|
||||
const matchSmallScreens = useMediaQuery(theme.breakpoints.down('md'));
|
||||
|
||||
React.useEffect(function initiateChatwoot() {
|
||||
@@ -24,17 +25,17 @@ const Chatwoot = ({ ready }) => {
|
||||
|
||||
React.useEffect(
|
||||
function initiateUser() {
|
||||
if (!currentUser?.data?.id || !ready) return;
|
||||
window.$chatwoot.setUser(currentUser.data?.id, {
|
||||
email: currentUser?.data?.email,
|
||||
name: currentUser?.data?.fullName,
|
||||
if (!currentUser?.id || !ready) return;
|
||||
window.$chatwoot.setUser(currentUser.id, {
|
||||
email: currentUser.email,
|
||||
name: currentUser.fullName,
|
||||
});
|
||||
|
||||
if (!matchSmallScreens) {
|
||||
window.$chatwoot.toggleBubbleVisibility('show');
|
||||
}
|
||||
},
|
||||
[currentUser?.data, ready, matchSmallScreens],
|
||||
[currentUser, ready, matchSmallScreens],
|
||||
);
|
||||
React.useLayoutEffect(
|
||||
function hideChatwoot() {
|
||||
|
@@ -21,7 +21,8 @@ import usePaddle from 'hooks/usePaddle.ee';
|
||||
|
||||
export default function UpgradeFreeTrial() {
|
||||
const { data: plans, isLoading: isPaymentPlansLoading } = usePaymentPlans();
|
||||
const { data: currentUser } = useCurrentUser();
|
||||
const { data } = useCurrentUser();
|
||||
const currentUser = data?.data;
|
||||
const { loaded: paddleLoaded } = usePaddle();
|
||||
const [selectedIndex, setSelectedIndex] = React.useState(0);
|
||||
const selectedPlan = plans?.data?.[selectedIndex];
|
||||
@@ -30,13 +31,13 @@ export default function UpgradeFreeTrial() {
|
||||
const handleCheckout = React.useCallback(() => {
|
||||
window.Paddle.Checkout?.open({
|
||||
product: selectedPlan.productId,
|
||||
email: currentUser?.data?.email,
|
||||
email: currentUser?.email,
|
||||
passthrough: JSON.stringify({
|
||||
id: currentUser?.data?.id,
|
||||
email: currentUser?.data?.email,
|
||||
id: currentUser?.id,
|
||||
email: currentUser?.email,
|
||||
}),
|
||||
});
|
||||
}, [selectedPlan, currentUser?.data]);
|
||||
}, [selectedPlan, currentUser]);
|
||||
|
||||
if (isPaymentPlansLoading || !plans?.data?.length) return null;
|
||||
|
||||
|
Reference in New Issue
Block a user