mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-22 15:51:12 -05:00
Implement Phase 6: Lock Management
This commit is contained in:
@@ -397,6 +397,34 @@ export const useModerationQueue = () => {
|
||||
}
|
||||
}, [user, currentLock, toast, fetchStats]);
|
||||
|
||||
// Check if submission is locked by current user
|
||||
const isLockedByMe = useCallback((submissionId: string): boolean => {
|
||||
return currentLock?.submissionId === submissionId;
|
||||
}, [currentLock]);
|
||||
|
||||
// Check if submission is locked by another moderator
|
||||
const isLockedByOther = useCallback((submissionId: string, assignedTo: string | null, lockedUntil: string | null): boolean => {
|
||||
if (!assignedTo || !lockedUntil) return false;
|
||||
if (user?.id === assignedTo) return false; // It's our lock
|
||||
return new Date(lockedUntil) > new Date(); // Lock is still active
|
||||
}, [user]);
|
||||
|
||||
// Get lock progress percentage (0-100)
|
||||
const getLockProgress = useCallback((): number => {
|
||||
const timeLeft = getTimeRemaining();
|
||||
if (timeLeft === null) return 0;
|
||||
const totalTime = 15 * 60 * 1000; // 15 minutes in ms
|
||||
return Math.max(0, Math.min(100, (timeLeft / totalTime) * 100));
|
||||
}, [getTimeRemaining]);
|
||||
|
||||
// Auto-release lock after moderation action
|
||||
const releaseAfterAction = useCallback(async (submissionId: string, action: 'approved' | 'rejected'): Promise<void> => {
|
||||
if (currentLock?.submissionId === submissionId) {
|
||||
await releaseLock(submissionId);
|
||||
console.log(`🔓 Auto-released lock after ${action} action`);
|
||||
}
|
||||
}, [currentLock, releaseLock]);
|
||||
|
||||
return {
|
||||
currentLock,
|
||||
queueStats,
|
||||
@@ -409,6 +437,11 @@ export const useModerationQueue = () => {
|
||||
escalateSubmission,
|
||||
reassignSubmission,
|
||||
refreshStats: fetchStats,
|
||||
// New helpers
|
||||
isLockedByMe,
|
||||
isLockedByOther,
|
||||
getLockProgress,
|
||||
releaseAfterAction,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user