Conversation
…o cash-reward-redemption
There was a problem hiding this comment.
Pull request overview
This PR enhances the Tax & Cash banking info form by introducing structured, per-field validation error handling based on Impact API validation metadata, and adds a new “Partner Info Modal” component to the Mint component library/stencilbook.
Changes:
- Map backend validation errors (
field+errorPath) to form field names and frontend-friendly error codes. - Add configurable per-field ICU error-message templates and wire them into form validation rendering.
- Introduce a new
sqm-partner-info-modalcomponent (view + stories) and register it in the stencilbook; bump package version.
Reviewed changes
Copilot reviewed 9 out of 11 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/mint-components/src/components/tax-and-cash/sqm-banking-info-form/useBankingInfoForm.tsx | Adds API→form field/error-code mapping and includes errorPath in GraphQL validationErrors. |
| packages/mint-components/src/components/tax-and-cash/sqm-banking-info-form/sqm-banking-info-form.tsx | Adds per-field error message props + ICU templates and renders richer invalid messages when an API errorCode is present. |
| packages/mint-components/src/components/tax-and-cash/sqm-banking-info-form/sqm-banking-info-form-view.tsx | Extends form error shape to include errorCode and adds text.errorMessages. |
| packages/mint-components/src/components/tax-and-cash/sqm-banking-info-form/formDefinitions.tsx | Passes errorCode + fieldName into validation message builder for each form input. |
| packages/mint-components/src/components/tax-and-cash/sqm-banking-info-form/readme.md | Documents the newly added per-field error-message props. |
| packages/mint-components/src/components/sqm-stencilbook/sqm-stencilbook.tsx | Registers Partner Info Modal stories in the stencilbook. |
| packages/mint-components/src/components/sqm-partner-info-modal/sqm-partner-info-modal.tsx | Adds new Partner Info Modal component (currently demo-hook driven). |
| packages/mint-components/src/components/sqm-partner-info-modal/sqm-partner-info-modal-view.tsx | Implements the modal UI (dialog + selects + submit button). |
| packages/mint-components/src/components/sqm-partner-info-modal/PartnerInfoModal.stories.tsx | Adds Storybook stories for the Partner Info Modal. |
| packages/mint-components/src/components.d.ts | Updates generated component typings for new/updated props and new component. |
| packages/mint-components/package.json | Bumps package version to 2.1.8-0. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const mappedValidationErrors = validationErrors?.reduce( | ||
| (agg, error) => { | ||
| const formField = | ||
| API_FIELD_TO_FORM_FIELD[error.field] || error.field; | ||
| const errorCode = | ||
| API_ERROR_PATH_TO_FRONTEND[error.errorPath] || error.errorPath; | ||
| return { | ||
| ...agg, | ||
|
|
||
| [error.field]: { | ||
| [formField]: { | ||
| type: "invalid", | ||
| errorCode, | ||
| }, |
There was a problem hiding this comment.
errorCode falls back to error.errorPath, but the UI templates’ other branch is documented to display the raw API message. Falling back to the dot-delimited path will surface non-user-friendly strings like withdrawal.settings.error.routingcode in the UI. Consider using error.message as the fallback display value (or pass both a stable code and a human message separately).
| helpText: getValidationErrorMessage({ | ||
| type: errors?.inputErrors?.beneficiaryTaxPayerId?.type, | ||
| label: props.text.taxPayerIdLabel, | ||
| errorCode: errors?.inputErrors?.taxPayerId?.errorCode, |
There was a problem hiding this comment.
The Tax Payer ID field’s error helper reads errors?.inputErrors?.taxPayerId?.errorCode, but the error being checked is errors?.inputErrors?.beneficiaryTaxPayerId. This prevents the specific API errorCode from being shown for this field. Use the same key (beneficiaryTaxPayerId) when reading errorCode (while still using fieldName: "taxPayerId" if you intend to select the taxPayerId template).
| errorCode: errors?.inputErrors?.taxPayerId?.errorCode, | |
| errorCode: errors?.inputErrors?.beneficiaryTaxPayerId?.errorCode, |
| render() { | ||
| // AL: TODO add usePartnerInfoModal | ||
| const props = useDemoPartnerInfoModal(this); | ||
|
|
||
| return <PartnerInfoModalView {...props} />; | ||
| } |
There was a problem hiding this comment.
render() always uses useDemoPartnerInfoModal(this) (and leaves a TODO for the real hook). As written, the component will behave like a demo (e.g., default open: true, hardcoded brand/countries) in production builds. Gate the demo hook behind isDemo() and implement/use the real data hook (or do not ship the component until it is wired up).
| return ( | ||
| <sl-dialog | ||
| class={sheet.classes.Dialog} | ||
| open={true} |
There was a problem hiding this comment.
sl-dialog is always rendered with open={true}, ignoring states.open. This makes the open state ineffective (e.g., the Closed story can never actually close the dialog). Bind open to states.open.
| open={true} | |
| open={states.open} |
| onSl-request-close={(e: any) => { | ||
| e.preventDefault(); | ||
| }} | ||
| onSl-hide={(e: any) => { | ||
| // Prevent closing when clicking outside the dialog but not dropdowns | ||
| if (e.target?.tagName === "SL-DIALOG") { | ||
| e.preventDefault(); | ||
| } | ||
| }} |
There was a problem hiding this comment.
The dialog cannot be closed: onSl-request-close always calls preventDefault, the close button is hidden, and callbacks.onClose is never invoked. This is likely to trap users (ESC / overlay click won’t work). Consider allowing close and calling callbacks.onClose, while still preventing close only in the specific cases you need (e.g., overlay click).
| export const FullStackDemo = () => { | ||
| return ( | ||
| <sqm-partner-info-modal | ||
| brand-name="Acme" | ||
| header-new-partner="Welcome to {brandName} Program!" | ||
| description-new-partner="We just need a bit more information about you before you start earning cash!" | ||
| submit-button-label="Submit" | ||
| ></sqm-partner-info-modal> | ||
| ); |
There was a problem hiding this comment.
FullStackDemo uses attributes like brand-name and header-new-partner, but the component’s @Prop names are modalBrandHeader, descriptionNewPartner, etc. This demo won’t actually wire text through. Update the attributes to the correct kebab-case prop names (e.g., modal-brand-header, description-new-partner, etc.).
Description of the change
Type of change
Links
Checklists
Development
Paperwork
Code review