diff --git a/src/components/layout/vertical/VerticalMenu.tsx b/src/components/layout/vertical/VerticalMenu.tsx
index d15db3e..75e7dfd 100644
--- a/src/components/layout/vertical/VerticalMenu.tsx
+++ b/src/components/layout/vertical/VerticalMenu.tsx
@@ -16,9 +16,6 @@ import CustomChip from "@core/components/mui/Chip";
// Hook Imports
import useVerticalNav from "@menu/hooks/useVerticalNav";
-import { useFarmHub } from "@/hooks/useFarmHub";
-import { useFarmAccessProfile } from "@/hooks/useFarmAccessProfile";
-import { hasAccessByRule } from "@/libs/api/services/accessControlService";
// Styled Component Imports
import StyledVerticalNavExpandIcon from "@menu/styles/vertical/StyledVerticalNavExpandIcon";
@@ -55,10 +52,6 @@ const VerticalMenu = ({ scrollMenu }: Props) => {
const t = useTranslations('navigation')
const theme = useTheme();
const verticalNavOptions = useVerticalNav();
- const { farmHub } = useFarmHub();
- const farmUuid = farmHub?.farm_uuid ?? null;
- const { profile } = useFarmAccessProfile(farmUuid);
- const canShowSensor7Menu = hasAccessByRule(profile, "sensor-7-page-access");
// Vars
const { isBreakpointReached, transitionDuration } = verticalNavOptions;
@@ -111,16 +104,12 @@ const VerticalMenu = ({ scrollMenu }: Props) => {
}>
{t('cropZoning')}
-
- {canShowSensor7Menu && (
-
-
-
- }>
- Sensor 7
-
- )}
+
+ }>
+ Sensor 7
+
+
}>
diff --git a/src/hooks/useFarmAccessProfile.ts b/src/hooks/useFarmAccessProfile.ts
deleted file mode 100644
index f928f7e..0000000
--- a/src/hooks/useFarmAccessProfile.ts
+++ /dev/null
@@ -1,60 +0,0 @@
-"use client";
-
-import { useEffect, useState } from "react";
-import type { ApiError } from "@/libs/api/client";
-import {
- accessControlService,
- type FarmAccessProfile,
-} from "@/libs/api/services/accessControlService";
-
-interface UseFarmAccessProfileResult {
- profile: FarmAccessProfile | null;
- isLoading: boolean;
- error: ApiError | null;
-}
-
-export const useFarmAccessProfile = (
- farmUuid: string | null | undefined,
-): UseFarmAccessProfileResult => {
- const [profile, setProfile] = useState(null);
- const [isLoading, setIsLoading] = useState(Boolean(farmUuid));
- const [error, setError] = useState(null);
-
- useEffect(() => {
- let active = true;
-
- if (!farmUuid) {
- setProfile(null);
- setError(null);
- setIsLoading(false);
- return () => {
- active = false;
- };
- }
-
- setIsLoading(true);
- setError(null);
-
- accessControlService
- .getFarmAccessProfile(farmUuid)
- .then((nextProfile) => {
- if (!active) return;
- setProfile(nextProfile);
- })
- .catch((nextError: ApiError) => {
- if (!active) return;
- setProfile(null);
- setError(nextError);
- })
- .finally(() => {
- if (!active) return;
- setIsLoading(false);
- });
-
- return () => {
- active = false;
- };
- }, [farmUuid]);
-
- return { profile, isLoading, error };
-};
diff --git a/src/libs/api/services/accessControlService.ts b/src/libs/api/services/accessControlService.ts
deleted file mode 100644
index 71a0e13..0000000
--- a/src/libs/api/services/accessControlService.ts
+++ /dev/null
@@ -1,75 +0,0 @@
-import { apiClient } from "../client";
-
-export interface AccessMatchedRule {
- code: string;
- name: string;
- effect: "allow" | "deny" | string;
- priority: number;
-}
-
-export interface AccessSubscriptionPlan {
- uuid: string;
- code: string;
- name: string;
-}
-
-export interface FarmAccessProfile {
- farm_uuid: string;
- subscription_plan?: AccessSubscriptionPlan | null;
- matched_rules: AccessMatchedRule[];
- resolved_from_profile: boolean;
-}
-
-interface AccessProfileEnvelope {
- code?: number;
- msg?: string;
- data?: FarmAccessProfile;
-}
-
-const ACCESS_PREFIX = "/api/access-control/farms";
-
-export const accessControlService = {
- async getFarmAccessProfile(farmUuid: string): Promise {
- const response = await apiClient.get(
- `${ACCESS_PREFIX}/${encodeURIComponent(farmUuid)}/profile/`,
- );
-
- const payload =
- response && typeof response === "object" && "data" in response
- ? response.data
- : response;
-
- return {
- farm_uuid: payload?.farm_uuid ?? farmUuid,
- subscription_plan: payload?.subscription_plan ?? null,
- matched_rules: Array.isArray(payload?.matched_rules)
- ? payload.matched_rules
- : [],
- resolved_from_profile: Boolean(payload?.resolved_from_profile),
- };
- },
-};
-
-export const hasAccessByRule = (
- profile: FarmAccessProfile | null,
- requiredRuleCode: string,
-): boolean => {
- if (!profile) return false;
-
- const relevantRules = profile.matched_rules.filter((rule) =>
- rule.code === requiredRuleCode,
- );
-
- if (!relevantRules.length) return false;
-
- const sortedRules = [...relevantRules].sort((left, right) => {
- if (right.priority !== left.priority) {
- return right.priority - left.priority;
- }
-
- if (left.effect === right.effect) return 0;
- return left.effect === "deny" ? -1 : 1;
- });
-
- return sortedRules[0].effect === "allow";
-};
diff --git a/src/views/dashboards/farm/sensor7/Sensor7Page.tsx b/src/views/dashboards/farm/sensor7/Sensor7Page.tsx
index 90a59d0..27c7614 100644
--- a/src/views/dashboards/farm/sensor7/Sensor7Page.tsx
+++ b/src/views/dashboards/farm/sensor7/Sensor7Page.tsx
@@ -31,9 +31,7 @@ import Typography from "@mui/material/Typography";
import { alpha, useTheme } from "@mui/material/styles";
import { useFarmHub } from "@/hooks/useFarmHub";
-import { useFarmAccessProfile } from "@/hooks/useFarmAccessProfile";
import type { ApiError } from "@/libs/api/client";
-import { hasAccessByRule } from "@/libs/api/services/accessControlService";
import {
sensorExternalApiService,
type SensorExternalCatalog,
@@ -41,7 +39,6 @@ import {
type SensorExternalRequestLog,
} from "@/libs/api/services/sensorExternalApiService";
-const SENSOR_7_ACCESS_RULE = "sensor-7-page-access";
const PAGE_SIZE_OPTIONS = [10, 20, 50, 100];
const DEFAULT_PAGE_SIZE = 20;
@@ -337,8 +334,6 @@ const Sensor7Page = () => {
const theme = useTheme();
const { farmHub } = useFarmHub();
const farmUuid = farmHub?.farm_uuid ?? null;
- const { profile, isLoading, error } = useFarmAccessProfile(farmUuid);
- const canAccessSensor7 = hasAccessByRule(profile, SENSOR_7_ACCESS_RULE);
const [logs, setLogs] = useState([]);
const [count, setCount] = useState(0);
@@ -378,7 +373,7 @@ const Sensor7Page = () => {
const loadLogs = useCallback(
async (targetPage = page, targetPageSize = pageSize) => {
- if (!farmUuid || !canAccessSensor7) {
+ if (!farmUuid) {
setLogs([]);
setCount(0);
setSelectedLogId(null);
@@ -431,7 +426,7 @@ const Sensor7Page = () => {
}
}
},
- [canAccessSensor7, farmUuid, page, pageSize],
+ [farmUuid, page, pageSize],
);
useEffect(() => {
@@ -444,9 +439,9 @@ const Sensor7Page = () => {
}, [farmUuid]);
useEffect(() => {
- if (!farmUuid || !canAccessSensor7) return;
+ if (!farmUuid) return;
void loadLogs(page, pageSize);
- }, [canAccessSensor7, farmUuid, loadLogs, page, pageSize]);
+ }, [farmUuid, loadLogs, page, pageSize]);
const handlePageSizeChange = (event: SelectChangeEvent) => {
const nextPageSize = Number(event.target.value);
@@ -457,14 +452,6 @@ const Sensor7Page = () => {
const heroBorder = alpha(theme.palette.primary.main, 0.18);
const heroGlow = alpha(theme.palette.primary.main, 0.2);
- if (isLoading) {
- return (
-
-
-
- );
- }
-
if (!farmUuid) {
return (
@@ -478,32 +465,6 @@ const Sensor7Page = () => {
);
}
- if (error) {
- return (
-
-
- مانیتورینگ سنسور خارجی
-
- {resolveErrorMessage(error, "خطا در دریافت سطح دسترسی مزرعه.")}
-
-
-
- );
- }
-
- if (!canAccessSensor7) {
- return (
-
-
- مانیتورینگ سنسور خارجی
-
- شما به این صفحه دسترسی ندارید.
-
-
-
- );
- }
-
const metrics = [
{
icon: "tabler-database",