Skip to content

Commit

Permalink
Pad manuscript number with zeros in uuid (#4435)
Browse files Browse the repository at this point in the history
* Pad manuscript number with zeros in uuid

* linting
  • Loading branch information
lctrt authored Nov 7, 2024
1 parent 8e6cc2f commit 89b4455
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,10 @@ export const getManuscriptVersionUID = ({
version.type === 'Original Research' ? 'org' : 'rev';

const lifecycleCode = getLifecycleCode(version);
return `${teamId}-${grantId}-${manuscriptCount}-${manuscriptTypeCode}-${lifecycleCode}-${manuscriptVersionCount}`;
return `${teamId}-${grantId}-${String(manuscriptCount).padStart(
3,
'0',
)}-${manuscriptTypeCode}-${lifecycleCode}-${manuscriptVersionCount}`;
};

const ManuscriptVersionCard: React.FC<ManuscriptVersionCardProps> = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,4 +541,15 @@ describe('getManuscriptversionUID', () => {
}),
).toBe('AT1-000AAA-234-rev-P-9');
});
it('pads manuscript count with leading 0s', () => {
expect(
getManuscriptVersionUID({
version: { type: 'Original Research', lifecycle: 'Preprint' },
grantId: '000AAA',
teamId: 'AT1',
manuscriptVersionCount: 9,
manuscriptCount: 4,
}),
).toBe('AT1-000AAA-004-org-P-9');
});
});

0 comments on commit 89b4455

Please sign in to comment.