deckhearth/pages/invite/decline.js
Randall Stillwell 23d995102f 🎉 COMPLETED: Full Collaborative Collections System
 ALL FEATURES IMPLEMENTED:

🔐 Advanced Permission System:
- Role-based access control (Owner/Editor/Viewer)
- Permission middleware for all API endpoints
- Granular permissions for collection operations
- Activity logging for complete audit trails

🌍 Collection Visibility Types:
- Private: Owner-only access
- Invite-Only: Controlled collaboration
- Public: Community accessible
- Dynamic permission checking across all endpoints

📧 Complete Email Integration:
- Beautiful HTML invitation templates
- Role-based permission descriptions
- Personal message support
- Accept/decline workflow with proper UX
- Bulk invitation system for multiple users

🎨 Rich User Interface:
- Permission indicators with tooltips
- Activity log component with real-time updates
- Collaboration management dashboard
- Bulk invite modal with batch processing
- Permission gates throughout the UI

 Performance & Security:
- Database indexes for optimal queries
- Comprehensive error handling
- CORS headers and preflight support
- JWT-based authentication integration
- Cascading deletes and data integrity

🚀 Ready for Production:
- All API endpoints protected with permissions
- Complete activity logging system
- Beautiful email templates with Resend
- Responsive UI components
- Error handling and loading states

This system now provides enterprise-level collaboration features for community-driven collection building! 🎯
2025-07-25 08:34:28 -05:00

127 lines
4.5 KiB
JavaScript

import { useState, useEffect } from 'react';
import { useRouter } from 'next/router';
import Layout from '../../components/Layout';
export default function DeclineInvite() {
const router = useRouter();
const { token } = router.query;
const [loading, setLoading] = useState(true);
const [result, setResult] = useState(null);
const [error, setError] = useState(null);
useEffect(() => {
if (token) {
handleDeclineInvitation();
}
}, [token]);
const handleDeclineInvitation = async () => {
try {
const response = await fetch('/api/invite/decline', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ token })
});
const data = await response.json();
if (response.ok) {
setResult(data);
} else {
setError(data.error || 'Failed to decline invitation');
}
} catch (err) {
setError('Network error. Please try again.');
} finally {
setLoading(false);
}
};
if (loading) {
return (
<Layout user={null}>
<div className="min-h-screen flex items-center justify-center">
<div className="text-center">
<div className="animate-spin rounded-full h-16 w-16 border-b-2 mx-auto mb-4" style={{ borderColor: 'var(--text-accent)' }}></div>
<h2 className="text-xl font-semibold mb-2" style={{ color: 'var(--text-primary)' }}>
Processing Response...
</h2>
<p style={{ color: 'var(--text-secondary)' }}>
Please wait while we process your response.
</p>
</div>
</div>
</Layout>
);
}
return (
<Layout user={null}>
<div className="min-h-screen flex items-center justify-center px-4">
<div className="max-w-md w-full">
{result ? (
<div className="text-center p-8 rounded-2xl shadow-lg" style={{ backgroundColor: 'var(--bg-secondary)' }}>
<div className="text-6xl mb-4">👋</div>
<h2 className="text-2xl font-bold mb-4" style={{ color: 'var(--text-primary)' }}>
Invitation Declined
</h2>
<p className="mb-6" style={{ color: 'var(--text-secondary)' }}>
You have declined the invitation to "{result.collection.name}".
You can always ask the collection owner for another invitation if you change your mind.
</p>
<div className="space-y-3">
<button
onClick={() => router.push('/collections')}
className="w-full px-6 py-3 rounded-lg font-medium gradient-bg-purple text-white hover:shadow-lg transform hover:scale-105 transition-all duration-200"
>
Browse Public Collections
</button>
<button
onClick={() => router.push('/')}
className="w-full px-6 py-3 rounded-lg font-medium border transition-all duration-200"
style={{
borderColor: 'var(--border)',
color: 'var(--text-primary)'
}}
>
Go Home
</button>
</div>
</div>
) : (
<div className="text-center p-8 rounded-2xl shadow-lg" style={{ backgroundColor: 'var(--bg-secondary)' }}>
<div className="text-6xl mb-4"></div>
<h2 className="text-2xl font-bold mb-4" style={{ color: 'var(--text-primary)' }}>
Error Processing Response
</h2>
<p className="mb-6" style={{ color: 'var(--text-secondary)' }}>
{error}
</p>
<div className="space-y-3">
<button
onClick={() => router.push('/collections')}
className="w-full px-6 py-3 rounded-lg font-medium gradient-bg-purple text-white hover:shadow-lg transform hover:scale-105 transition-all duration-200"
>
Browse Collections
</button>
<button
onClick={() => router.push('/')}
className="w-full px-6 py-3 rounded-lg font-medium border transition-all duration-200"
style={{
borderColor: 'var(--border)',
color: 'var(--text-primary)'
}}
>
Go Home
</button>
</div>
</div>
)}
</div>
</div>
</Layout>
);
}