(false);
useEffect(() => {
setIsShowFullDataModal(getIsShowFullDataModal(dataItems));
}, [dataItems]);
const onCloseFullDataModal = (_birthDate: string) => {
dispatch(actions.form.addDate(_birthDate));
setIsShowFullDataModal(getIsShowFullDataModal(dataItems));
};
const handleCompatibility = () => {
dispatch(
actions.siteConfig.update({
home: {
pathFromHome: EPathsFromHome.navbar,
isShowNavbar: showNavbarFooter,
},
})
);
navigate(routes.client.compatibility());
};
const handleBreath = () => {
dispatch(
actions.siteConfig.update({
home: {
pathFromHome: EPathsFromHome.navbar,
isShowNavbar: showNavbarFooter,
},
})
);
navigate(routes.client.breath());
};
const navbarItems: INavbarHomeItems[] = [
{
title: "Breathing",
path: routes.client.breath(),
paths: [routes.client.breath(), routes.client.breathResult()],
image: "Breath.svg",
onClick: handleBreath,
},
{
title: "Aura",
path: routes.client.home(),
paths: [routes.client.home()],
image: "Aura.svg",
active: true,
onClick: () => null,
},
{
title: "Compatibility",
path: routes.client.compatibility(),
paths: [
routes.client.compatibility(),
routes.client.compatibilityResult(),
],
image: "Compatibility.svg",
onClick: handleCompatibility,
},
{
title: "Advisors",
path: routes.client.advisors(),
paths: [routes.client.advisors()],
image: "moon.svg",
onClick: () => null,
},
{
title: "My Moon",
path: routes.client.wallpaper(),
paths: [routes.client.wallpaper()],
image: "moon.svg",
onClick: () => null,
},
];
return (
{showHeader ? setIsMenuOpen(true)} /> : null}
{isRouteFullDataModal && (
setIsShowFullDataModal(false)}
>
)}
{showFooter ? : null}
{showNavbar ? (
setIsMenuOpen(false)} />
) : null}
{showNavbarFooter && hasNavbarFooter(location.pathname) ? (
) : null}
);
}
// enum EIsAuthPageType {
// private,
// public,
// }
// interface ICheckIsAuthOutletProps {
// redirectUrl: string;
// pageType: EIsAuthPageType;
// }
// function CheckIsAuthOutlet({
// redirectUrl,
// pageType,
// }: ICheckIsAuthOutletProps): JSX.Element {
// const { user } = useAuth();
// if (user && pageType === EIsAuthPageType.public) {
// return ;
// }
// if (!user && pageType === EIsAuthPageType.private) {
// return ;
// }
// return ;
// }
// interface IShortPathOutletProps {
// productKey: EProductKeys;
// requiredParameters: unknown[];
// isProductPage?: boolean;
// redirectUrls: {
// user?: {
// yes?: string;
// no?: string;
// force?: string;
// };
// data?: {
// yes?: string;
// no?: string;
// force?: string;
// };
// purchasedProduct?: {
// yes?: string;
// no?: string;
// force?: string;
// };
// force?: {
// yes?: string;
// no?: string;
// force?: string;
// };
// };
// }
// function ShortPathOutlet(props: IShortPathOutletProps): JSX.Element {
// const dispatch = useDispatch();
// const { productKey, requiredParameters, redirectUrls, isProductPage } = props;
// const { user, token } = useAuth();
// const dateOfPaymentChatMike = useSelector(
// selectors.selectDateOfPaymentChatMike
// );
// const queryParameters = new URLSearchParams(window.location.search);
// const paymentMadeChatMike = queryParameters.get("paymentMadeChatMike");
// if (paymentMadeChatMike && !dateOfPaymentChatMike) {
// dispatch(actions.userConfig.setDateOfPaymentChatMike(new Date()));
// }
// const isForcePaymentStatus = useMemo(() => {
// if ((Date.now() - new Date(dateOfPaymentChatMike).getTime()) / 1000 < 180) {
// return true;
// }
// if (paymentMadeChatMike && !dateOfPaymentChatMike) {
// return true;
// }
// return false;
// }, [dateOfPaymentChatMike, paymentMadeChatMike]);
// const api = useApi();
// const isForce = useSelector(selectors.selectIsForceShortPath);
// const loadData = useCallback(async () => {
// if (!token?.length || !user?.email || !productKey?.length)
// return {
// status: "error",
// error: "Missing params",
// };
// try {
// const purchased = await api.checkProductPurchased({
// productKey,
// token,
// });
// return purchased;
// } catch (error) {
// console.error(error);
// return {
// status: "error",
// error: "Something went wrong",
// };
// }
// // eslint-disable-next-line react-hooks/exhaustive-deps
// }, [token]);
// const { data, isPending } = useApiCall(loadData, "pending");
// if (isPending) {
// return ;
// }
// const isPurchasedProduct = !!(data && "active" in data && data.active);
// const isUser = !!user && !!token.length;
// const isFullData = requiredParameters.every((item) => !!item);
// if (!isFullData) {
// if (isForce && redirectUrls.data?.force) {
// return ;
// }
// if (redirectUrls.data?.no && !isForce) {
// return ;
// }
// return ;
// }
// if (!isUser) {
// if (isForce && redirectUrls.user?.force) {
// return ;
// }
// if (redirectUrls.user?.no && !isForce) {
// return ;
// }
// return ;
// }
// if (!isPurchasedProduct && !isForcePaymentStatus) {
// if (isForce && redirectUrls.purchasedProduct?.force) {
// return (
//
// );
// }
// if (redirectUrls.purchasedProduct?.no && !isForce) {
// return ;
// }
// return ;
// }
// if (isProductPage) {
// return ;
// }
// return ;
// }
export function AuthorizedUserOutlet(): JSX.Element {
const status = useSelector(selectors.selectStatus);
const { user } = useAuth();
return user && status === "subscribed" ? (
) : (
);
}
export function PrivateOutlet(): JSX.Element {
const { user } = useAuth();
return user ? (
) : (
);
}
function PrivateSubscriptionOutlet(): JSX.Element {
const isProduction = import.meta.env.MODE === "production";
const status = useSelector(selectors.selectStatus);
return status === "subscribed" || !isProduction ? (
) : (
);
}
function getIsShowFullDataModal(dataItems: Array = []): boolean {
let hasNoDataItem = false;
for (const item of dataItems) {
if (!item) {
hasNoDataItem = true;
break;
}
}
return hasNoDataItem;
}
function SkipStep(): JSX.Element {
const { user } = useAuth();
return user ? (
) : (
);
}
function MainPage(): JSX.Element {
const status = useSelector(selectors.selectStatus);
const route = getRouteBy(status);
const [shouldRedirect, setShouldRedirect] = useState(false);
useEffect(() => {
// Check if we're navigating to auth and on witlab.app domain
if (route === routes.client.auth()) {
const isWitlabDomain =
window.location.hostname === "witlab.app" ||
window.location.hostname.endsWith(".witlab.app");
// If we're on witlab.app domain, use server-side navigation
if (isWitlabDomain) {
navigateToAuth();
setShouldRedirect(true);
}
}
}, [route]);
// If we're redirecting via server-side navigation, return empty fragment
if (shouldRedirect) {
return <>>;
}
// For all other cases, use client-side navigation
return ;
}
export default App;