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 @@ -15,10 +15,10 @@ extension BookingDetailsViewModel {
let rows: [Row]

init(_ booking: Booking) {
let appointmentDate = booking.startDate.formatted(date: .numeric, time: .omitted)
let appointmentDate = booking.startDate.toString(dateStyle: .short, timeStyle: .none, timeZone: BookingListTab.utcTimeZone)
let appointmentTimeFrame = [
booking.startDate.formatted(date: .omitted, time: .shortened),
booking.endDate.formatted(date: .omitted, time: .shortened)
booking.startDate.toString(dateStyle: .none, timeStyle: .short, timeZone: BookingListTab.utcTimeZone),
booking.endDate.toString(dateStyle: .none, timeStyle: .short, timeZone: BookingListTab.utcTimeZone)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please elaborate on why utcTimeZone is used for formatting?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I followed the Huong's suggestion here: #16214 (review)

There is discussion thread about timezone usage for bookings: p1759398245019489-slack-C09FHQNQERG where it's confirmed that we should use the UTC timezone

].joined(separator: " - ")

rows = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ extension BookingDetailsViewModel {
@Published var serviceAndCustomerLine: String

init(_ booking: Booking, customerName: String? = nil) {
bookingDate = booking.startDate.formatted(
date: .numeric,
time: .shortened
bookingDate = booking.startDate.toString(
dateStyle: .short,
timeStyle: .short,
timeZone: BookingListTab.utcTimeZone
)

/// Temporary hardcode for service name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ extension BookingDetailsView {
struct CustomerDetailsView: View {
@ObservedObject var content: BookingDetailsViewModel.CustomerContent
let showNotice: (Notice) -> Void
@State private var showingPhoneOptions = false
@State private var selectedPhoneNumber: String?

private enum Row: Hashable {
case name(String)
Expand Down Expand Up @@ -77,7 +79,7 @@ extension BookingDetailsView {
}
.padding(.vertical, Layout.rowTextVerticalPadding)
.tappable {
emailText.sendToPasteboard()
emailText.sendToPasteboard(includeTrailingNewline: false)
showNotice(
Notice(
title: Localization.emailCopiedMessage,
Expand All @@ -98,7 +100,25 @@ extension BookingDetailsView {
}
.padding(.vertical, Layout.rowTextVerticalPadding)
.tappable {
print("On phone ellipsis")
selectedPhoneNumber = phoneText
showingPhoneOptions = true
}
.confirmationDialog(
selectedPhoneNumber ?? "",
isPresented: $showingPhoneOptions,
titleVisibility: .visible
) {
Button(Localization.callActionTitle) {
guard let phoneNumber = selectedPhoneNumber else { return }
if PhoneHelper.callPhoneNumber(phone: phoneNumber) == false {
showNotice(Notice(title: Localization.phoneNumberErrorNotice, feedbackType: .error))
}
}
Button(Localization.copyActionTitle) {
guard let phoneNumber = selectedPhoneNumber else { return }
phoneNumber.sendToPasteboard(includeTrailingNewline: false)
showNotice(Notice(title: Localization.phoneNumberCopied, feedbackType: .success))
}
}
}

Expand Down Expand Up @@ -127,6 +147,30 @@ private extension BookingDetailsView.CustomerDetailsView {
comment: "Toast message shown when the user copies the customer's email address."
)

static let callActionTitle = NSLocalizedString(
"BookingDetailsView.phoneNumberOptions.call",
value: "Call",
comment: "Action to call the phone number."
)

static let copyActionTitle = NSLocalizedString(
"BookingDetailsView.phoneNumberOptions.copy",
value: "Copy",
comment: "Action to copy the phone number."
)

static let phoneNumberCopied = NSLocalizedString(
"BookingDetailsView.phoneNumberOptions.copied",
value: "Phone number copied",
comment: "Notice message shown when the phone number is copied."
)

static let phoneNumberErrorNotice = NSLocalizedString(
"BookingDetailsView.phoneNumberOptions.error",
value: "Could not place a call to this number.",
comment: "Notice message shown when a phone call cannot be initiated."
)

/// Customer section
static let billingAddressRowTitle = NSLocalizedString(
"BookingDetailsView.customer.billingAddress.title",
Expand Down