Skip to content

fix: Campaign Message Tab Displays Incorrect Data for "Alternate Days" and "Alternate Weeks (≥2)" Schedules#4741

Merged
vinaypanduga merged 2 commits into
mainfrom
main-ng-9
Jul 17, 2026
Merged

fix: Campaign Message Tab Displays Incorrect Data for "Alternate Days" and "Alternate Weeks (≥2)" Schedules#4741
vinaypanduga merged 2 commits into
mainfrom
main-ng-9

Conversation

@narayanangourav-sutara

Copy link
Copy Markdown
Contributor

No description provided.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces a CampaignFrequency field across the campaign creation, overview, and messaging components, updating the database schema and API payloads to support it. The timeline date generation logic has been refactored to incorporate the campaign's frequency. Feedback on the changes includes importing the missing DEFAULT_FREQUENCY constant and adding optional chaining in useCampaignSetupForm.ts to prevent potential runtime errors, as well as ensuring form.startDate and form.endDate are defined before calling buildFrequencyTimelineDates in campaignCommunicationUtils.ts.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +97 to +103
const assignmentFrequency = useMemo(
() =>
assignmentConfigs[activeAssignmentGradeId]?.frequency ??
Object.values(assignmentConfigs)[0]?.frequency ??
DEFAULT_FREQUENCY,
[activeAssignmentGradeId, assignmentConfigs],
);

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.

medium

The DEFAULT_FREQUENCY constant is used here but it is not imported in this file. Please make sure to import it from ../components/campaignSetup/campaignAssignmentUtils at the top of the file:

import { DEFAULT_FREQUENCY } from '../components/campaignSetup/campaignAssignmentUtils';

Additionally, to prevent potential runtime errors if assignmentConfigs is null or undefined, we should use optional chaining and a fallback empty object when calling Object.values.

Suggested change
const assignmentFrequency = useMemo(
() =>
assignmentConfigs[activeAssignmentGradeId]?.frequency ??
Object.values(assignmentConfigs)[0]?.frequency ??
DEFAULT_FREQUENCY,
[activeAssignmentGradeId, assignmentConfigs],
);
const assignmentFrequency = useMemo(
() =>
assignmentConfigs?.[activeAssignmentGradeId]?.frequency ??
Object.values(assignmentConfigs ?? {})[0]?.frequency ??
DEFAULT_FREQUENCY,
[activeAssignmentGradeId, assignmentConfigs],
);

Comment on lines +64 to +66
if (form && frequency) {
return buildFrequencyTimelineDates(form.startDate, form.endDate, frequency);
}

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.

medium

To prevent potential runtime errors or passing undefined values to buildFrequencyTimelineDates, we should ensure that both form.startDate and form.endDate are defined before calling the function.

Suggested change
if (form && frequency) {
return buildFrequencyTimelineDates(form.startDate, form.endDate, frequency);
}
if (form?.startDate && form?.endDate && frequency) {
return buildFrequencyTimelineDates(form.startDate, form.endDate, frequency);
}

@narayanangourav-sutara narayanangourav-sutara changed the title fix: CCampaign Message Tab Displays Incorrect Data for "Alternate Days" and "Alternate Weeks (≥2)" Schedules fix: Campaign Message Tab Displays Incorrect Data for "Alternate Days" and "Alternate Weeks (≥2)" Schedules Jul 17, 2026
@vinaypanduga
vinaypanduga merged commit d9df11b into main Jul 17, 2026
1 check passed
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