Repository navigation
Expand file tree
/
Copy pathdiff_draft.txt
More file actions
208 lines (201 loc) · 9.09 KB
/
Copy pathdiff_draft.txt
File metadata and controls
208 lines (201 loc) · 9.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
commit 02b43e23ce11a0e6545ea4e5b77a0e3efc9ced55
Author: akshay-intellisys <akshaymore.intellisys@gmail.com>
Date: Thu Jun 11 11:52:53 2026 +0530
client data design draft
diff --git a/dashboard-next/app/dashboard/components/PremiumDashboardShell.jsx b/dashboard-next/app/dashboard/components/PremiumDashboardShell.jsx
index 471ef9d..b0cd3c9 100644
--- a/dashboard-next/app/dashboard/components/PremiumDashboardShell.jsx
+++ b/dashboard-next/app/dashboard/components/PremiumDashboardShell.jsx
@@ -22,6 +22,15 @@ import BottomGrid from './BottomGrid';
const MAX_SCHEDULE_DELAY_MINUTES = 1440;
const MAX_SCHEDULE_DELAY_HOURS = 24;
const MAX_SCHEDULE_DELAY_SECONDS = 86400;
+const DEFAULT_WORKFLOW_STEP_COUNT = 7;
+
+function getSequentialActiveWorkflowStep(stepCompletionChecks = [], totalSteps = DEFAULT_WORKFLOW_STEP_COUNT) {
+ const safeTotal = Math.max(1, Number(totalSteps) || DEFAULT_WORKFLOW_STEP_COUNT);
+ const firstIncompleteIndex = Array.from({ length: safeTotal }, (_, index) => Boolean(stepCompletionChecks[index]))
+ .findIndex((done) => !done);
+
+ return firstIncompleteIndex === -1 ? safeTotal + 1 : firstIncompleteIndex + 1;
+}
function getDelayInputLimit(unit = 'minutes') {
const normalizedUnit = normalizeDurationUnit(unit);
@@ -692,13 +701,13 @@ export default function PremiumDashboardShell({
return () => clearTimeout(timer);
}, [showTimelineAddPopup]);
const timelineSortedCards = useMemo(() => {
- const combinedCards = [...(timelineCards || []), ...(timelineCustomTasks || [])];
+ const combinedCards = [...(timelineCards || [])];
return combinedCards.sort((a, b) => {
const aTime = parseEventDate(`${a.date} ${a.time || ''}`)?.getTime?.() || parseEventDate(a.date)?.getTime?.() || 0;
const bTime = parseEventDate(`${b.date} ${b.time || ''}`)?.getTime?.() || parseEventDate(b.date)?.getTime?.() || 0;
return bTime - aTime;
});
- }, [timelineCards, timelineCustomTasks]);
+ }, [timelineCards]);
const groupedTimelineCards = useMemo(() => {
return timelineSortedCards.reduce((groups, item) => {
const label = timelineDateLabel(item.date);
@@ -776,6 +785,7 @@ export default function PremiumDashboardShell({
const [showCampaignPopup, setShowCampaignPopup] = useState(false);
const [showSelectDraftPopup, setShowSelectDraftPopup] = useState(false);
const [showTestEmailPopup, setShowTestEmailPopup] = useState(false);
+ const [workflowPosition, setWorkflowPosition] = useState(1);
const [showDayPopup, setShowDayPopup] = useState(false);
const [showDraftContinueWarning, setShowDraftContinueWarning] = useState(false);
const [draftSaving, setDraftSaving] = useState(false);
@@ -883,23 +893,24 @@ export default function PremiumDashboardShell({
return false;
});
}, [campaignProjectFilter, senderAccounts]);
- const completedWorkflowSteps = useMemo(() => {
+ const workflowStepCount = workflowSteps?.length || DEFAULT_WORKFLOW_STEP_COUNT;
+ const workflowCompletionChecks = useMemo(() => {
const hasList = Boolean(selectedListId);
const hasOverview = Array.isArray(previewRows) && previewRows.length > 0;
const hasCampaignSetup = Boolean(String(effectiveCampaignName || '').trim());
const hasDraft = Boolean(String(effectiveDraftSubject || '').trim() || String(effectiveDraftMessage || '').replace(/<[^>]*>/g, '').trim());
- const hasDraftSummary = hasDraft;
- const hasTestMail = Boolean(String(testEmailTo || '').trim());
+ const hasTestMail = workflowPosition > 6;
const hasSchedule = sendMode === 'send_now' || Boolean(String(scheduledSlot || manualScheduledSlot || scheduledTimeValue || '').trim());
return [
hasList,
hasOverview,
hasCampaignSetup,
- hasDraft,
- hasDraftSummary,
+ // Draft data can prefill the editor, but only the workflow position can complete these steps.
+ workflowPosition > 4 && hasDraft,
+ workflowPosition > 5 && hasDraft,
hasTestMail,
- hasSchedule
+ workflowPosition > 7 && hasSchedule
];
}, [
selectedListId,
@@ -907,15 +918,13 @@ export default function PremiumDashboardShell({
effectiveCampaignName,
effectiveDraftSubject,
effectiveDraftMessage,
- testEmailTo,
+ workflowPosition,
+ sendMode,
scheduledSlot,
- manualScheduledSlot
+ manualScheduledSlot,
+ scheduledTimeValue
]);
- const activeWorkflowStep = Math.max(1, Math.min(
- workflowSteps.length,
- completedWorkflowSteps.findIndex((done) => !done) + 1 || workflowSteps.length
- ));
- const completedWorkflowCount = completedWorkflowSteps.filter(Boolean).length;
+ const activeWorkflowStep = getSequentialActiveWorkflowStep(workflowCompletionChecks, workflowStepCount);
useEffect(() => {
setSendMode(initialScheduleMode || 'send_now');
@@ -2211,6 +2220,7 @@ export default function PremiumDashboardShell({
}
setShowClientListSelectionNote(false);
onSelectList?.(selectedList);
+ setWorkflowPosition((current) => Math.max(current, 2));
setShowClientListPopup(false);
setShowOverviewPopup(true);
};
@@ -2238,6 +2248,7 @@ export default function PremiumDashboardShell({
return;
}
setShowOverviewNotice(false);
+ setWorkflowPosition((current) => Math.max(current, 3));
setShowOverviewPopup(false);
setShowCampaignPopup(true);
};
@@ -2255,6 +2266,7 @@ export default function PremiumDashboardShell({
};
const handleOverviewNext = () => {
setShowOverviewNotice(false);
+ setWorkflowPosition((current) => Math.max(current, 3));
setShowOverviewPopup(false);
setShowCampaignPopup(true);
};
@@ -2496,6 +2508,7 @@ export default function PremiumDashboardShell({
const details = buildScheduleSuccessDetails(result);
setScheduleSuccessDetails(details);
+ setWorkflowPosition((current) => Math.max(current, workflowStepCount + 1));
setShowScheduleSuccessPopup(false);
setScheduleInlineNotice({
tone: 'success',
@@ -2527,7 +2540,8 @@ export default function PremiumDashboardShell({
onShowMessage?.(`Please fill: ${campaignMissingFields.join(', ')} before continuing.`, 'warning');
return;
}
- setShowCampaignNotice(false);
+ setShowCampaignNotice(false);
+ setWorkflowPosition((current) => Math.max(current, 4));
setShowCampaignPopup(false);
setShowSelectDraftPopup(true);
};
@@ -2609,7 +2623,12 @@ export default function PremiumDashboardShell({
replies: Boolean(campaign?.tracking?.replies)
});
setShowCampaignNotice(false);
- openWorkflowStep(campaign.workflowOpenStep || campaign.workflowStep || 3);
+ const resumeWorkflowStep = Math.max(
+ 1,
+ Math.min(workflowStepCount + 1, Number(campaign.workflowOpenStep || campaign.workflowStep || 3) || 3)
+ );
+ setWorkflowPosition(resumeWorkflowStep);
+ openWorkflowStep(resumeWorkflowStep);
onShowMessage?.(
isNextProcess
? `${campaign.workflowStepLabel || 'Next mail'} is ready. Review the draft and continue.`
@@ -2638,7 +2657,8 @@ export default function PremiumDashboardShell({
onSelectedDraftTypeChange,
onShowMessage,
effectiveSavedDrafts,
- senderAccounts
+ senderAccounts,
+ workflowStepCount
]);
useEffect(() => {
if (selectedListId) {
@@ -2793,7 +2813,6 @@ export default function PremiumDashboardShell({
<Workflow
workflowSteps={workflowSteps}
- completedWorkflowSteps={completedWorkflowSteps}
activeWorkflowStep={activeWorkflowStep}
handleWorkflowAction={handleWorkflowAction}
selectedDraftType={selectedDraftType}
@@ -2894,7 +2913,6 @@ export default function PremiumDashboardShell({
onTimelineTaskStatesChange={onTimelineTaskStatesChange}
setSelectedTimelineTask={setSelectedTimelineTask}
setShowTimelinePopup={setShowTimelinePopup}
- setShowTimelineAddPopup={setShowTimelineAddPopup}
workspaceOverviewItems={workspaceOverviewItems}
openAnchoredPopup={openAnchoredPopup}
setShowLogsPopup={setShowLogsPopup}
@@ -4484,6 +4502,7 @@ export default function PremiumDashboardShell({
return;
}
setShowDraftContinueWarning(false);
+ setWorkflowPosition((current) => Math.max(current, 5));
setShowSelectDraftPopup(false);
setShowDraftSummaryPopup(true);
}}
@@ -4689,6 +4708,7 @@ export default function PremiumDashboardShell({
type="button"
className="premium-template-next"
onClick={async () => {
+ setWorkflowPosition((current) => Math.max(current, 7));
setShowTestEmailPopup(false);
setShowSchedulePopup(true);
}}
@@ -4802,6 +4822,7 @@ export default function PremiumDashboardShell({
onShowMessage?.('Complete required details first.', 'warning');
return;
}
+ setWorkflowPosition((current) => Math.max(current, 6));
setShowDraftSummaryPopup(false);
setShowTestEmailPopup(true);
}}