-
Notifications
You must be signed in to change notification settings - Fork 2
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
MOB-452 : add cta button to submit trades #139
MOB-452 : add cta button to submit trades #139
Conversation
self?.updateValidationErrors(errors) | ||
.sink { [weak self] triggerOrdersInput, errors in | ||
#if DEBUG | ||
if let triggerOrdersInput { |
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 remove this in the future
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.
🐞
private func update(triggerOrdersInput: TriggerOrdersInput?, errors: [ValidationError]) { | ||
|
||
viewModel?.takeProfitStopLossInputAreaViewModel?.takeProfitAlert = nil | ||
viewModel?.takeProfitStopLossInputAreaViewModel?.stopLossAlert = nil | ||
|
||
for error in errors { | ||
let alert = InlineAlertViewModel(.init(title: error.resources.title?.localized, body: error.resources.text?.localized, level: .error)) | ||
switch error.code { | ||
case "TRIGGER_MUST_ABOVE_INDEX_PRICE": | ||
print("mmm: \(error)") | ||
if triggerOrdersInput?.stopLossOrder?.side == .buy { | ||
viewModel?.takeProfitStopLossInputAreaViewModel?.stopLossAlert = alert | ||
} | ||
if triggerOrdersInput?.takeProfitOrder?.side == .sell { | ||
viewModel?.takeProfitStopLossInputAreaViewModel?.takeProfitAlert = alert | ||
} | ||
case "TRIGGER_MUST_BELOW_INDEX_PRICE": | ||
print("mmm: \(error)") | ||
if triggerOrdersInput?.stopLossOrder?.side == .sell { | ||
viewModel?.takeProfitStopLossInputAreaViewModel?.stopLossAlert = alert | ||
} | ||
if triggerOrdersInput?.takeProfitOrder?.side == .buy { | ||
viewModel?.takeProfitStopLossInputAreaViewModel?.takeProfitAlert = alert | ||
} | ||
default: | ||
print("mmm: ", error.code) |
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.
@ruixhuang here is the error display logic
if let error = errors.first { | ||
viewModel?.submissionReadiness = .fixErrors(cta: error.resources.action?.localized) | ||
} else if triggerOrdersInput?.takeProfitOrder?.price?.triggerPrice?.doubleValue == nil | ||
&& triggerOrdersInput?.takeProfitOrder?.orderId == nil |
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 am not doing this check on Android. It seems to ready for submission if there is no ValidationError.
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.
went over this with mulan today, without this check, the "Add triggers" button is enabled even with empty input. I don't think that is great UX, what do you think?
We discussed adding something to abacus like containsChanges
to denote whether that button should be enabled or not, even with no errors
let alert = InlineAlertViewModel(.init(title: error.resources.title?.localized, body: error.resources.text?.localized, level: .error)) | ||
switch error.code { | ||
case "TRIGGER_MUST_ABOVE_INDEX_PRICE": | ||
print("mmm: \(error)") |
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.
FYI, the "error.fields" should now contains the TriggerOrdersInputField where the error occurs.. It's probably easier to check for that.
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 will do that in a follow up PR
let buttonState: PlatformButtonState | ||
switch submissionReadiness { | ||
case .readyToSubmit: | ||
buttonText = DataLocalizer.shared?.localize(path: "APP.TRADE.ADD_TRIGGERS", params: nil) ?? "" |
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.
We'd also need an "Edit Trigger" in addition to "Add Trigger".
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
* bump 1.6.36 -> 1.6.38 * some ui * add label accessory to platform input, split out input views into view models * clean up * add cta button * hook up button and button states * abacus? * clean up * add case handling for USER_MAX_ORDERS
* bump 1.6.36 -> 1.6.38 * some ui * add label accessory to platform input, split out input views into view models * clean up * add cta button * hook up button and button states * abacus? * clean up * add case handling for USER_MAX_ORDERS
* bump 1.6.36 -> 1.6.38 * some ui * add label accessory to platform input, split out input views into view models * clean up * add cta button * hook up button and button states * abacus? * clean up * add case handling for USER_MAX_ORDERS
Links (dYdX Internal Use Only)
Linear Ticket: MOB-452 : add cta button to submit trades
Figma Design: https://www.figma.com/file/mKevZOfE9nj6MZpiolKYW1/dYdX-%E2%80%BA-Mobile?type=design&node-id=5621-13681&mode=design&t=yQplL4xfSnUqF508-4
Description / Intuition
Before/After Screenshots or Videos
Untitled.mov
Type of Change