Skip to content

Commit d91f03d

Browse files
committed
fix(admin): use templateReferenceId for template navigation
Changed all template actions (edit, download, duplicate, delete) to use the stable templateReferenceId instead of documentId. The backend findOne resolves numeric IDs via templateReferenceId lookup, ensuring the correct template is always opened.
1 parent 57ce208 commit d91f03d

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

admin/src/pages/EmailDesigner/TemplateList.jsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,8 +1113,8 @@ const TemplateList = () => {
11131113
fetchStats();
11141114

11151115
// Navigate to the duplicated template
1116-
if (duplicated?.documentId) {
1117-
navigate(`/plugins/magic-mail/designer/${duplicated.documentId}`);
1116+
if (duplicated?.templateReferenceId) {
1117+
navigate(`/plugins/magic-mail/designer/${duplicated.templateReferenceId}`);
11181118
}
11191119
} catch (error) {
11201120
toggleNotification({
@@ -1523,7 +1523,7 @@ const TemplateList = () => {
15231523
</Thead>
15241524
<Tbody>
15251525
{paginatedTemplates.map((template) => (
1526-
<Tr key={template.documentId}>
1526+
<Tr key={template.templateReferenceId}>
15271527
<Td>
15281528
<Typography variant="omega" fontWeight="bold" style={{ fontSize: '13px' }}>
15291529
#{template.templateReferenceId}
@@ -1544,29 +1544,29 @@ const TemplateList = () => {
15441544
<Flex gap={2} justifyContent="flex-end">
15451545
<IconButtonPrimary
15461546
onClick={() =>
1547-
navigate(`/plugins/magic-mail/designer/${template.documentId}`)
1547+
navigate(`/plugins/magic-mail/designer/${template.templateReferenceId}`)
15481548
}
15491549
aria-label="Edit Template"
15501550
title="Edit Template"
15511551
>
15521552
<PencilIcon />
15531553
</IconButtonPrimary>
15541554
<IconButton
1555-
onClick={() => handleDownload(template.documentId, 'html')}
1555+
onClick={() => handleDownload(template.templateReferenceId, 'html')}
15561556
aria-label="Download HTML"
15571557
title="Download as HTML"
15581558
>
15591559
<DocumentArrowDownIcon />
15601560
</IconButton>
15611561
<IconButton
1562-
onClick={() => handleDownload(template.documentId, 'json')}
1562+
onClick={() => handleDownload(template.templateReferenceId, 'json')}
15631563
aria-label="Download JSON"
15641564
title="Download as JSON"
15651565
>
15661566
<CodeBracketIcon />
15671567
</IconButton>
15681568
<IconButton
1569-
onClick={() => handleDuplicate(template.documentId, template.name)}
1569+
onClick={() => handleDuplicate(template.templateReferenceId, template.name)}
15701570
aria-label="Duplicate Template"
15711571
title="Duplicate Template"
15721572
>
@@ -1590,7 +1590,7 @@ const TemplateList = () => {
15901590
<PaperAirplaneIcon />
15911591
</IconButtonSuccess>
15921592
<IconButtonDanger
1593-
onClick={() => handleDelete(template.documentId, template.name)}
1593+
onClick={() => handleDelete(template.templateReferenceId, template.name)}
15941594
aria-label="Delete Template"
15951595
title="Delete Template"
15961596
>

0 commit comments

Comments
 (0)