refactor: Consolidate project ID retrieval in PolicySelectionModal and RolePermissionsSection for improved clarity and consistency

This commit is contained in:
Victor Santos
2025-12-03 16:25:27 -03:00
parent 935d400a97
commit 8f3e5a8362
2 changed files with 5 additions and 8 deletions
@@ -47,9 +47,9 @@ type TForm = { permissions: Record<ProjectPermissionSub, boolean> };
const Content = ({ onClose, type: projectType }: ContentProps) => { const Content = ({ onClose, type: projectType }: ContentProps) => {
const rootForm = useFormContext<TFormSchema>(); const rootForm = useFormContext<TFormSchema>();
const [search, setSearch] = useState(""); const [search, setSearch] = useState("");
const { currentProject } = useProject(); const { currentProject, projectId } = useProject();
const isSecretManagerProject = currentProject.type === ProjectType.SecretManager; const isSecretManagerProject = currentProject.type === ProjectType.SecretManager;
const { data: integrations = [] } = useGetWorkspaceIntegrations(currentProject?.id ?? "", { const { data: integrations = [] } = useGetWorkspaceIntegrations(projectId, {
enabled: isSecretManagerProject, enabled: isSecretManagerProject,
refetchInterval: false refetchInterval: false
}); });
@@ -103,14 +103,11 @@ export const renderConditionalComponents = (
}; };
export const RolePermissionsSection = ({ roleSlug, isDisabled }: Props) => { export const RolePermissionsSection = ({ roleSlug, isDisabled }: Props) => {
const { currentProject } = useProject(); const { currentProject, projectId } = useProject();
const projectId = currentProject?.id || "";
const isSecretManagerProject = currentProject.type === ProjectType.SecretManager; const isSecretManagerProject = currentProject.type === ProjectType.SecretManager;
const { data: role, isPending } = useGetProjectRoleBySlug( const { data: role, isPending } = useGetProjectRoleBySlug(projectId, roleSlug as string);
currentProject?.id ?? "",
roleSlug as string
);
const { data: integrations = [] } = useGetWorkspaceIntegrations(projectId, { const { data: integrations = [] } = useGetWorkspaceIntegrations(projectId, {
enabled: isSecretManagerProject, enabled: isSecretManagerProject,
refetchInterval: false refetchInterval: false