Skip to content

Commit a5ddcbf

Browse files
committed
feat(api): prevent activating a different version when another is pending approval
1 parent eebef92 commit a5ddcbf

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

apps/app/src/actions/policies/set-active-version.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ export const setActiveVersionAction = authActionClient
3939
return { success: false, error: 'Policy not found' };
4040
}
4141

42+
// Prevent activating a different version when another is pending approval
43+
if (policy.pendingVersionId && policy.pendingVersionId !== versionId) {
44+
return { success: false, error: 'Another version is already pending approval' };
45+
}
46+
4247
// Get version to activate
4348
const version = await db.policyVersion.findUnique({
4449
where: { id: versionId },

0 commit comments

Comments
 (0)