feat(campaigns): add highlighted campaign feature with admin controls and UI updates
This commit is contained in:
@@ -440,6 +440,7 @@ class NocoDBService {
|
||||
'Allow Email Editing': campaignData.allow_email_editing,
|
||||
'Allow Custom Recipients': campaignData.allow_custom_recipients,
|
||||
'Show Response Wall Button': campaignData.show_response_wall,
|
||||
'Highlight Campaign': campaignData.highlight_campaign,
|
||||
'Target Government Levels': campaignData.target_government_levels,
|
||||
'Created By User ID': campaignData.created_by_user_id,
|
||||
'Created By User Email': campaignData.created_by_user_email,
|
||||
@@ -474,6 +475,7 @@ class NocoDBService {
|
||||
if (updates.allow_email_editing !== undefined) mappedUpdates['Allow Email Editing'] = updates.allow_email_editing;
|
||||
if (updates.allow_custom_recipients !== undefined) mappedUpdates['Allow Custom Recipients'] = updates.allow_custom_recipients;
|
||||
if (updates.show_response_wall !== undefined) mappedUpdates['Show Response Wall Button'] = updates.show_response_wall;
|
||||
if (updates.highlight_campaign !== undefined) mappedUpdates['Highlight Campaign'] = updates.highlight_campaign;
|
||||
if (updates.target_government_levels !== undefined) mappedUpdates['Target Government Levels'] = updates.target_government_levels;
|
||||
if (updates.updated_at !== undefined) mappedUpdates['UpdatedAt'] = updates.updated_at;
|
||||
|
||||
@@ -497,6 +499,54 @@ class NocoDBService {
|
||||
}
|
||||
}
|
||||
|
||||
// Get the currently highlighted campaign
|
||||
async getHighlightedCampaign() {
|
||||
try {
|
||||
const response = await this.getAll(this.tableIds.campaigns, {
|
||||
where: `(Highlight Campaign,eq,true)`,
|
||||
limit: 1
|
||||
});
|
||||
return response.list && response.list.length > 0 ? response.list[0] : null;
|
||||
} catch (error) {
|
||||
console.error('Get highlighted campaign failed:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// Set a campaign as highlighted (and unset all others)
|
||||
async setHighlightedCampaign(campaignId) {
|
||||
try {
|
||||
// First, unset any existing highlighted campaigns
|
||||
const currentHighlighted = await this.getHighlightedCampaign();
|
||||
if (currentHighlighted) {
|
||||
const currentId = currentHighlighted.ID || currentHighlighted.Id || currentHighlighted.id;
|
||||
if (currentId && currentId !== campaignId) {
|
||||
await this.updateCampaign(currentId, { highlight_campaign: false });
|
||||
}
|
||||
}
|
||||
|
||||
// Then set the new highlighted campaign
|
||||
await this.updateCampaign(campaignId, { highlight_campaign: true });
|
||||
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
console.error('Set highlighted campaign failed:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// Unset highlighted campaign
|
||||
async unsetHighlightedCampaign(campaignId) {
|
||||
try {
|
||||
await this.updateCampaign(campaignId, { highlight_campaign: false });
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
console.error('Unset highlighted campaign failed:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Campaign email tracking methods
|
||||
async logCampaignEmail(emailData) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user