@@ -4,6 +4,8 @@ import SwiftUI
44struct PointOfSaleSettingsStoreDetailView : View {
55 @Environment ( \. dismiss) private var dismiss
66 @State private var shouldShowReceiptInformation = false
7+ @State private var posSettings : PointOfSaleSettings = . empty
8+ @State private var isLoadingSettings = true
79
810 var storeName : String {
911 guard let site = ServiceLocator . stores. sessionManager. defaultSite else {
@@ -42,33 +44,33 @@ struct PointOfSaleSettingsStoreDetailView: View {
4244 . font ( . caption)
4345 . foregroundStyle ( . secondary)
4446 }
45-
47+
4648 Group {
4749 Spacer ( )
4850 Text ( " Receipt Information " )
4951 . font ( . title2)
5052 Text ( " Store name " )
51- Text ( " WIP " )
53+ Text ( isLoadingSettings ? " Loading... " : posSettings . storeName )
5254 . font ( . caption)
5355 . foregroundStyle ( . secondary)
5456
5557 Text ( " Physical address " )
56- Text ( " WIP " )
58+ Text ( isLoadingSettings ? " Loading... " : posSettings . storeAddress )
5759 . font ( . caption)
5860 . foregroundStyle ( . secondary)
5961
6062 Text ( " Phone number " )
61- Text ( " WIP " )
63+ Text ( isLoadingSettings ? " Loading... " : posSettings . storePhone )
6264 . font ( . caption)
6365 . foregroundStyle ( . secondary)
6466
6567 Text ( " Email " )
66- Text ( " WIP " )
68+ Text ( isLoadingSettings ? " Loading... " : posSettings . storeEmail )
6769 . font ( . caption)
6870 . foregroundStyle ( . secondary)
6971
7072 Text ( " Refund & Returns Policy " )
71- Text ( " WIP " )
73+ Text ( isLoadingSettings ? " Loading... " : posSettings . refundReturnsPolicy )
7274 . font ( . caption)
7375 . foregroundStyle ( . secondary)
7476
@@ -84,18 +86,43 @@ struct PointOfSaleSettingsStoreDetailView: View {
8486 }
8587 . task {
8688 shouldShowReceiptInformation = await isPluginSupported ( . wooCommerce, minimumVersion: " 10.0 " )
87- /**
88- TODO - WOOMOB-1160: retrieval for woocommerce_pos_ settings
89- woocommerce_pos_store_name
90- woocommerce_pos_store_address
91- woocommerce_pos_store_phone
92- woocommerce_pos_store_email
93- woocommerce_pos_refund_returns_policy
94- */
89+ }
90+ . task {
91+ let siteID = ServiceLocator . stores. sessionManager. defaultSite? . siteID ?? 0
92+ let action = SettingAction . retrievePointOfSaleSettings ( siteID: siteID) { result in
93+ switch result {
94+ case . success( let siteSettings) :
95+ self . posSettings = PointOfSaleSettings ( from: siteSettings)
96+ self . isLoadingSettings = false
97+ case . failure( let error) :
98+ DDLogError ( " Failed to load POS settings: \( error) " )
99+ self . posSettings = . empty
100+ self . isLoadingSettings = false
101+ }
102+ }
103+ ServiceLocator . stores. dispatch ( action)
95104 }
96105 }
97106}
98107
108+ struct PointOfSaleSettings {
109+ let storeName : String
110+ let storeAddress : String
111+ let storePhone : String
112+ let storeEmail : String
113+ let refundReturnsPolicy : String
114+
115+ init ( from siteSettings: [ SiteSetting ] ) {
116+ self . storeName = siteSettings. first { $0. settingID == " woocommerce_pos_store_name " } ? . value ?? " Not set "
117+ self . storeAddress = siteSettings. first { $0. settingID == " woocommerce_pos_store_address " } ? . value ?? " Not set "
118+ self . storePhone = siteSettings. first { $0. settingID == " woocommerce_pos_store_phone " } ? . value ?? " Not set "
119+ self . storeEmail = siteSettings. first { $0. settingID == " woocommerce_pos_store_email " } ? . value ?? " Not set "
120+ self . refundReturnsPolicy = siteSettings. first { $0. settingID == " woocommerce_pos_refund_returns_policy " } ? . value ?? " Not set "
121+ }
122+
123+ static let empty = PointOfSaleSettings ( from: [ ] )
124+ }
125+
99126private extension PointOfSaleSettingsStoreDetailView {
100127 @MainActor
101128 func isPluginSupported( _ plugin: Plugin , minimumVersion: String ) async -> Bool {
0 commit comments