fix: Correctly show recipient count during creation and edit
This commit is contained in:
@@ -326,19 +326,9 @@ export default function CampaignDetailsPage() {
|
|||||||
const c = campaign.data;
|
const c = campaign.data;
|
||||||
const s = stats?.data;
|
const s = stats?.data;
|
||||||
|
|
||||||
// Get recipient count for draft campaigns
|
// Get recipient count for draft campaigns from the campaign's totalRecipients field
|
||||||
const getDraftRecipientCount = () => {
|
// The backend calculates this for all audience types when the campaign is created/updated
|
||||||
if (!campaign?.data) return 0;
|
const draftRecipientCount = isEditMode && campaign?.data ? campaign.data.totalRecipients : 0;
|
||||||
const c = campaign.data;
|
|
||||||
|
|
||||||
if (c.audienceType === CampaignAudienceType.SEGMENT && c.segmentId && segments) {
|
|
||||||
const segment = segments.find(s => s.id === c.segmentId);
|
|
||||||
return segment?.memberCount || 0;
|
|
||||||
}
|
|
||||||
return 0; // We'd need total contact count for ALL audience type
|
|
||||||
};
|
|
||||||
|
|
||||||
const draftRecipientCount = isEditMode ? getDraftRecipientCount() : 0;
|
|
||||||
|
|
||||||
// Render edit form for drafts
|
// Render edit form for drafts
|
||||||
if (isEditMode) {
|
if (isEditMode) {
|
||||||
|
|||||||
@@ -279,6 +279,20 @@ export default function CreateCampaignPage() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{audienceType === CampaignAudienceType.ALL && (
|
||||||
|
<div className="bg-blue-50 border border-blue-200 rounded-lg p-4 flex items-start gap-3">
|
||||||
|
<Users className="h-5 w-5 text-blue-600 mt-0.5" />
|
||||||
|
<div>
|
||||||
|
<p className="text-sm font-medium text-blue-900">
|
||||||
|
All subscribed contacts
|
||||||
|
</p>
|
||||||
|
<p className="text-xs text-blue-700 mt-1">
|
||||||
|
This campaign will be sent to all contacts who haven't unsubscribed
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
@@ -335,6 +349,13 @@ export default function CreateCampaignPage() {
|
|||||||
<span className="font-medium">{estimatedRecipients.toLocaleString()}</span>
|
<span className="font-medium">{estimatedRecipients.toLocaleString()}</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{audienceType === CampaignAudienceType.ALL && (
|
||||||
|
<div className="flex justify-between py-2">
|
||||||
|
<span className="text-neutral-500">Recipients</span>
|
||||||
|
<span className="font-medium">All subscribed</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Info Note */}
|
{/* Info Note */}
|
||||||
|
|||||||
Reference in New Issue
Block a user