Skip to content

Commit eb4d8d7

Browse files
authored
Bookings: Split summary text into 2 lines for booking details header (#16324)
2 parents 6a89b29 + d5c7f92 commit eb4d8d7

File tree

5 files changed

+28
-16
lines changed

5 files changed

+28
-16
lines changed

WooCommerce/Classes/Extensions/Booking+Helpers.swift

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@ import Foundation
22
import struct Yosemite.Booking
33

44
extension Booking {
5+
var productName: String? {
6+
orderInfo?.productInfo?.name
7+
}
8+
9+
var customerName: String {
10+
guard let name = orderInfo?.customerInfo?.billingAddress.fullName else {
11+
return Localization.guest
12+
}
13+
return name.isEmpty ? Localization.guest : name
14+
}
15+
516
var summaryText: String {
6-
let productName = orderInfo?.productInfo?.name
7-
let customerName: String = {
8-
guard let name = orderInfo?.customerInfo?.billingAddress.fullName else {
9-
return Localization.guest
10-
}
11-
return name.isEmpty ? Localization.guest : name
12-
}()
1317
return [productName, customerName]
1418
.compactMap { $0 }
1519
.joined(separator: "")

WooCommerce/Classes/ViewModels/Booking Details/HeaderContent.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@ extension BookingDetailsViewModel {
1111
@Published private(set) var bookingDate: String = ""
1212
@Published private(set) var attendanceStatus: BookingAttendanceStatus = .unknown
1313
@Published private(set) var bookingStatus: BookingStatus = .unknown
14-
@Published private(set) var serviceAndCustomerLine: String = ""
14+
@Published private(set) var serviceLine: String = ""
15+
@Published private(set) var customerLine: String = ""
1516

1617
func update(with booking: Booking) {
1718
bookingDate = booking.startDate.toString(
1819
dateStyle: .short,
1920
timeStyle: .short,
2021
timeZone: BookingListTab.utcTimeZone
2122
)
22-
serviceAndCustomerLine = booking.summaryText
23+
serviceLine = booking.productName ?? ""
24+
customerLine = booking.customerName
2325
attendanceStatus = booking.attendanceStatus
2426
bookingStatus = booking.bookingStatus
2527
}

WooCommerce/Classes/ViewRelated/Bookings/Booking Details/BookingDetailsView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ struct BookingDetailsView: View {
1414
enum Layout {
1515
static let contentSidePadding: CGFloat = 16
1616
static let contentVerticalPadding: CGFloat = 16
17-
static let headerContentVerticalPadding: CGFloat = 6
18-
static let headerBadgesAdditionalTopPadding: CGFloat = 4
17+
static let headerContentVerticalPadding: CGFloat = 2
18+
static let headerBadgesAdditionalTopPadding: CGFloat = 6
1919
static let sectionFooterTextVerticalPadding: CGFloat = 8
2020
static let rowTextVerticalPadding: CGFloat = 11
2121
}

WooCommerce/Classes/ViewRelated/Bookings/Booking Details/HeaderView.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,14 @@ extension BookingDetailsView {
1111
.font(TextFont.bodyMedium)
1212
.foregroundColor(.primary)
1313
}
14-
if !content.serviceAndCustomerLine.isEmpty {
15-
Text(content.serviceAndCustomerLine)
16-
.font(.footnote.weight(.medium))
14+
if !content.serviceLine.isEmpty {
15+
Text(content.serviceLine)
16+
.font(.body)
17+
.foregroundColor(.secondary)
18+
}
19+
if !content.customerLine.isEmpty {
20+
Text(content.customerLine)
21+
.font(.body)
1722
.foregroundColor(.secondary)
1823
}
1924
HStack {

WooCommerce/WooCommerceTests/ViewRelated/Bookings/BookingDetailsViewModelTests.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ final class BookingDetailsViewModelTests: XCTestCase {
126126
XCTAssertFalse(hasCustomerSection)
127127
}
128128

129-
func test_header_content_uses_booking_summary_text() {
129+
func test_header_content_uses_correct_contents() {
130130
// Given
131131
let billingAddress = Address.fake().copy(
132132
firstName: "Jane",
@@ -159,7 +159,8 @@ final class BookingDetailsViewModelTests: XCTestCase {
159159
return
160160
}
161161

162-
XCTAssertEqual(headerContent.serviceAndCustomerLine, "Massage Therapy • Jane Smith")
162+
XCTAssertEqual(headerContent.serviceLine, "Massage Therapy")
163+
XCTAssertEqual(headerContent.customerLine, "Jane Smith")
163164
}
164165

165166
func test_customer_content_populated_from_billing_address() {

0 commit comments

Comments
 (0)