diff --git a/frontend/src/layouts/AppLayout/AppLayout.tsx b/frontend/src/layouts/AppLayout/AppLayout.tsx
index b8d4ad87e..1e0c7f224 100644
--- a/frontend/src/layouts/AppLayout/AppLayout.tsx
+++ b/frontend/src/layouts/AppLayout/AppLayout.tsx
@@ -13,18 +13,7 @@ import { useTranslation } from "react-i18next";
import Link from "next/link";
import { useRouter } from "next/router";
import { faGithub, faSlack } from "@fortawesome/free-brands-svg-icons";
-import {
- faAngleDown,
- faArrowLeft,
- faArrowUpRightFromSquare,
- faBook,
- faCheck,
- faEnvelope,
- faInfinity,
- faMobile,
- faPlus,
- faQuestion
-} from "@fortawesome/free-solid-svg-icons";
+import { faAngleDown, faArrowLeft, faArrowUpRightFromSquare, faBook, faCheck, faEnvelope, faInfinity, faMobile, faPlus, faQuestion } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { yupResolver } from "@hookform/resolvers/yup";
import { DropdownMenuTrigger } from "@radix-ui/react-dropdown-menu";
@@ -52,14 +41,7 @@ import {
} from "@app/components/v2";
import { useOrganization, useSubscription, useUser, useWorkspace } from "@app/context";
import { usePopUp } from "@app/hooks";
-import {
- fetchOrgUsers,
- useAddUserToWs,
- useCreateWorkspace,
- useGetOrgTrialUrl,
- useLogoutUser,
- useUploadWsKey
-} from "@app/hooks/api";
+import { fetchOrgUsers, useAddUserToWs, useCreateWorkspace, useGetOrgTrialUrl, useLogoutUser, useUploadWsKey } from "@app/hooks/api";
interface LayoutProps {
children: React.ReactNode;
@@ -107,9 +89,7 @@ export const AppLayout = ({ children }: LayoutProps) => {
const { subscription } = useSubscription();
// const [ isLearningNoteOpen, setIsLearningNoteOpen ] = useState(true);
- const isAddingProjectsAllowed = subscription?.workspaceLimit
- ? subscription.workspacesUsed < subscription.workspaceLimit
- : true;
+ const isAddingProjectsAllowed = subscription?.workspaceLimit ? (subscription.workspacesUsed < subscription.workspaceLimit) : true;
const createWs = useCreateWorkspace();
const uploadWsKey = useUploadWsKey();
@@ -130,22 +110,22 @@ export const AppLayout = ({ children }: LayoutProps) => {
const { t } = useTranslation();
- useEffect(() => {
- const handleRouteChange = () => {
- window.Intercom("update");
- };
-
- router.events.on("routeChangeComplete", handleRouteChange);
-
- return () => {
- router.events.off("routeChangeComplete", handleRouteChange);
- };
- }, []);
+ useEffect(() => {
+ const handleRouteChange = () => {
+ (window).Intercom("update");
+ };
+
+ router.events.on("routeChangeComplete", handleRouteChange);
+
+ return () => {
+ router.events.off("routeChangeComplete", handleRouteChange);
+ };
+ }, []);
const logout = useLogoutUser();
const logOutUser = async () => {
try {
- console.log("Logging out...");
+ console.log("Logging out...")
await logout.mutateAsync();
localStorage.removeItem("protectedKey");
localStorage.removeItem("protectedKeyIV");
@@ -165,30 +145,27 @@ export const AppLayout = ({ children }: LayoutProps) => {
const changeOrg = async (orgId) => {
localStorage.setItem("orgData.id", orgId);
- router.push(`/org/${orgId}/overview`);
- };
+ router.push(`/org/${orgId}/overview`)
+ }
// TODO(akhilmhdh): This entire logic will be rechecked and will try to avoid
// Placing the localstorage as much as possible
// Wait till tony integrates the azure and its launched
useEffect(() => {
+
// Put a user in an org if they're not in one yet
const putUserInOrg = async () => {
if (tempLocalStorage("orgData.id") === "") {
localStorage.setItem("orgData.id", orgs[0]?._id);
}
- if (
- currentOrg &&
- ((workspaces?.length === 0 && router.asPath.includes("project")) ||
- router.asPath.includes("/project/undefined") ||
- (!orgs?.map((org) => org._id)?.includes(router.query.id) &&
- !router.asPath.includes("project") &&
- !router.asPath.includes("personal") &&
- !router.asPath.includes("integration")))
- ) {
+ if (currentOrg && (
+ (workspaces?.length === 0 && router.asPath.includes("project"))
+ || router.asPath.includes("/project/undefined")
+ || (!orgs?.map(org => org._id)?.includes(router.query.id) && !router.asPath.includes("project") && !router.asPath.includes("personal") && !router.asPath.includes("integration"))
+ )) {
router.push(`/org/${currentOrg?._id}/overview`);
- }
+ }
// else if (!router.asPath.includes("org") && !router.asPath.includes("project") && !router.asPath.includes("integrations") && !router.asPath.includes("personal-settings")) {
// const pathSegments = router.asPath.split("/").filter((segment) => segment.length > 0);
@@ -267,171 +244,134 @@ export const AppLayout = ({ children }: LayoutProps) => {
<>
-