Skip to content

Commit e234ea5

Browse files
committed
Merge branch 'trunk' into task/WOOMOB-1290-remove-IAP-usage
2 parents 0ce2260 + 48d6782 commit e234ea5

File tree

144 files changed

+10432
-14190
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+10432
-14190
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<!--
22
Contains editorialized release notes. Raw release notes should go into `RELEASE-NOTES.txt`.
33
-->
4+
## 23.5
5+
This update brings smoother store management and better control. You can now filter orders by source, and manage all POS orders directly within the POS interface. Plus, we fixed a scrolling issue on the Create Coupon screen for a more seamless experience.
6+
47
## 23.4
58
This update delivers important fixes for a smoother store management experience. We've resolved navigation issues in order details and corrected store widget display on iOS 26. Update now for a more polished and reliable app experience.
69

Modules/Sources/Fakes/Networking.generated.swift

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,26 @@ extension Networking.Booking {
339339
startDate: .fake(),
340340
statusKey: .fake(),
341341
localTimezone: .fake(),
342-
currency: .fake()
342+
currency: .fake(),
343+
orderInfo: .fake()
344+
)
345+
}
346+
}
347+
extension Networking.BookingResource {
348+
/// Returns a "ready to use" type filled with fake values.
349+
///
350+
public static func fake() -> Networking.BookingResource {
351+
.init(
352+
siteID: .fake(),
353+
resourceID: .fake(),
354+
name: .fake(),
355+
quantity: .fake(),
356+
role: .fake(),
357+
email: .fake(),
358+
phoneNumber: .fake(),
359+
imageID: .fake(),
360+
imageURL: .fake(),
361+
description: .fake()
343362
)
344363
}
345364
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import Foundation
2+
3+
/// Mapper: Booking
4+
///
5+
struct BookingMapper: Mapper {
6+
let siteID: Int64
7+
8+
func map(response: Data) throws -> Booking {
9+
let decoder = JSONDecoder()
10+
decoder.dateDecodingStrategy = .formatted(DateFormatter.Defaults.dateTimeFormatter)
11+
decoder.userInfo = [
12+
.siteID: siteID
13+
]
14+
if hasDataEnvelope(in: response) {
15+
return try decoder.decode(BookingEnvelope.self, from: response).booking
16+
} else {
17+
return try decoder.decode(Booking.self, from: response)
18+
}
19+
}
20+
}
21+
22+
private struct BookingEnvelope: Decodable {
23+
let booking: Booking
24+
25+
private enum CodingKeys: String, CodingKey {
26+
case booking = "data"
27+
}
28+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import Foundation
2+
3+
/// Mapper: BookingResource
4+
///
5+
struct BookingResourceMapper: Mapper {
6+
let siteID: Int64
7+
8+
func map(response: Data) throws -> BookingResource {
9+
let decoder = JSONDecoder()
10+
decoder.userInfo = [
11+
.siteID: siteID
12+
]
13+
if hasDataEnvelope(in: response) {
14+
return try decoder.decode(BookingResourceEnvelope.self, from: response).bookingResource
15+
} else {
16+
return try decoder.decode(BookingResource.self, from: response)
17+
}
18+
}
19+
}
20+
21+
private struct BookingResourceEnvelope: Decodable {
22+
let bookingResource: BookingResource
23+
24+
private enum CodingKeys: String, CodingKey {
25+
case bookingResource = "data"
26+
}
27+
}

Modules/Sources/Networking/Model/Bookings/Booking.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ public struct Booking: Codable, GeneratedCopiable, Hashable, GeneratedFakeable {
2222
public let statusKey: String
2323
public let localTimezone: String
2424
public let currency: String
25+
public let orderInfo: BookingOrderInfo?
2526

26-
// periphery: ignore - to be used later
2727
public var bookingStatus: BookingStatus {
2828
return BookingStatus(rawValue: statusKey) ?? .unknown
2929
}
@@ -47,7 +47,8 @@ public struct Booking: Codable, GeneratedCopiable, Hashable, GeneratedFakeable {
4747
startDate: Date,
4848
statusKey: String,
4949
localTimezone: String,
50-
currency: String) {
50+
currency: String,
51+
orderInfo: BookingOrderInfo?) {
5152
self.siteID = siteID
5253
self.bookingID = bookingID
5354
self.allDay = allDay
@@ -66,6 +67,7 @@ public struct Booking: Codable, GeneratedCopiable, Hashable, GeneratedFakeable {
6667
self.statusKey = statusKey
6768
self.localTimezone = localTimezone
6869
self.currency = currency
70+
self.orderInfo = orderInfo
6971
}
7072

7173
/// The public initializer for Booking.
@@ -99,6 +101,7 @@ public struct Booking: Codable, GeneratedCopiable, Hashable, GeneratedFakeable {
99101
let statusKey = try container.decode(String.self, forKey: .statusKey)
100102
let localTimezone = try container.decode(String.self, forKey: .localTimezone)
101103
let currency = try container.decode(String.self, forKey: .currency)
104+
let orderInfo: BookingOrderInfo? = nil // to be prefilled when synced
102105

103106
self.init(siteID: siteID,
104107
bookingID: bookingID,
@@ -117,7 +120,8 @@ public struct Booking: Codable, GeneratedCopiable, Hashable, GeneratedFakeable {
117120
startDate: startDate,
118121
statusKey: statusKey,
119122
localTimezone: localTimezone,
120-
currency: currency)
123+
currency: currency,
124+
orderInfo: orderInfo)
121125
}
122126

123127
public func encode(to encoder: Encoder) throws {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import Foundation
2+
3+
public struct BookingCustomerInfo: Hashable {
4+
public let billingAddress: Address
5+
6+
public init(billingAddress: Address) {
7+
self.billingAddress = billingAddress
8+
}
9+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// periphery:ignore:all
2+
import Foundation
3+
4+
public struct BookingOrderInfo: Hashable {
5+
public let statusKey: String
6+
public let paymentInfo: BookingPaymentInfo?
7+
public let customerInfo: BookingCustomerInfo?
8+
public let productInfo: BookingProductInfo?
9+
10+
public init(statusKey: String,
11+
paymentInfo: BookingPaymentInfo?,
12+
customerInfo: BookingCustomerInfo?,
13+
productInfo: BookingProductInfo?) {
14+
self.statusKey = statusKey
15+
self.paymentInfo = paymentInfo
16+
self.customerInfo = customerInfo
17+
self.productInfo = productInfo
18+
}
19+
20+
public init(booking: Booking, order: Order) {
21+
self.customerInfo = {
22+
guard let billingAddress = order.billingAddress else {
23+
return nil
24+
}
25+
return BookingCustomerInfo(billingAddress: billingAddress)
26+
}()
27+
self.productInfo = BookingProductInfo(name: order.items.first(where: { $0.productID == booking.productID })?.name ?? "")
28+
self.paymentInfo = BookingPaymentInfo(
29+
paymentMethodID: order.paymentMethodID,
30+
paymentMethodTitle: order.paymentMethodTitle,
31+
subtotal: order.items.map({ Double($0.subtotal) ?? 0 }).reduce(0, +).description,
32+
subtotalTax: order.items.map({ Double($0.subtotalTax) ?? 0 }).reduce(0, +).description,
33+
total: order.total,
34+
totalTax: order.totalTax
35+
)
36+
self.statusKey = order.status.rawValue
37+
}
38+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import Foundation
2+
3+
public struct BookingPaymentInfo: Hashable {
4+
public let paymentMethodID: String
5+
public let paymentMethodTitle: String
6+
public let subtotal: String
7+
public let subtotalTax: String
8+
public let total: String
9+
public let totalTax: String
10+
11+
public init(paymentMethodID: String,
12+
paymentMethodTitle: String,
13+
subtotal: String,
14+
subtotalTax: String,
15+
total: String,
16+
totalTax: String) {
17+
self.paymentMethodID = paymentMethodID
18+
self.paymentMethodTitle = paymentMethodTitle
19+
self.subtotal = subtotal
20+
self.subtotalTax = subtotalTax
21+
self.total = total
22+
self.totalTax = totalTax
23+
}
24+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import Foundation
2+
3+
public struct BookingProductInfo: Hashable {
4+
public let name: String
5+
6+
public init(name: String) {
7+
self.name = name
8+
}
9+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import Codegen
2+
import Foundation
3+
4+
public struct BookingResource: Hashable, Decodable, GeneratedFakeable, GeneratedCopiable {
5+
public let siteID: Int64
6+
public let resourceID: Int64
7+
public let name: String
8+
public let quantity: Int64
9+
public let role: String
10+
public let email: String?
11+
public let phoneNumber: String?
12+
public let imageID: Int64
13+
public let imageURL: String?
14+
public let description: String?
15+
16+
public init(siteID: Int64,
17+
resourceID: Int64,
18+
name: String,
19+
quantity: Int64,
20+
role: String,
21+
email: String?,
22+
phoneNumber: String?,
23+
imageID: Int64,
24+
imageURL: String?,
25+
description: String?) {
26+
self.siteID = siteID
27+
self.resourceID = resourceID
28+
self.name = name
29+
self.quantity = quantity
30+
self.role = role
31+
self.email = email
32+
self.phoneNumber = phoneNumber
33+
self.imageID = imageID
34+
self.imageURL = imageURL
35+
self.description = description
36+
}
37+
38+
public init(from decoder: Decoder) throws {
39+
guard let siteID = decoder.userInfo[.siteID] as? Int64 else {
40+
throw BookingResourceDecodingError.missingSiteID
41+
}
42+
43+
let container = try decoder.container(keyedBy: CodingKeys.self)
44+
45+
let resourceID = try container.decode(Int64.self, forKey: .resourceID)
46+
let name = try container.decode(String.self, forKey: .name)
47+
let quantity = try container.decode(Int64.self, forKey: .quantity)
48+
let role = try container.decode(String.self, forKey: .role)
49+
let email = try container.decodeIfPresent(String.self, forKey: .email)
50+
let phoneNumber = try container.decodeIfPresent(String.self, forKey: .phoneNumber)
51+
let imageID = try container.decode(Int64.self, forKey: .imageID)
52+
let imageURL = try container.decodeIfPresent(String.self, forKey: .imageURL)
53+
let description = try container.decodeIfPresent(String.self, forKey: .description)
54+
55+
self.init(siteID: siteID,
56+
resourceID: resourceID,
57+
name: name,
58+
quantity: quantity,
59+
role: role,
60+
email: email,
61+
phoneNumber: phoneNumber,
62+
imageID: imageID,
63+
imageURL: imageURL,
64+
description: description)
65+
}
66+
}
67+
68+
private extension BookingResource {
69+
enum CodingKeys: String, CodingKey {
70+
case resourceID = "id"
71+
case name
72+
case quantity = "qty"
73+
case role
74+
case email
75+
case phoneNumber = "phone_number"
76+
case imageID = "image_id"
77+
case imageURL = "image_url"
78+
case description
79+
}
80+
}
81+
82+
// MARK: - Decoding Errors
83+
//
84+
enum BookingResourceDecodingError: Error {
85+
case missingSiteID
86+
}

0 commit comments

Comments
 (0)