Skip to content

Commit

Permalink
Fixed the bugs in disabling the navigation menu items
Browse files Browse the repository at this point in the history
  • Loading branch information
tahierhussain committed Jan 28, 2025
1 parent 3638836 commit 4e15ba1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
16 changes: 12 additions & 4 deletions frontend/src/components/navigations/side-nav-bar/SideNavBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import task from "../../../assets/task.svg";
import VectorDbIcon from "../../../assets/vector-db.svg";
import TextExtractorIcon from "../../../assets/text-extractor.svg";
import { useSessionStore } from "../../../store/session-store";
import { useMemo } from "react";

let getMenuItem;
try {
Expand Down Expand Up @@ -191,11 +192,18 @@ const SideNavBar = ({ collapsed }) => {
data[0]?.subMenu?.splice(1, 0, getMenuItem.default(orgName));
}

const shouldDisableAll =
!unstractSubscriptionPlan?.subscriptionId &&
unstractSubscriptionPlan?.planType !== UNSTRACT_SUBSCRIPTION_PLANS?.TRIAL;
const shouldDisableAll = useMemo(() => {
if (!unstractSubscriptionPlan || !UNSTRACT_SUBSCRIPTION_PLANS) {
return undefined;
}

return (
!unstractSubscriptionPlan?.subscriptionId &&
unstractSubscriptionPlan?.planType !== UNSTRACT_SUBSCRIPTION_PLANS?.TRIAL
);
}, [unstractSubscriptionPlan]);

if (shouldDisableAll) {
if (shouldDisableAll === false) {
data.forEach((mainMenuItem) => {
mainMenuItem.subMenu.forEach((subMenuItem) => {
subMenuItem.disable = true;
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/components/navigations/top-nav-bar/TopNavBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function TopNavBar({ isSimpleLayout, topNavBarOptions }) {

const shouldDisableRouting = useMemo(() => {
if (!unstractSubscriptionPlan || !UNSTRACT_SUBSCRIPTION_PLANS) {
return false;
return undefined;
}

return (
Expand Down Expand Up @@ -218,7 +218,7 @@ function TopNavBar({ isSimpleLayout, topNavBarOptions }) {
<Button
onClick={() => navigate(`/${orgName}/profile`)}
className="logout-button"
disabled={shouldDisableRouting}
disabled={shouldDisableRouting === false}
>
<UserOutlined /> Profile
</Button>
Expand Down Expand Up @@ -257,7 +257,7 @@ function TopNavBar({ isSimpleLayout, topNavBarOptions }) {
<Button
onClick={() => navigate(`/${orgName}/review`)}
className="logout-button"
disabled={shouldDisableRouting}
disabled={shouldDisableRouting === false}
>
<FileProtectOutlined /> Review
</Button>
Expand All @@ -273,7 +273,7 @@ function TopNavBar({ isSimpleLayout, topNavBarOptions }) {
<Button
onClick={() => navigate(`/${orgName}/review/approve`)}
className="logout-button"
disabled={shouldDisableRouting}
disabled={shouldDisableRouting === false}
>
<LikeOutlined /> Approve
</Button>
Expand All @@ -286,7 +286,7 @@ function TopNavBar({ isSimpleLayout, topNavBarOptions }) {
<Button
onClick={() => navigate(`/${orgName}/review/download_and_sync`)}
className="logout-button"
disabled={shouldDisableRouting}
disabled={shouldDisableRouting === false}
>
<DownloadOutlined /> Download and Sync Manager
</Button>
Expand Down

0 comments on commit 4e15ba1

Please sign in to comment.