Skip to content

Cash reward redemption#490

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

Cash reward redemption#490
Sam Beveridge (00salmon) wants to merge 19 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.
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.

Sam Beveridge (00salmon) and others added 3 commits April 7, 2026 13:53
…eUserInfoForm and useTaxAndCash step logic. Handle Impact API sending back DZ and 000000 for phone number data
Copilot AI review requested due to automatic review settings April 9, 2026 00:28
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.

AndiLuo added 2 commits April 9, 2026 16:33
… partner creation in to widget verificaiton flow. Some view refactors for all 3 components
Copilot AI review requested due to automatic review settings April 10, 2026 23:31
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.

Copilot AI review requested due to automatic review settings April 14, 2026 18:39
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

Copilot reviewed 21 out of 23 changed files in this pull request and generated 12 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +512 to 522
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 14, 2026

Choose a reason for hiding this comment

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

The fallback for unknown API error codes uses error.errorPath as the displayed errorCode. Even after fixing the field name, the error “code/path” strings aren’t user-friendly, while the API already provides a human-readable message. Consider storing both a short mapped errorCode (for ICU select) and a separate errorMessage fallback (or use message as the other branch value) so the UI doesn’t show internal code strings to end users.

Copilot uses AI. Check for mistakes.
Comment on lines +55 to +64
// Early partner creation does not collect these fields
if (
!billingAddress ||
!billingCity ||
!billingPostalCode ||
!billingState ||
!phoneNumber
) {
return "/1";
}
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

getCurrentStep treats any non-empty phoneNumber as “present”, but elsewhere in this PR the Impact placeholder value ("0000000") is treated as “missing” and cleared for the form. As written, a placeholder phone number will bypass the “missing fields” redirect and advance the flow incorrectly. Consider treating the placeholder value as missing here as well (and ideally centralize this sentinel handling so it’s consistent across the flow).

Copilot uses AI. Check for mistakes.
Comment on lines +155 to +159
? null
: user.impactConnection.publisher.phoneNumberCountryCode,
phoneNumber:
user.impactConnection.publisher.phoneNumber === "0000000"
? null
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

setUserFormContext sets phoneNumber / phoneNumberCountryCode to null when the placeholder is detected. In this codebase, the form view props for these fields are typed as string | undefined, and web components like sl-input/sl-select typically expect a string value. Use an empty string or undefined for “no value” to avoid passing null into input value props and to keep downstream payload building consistent.

Suggested change
? null
: user.impactConnection.publisher.phoneNumberCountryCode,
phoneNumber:
user.impactConnection.publisher.phoneNumber === "0000000"
? null
? undefined
: user.impactConnection.publisher.phoneNumberCountryCode,
phoneNumber:
user.impactConnection.publisher.phoneNumber === "0000000"
? undefined

Copilot uses AI. Check for mistakes.
Comment on lines 510 to 521
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 14, 2026

Choose a reason for hiding this comment

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

validationErrors are queried with a code field (see the GraphQL documents above), but the TypeScript result types and mapping logic expect errorPath (error.errorPath). This means errorCode will be undefined at runtime and the per-field ICU error messages won’t resolve correctly. Update the result types and mapping to use the actual response field name (or query the field you intend to use) and ensure the reducer reads that same property consistently.

Copilot uses AI. Check for mistakes.
Comment on lines +243 to +244
errorCode: errors?.inputErrors?.taxPayerId?.errorCode,
fieldName: "taxPayerId",
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

For the beneficiaryTaxPayerId field, the error type is read from errors.inputErrors.beneficiaryTaxPayerId, but the new errorCode is read from errors.inputErrors.taxPayerId. This mismatch will prevent the correct per-field error message from being selected. Use the same key consistently (likely beneficiaryTaxPayerId) for both type and errorCode.

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

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings April 15, 2026 23:52
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

Copilot reviewed 22 out of 24 changed files in this pull request and generated 12 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +213 to +217
validationErrors: {
field: string;
message: string;
errorPath: string;
}[];
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

validationErrors is typed with an errorPath field, but the GraphQL mutations in this file request validationErrors { code }. This mismatch will cause the new error-code mapping to see undefined at runtime. Update the TypeScript result types to match the actual response shape (or request the correct field).

Copilot uses AI. Check for mistakes.
Comment on lines +271 to +276
const vars = {
user: {
id: user.id,
accountId: user.accountId,
},
firstName: user.firstName,
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

onSubmit constructs vars using user.id/accountId/firstName/lastName without verifying user is defined. Since showModal only checks userLoading (not user), the modal can be interactive even if user is missing, leading to a crash. Add a guard (and surface networkErrorText if user data is unavailable).

Copilot uses AI. Check for mistakes.
Comment on lines 252 to 256
validationErrors {
field
message
code
}
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

The mutation requests validationErrors { code }, but downstream logic reads errorPath. Either request errorPath from the API (if supported) or switch the mapping logic/types to use code consistently.

Copilot uses AI. Check for mistakes.
Comment on lines +189 to +190
console.log(states, "partner info modal states"); // TEMP

Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

Remove the temporary console.log debug statement before merging. Leaving this in a production component will spam logs and may expose internal state.

Suggested change
console.log(states, "partner info modal states"); // TEMP

Copilot uses AI. Check for mistakes.
const formField =
API_FIELD_TO_FORM_FIELD[error.field] || error.field;
const errorCode =
API_ERROR_PATH_TO_FRONTEND[error.errorPath] || error.errorPath;
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

The error mapping uses error.errorPath, but the mutations request validationErrors { code }. As a result errorCode will be undefined and the per-field ICU error messages won’t be used. Use the actual field returned by the API (e.g., error.code) when computing errorCode.

Suggested change
API_ERROR_PATH_TO_FRONTEND[error.errorPath] || error.errorPath;
API_ERROR_PATH_TO_FRONTEND[error.code] || error.code;

Copilot uses AI. Check for mistakes.
Comment on lines +159 to +167
// when creating an impact connection without sending phoneNumber data, the impactAPI defaults the value to "000000" and the phoneNumberCountryCode to "DZ"
phoneNumberCountryCode:
user.impactConnection.publisher.phoneNumberCountryCode,
phoneNumber: user.impactConnection.publisher.phoneNumber,
user.impactConnection.publisher.phoneNumber === "0000000"
? null
: user.impactConnection.publisher.phoneNumberCountryCode,
phoneNumber:
user.impactConnection.publisher.phoneNumber === "0000000"
? null
: user.impactConnection.publisher.phoneNumber,
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

The comment says Impact defaults missing phone numbers to "000000", but the code checks for "0000000". This inconsistency likely prevents the placeholder value from being normalized to null as intended. Use the correct placeholder value (and consider centralizing it as a constant so it’s consistent across the codebase).

Copilot uses AI. Check for mistakes.
);
}, [financeNetworkData, currenciesData, countryCode]);

console.log(countryCode, currency, "initial country and currency state"); // TEMP
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

Remove the temporary console.log debugging statements before merging (e.g., logging initial country/currency and other internal state). These create noisy production logs and can leak user-related information.

Suggested change
console.log(countryCode, currency, "initial country and currency state"); // TEMP

Copilot uses AI. Check for mistakes.
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.

5 participants