Skip to content

fix(frontend): campaign validation and undefined product price guard#41

Open
dmeiser wants to merge 2 commits into
mainfrom
fix/frontend-campaign-validation
Open

fix(frontend): campaign validation and undefined product price guard#41
dmeiser wants to merge 2 commits into
mainfrom
fix/frontend-campaign-validation

Conversation

@dmeiser

@dmeiser dmeiser commented Jun 19, 2026

Copy link
Copy Markdown
Owner

Fixes two latent frontend bugs found during the project analysis:

  1. Campaign unit-field validation was effectively disabled because the submit handler passed formState.submitting === false as the shared-campaign flag, making validateUnitFields always return valid in manual mode. Now the real isSharedCampaignMode is threaded from useCreateCampaignPageSetup into the validation hook.
  2. OrderEditorDialog could crash with undefined.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.

dmeiser added 2 commits June 19, 2026 15:29
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.
Copilot AI review requested due to automatic review settings June 19, 2026 19:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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 isSharedCampaignMode from page setup into the create-campaign submit/validation hook so unit-field validation behaves correctly.
  • Guard product price rendering in OrderEditorDialog to avoid toFixed() 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
}
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