From c01c92e015c194d4e13a9588bb04630e7146835b Mon Sep 17 00:00:00 2001 From: Felipe Trost Date: Thu, 16 Nov 2023 15:38:34 +0100 Subject: [PATCH 1/2] Fixed wrong import --- src/management-system-v2/components/process-list.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/management-system-v2/components/process-list.tsx b/src/management-system-v2/components/process-list.tsx index e2684fe02..24d5c472e 100644 --- a/src/management-system-v2/components/process-list.tsx +++ b/src/management-system-v2/components/process-list.tsx @@ -38,12 +38,12 @@ import useLastClickedStore from '@/lib/use-last-clicked-process-store'; import classNames from 'classnames'; import { generateDateString } from '@/lib/utils'; import ProcessEditButton from './process-edit-button'; -import { AuthCan } from '@/lib/iamComponents'; import { toCaslResource } from '@/lib/ability/caslAbility'; import { ApiData, useDeleteAsset, useInvalidateAsset, usePostAsset } from '@/lib/fetch-data'; import { useUserPreferences } from '@/lib/user-preferences'; import ProcessDeleteSingleModal from './process-delete-single'; import { useAbilityStore } from '@/lib/abilityStore'; +import { AuthCan } from '@/lib/clientAuthComponents'; type Processes = ApiData<'/process', 'get'>; type Process = Processes[number]; From f7798e30688176a893c7a5f604cd5b61beb592af Mon Sep 17 00:00:00 2001 From: Felipe Trost Date: Thu, 16 Nov 2023 18:38:51 +0100 Subject: [PATCH 2/2] Updated AuthCan types --- src/management-system-v2/lib/clientAuthComponents.tsx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/management-system-v2/lib/clientAuthComponents.tsx b/src/management-system-v2/lib/clientAuthComponents.tsx index 1a1f7d921..7220e4ef9 100644 --- a/src/management-system-v2/lib/clientAuthComponents.tsx +++ b/src/management-system-v2/lib/clientAuthComponents.tsx @@ -1,17 +1,18 @@ 'use client'; -import { ReactElement, ReactNode, useEffect, useMemo } from 'react'; +import { ReactElement, ReactNode, useEffect, useMemo, FC, PropsWithChildren } from 'react'; import { useAbilityStore } from './abilityStore'; import { useSession } from 'next-auth/react'; import { Route } from 'next'; -import { AbilityRule, ResourceActionType, ResourceType } from './ability/caslAbility'; +import { AbilityRule, ResourceActionType } from './ability/caslAbility'; import { PackRule } from '@casl/ability/extra'; import { useCsrfTokenStore } from './csrfTokenStore'; import { useRouter } from 'next/navigation'; +import Ability from './ability/abilityHelper'; export type AuthCanProps = { action: ResourceActionType | ResourceActionType[]; - resource: ResourceType | ResourceType[]; + resource: Parameters[1]; notLoggedIn?: ReactElement; fallback?: ReactElement; fallbackRedirect?: Route; @@ -40,7 +41,7 @@ export const FetchAbility = () => { return <>; }; -export const AuthCan = ({ +export const AuthCan: FC> = ({ action, resource, fallback, @@ -48,8 +49,6 @@ export const AuthCan = ({ notLoggedIn, children, fallbackRedirect, -}: AuthCanProps & { - children: ReactNode; }) => { const router = useRouter(); const { status } = useSession();