Skip to content

Cash reward redemption#490

Open
Sam Beveridge (00salmon) wants to merge 10 commits intomasterfrom
cash-reward-redemption
Open

Cash reward redemption#490
Sam Beveridge (00salmon) wants to merge 10 commits intomasterfrom
cash-reward-redemption

Conversation

@00salmon
Copy link
Copy Markdown
Contributor

Description of the change

Description here

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation or Development tools (readme, specs, tests, code formatting)

Links

  • Jira issue number: (PUT IT HERE)
  • Process.st launch checklist: (PUT IT HERE)

Checklists

Development

  • Prettier was run (if applicable)
  • The behaviour changes in the pull request are covered by specs
  • All tests related to the changed code pass in development

Paperwork

  • This pull request has a descriptive title and information useful to a reviewer
  • This pull request has a Jira number
  • This pull request has a Process.st launch checklist

Code review

  • Changes have been reviewed by at least one other engineer
  • Security impacts of this change have been considered

Copilot AI review requested due to automatic review settings April 6, 2026 21:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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-modal component (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.

Comment on lines 524 to 535
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,
},
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

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

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).

Copilot uses AI. Check for mistakes.
helpText: getValidationErrorMessage({
type: errors?.inputErrors?.beneficiaryTaxPayerId?.type,
label: props.text.taxPayerIdLabel,
errorCode: errors?.inputErrors?.taxPayerId?.errorCode,
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

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

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).

Suggested change
errorCode: errors?.inputErrors?.taxPayerId?.errorCode,
errorCode: errors?.inputErrors?.beneficiaryTaxPayerId?.errorCode,

Copilot uses AI. Check for mistakes.
Comment on lines +113 to +118
render() {
// AL: TODO add usePartnerInfoModal
const props = useDemoPartnerInfoModal(this);

return <PartnerInfoModalView {...props} />;
}
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

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

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).

Copilot uses AI. Check for mistakes.
return (
<sl-dialog
class={sheet.classes.Dialog}
open={true}
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
open={true}
open={states.open}

Copilot uses AI. Check for mistakes.
Comment on lines +118 to +126
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();
}
}}
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

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

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).

Copilot uses AI. Check for mistakes.
Comment on lines +162 to +170
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>
);
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

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

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.).

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings April 7, 2026 17:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants