mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-21 22:51:12 -05:00
feat: Implement authentication integration
This commit is contained in:
@@ -445,7 +445,6 @@ export const ModerationQueue = forwardRef<ModerationQueueRef>((props, ref) => {
|
||||
}
|
||||
|
||||
// STEP 4: Update submission status
|
||||
const { data: { user } } = await supabase.auth.getUser();
|
||||
const { error: updateError } = await supabase
|
||||
.from('content_submissions')
|
||||
.update({
|
||||
@@ -482,7 +481,6 @@ export const ModerationQueue = forwardRef<ModerationQueueRef>((props, ref) => {
|
||||
};
|
||||
|
||||
// Get current user ID for reviewer tracking
|
||||
const { data: { user } } = await supabase.auth.getUser();
|
||||
if (user) {
|
||||
updateData[reviewerField] = user.id;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useToast } from '@/hooks/use-toast';
|
||||
import { useUserRole } from '@/hooks/useUserRole';
|
||||
import { useAuth } from '@/hooks/useAuth';
|
||||
import {
|
||||
fetchSubmissionItems,
|
||||
buildDependencyTree,
|
||||
@@ -48,6 +49,7 @@ export function SubmissionReviewManager({
|
||||
|
||||
const { toast } = useToast();
|
||||
const { isAdmin, isSuperuser } = useUserRole();
|
||||
const { user } = useAuth();
|
||||
const isMobile = useIsMobile();
|
||||
const Container = isMobile ? Sheet : Dialog;
|
||||
|
||||
@@ -116,10 +118,19 @@ export function SubmissionReviewManager({
|
||||
};
|
||||
|
||||
const handleApprove = async () => {
|
||||
if (!user?.id) {
|
||||
toast({
|
||||
title: 'Authentication Required',
|
||||
description: 'You must be logged in to approve items',
|
||||
variant: 'destructive',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
setLoading(true);
|
||||
try {
|
||||
const selectedItems = items.filter(item => selectedItemIds.has(item.id));
|
||||
await approveSubmissionItems(selectedItems, 'current-user-id'); // TODO: Get from auth
|
||||
await approveSubmissionItems(selectedItems, user.id);
|
||||
|
||||
toast({
|
||||
title: 'Success',
|
||||
@@ -162,9 +173,18 @@ export function SubmissionReviewManager({
|
||||
};
|
||||
|
||||
const handleEscalate = async (reason: string) => {
|
||||
if (!user?.id) {
|
||||
toast({
|
||||
title: 'Authentication Required',
|
||||
description: 'You must be logged in to escalate submissions',
|
||||
variant: 'destructive',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
setLoading(true);
|
||||
try {
|
||||
await escalateSubmission(submissionId, reason, 'current-user-id'); // TODO: Get from auth
|
||||
await escalateSubmission(submissionId, reason, user.id);
|
||||
|
||||
toast({
|
||||
title: 'Escalated',
|
||||
|
||||
@@ -154,6 +154,10 @@ export async function approveSubmissionItems(
|
||||
items: SubmissionItemWithDeps[],
|
||||
userId: string
|
||||
): Promise<void> {
|
||||
if (!userId) {
|
||||
throw new Error('User authentication required to approve items');
|
||||
}
|
||||
|
||||
// Sort by dependency order (parents first)
|
||||
const sortedItems = topologicalSort(items);
|
||||
|
||||
@@ -285,6 +289,10 @@ export async function escalateSubmission(
|
||||
reason: string,
|
||||
userId: string
|
||||
): Promise<void> {
|
||||
if (!userId) {
|
||||
throw new Error('User authentication required to escalate submission');
|
||||
}
|
||||
|
||||
const { error } = await supabase
|
||||
.from('content_submissions')
|
||||
.update({
|
||||
|
||||
Reference in New Issue
Block a user