Setup Campaign from Microplan
Overview
The "Setup Campaign" feature facilitates the creation of a campaign using an approved microplan. It ensures that only authorized users can initiate the setup process, generates required campaign data, and integrates with external APIs to fetch user, facility, and target data.
. User Role Validation
Role Required: MICROPLAN_CAMPAIGN_INTEGRATOR
Validation Logic:
Only users with the above role can select an approved microplan to initiate the campaign setup.
If the user lacks the role, access to the feature is denied with a proper error message.
Campaign Object Creation
Input: Approved microplan object.
Steps:
Extract the base campaign object from the selected microplan.
Create a new campaign object by cloning the base campaign object with the following updates:
Add unique identifiers (
campaignId
,createdBy
).Set the campaign status to
draft
.
Save the new campaign object to the backend.
Generate Empty Templates
Trigger: After updating the campaign object with selected boundaries, it gets auto-generated from Backend
Steps:
Automatically generate empty templates for the campaign, including:
User assignments.
Facility data placeholders.
Target data placeholders.
Fetch Data from Microplan API
API Endpoint: project-factory/v1/project-type/fetch-from-microplan
Steps:
Call the Microplan API to fetch:
User data.
Facility data.
Target data.
Populate the empty templates with the fetched data.
Save the updated templates back to the backend.
Campaign Search Polling
Purpose: Monitor the progress of data population and transition to the next step once completed.
Steps:
The UI triggers a periodic call to the
campaignSearch
endpoint:API Endpoint:
/campaign-search
Parameters:
campaignId
.
Check the status of the campaign:
If Completed:
Navigate the user to the Setup Campaign page.
If In Progress:
Re-trigger the data fetch from Microplan API to ensure completion.
Continue polling.
Navigation to "Setup Campaign" Page.
Steps:
Transition the user to the Setup Campaign page.
Pass the necessary campaign data as route parameters or via state management.
API Details:
project-factory/v1/project-type/fetch-from-microplan
MICROPLAN_CAMPAIGN_INTEGRATOR
project-factory/v1/project-type/search
CAMPAIGN_MANAGER
project-factory/v1/project-type/create
CAMPAIGN_MANAGER
project-factory/v1/project-type/update
CAMPAIGN_MANAGER
project-factory/v1/data/_download
CAMPAIGN_MANAGER
Last updated