-
Notifications
You must be signed in to change notification settings - Fork 51
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
Update collect input to use FormType variable #834
Conversation
export interface SelectionResult extends ICollectInputsResult { | ||
// selected button. Null if the form was skipped. | ||
selection?: string | null; | ||
} | ||
|
||
// Contains data collected from a signature form | ||
export interface SignatureResult extends ICollectInputsResult { | ||
// signature in svg format. Null if the form was skipped. | ||
signatureSvg?: string | null; | ||
} | ||
|
||
// Contains data collected from a phone form | ||
export interface PhoneResult extends ICollectInputsResult { | ||
// the submitted phone number in E.164 format. Null if the form was skipped. | ||
phone?: string | null; | ||
} | ||
|
||
// Contains data collected from an email form | ||
export interface EmailResult extends ICollectInputsResult { | ||
// the submitted email. Null if the form was skipped. | ||
email?: string | null; | ||
} | ||
|
||
// Contains data collected from a text form | ||
export interface TextResult extends ICollectInputsResult { | ||
// the submitted text. Null if the form was skipped. | ||
text?: string | null; | ||
} | ||
|
||
// Contains data collected from an email form | ||
export interface NumericResult extends ICollectInputsResult { | ||
// the submitted number as a string. Null if the form was skipped. | ||
numericString?: string | null; | ||
} |
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.
@nazli-stripe A bit not clear about how user can use these types? Do they need to cast from the ICollectInputsResult
directly?
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.
@nazli-stripe how about this? is it what we want?
"" | ||
} | ||
} | ||
|
||
class func mapFromCollectInputsResults(_ results: [CollectInputsResult]) -> NSDictionary { | ||
var collectInputResults: [NSDictionary] = [] | ||
for result in results { | ||
if result is EmailResult { |
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 already have this check if result is EmailResult
and don't need to call mapFormType
as we are in the if
block. We can directly set the formType to email
. Same for other result types
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.
Instead of keeping the big if else
growthing, given current each block is 80% the same, I'm wondering the possibility to extract that unique part in future pr and reduce duplication.
@@ -779,6 +801,18 @@ internal fun mapFromReaderSettings(settings: ReaderSettings): ReadableMap { | |||
} | |||
} | |||
|
|||
@OptIn(CollectInputs::class) | |||
private fun CollectInputsResult.getFormType(): String { |
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.
same feedback as iOS
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.
left one comment, not blocking. Feel free to merge
Summary
Update collect input to use FormType variable instead of each tag like: text, phone, etc.
Motivation
https://jira.corp.stripe.com/browse/TERMINAL-40991
Testing
Documentation
Select one: