diff --git a/resources/js/helpers/utils.ts b/resources/js/helpers/utils.ts index 8c5c9da..3acbbfd 100644 --- a/resources/js/helpers/utils.ts +++ b/resources/js/helpers/utils.ts @@ -1,3 +1,4 @@ +import { useUserStore } from "../store/UserStore"; import { extractFileNameFromUrl } from "./url"; /** @@ -102,3 +103,14 @@ export const generateRandomElementId = (prefix: string = ""): string => { return randomId; }; + +/** + * Return if the current user has a permission. + * + * @param {string} permission The permission to check. + * @returns {boolean} If the user has the permission. + */ +export const userHasPermission = (permission: string): boolean => { + const userStore = useUserStore(); + return userStore.permissions && userStore.permissions.includes(permission); +};