11import SwiftUI
22import UIKit
33import struct WooFoundation. WooAnalyticsEvent
4+ import struct WooFoundation. SafariView
45
56struct POSOrdersView : View {
67 @Binding var isPresented : Bool
@@ -9,8 +10,17 @@ struct POSOrdersView: View {
910 @Environment ( \. posAnalytics) private var analytics
1011 @State private var isSearching : Bool = false
1112 @State private var searchTerm : String = " "
13+ @State private var showBlog = false
1214
1315 var body : some View {
16+ contentView
17+ . task {
18+ await orderListModel. ordersController. loadOrders ( )
19+ }
20+ }
21+
22+ @ViewBuilder
23+ private var contentView : some View {
1424 switch ( orderListModel. ordersController. ordersViewState, isSearching) {
1525 case ( . error( let error) , false ) :
1626 errorView ( error)
@@ -70,16 +80,6 @@ struct POSOrdersView: View {
7080 @ViewBuilder
7181 private func errorView( _ error: PointOfSaleErrorState ) -> some View {
7282 ZStack {
73- VStack {
74- POSPageHeaderView (
75- title: POSOrderListView . Localization. ordersTitle,
76- backButtonConfiguration: . init( state: . enabled, action: {
77- isPresented = false
78- } ) )
79- . posHeaderBackButtonIcon ( systemName: " xmark " )
80- Spacer ( )
81- }
82-
8383 VStack {
8484 Spacer ( )
8585 POSListErrorView ( error: error) {
@@ -89,12 +89,7 @@ struct POSOrdersView: View {
8989 }
9090 Spacer ( )
9191 }
92- }
93- }
9492
95- @ViewBuilder
96- private func emptyView( ) -> some View {
97- ZStack {
9893 VStack {
9994 POSPageHeaderView (
10095 title: POSOrderListView . Localization. ordersTitle,
@@ -104,18 +99,34 @@ struct POSOrdersView: View {
10499 . posHeaderBackButtonIcon ( systemName: " xmark " )
105100 Spacer ( )
106101 }
102+ }
103+ }
107104
105+ @ViewBuilder
106+ private func emptyView( ) -> some View {
107+ ZStack {
108108 VStack {
109109 Spacer ( )
110110 POSListEmptyView (
111111 viewModel: POSOrderListEmptyViewModel ( isSearching: false )
112112 ) {
113- Task { @MainActor in
114- await orderListModel. ordersController. loadOrders ( )
115- }
113+ showBlog = true
116114 }
117115 Spacer ( )
118116 }
117+
118+ VStack {
119+ POSPageHeaderView (
120+ title: POSOrderListView . Localization. ordersTitle,
121+ backButtonConfiguration: . init( state: . enabled, action: {
122+ isPresented = false
123+ } ) )
124+ . posHeaderBackButtonIcon ( systemName: " xmark " )
125+ Spacer ( )
126+ }
127+ }
128+ . posFullScreenCover ( isPresented: $showBlog) {
129+ SafariView ( url: POSConstants . URLs. wooCommerceBlog. asURL ( ) )
119130 }
120131 }
121132}
0 commit comments