import { useAppSelector } from "@/rtk/hooks"

export const checkPermissions = (requirement:string) => {
    try {
        const requirePermissions = requirement.split(',')
        const user = useAppSelector((state) => state.authentication.user)
        const userPermissoions = user?.user?.permission.split(',')

        for(let i=0; i <= userPermissoions.length; i++){
            if(requirePermissions.includes(userPermissoions[i])){
                return true
            }
        }
        return false
    } catch (error) {
        console.log(error)
        return false
    }
}