roles: fix permissions
This commit is contained in:
@@ -105,6 +105,16 @@ class MainActivity : ComponentActivity() {
|
|||||||
val canDeleteCashPayment: (String) -> Boolean = { propertyId ->
|
val canDeleteCashPayment: (String) -> Boolean = { propertyId ->
|
||||||
state.isSuperAdmin || state.propertyRoles[propertyId]?.contains("ADMIN") == true
|
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 ->
|
val canManagePropertyUsers: (String) -> Boolean = { propertyId ->
|
||||||
state.isSuperAdmin || state.propertyRoles[propertyId]?.contains("ADMIN") == true
|
state.isSuperAdmin || state.propertyRoles[propertyId]?.contains("ADMIN") == true
|
||||||
}
|
}
|
||||||
@@ -579,9 +589,9 @@ class MainActivity : ComponentActivity() {
|
|||||||
is AppRoute.BookingPayments -> BookingPaymentsScreen(
|
is AppRoute.BookingPayments -> BookingPaymentsScreen(
|
||||||
propertyId = currentRoute.propertyId,
|
propertyId = currentRoute.propertyId,
|
||||||
bookingId = currentRoute.bookingId,
|
bookingId = currentRoute.bookingId,
|
||||||
canAddCash = canManageRazorpaySettings(currentRoute.propertyId),
|
canAddCash = canAddBookingPayment(currentRoute.propertyId),
|
||||||
canDeleteCash = canDeleteCashPayment(currentRoute.propertyId),
|
canDeleteCash = canDeleteCashPayment(currentRoute.propertyId),
|
||||||
canRefund = canManageRazorpaySettings(currentRoute.propertyId),
|
canRefund = canRefundBookingPayment(currentRoute.propertyId),
|
||||||
onBack = {
|
onBack = {
|
||||||
route.value = AppRoute.BookingDetailsTabs(
|
route.value = AppRoute.BookingDetailsTabs(
|
||||||
currentRoute.propertyId,
|
currentRoute.propertyId,
|
||||||
|
|||||||
@@ -240,7 +240,12 @@ private fun PaymentCard(
|
|||||||
payment.currency?.let { append(" $it") }
|
payment.currency?.let { append(" $it") }
|
||||||
}
|
}
|
||||||
Text(text = amountText, style = MaterialTheme.typography.titleMedium)
|
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) }) {
|
TextButton(onClick = { onRefund(payment) }) {
|
||||||
Text("Refund")
|
Text("Refund")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user