fix bug: "ADMIN" only disable action

This commit is contained in:
Warunee Tamkoo 2025-11-08 21:35:03 +07:00
parent 3856035ce1
commit d4b61dd490
7 changed files with 75 additions and 23 deletions

View file

@ -273,13 +273,13 @@ async function fetchOrganizationActive() {
});
}
const tokenParsedData = ref<string[]>([]);
/**
* function fetch อมลของ Tree
* @param id id โครงสราง
*/
async function fetchDataTree(id: string) {
const tokenParsedData = await tokenParsed();
const isSuperAdmin = tokenParsedData.role.includes("SUPER_ADMIN");
const isSuperAdmin = tokenParsedData.value.includes("SUPER_ADMIN");
if (!isSuperAdmin) {
nodes.value = [];
}
@ -411,7 +411,11 @@ function updatemodalPersonal(modal: boolean) {
}
function hideBtnAction(id: string) {
if (dataPosition.value?.profileId === id) {
if (
dataPosition.value?.profileId === id &&
tokenParsedData.value.includes("ADMIN") &&
!tokenParsedData.value.includes("SUPER_ADMIN")
) {
return false;
} else {
return true;
@ -432,8 +436,10 @@ watch(
}
);
onMounted(() => {
onMounted(async () => {
fetchOrganizationActive();
const token = await tokenParsed();
tokenParsedData.value = token?.role || [];
});
</script>