roles: fix permissions

This commit is contained in:
androidlover5842
2026-02-02 05:27:06 +05:30
parent 86307a66c8
commit 342ff6a237
2 changed files with 18 additions and 3 deletions

View File

@@ -105,6 +105,16 @@ class MainActivity : ComponentActivity() {
val canDeleteCashPayment: (String) -> Boolean = { propertyId ->
state.isSuperAdmin || state.propertyRoles[propertyId]?.contains("ADMIN") == true
}
val canAddBookingPayment: (String) -> Boolean = { propertyId ->
state.isSuperAdmin || state.propertyRoles[propertyId]?.any {
it == "ADMIN" || it == "MANAGER" || it == "STAFF"
} == true
}
val canRefundBookingPayment: (String) -> Boolean = { propertyId ->
state.isSuperAdmin || state.propertyRoles[propertyId]?.any {
it == "ADMIN" || it == "MANAGER"
} == true
}
val canManagePropertyUsers: (String) -> Boolean = { propertyId ->
state.isSuperAdmin || state.propertyRoles[propertyId]?.contains("ADMIN") == true
}
@@ -579,9 +589,9 @@ class MainActivity : ComponentActivity() {
is AppRoute.BookingPayments -> BookingPaymentsScreen(
propertyId = currentRoute.propertyId,
bookingId = currentRoute.bookingId,
canAddCash = canManageRazorpaySettings(currentRoute.propertyId),
canAddCash = canAddBookingPayment(currentRoute.propertyId),
canDeleteCash = canDeleteCashPayment(currentRoute.propertyId),
canRefund = canManageRazorpaySettings(currentRoute.propertyId),
canRefund = canRefundBookingPayment(currentRoute.propertyId),
onBack = {
route.value = AppRoute.BookingDetailsTabs(
currentRoute.propertyId,

View File

@@ -240,7 +240,12 @@ private fun PaymentCard(
payment.currency?.let { append(" $it") }
}
Text(text = amountText, style = MaterialTheme.typography.titleMedium)
if (canRefund && (!payment.id.isNullOrBlank() || !payment.gatewayPaymentId.isNullOrBlank())) {
val hasRefundableAmount = (payment.amount ?: 0L) > 0L
if (
canRefund &&
hasRefundableAmount &&
(!payment.id.isNullOrBlank() || !payment.gatewayPaymentId.isNullOrBlank())
) {
TextButton(onClick = { onRefund(payment) }) {
Text("Refund")
}