-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NT-169] Add shipping type to Reward model #837
Conversation
@@ -25,14 +25,28 @@ public struct Reward { | |||
|
|||
public struct Shipping { | |||
public let enabled: Bool | |||
public let location: Location? | |||
public let preference: Preference? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is deprecated but I think we should only remove it when we remove DeprecatedRewardPledgeViewController
.
if project.state == .live, reward.shipping.enabled, let type = reward.shipping.type { | ||
switch type { | ||
case .anywhere: | ||
return localizedString(key: "Ships_worldwide", defaultValue: "Ships worldwide") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will add these strings for translations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good..had couple questions
@@ -319,8 +319,7 @@ let allRewards: [(String, Reward)] = { | |||
|> Reward.lens.shipping .~ ( | |||
.template | |||
|> Reward.Shipping.lens.enabled .~ true | |||
|> Reward.Shipping.lens.preference .~ .restricted | |||
|> Reward.Shipping.lens.summary .~ "Anywhere in the world" | |||
|> Reward.Shipping.lens.type .~ .anywhere |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did we also wanted to add tests for other ShippingType
cases or do you think this is sufficient?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are tested in the VM tests so I think it's ok to just have the anywhere
case for snapshots.
XCTAssertEqual(reward.value?.backersCount, 10) | ||
XCTAssertEqual(true, reward.value?.shipping.enabled) | ||
XCTAssertEqual(.singleLocation, reward.value?.shipping.type) | ||
XCTAssertEqual(.init(id: 123, localizedName: "United States"), reward.value?.shipping.location) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess same question here about testing all the remaining cases (noShipping
& multipleLocations
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, let me add those.
if let name = reward.shipping.location?.localizedName { | ||
return localizedString( | ||
key: "location_name_only", | ||
defaultValue: "%{location_name} only", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When these strings are translated does this mean that in German it would result to United States nur
? I believe (and my German is very rusty at this point) that the right order should be Nur United States
. 🤔
Do we have a mechanism to switch the order?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah the translator can move these around, I'm adding those strings for translation shortly 👍
📲 What
Adds
ShippingType
toReward
to allow us to be more descriptive about the type of shipping options a particular reward has.Related back-end PR: https://github.com/kickstarter/kickstarter/pull/16934
🤔 Why
Currently we only use the non-localized
summary
field that is returned with each reward's shipping info. By using an enumerable type we can maintain more meaningful localized strings at the client.🛠 How
ShippingType
andLocation
toReward.Shipping
.👀 See
✅ Acceptance criteria
anywhere
display "Ships worldwide".multiple_locations
display "Limited shipping".single_location
where that location isUnited States
display "United States only".no_shipping
do not display a pill for shipping.⏰ TODO