DONE: layout letter with letterhead and footer, notification for newly...

This commit is contained in:
ISMAIL MASSERAN
2026-06-28 02:16:49 +00:00
parent 94ecbe5887
commit 034ecf947f
400 changed files with 29802 additions and 5446 deletions
@@ -28,7 +28,7 @@ function userCanImpersonate(): boolean {
)
}
function targetCanBeImpersonated(target: UserListItem, currentUserId?: string): boolean {
function isImpersonateTargetVisible(target: UserListItem, currentUserId?: string): boolean {
if (!currentUserId || target.id === currentUserId) {
return false
}
@@ -36,6 +36,14 @@ function targetCanBeImpersonated(target: UserListItem, currentUserId?: string):
return !target.roles?.some((role) => role.name === DEVELOPER_ROLE)
}
function targetCanBeImpersonated(target: UserListItem, currentUserId?: string): boolean {
if (!isImpersonateTargetVisible(target, currentUserId)) {
return false
}
return target.status === 'active'
}
export function useImpersonate() {
const authStore = useAuthStore()
const router = useRouter()
@@ -44,10 +52,26 @@ export function useImpersonate() {
const impersonating = computed(() => authStore.isImpersonating)
const canImpersonate = computed(() => userCanImpersonate())
function showImpersonateButton(target: UserListItem): boolean {
return canImpersonate.value && isImpersonateTargetVisible(target, authStore.user?.id)
}
function canImpersonateUser(target: UserListItem): boolean {
return canImpersonate.value && targetCanBeImpersonated(target, authStore.user?.id)
}
function impersonateButtonTitle(target: UserListItem): string {
if (impersonating.value) {
return 'Anda sedang menyamar pengguna'
}
if (target.status !== 'active') {
return 'Hanya pengguna aktif boleh disamar'
}
return 'Menyamar sebagai pengguna'
}
async function refreshImpersonationStatus() {
await authStore.refreshImpersonationStatus()
}
@@ -136,7 +160,9 @@ export function useImpersonate() {
return {
canImpersonate,
showImpersonateButton,
canImpersonateUser,
impersonateButtonTitle,
impersonating,
loading,
refreshImpersonationStatus,