Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ sealed class WooPosSettingsDetailDestination {

sealed class Help : WooPosSettingsDetailDestination() {
data object Overview : Help() {
override val titleRes: Int = R.string.woopos_get_support_title
override val titleRes: Int = R.string.woopos_settings_help_category
override val parentDestination: WooPosSettingsDetailDestination? = null
override val childDestinations: List<WooPosSettingsDetailDestination> = emptyList()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ enum class WooPosSettingsCategory(
WooPosSettingsDetailDestination.Hardware.Overview
),
HELP(
R.string.woopos_get_support_title,
R.string.woopos_settings_help_category,
R.string.woopos_settings_help_category_subtitle,
Icons.AutoMirrored.Filled.Help,
WooPosSettingsDetailDestination.Help.Overview,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ class WooPosSettingsReceiptRepository @Inject constructor(
val settings = response.model ?: emptyMap()
val receiptInfo = WooPosSettingsStoreState.ReceiptInfo(
storeName = settings["woocommerce_pos_store_name"] ?: "",
address = settings["woocommerce_pos_store_address"] ?: "",
address = formatReceiptAddress(settings["woocommerce_pos_store_address"] ?: ""),
phone = settings["woocommerce_pos_store_phone"] ?: "",
email = settings["woocommerce_pos_store_email"] ?: "",
refundPolicy = settings["woocommerce_pos_refund_returns_policy"] ?: ""
)

Expand All @@ -41,6 +42,10 @@ class WooPosSettingsReceiptRepository @Inject constructor(
}
}

private fun formatReceiptAddress(address: String): String {
return address.replace("\n", ", ").replace(Regex(",\\s*,"), ",").trim()
Copy link

Copilot AI Sep 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The regex pattern for removing duplicate commas could be simplified. Consider using .replace(Regex(",+\\s*"), ", ") to handle multiple consecutive commas and whitespace more efficiently.

Suggested change
return address.replace("\n", ", ").replace(Regex(",\\s*,"), ",").trim()
return address.replace("\n", ", ").replace(Regex(",+\\s*"), ", ").trim()

Copilot uses AI. Check for mistakes.
}

private fun isWooCommerceVersionAtLeast10(): Boolean {
val wooCoreVersion = getWooCoreVersion() ?: return false
return wooCoreVersion.semverCompareTo(WC_VERSION_SUPPORTS_RECEIPTS) >= 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import androidx.compose.foundation.layout.size
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Email
import androidx.compose.material.icons.filled.Home
import androidx.compose.material.icons.filled.Phone
import androidx.compose.material.icons.filled.Receipt
Expand Down Expand Up @@ -120,12 +121,7 @@ private fun StoreInformationSection(storeInfo: WooPosSettingsStoreState.StoreInf

@Composable
private fun ReceiptLoadingSection() {
WooPosShimmerBox(
modifier = Modifier
.fillMaxWidth(0.3f)
.height(32.dp)
.padding(start = WooPosSpacing.Large.value, bottom = WooPosSpacing.Small.value)
)
SectionTitle(stringResource(R.string.woopos_settings_receipt_information_title))

repeat(5) {
ReceiptMenuItemShimmer()
Expand All @@ -137,11 +133,14 @@ private fun ReceiptMenuItemShimmer() {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(WooPosSpacing.Large.value),
.padding(
vertical = WooPosSpacing.Medium.value,
horizontal = WooPosSpacing.Large.value
),
verticalAlignment = Alignment.CenterVertically
) {
WooPosShimmerBox(
modifier = Modifier.size(28.dp)
modifier = Modifier.size(24.dp)
)

Column(
Expand All @@ -152,15 +151,15 @@ private fun ReceiptMenuItemShimmer() {
WooPosShimmerBox(
modifier = Modifier
.fillMaxWidth(0.4f)
.height(24.dp)
.height(28.dp)
)

Spacer(modifier = Modifier.height(WooPosSpacing.Small.value))

WooPosShimmerBox(
modifier = Modifier
.fillMaxWidth(0.7f)
.height(14.dp)
.height(16.dp)
)
}
}
Expand Down Expand Up @@ -188,6 +187,12 @@ private fun ReceiptInformationSection(receiptInfo: WooPosSettingsStoreState.Rece
subtitle = receiptInfo.phone.ifBlank { stringResource(R.string.woopos_settings_store_not_set) }
)

WooPosSettingsDetailsMenuItem(
icon = Icons.Default.Email,
title = stringResource(R.string.woopos_settings_store_email_label),
subtitle = receiptInfo.email.ifBlank { stringResource(R.string.woopos_settings_store_not_set) }
)

WooPosSettingsDetailsMenuItem(
icon = Icons.Default.Receipt,
title = stringResource(R.string.woopos_settings_refund_policy_label),
Expand All @@ -211,6 +216,7 @@ fun WooPosSettingsStoreScreenPreview() {
storeName = "My WooCommerce Store",
address = "123 Main Street, City, State 12345, US",
phone = "+1 555 1234 1234",
email = "store@example.com",
refundPolicy = "Returns accepted within 30 days"
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ data class WooPosSettingsStoreState(
val storeName: String,
val address: String,
val phone: String,
val email: String,
val refundPolicy: String
)

Expand Down
2 changes: 2 additions & 0 deletions WooCommerce/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4370,6 +4370,7 @@
<string name="woopos_settings_card_reader_documentation_title">Documentation</string>
<string name="woopos_settings_card_reader_documentation_subtitle">Learn more about accepting mobile payments</string>
<string name="woopos_settings_card_reader_connected_reader">Connected reader</string>
<string name="woopos_settings_help_category">Help</string>
<string name="woopos_settings_help_category_subtitle">Get help and support</string>
<string name="woopos_settings_help_product_limitations_subtitle">Learn about which products are supported in POS</string>
<string name="woopos_settings_help_documentation_subtitle">View guides and tutorials</string>
Expand Down Expand Up @@ -4580,6 +4581,7 @@
<string name="woopos_settings_store_name_label">Store name</string>
<string name="woopos_settings_store_address_label">Address</string>
<string name="woopos_settings_store_phone_label">Phone</string>
<string name="woopos_settings_store_email_label">Email</string>
<string name="woopos_settings_refund_policy_label">Refund &amp; Returns Policy</string>
<string name="woopos_settings_store_not_set">Not set</string>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class WooPosSettingsStoreViewModelTest {
storeName = "Test Store",
address = "123 Test St",
phone = "+1234567890",
email = "test@example.com",
refundPolicy = "30 day returns"
)
whenever(storeRepository.getStoreInfo()).thenReturn(storeInfo)
Expand Down