From 6d3b7ac247f06a20e8e3fc1b64a751a19a222e27 Mon Sep 17 00:00:00 2001 From: "Md. Ashikul Alam" <32668488+Nil20@users.noreply.github.com> Date: Thu, 9 Jan 2025 16:54:35 +0600 Subject: [PATCH] fix: add prop to protected component to show update action (#8307) --- packages/client/src/components/ProtectedComponent.tsx | 8 ++++++-- packages/client/src/views/RecordAudit/ActionMenu.tsx | 5 ++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/client/src/components/ProtectedComponent.tsx b/packages/client/src/components/ProtectedComponent.tsx index 9ecc41aa367..414a565ba3a 100644 --- a/packages/client/src/components/ProtectedComponent.tsx +++ b/packages/client/src/components/ProtectedComponent.tsx @@ -15,19 +15,23 @@ import { Scope } from '@opencrvs/commons/client' interface ScopeComponentProps { scopes?: Scope[] denyScopes?: Scope[] + conditional?: boolean children: React.ReactNode } const ProtectedComponent: React.FC = ({ scopes, denyScopes, - children + children, + conditional }) => { const { hasAnyScope } = usePermissions() const hasRequiredScope = !scopes || hasAnyScope(scopes) const hasDeniedScope = denyScopes && hasAnyScope(denyScopes) - return hasRequiredScope && !hasDeniedScope ? <>{children} : null + return (hasRequiredScope && !hasDeniedScope) || conditional ? ( + <>{children} + ) : null } export default ProtectedComponent diff --git a/packages/client/src/views/RecordAudit/ActionMenu.tsx b/packages/client/src/views/RecordAudit/ActionMenu.tsx index 796a3c82963..8af0ca07b98 100644 --- a/packages/client/src/views/RecordAudit/ActionMenu.tsx +++ b/packages/client/src/views/RecordAudit/ActionMenu.tsx @@ -169,7 +169,10 @@ export const ActionMenu: React.FC<{ isActionable={isActionable} /> - +