fix(frontend): campaign validation and undefined product price guard#41
Open
dmeiser wants to merge 2 commits into
Open
fix(frontend): campaign validation and undefined product price guard#41dmeiser wants to merge 2 commits into
dmeiser wants to merge 2 commits into
Conversation
The cloudfront_domain output was returning the CloudFront distribution ARN, which is invalid when used as a Route53 alias target. Return the actual domain name from cloudfront_distribution. tofu validate passes (pre-existing hash_key deprecation warnings remain).
…t price - Pass the real isSharedCampaignMode into useCreateCampaignSubmitHandler and useCreateCampaignValidation so unit-field validation is no longer always skipped in manual mode. - Guard product?.price?.toFixed(2) in OrderEditorDialog to avoid a TypeError when product is undefined. Typecheck, lint, and relevant tests pass.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses two frontend runtime/validation issues in the campaign and order-editing flows, and also adjusts an OpenTofu Cognito module output related to CloudFront-backed custom domains.
Changes:
- Thread
isSharedCampaignModefrom page setup into the create-campaign submit/validation hook so unit-field validation behaves correctly. - Guard product price rendering in
OrderEditorDialogto avoidtoFixed()crashes when product/price is missing. - Update Cognito module output wiring for the CloudFront “domain” output.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tofu/application/modules/cognito/main.tf | Changes the exported Cognito CloudFront-related output value used downstream (e.g., Route53 alias configuration). |
| frontend/src/hooks/useCreateCampaignSubmitHandler.ts | Updates submit handler hook signature and passes shared-campaign mode into validation. |
| frontend/src/hooks/useCreateCampaignPageSetup.ts | Updates the hook call site to pass isSharedCampaignMode into the submit handler. |
| frontend/src/components/OrderEditorDialog.tsx | Adds a guard/fallback when formatting product prices to prevent runtime crashes. |
Comment on lines
+51
to
+54
| export const useCreateCampaignSubmitHandler = ( | ||
| formState: FormState, | ||
| isSharedCampaignMode: boolean, | ||
| ) => { |
| /> | ||
| </TableCell> | ||
| <TableCell align="right">${product?.price.toFixed(2)}</TableCell> | ||
| <TableCell align="right">${product?.price?.toFixed(2) ?? '—'}</TableCell> |
Comment on lines
368
to
371
| output "cloudfront_domain" { | ||
| description = "CloudFront domain name backing the Cognito custom domain" | ||
| value = aws_cognito_user_pool_domain.custom.cloudfront_distribution_arn | ||
| value = aws_cognito_user_pool_domain.custom.cloudfront_distribution | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes two latent frontend bugs found during the project analysis:
formState.submitting === falseas the shared-campaign flag, makingvalidateUnitFieldsalways return valid in manual mode. Now the realisSharedCampaignModeis threaded fromuseCreateCampaignPageSetupinto the validation hook.OrderEditorDialogcould crash withundefined.toFixed(2)when a product lookup failed. Added an optional-chain guard and a fallback em dash.Validation:
npm run typecheck,npm run lint, and the affected test files pass.