Skip to content

Commit 303cdcc

Browse files
authored
Merge pull request #14557 from woocommerce/woomob-1258-woo-possettings-fix-minor-findings-from-cft
[WOOMOB-1258][Woo POS][Settings] Fix minor findings from the CFT
2 parents aff87c5 + ba60a54 commit 303cdcc

File tree

7 files changed

+28
-13
lines changed

7 files changed

+28
-13
lines changed

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/settings/WooPosSettingsState.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ sealed class WooPosSettingsDetailDestination {
5151

5252
sealed class Help : WooPosSettingsDetailDestination() {
5353
data object Overview : Help() {
54-
override val titleRes: Int = R.string.woopos_get_support_title
54+
override val titleRes: Int = R.string.woopos_settings_help_category
5555
override val parentDestination: WooPosSettingsDetailDestination? = null
5656
override val childDestinations: List<WooPosSettingsDetailDestination> = emptyList()
5757
}

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/settings/categories/WooPosSettingsCategoriesState.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ enum class WooPosSettingsCategory(
2929
WooPosSettingsDetailDestination.Hardware.Overview
3030
),
3131
HELP(
32-
R.string.woopos_get_support_title,
32+
R.string.woopos_settings_help_category,
3333
R.string.woopos_settings_help_category_subtitle,
3434
Icons.AutoMirrored.Filled.Help,
3535
WooPosSettingsDetailDestination.Help.Overview,

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/settings/details/store/WooPosSettingsReceiptRepository.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ class WooPosSettingsReceiptRepository @Inject constructor(
3030
val settings = response.model ?: emptyMap()
3131
val receiptInfo = WooPosSettingsStoreState.ReceiptInfo(
3232
storeName = settings["woocommerce_pos_store_name"] ?: "",
33-
address = settings["woocommerce_pos_store_address"] ?: "",
33+
address = formatReceiptAddress(settings["woocommerce_pos_store_address"] ?: ""),
3434
phone = settings["woocommerce_pos_store_phone"] ?: "",
35+
email = settings["woocommerce_pos_store_email"] ?: "",
3536
refundPolicy = settings["woocommerce_pos_refund_returns_policy"] ?: ""
3637
)
3738

@@ -41,6 +42,10 @@ class WooPosSettingsReceiptRepository @Inject constructor(
4142
}
4243
}
4344

45+
private fun formatReceiptAddress(address: String): String {
46+
return address.replace("\n", ", ").replace(Regex(",\\s*,"), ",").trim()
47+
}
48+
4449
private fun isWooCommerceVersionAtLeast10(): Boolean {
4550
val wooCoreVersion = getWooCoreVersion() ?: return false
4651
return wooCoreVersion.semverCompareTo(WC_VERSION_SUPPORTS_RECEIPTS) >= 0

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/settings/details/store/WooPosSettingsStoreScreen.kt

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import androidx.compose.foundation.layout.size
1111
import androidx.compose.foundation.rememberScrollState
1212
import androidx.compose.foundation.verticalScroll
1313
import androidx.compose.material.icons.Icons
14+
import androidx.compose.material.icons.filled.Email
1415
import androidx.compose.material.icons.filled.Home
1516
import androidx.compose.material.icons.filled.Phone
1617
import androidx.compose.material.icons.filled.Receipt
@@ -120,12 +121,7 @@ private fun StoreInformationSection(storeInfo: WooPosSettingsStoreState.StoreInf
120121

121122
@Composable
122123
private fun ReceiptLoadingSection() {
123-
WooPosShimmerBox(
124-
modifier = Modifier
125-
.fillMaxWidth(0.3f)
126-
.height(32.dp)
127-
.padding(start = WooPosSpacing.Large.value, bottom = WooPosSpacing.Small.value)
128-
)
124+
SectionTitle(stringResource(R.string.woopos_settings_receipt_information_title))
129125

130126
repeat(5) {
131127
ReceiptMenuItemShimmer()
@@ -137,11 +133,14 @@ private fun ReceiptMenuItemShimmer() {
137133
Row(
138134
modifier = Modifier
139135
.fillMaxWidth()
140-
.padding(WooPosSpacing.Large.value),
136+
.padding(
137+
vertical = WooPosSpacing.Medium.value,
138+
horizontal = WooPosSpacing.Large.value
139+
),
141140
verticalAlignment = Alignment.CenterVertically
142141
) {
143142
WooPosShimmerBox(
144-
modifier = Modifier.size(28.dp)
143+
modifier = Modifier.size(24.dp)
145144
)
146145

147146
Column(
@@ -152,15 +151,15 @@ private fun ReceiptMenuItemShimmer() {
152151
WooPosShimmerBox(
153152
modifier = Modifier
154153
.fillMaxWidth(0.4f)
155-
.height(24.dp)
154+
.height(28.dp)
156155
)
157156

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

160159
WooPosShimmerBox(
161160
modifier = Modifier
162161
.fillMaxWidth(0.7f)
163-
.height(14.dp)
162+
.height(16.dp)
164163
)
165164
}
166165
}
@@ -188,6 +187,12 @@ private fun ReceiptInformationSection(receiptInfo: WooPosSettingsStoreState.Rece
188187
subtitle = receiptInfo.phone.ifBlank { stringResource(R.string.woopos_settings_store_not_set) }
189188
)
190189

190+
WooPosSettingsDetailsMenuItem(
191+
icon = Icons.Default.Email,
192+
title = stringResource(R.string.woopos_settings_store_email_label),
193+
subtitle = receiptInfo.email.ifBlank { stringResource(R.string.woopos_settings_store_not_set) }
194+
)
195+
191196
WooPosSettingsDetailsMenuItem(
192197
icon = Icons.Default.Receipt,
193198
title = stringResource(R.string.woopos_settings_refund_policy_label),
@@ -211,6 +216,7 @@ fun WooPosSettingsStoreScreenPreview() {
211216
storeName = "My WooCommerce Store",
212217
address = "123 Main Street, City, State 12345, US",
213218
phone = "+1 555 1234 1234",
219+
email = "[email protected]",
214220
refundPolicy = "Returns accepted within 30 days"
215221
)
216222
)

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/settings/details/store/WooPosSettingsStoreState.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ data class WooPosSettingsStoreState(
1313
val storeName: String,
1414
val address: String,
1515
val phone: String,
16+
val email: String,
1617
val refundPolicy: String
1718
)
1819

WooCommerce/src/main/res/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4372,6 +4372,7 @@
43724372
<string name="woopos_settings_card_reader_documentation_title">Documentation</string>
43734373
<string name="woopos_settings_card_reader_documentation_subtitle">Learn more about accepting mobile payments</string>
43744374
<string name="woopos_settings_card_reader_connected_reader">Connected reader</string>
4375+
<string name="woopos_settings_help_category">Help</string>
43754376
<string name="woopos_settings_help_category_subtitle">Get help and support</string>
43764377
<string name="woopos_settings_help_product_limitations_subtitle">Learn about which products are supported in POS</string>
43774378
<string name="woopos_settings_help_documentation_subtitle">View guides and tutorials</string>
@@ -4582,6 +4583,7 @@
45824583
<string name="woopos_settings_store_name_label">Store name</string>
45834584
<string name="woopos_settings_store_address_label">Address</string>
45844585
<string name="woopos_settings_store_phone_label">Phone</string>
4586+
<string name="woopos_settings_store_email_label">Email</string>
45854587
<string name="woopos_settings_refund_policy_label">Refund &amp; Returns Policy</string>
45864588
<string name="woopos_settings_store_not_set">Not set</string>
45874589

WooCommerce/src/test/kotlin/com/woocommerce/android/ui/woopos/settings/details/store/WooPosSettingsStoreViewModelTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class WooPosSettingsStoreViewModelTest {
3131
storeName = "Test Store",
3232
address = "123 Test St",
3333
phone = "+1234567890",
34+
email = "[email protected]",
3435
refundPolicy = "30 day returns"
3536
)
3637
whenever(storeRepository.getStoreInfo()).thenReturn(storeInfo)

0 commit comments

Comments
 (0)