Skip to content
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

Merged
merged 2 commits into from
Oct 18, 2024
Merged

Conversation

tim-lin-bbpos
Copy link
Collaborator

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

  • I tested this manually
  • I added automated tests

Documentation

Select one:

  • This is breaking change require documentation updates.
  • I have added relevant documentation for my changes.
  • This PR does not result in any developer-facing changes.

Comment on lines +457 to +490
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;
}
Copy link
Collaborator Author

@tim-lin-bbpos tim-lin-bbpos Oct 17, 2024

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?

Copy link
Collaborator Author

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 {
Copy link
Collaborator

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 ifblock. We can directly set the formType to email. Same for other result types

Copy link
Collaborator Author

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 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

same feedback as iOS

Copy link
Collaborator

@nazli-stripe nazli-stripe left a 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

@tim-lin-bbpos tim-lin-bbpos changed the title [WIP] Update collect input to use FormType variable Update collect input to use FormType variable Oct 18, 2024
@nazli-stripe nazli-stripe merged commit 872e02e into main Oct 18, 2024
3 checks passed
@nazli-stripe nazli-stripe deleted the bbpose/input branch October 18, 2024 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants