much better ui
This commit is contained in:
parent
fd68c47e9a
commit
2e14127a2c
3 changed files with 391 additions and 259 deletions
|
@ -29,6 +29,10 @@ interface ExtendedEventRequest extends SchemaEventRequest {
|
||||||
invoice_files?: string[]; // Array of invoice file IDs
|
invoice_files?: string[]; // Array of invoice file IDs
|
||||||
flyer_files?: string[]; // Add this for PR-related files
|
flyer_files?: string[]; // Add this for PR-related files
|
||||||
files?: string[]; // Generic files field
|
files?: string[]; // Generic files field
|
||||||
|
room_reservation_needed?: boolean;
|
||||||
|
room_reservation_location?: string;
|
||||||
|
room_reservation_confirmed?: boolean;
|
||||||
|
additional_notes?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface EventRequestDetailsProps {
|
interface EventRequestDetailsProps {
|
||||||
|
@ -1104,28 +1108,22 @@ const EventRequestDetails = ({
|
||||||
onClose,
|
onClose,
|
||||||
onStatusChange
|
onStatusChange
|
||||||
}: EventRequestDetailsProps): React.ReactNode => {
|
}: EventRequestDetailsProps): React.ReactNode => {
|
||||||
const [activeTab, setActiveTab] = useState<'details' | 'pr' | 'funding'>('details');
|
const [activeTab, setActiveTab] = useState('details');
|
||||||
const [status, setStatus] = useState<"submitted" | "pending" | "completed" | "declined">(request.status);
|
const [isConfirmModalOpen, setIsConfirmModalOpen] = useState(false);
|
||||||
const [isStatusChanging, setIsStatusChanging] = useState(false);
|
const [newStatus, setNewStatus] = useState<"submitted" | "pending" | "completed" | "declined">("pending");
|
||||||
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
// Format date for display
|
const [alertInfo, setAlertInfo] = useState<{ show: boolean; type: "success" | "error" | "warning" | "info"; message: string }>({
|
||||||
const formatDate = (dateString: string) => {
|
show: false,
|
||||||
if (!dateString) return 'Not specified';
|
type: "info",
|
||||||
try {
|
message: ""
|
||||||
const date = new Date(dateString);
|
|
||||||
return date.toLocaleDateString('en-US', {
|
|
||||||
year: 'numeric',
|
|
||||||
month: 'short',
|
|
||||||
day: 'numeric',
|
|
||||||
hour: '2-digit',
|
|
||||||
minute: '2-digit'
|
|
||||||
});
|
});
|
||||||
} catch (e) {
|
|
||||||
return dateString;
|
const formatDate = (dateString: string) => {
|
||||||
}
|
if (!dateString) return "Not specified";
|
||||||
|
const date = new Date(dateString);
|
||||||
|
return date.toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric', hour: 'numeric', minute: 'numeric' });
|
||||||
};
|
};
|
||||||
|
|
||||||
// Get status badge class based on status
|
|
||||||
const getStatusBadge = (status?: "submitted" | "pending" | "completed" | "declined") => {
|
const getStatusBadge = (status?: "submitted" | "pending" | "completed" | "declined") => {
|
||||||
if (!status) return 'badge-warning';
|
if (!status) return 'badge-warning';
|
||||||
|
|
||||||
|
@ -1143,46 +1141,95 @@ const EventRequestDetails = ({
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle status change
|
|
||||||
const handleStatusChange = async (newStatus: "submitted" | "pending" | "completed" | "declined") => {
|
const handleStatusChange = async (newStatus: "submitted" | "pending" | "completed" | "declined") => {
|
||||||
setIsStatusChanging(true);
|
setNewStatus(newStatus);
|
||||||
|
setIsConfirmModalOpen(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
const confirmStatusChange = async () => {
|
||||||
|
setIsSubmitting(true);
|
||||||
|
setAlertInfo({ show: false, type: "info", message: "" });
|
||||||
|
|
||||||
|
try {
|
||||||
await onStatusChange(request.id, newStatus);
|
await onStatusChange(request.id, newStatus);
|
||||||
setStatus(newStatus);
|
setAlertInfo({
|
||||||
setIsStatusChanging(false);
|
show: true,
|
||||||
};
|
type: "success",
|
||||||
|
message: `Status successfully changed to ${newStatus}.`
|
||||||
// Animation variants
|
});
|
||||||
const fadeInVariants = {
|
} catch (error) {
|
||||||
hidden: { opacity: 0, y: 20 },
|
setAlertInfo({
|
||||||
visible: { opacity: 1, y: 0, transition: { duration: 0.4 } }
|
show: true,
|
||||||
};
|
type: "error",
|
||||||
|
message: `Failed to update status: ${error}`
|
||||||
const tabVariants = {
|
});
|
||||||
hidden: { opacity: 0, y: 10 },
|
} finally {
|
||||||
visible: { opacity: 1, y: 0, transition: { duration: 0.3 } }
|
setIsSubmitting(false);
|
||||||
|
setIsConfirmModalOpen(false);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<motion.div
|
<div className="bg-transparent w-full">
|
||||||
className="bg-base-200 rounded-xl overflow-hidden shadow-xl max-w-5xl w-full"
|
{/* Tabs navigation */}
|
||||||
initial="hidden"
|
<div className="px-6 pt-2 mb-4">
|
||||||
animate="visible"
|
<div className="flex flex-wrap gap-2 border-b border-base-100/20">
|
||||||
variants={fadeInVariants}
|
<button
|
||||||
|
className={`px-4 py-2 font-medium transition-all rounded-t-lg ${activeTab === 'details' ? 'bg-primary/10 text-primary border-b-2 border-primary' : 'hover:bg-base-100/10 text-gray-300'}`}
|
||||||
|
onClick={() => setActiveTab('details')}
|
||||||
>
|
>
|
||||||
<div className="p-6">
|
|
||||||
<div className="bg-base-300/50 p-4 rounded-lg flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4">
|
|
||||||
<div className="flex flex-col gap-1">
|
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<span className="text-sm text-gray-400">Status:</span>
|
<svg xmlns="http://www.w3.org/2000/svg" className="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
<motion.span
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
|
||||||
className={`badge ${getStatusBadge(status)}`}
|
</svg>
|
||||||
initial={{ opacity: 0, scale: 0.9 }}
|
Event Details
|
||||||
animate={{ opacity: 1, scale: 1 }}
|
|
||||||
transition={{ duration: 0.2 }}
|
|
||||||
>
|
|
||||||
{status || 'Pending'}
|
|
||||||
</motion.span>
|
|
||||||
</div>
|
</div>
|
||||||
|
</button>
|
||||||
|
{request.as_funding_required && (
|
||||||
|
<button
|
||||||
|
className={`px-4 py-2 font-medium transition-all rounded-t-lg ${activeTab === 'funding' ? 'bg-primary/10 text-primary border-b-2 border-primary' : 'hover:bg-base-100/10 text-gray-300'}`}
|
||||||
|
onClick={() => setActiveTab('funding')}
|
||||||
|
>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" className="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
|
||||||
|
</svg>
|
||||||
|
AS Funding
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
{request.flyers_needed && (
|
||||||
|
<button
|
||||||
|
className={`px-4 py-2 font-medium transition-all rounded-t-lg ${activeTab === 'pr' ? 'bg-primary/10 text-primary border-b-2 border-primary' : 'hover:bg-base-100/10 text-gray-300'}`}
|
||||||
|
onClick={() => setActiveTab('pr')}
|
||||||
|
>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" className="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" />
|
||||||
|
</svg>
|
||||||
|
PR Materials
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Alert for status updates */}
|
||||||
|
{alertInfo.show && (
|
||||||
|
<div className="px-6 mb-4">
|
||||||
|
<CustomAlert
|
||||||
|
type={alertInfo.type}
|
||||||
|
title={alertInfo.type.charAt(0).toUpperCase() + alertInfo.type.slice(1)}
|
||||||
|
message={alertInfo.message}
|
||||||
|
onClose={() => setAlertInfo({ ...alertInfo, show: false })}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Status bar */}
|
||||||
|
<div className="mb-6 px-6">
|
||||||
|
<div className="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4 p-4 bg-base-100/10 rounded-lg border border-base-100/10">
|
||||||
|
<div className="space-y-1">
|
||||||
<div className="text-sm text-gray-400">
|
<div className="text-sm text-gray-400">
|
||||||
Requested by: <span className="text-white">
|
Requested by: <span className="text-white">
|
||||||
{request.requested_user_expand?.name ||
|
{request.requested_user_expand?.name ||
|
||||||
|
@ -1196,164 +1243,215 @@ const EventRequestDetails = ({
|
||||||
'No email available'}
|
'No email available'}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<span className={`badge ${getStatusBadge(request.status)}`}>
|
||||||
|
{request.status?.charAt(0).toUpperCase() + request.status?.slice(1) || 'Pending'}
|
||||||
|
</span>
|
||||||
|
<span className="text-xs text-gray-400">
|
||||||
|
Submitted on {formatDate(request.created)}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<div className="dropdown dropdown-end">
|
<div className="dropdown dropdown-end">
|
||||||
<motion.label
|
<label tabIndex={0} className="btn btn-sm">
|
||||||
tabIndex={0}
|
|
||||||
className="btn btn-sm btn-primary"
|
|
||||||
whileHover={{ scale: 1.05 }}
|
|
||||||
whileTap={{ scale: 0.95 }}
|
|
||||||
>
|
|
||||||
Update Status
|
Update Status
|
||||||
</motion.label>
|
<svg xmlns="http://www.w3.org/2000/svg" className="h-4 w-4 ml-1" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M19 9l-7 7-7-7" />
|
||||||
|
</svg>
|
||||||
|
</label>
|
||||||
<ul tabIndex={0} className="dropdown-content z-[101] menu p-2 shadow bg-base-200 rounded-lg w-52">
|
<ul tabIndex={0} className="dropdown-content z-[101] menu p-2 shadow bg-base-200 rounded-lg w-52">
|
||||||
<li><a onClick={() => handleStatusChange('pending')}>Pending</a></li>
|
<li>
|
||||||
<li><a onClick={() => handleStatusChange('completed')}>Completed</a></li>
|
<button
|
||||||
<li><a onClick={() => handleStatusChange('declined')}>Declined</a></li>
|
className={`flex items-center ${request.status === 'pending' ? 'bg-warning/20 text-warning' : ''}`}
|
||||||
|
onClick={() => handleStatusChange('pending')}
|
||||||
|
disabled={request.status === 'pending'}
|
||||||
|
>
|
||||||
|
<div className="w-2 h-2 rounded-full bg-warning mr-2"></div>
|
||||||
|
Pending
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<button
|
||||||
|
className={`flex items-center ${request.status === 'completed' ? 'bg-success/20 text-success' : ''}`}
|
||||||
|
onClick={() => handleStatusChange('completed')}
|
||||||
|
disabled={request.status === 'completed'}
|
||||||
|
>
|
||||||
|
<div className="w-2 h-2 rounded-full bg-success mr-2"></div>
|
||||||
|
Completed
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<button
|
||||||
|
className={`flex items-center ${request.status === 'declined' ? 'bg-error/20 text-error' : ''}`}
|
||||||
|
onClick={() => handleStatusChange('declined')}
|
||||||
|
disabled={request.status === 'declined'}
|
||||||
|
>
|
||||||
|
<div className="w-2 h-2 rounded-full bg-error mr-2"></div>
|
||||||
|
Declined
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Tabs */}
|
|
||||||
<div className="tabs tabs-boxed my-6 bg-base-300/30">
|
|
||||||
<motion.a
|
|
||||||
className={`tab ${activeTab === 'details' ? 'tab-active' : ''}`}
|
|
||||||
onClick={() => setActiveTab('details')}
|
|
||||||
whileHover={{ scale: 1.02 }}
|
|
||||||
whileTap={{ scale: 0.98 }}
|
|
||||||
>
|
|
||||||
Event Details
|
|
||||||
</motion.a>
|
|
||||||
<motion.a
|
|
||||||
className={`tab ${activeTab === 'pr' ? 'tab-active' : ''}`}
|
|
||||||
onClick={() => setActiveTab('pr')}
|
|
||||||
whileHover={{ scale: 1.02 }}
|
|
||||||
whileTap={{ scale: 0.98 }}
|
|
||||||
>
|
|
||||||
PR Materials
|
|
||||||
</motion.a>
|
|
||||||
<motion.a
|
|
||||||
className={`tab ${activeTab === 'funding' ? 'tab-active' : ''}`}
|
|
||||||
onClick={() => setActiveTab('funding')}
|
|
||||||
whileHover={{ scale: 1.02 }}
|
|
||||||
whileTap={{ scale: 0.98 }}
|
|
||||||
>
|
|
||||||
AS Funding
|
|
||||||
</motion.a>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Content */}
|
{/* Tab content */}
|
||||||
<AnimatePresence mode="wait">
|
<div className="px-6 pb-6">
|
||||||
{/* Event Details Tab */}
|
|
||||||
{activeTab === 'details' && (
|
{activeTab === 'details' && (
|
||||||
<motion.div
|
|
||||||
className="space-y-6"
|
|
||||||
key="details-tab"
|
|
||||||
initial="hidden"
|
|
||||||
animate="visible"
|
|
||||||
exit={{ opacity: 0, y: -10 }}
|
|
||||||
variants={tabVariants}
|
|
||||||
>
|
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||||
<div className="space-y-4">
|
<div className="space-y-6">
|
||||||
<div className="bg-base-300/20 p-4 rounded-lg">
|
<div className="bg-base-100/10 p-4 rounded-lg border border-base-100/10">
|
||||||
<h4 className="text-sm font-medium text-gray-400 mb-1">Event Name</h4>
|
<h3 className="text-lg font-semibold text-white mb-3 flex items-center">
|
||||||
<p className="text-lg">{request.name}</p>
|
<svg xmlns="http://www.w3.org/2000/svg" className="h-5 w-5 mr-2 text-primary" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
|
||||||
|
</svg>
|
||||||
|
Event Information
|
||||||
|
</h3>
|
||||||
|
<div className="space-y-3">
|
||||||
|
<div>
|
||||||
|
<label className="text-xs text-gray-400">Event Name</label>
|
||||||
|
<p className="text-white font-medium">{request.name}</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="bg-base-300/20 p-4 rounded-lg">
|
<div>
|
||||||
<h4 className="text-sm font-medium text-gray-400 mb-1">Location</h4>
|
<label className="text-xs text-gray-400">Event Description</label>
|
||||||
<p>{request.location || 'Not specified'}</p>
|
<p className="text-white">{request.event_description}</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="bg-base-300/20 p-4 rounded-lg">
|
<div className="grid grid-cols-1 sm:grid-cols-2 gap-3">
|
||||||
<h4 className="text-sm font-medium text-gray-400 mb-1">Start Date & Time</h4>
|
<div>
|
||||||
<p>{formatDate(request.start_date_time)}</p>
|
<label className="text-xs text-gray-400">Start Date & Time</label>
|
||||||
|
<p className="text-white">{formatDate(request.start_date_time)}</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="bg-base-300/20 p-4 rounded-lg">
|
<div>
|
||||||
<h4 className="text-sm font-medium text-gray-400 mb-1">End Date & Time</h4>
|
<label className="text-xs text-gray-400">End Date & Time</label>
|
||||||
<p>{formatDate(request.end_date_time)}</p>
|
<p className="text-white">{formatDate(request.end_date_time)}</p>
|
||||||
</div>
|
|
||||||
<div className="bg-base-300/20 p-4 rounded-lg">
|
|
||||||
<h4 className="text-sm font-medium text-gray-400 mb-1">Expected Attendance</h4>
|
|
||||||
<p>{request.expected_attendance || 'Not specified'}</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-4">
|
<div>
|
||||||
<div className="bg-base-300/20 p-4 rounded-lg">
|
<label className="text-xs text-gray-400">Location</label>
|
||||||
<h4 className="text-sm font-medium text-gray-400 mb-1">Event Description</h4>
|
<p className="text-white">{request.location}</p>
|
||||||
<p className="whitespace-pre-line">{request.event_description || 'No description provided'}</p>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="bg-base-300/20 p-4 rounded-lg">
|
|
||||||
<h4 className="text-sm font-medium text-gray-400 mb-1">Room Booking</h4>
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
{request.will_or_have_room_booking ? (
|
|
||||||
<span className="badge badge-success">Yes</span>
|
|
||||||
) : (
|
|
||||||
<span className="badge badge-ghost">No</span>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Display room booking file if available */}
|
<div className="bg-base-100/10 p-4 rounded-lg border border-base-100/10">
|
||||||
{request.room_booking && (
|
<h3 className="text-lg font-semibold text-white mb-3 flex items-center">
|
||||||
<div className="mt-3">
|
<svg xmlns="http://www.w3.org/2000/svg" className="h-5 w-5 mr-2 text-primary" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z" />
|
||||||
|
</svg>
|
||||||
|
Requirements & Special Requests
|
||||||
|
</h3>
|
||||||
|
<div className="space-y-3">
|
||||||
|
<div className="flex items-center">
|
||||||
|
<div className={`mr-2 badge ${request.as_funding_required ? 'badge-success' : 'badge-ghost'}`}>
|
||||||
|
{request.as_funding_required ? 'Yes' : 'No'}
|
||||||
|
</div>
|
||||||
|
<p className="text-white">AS Funding Required</p>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center">
|
||||||
|
<div className={`mr-2 badge ${request.flyers_needed ? 'badge-success' : 'badge-ghost'}`}>
|
||||||
|
{request.flyers_needed ? 'Yes' : 'No'}
|
||||||
|
</div>
|
||||||
|
<p className="text-white">PR Materials Needed</p>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center">
|
||||||
|
<div className={`mr-2 badge ${request.room_reservation_needed ? 'badge-success' : 'badge-ghost'}`}>
|
||||||
|
{request.room_reservation_needed ? 'Yes' : 'No'}
|
||||||
|
</div>
|
||||||
|
<p className="text-white">Room Reservation Needed</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="space-y-6">
|
||||||
|
{request.room_reservation_needed && (
|
||||||
|
<div className="bg-base-100/10 p-4 rounded-lg border border-base-100/10">
|
||||||
|
<h3 className="text-lg font-semibold text-white mb-3 flex items-center">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" className="h-5 w-5 mr-2 text-primary" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4" />
|
||||||
|
</svg>
|
||||||
|
Room Reservation Details
|
||||||
|
</h3>
|
||||||
|
<div className="space-y-3">
|
||||||
|
<div>
|
||||||
|
<label className="text-xs text-gray-400">Room/Location</label>
|
||||||
|
<p className="text-white">{request.room_reservation_location || 'Not specified'}</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label className="text-xs text-gray-400">Confirmation Status</label>
|
||||||
|
<p className="text-white">{request.room_reservation_confirmed ? 'Confirmed' : 'Not confirmed'}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{request.files && request.files.length > 0 && (
|
||||||
|
<div className="bg-base-100/10 p-4 rounded-lg border border-base-100/10">
|
||||||
|
<h3 className="text-lg font-semibold text-white mb-3 flex items-center">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" className="h-5 w-5 mr-2 text-primary" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
|
||||||
|
</svg>
|
||||||
|
Event Files
|
||||||
|
</h3>
|
||||||
|
<div className="grid grid-cols-1 sm:grid-cols-2 gap-2">
|
||||||
|
{request.files.map((file, index) => (
|
||||||
<FilePreview
|
<FilePreview
|
||||||
fileUrl={request.room_booking}
|
key={index}
|
||||||
fileName={request.room_booking.split('/').pop() || 'Room Booking'}
|
fileUrl={`/api/files/event_requests/${request.id}/${file}`}
|
||||||
collectionName={Collections.EVENT_REQUESTS}
|
fileName={file}
|
||||||
|
collectionName="event_requests"
|
||||||
recordId={request.id}
|
recordId={request.id}
|
||||||
originalFileName={request.room_booking}
|
originalFileName={file}
|
||||||
/>
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="bg-base-300/20 p-4 rounded-lg">
|
</div>
|
||||||
<h4 className="text-sm font-medium text-gray-400 mb-1">Food/Drinks Served</h4>
|
)}
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
{request.food_drinks_being_served ? (
|
{activeTab === 'funding' && request.as_funding_required && <ASFundingTab request={request} />}
|
||||||
<span className="badge badge-success">Yes</span>
|
{activeTab === 'pr' && request.flyers_needed && <PRMaterialsTab request={request} />}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Confirmation modal */}
|
||||||
|
{isConfirmModalOpen && (
|
||||||
|
<div className="fixed inset-0 bg-black/50 backdrop-blur-sm z-[300] flex items-center justify-center p-4">
|
||||||
|
<div className="bg-base-300 rounded-lg p-6 w-full max-w-md">
|
||||||
|
<h3 className="text-lg font-bold mb-4">Confirm Status Change</h3>
|
||||||
|
<p className="mb-4">
|
||||||
|
Are you sure you want to change the status to <span className="font-bold text-primary">{newStatus}</span>?
|
||||||
|
</p>
|
||||||
|
<div className="flex justify-end gap-2 mt-4">
|
||||||
|
<button
|
||||||
|
className="btn btn-ghost"
|
||||||
|
onClick={() => setIsConfirmModalOpen(false)}
|
||||||
|
disabled={isSubmitting}
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className="btn btn-primary"
|
||||||
|
onClick={confirmStatusChange}
|
||||||
|
disabled={isSubmitting}
|
||||||
|
>
|
||||||
|
{isSubmitting ? (
|
||||||
|
<>
|
||||||
|
<span className="loading loading-spinner loading-xs"></span>
|
||||||
|
Updating...
|
||||||
|
</>
|
||||||
) : (
|
) : (
|
||||||
<span className="badge badge-ghost">No</span>
|
'Confirm'
|
||||||
|
)}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<div className="bg-base-300/20 p-4 rounded-lg">
|
|
||||||
<h4 className="text-sm font-medium text-gray-400 mb-1">Submission Date</h4>
|
|
||||||
<p>{formatDate(request.created)}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</motion.div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* PR Materials Tab */}
|
|
||||||
{activeTab === 'pr' && (
|
|
||||||
<motion.div
|
|
||||||
key="pr-tab"
|
|
||||||
initial="hidden"
|
|
||||||
animate="visible"
|
|
||||||
exit={{ opacity: 0, y: -10 }}
|
|
||||||
variants={tabVariants}
|
|
||||||
>
|
|
||||||
<PRMaterialsTab request={request} />
|
|
||||||
</motion.div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* AS Funding Tab */}
|
|
||||||
{activeTab === 'funding' && (
|
|
||||||
<motion.div
|
|
||||||
key="funding-tab"
|
|
||||||
initial="hidden"
|
|
||||||
animate="visible"
|
|
||||||
exit={{ opacity: 0, y: -10 }}
|
|
||||||
variants={tabVariants}
|
|
||||||
>
|
|
||||||
<ASFundingTab request={request} />
|
|
||||||
</motion.div>
|
|
||||||
)}
|
|
||||||
</AnimatePresence>
|
|
||||||
</div>
|
|
||||||
</motion.div>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -221,21 +221,21 @@ const EventRequestManagementTable = ({
|
||||||
if (request.expand?.requested_user) {
|
if (request.expand?.requested_user) {
|
||||||
const user = request.expand.requested_user;
|
const user = request.expand.requested_user;
|
||||||
// Show "Loading..." instead of "Unknown" while data is being fetched
|
// Show "Loading..." instead of "Unknown" while data is being fetched
|
||||||
const name = user.name || 'Unknown';
|
const name = user.name || 'Loading...';
|
||||||
// Always show email regardless of emailVisibility
|
// Always show email regardless of emailVisibility
|
||||||
const email = user.email || 'Unknown';
|
const email = user.email || 'Loading...';
|
||||||
return { name, email };
|
return { name, email };
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then try the requested_user_expand
|
// Then try the requested_user_expand
|
||||||
if (request.requested_user_expand) {
|
if (request.requested_user_expand) {
|
||||||
const name = request.requested_user_expand.name || 'Unknown';
|
const name = request.requested_user_expand.name || 'Loading...';
|
||||||
const email = request.requested_user_expand.email || 'Unknown';
|
const email = request.requested_user_expand.email || 'Loading...';
|
||||||
return { name, email };
|
return { name, email };
|
||||||
}
|
}
|
||||||
|
|
||||||
// Last fallback - don't use "Unknown" to avoid confusing users
|
// Last fallback - don't use "Unknown" to avoid confusing users
|
||||||
return { name: 'Unknown', email: '(Unknown)' };
|
return { name: 'Loading...', email: 'Loading...' };
|
||||||
};
|
};
|
||||||
|
|
||||||
// Update openDetailModal to call the prop function
|
// Update openDetailModal to call the prop function
|
||||||
|
@ -317,13 +317,13 @@ const EventRequestManagementTable = ({
|
||||||
initial={{ opacity: 0, y: 10 }}
|
initial={{ opacity: 0, y: 10 }}
|
||||||
animate={{ opacity: 1, y: 0 }}
|
animate={{ opacity: 1, y: 0 }}
|
||||||
transition={{ duration: 0.3 }}
|
transition={{ duration: 0.3 }}
|
||||||
className="bg-base-200 rounded-xl p-8 text-center shadow-sm"
|
className="bg-gradient-to-b from-base-200 to-base-300 rounded-xl p-8 text-center shadow-sm border border-base-300/30"
|
||||||
>
|
>
|
||||||
<div className="flex flex-col items-center justify-center py-6">
|
<div className="flex flex-col items-center justify-center py-6">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" className="h-16 w-16 text-base-content/30 mb-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
<svg xmlns="http://www.w3.org/2000/svg" className="h-16 w-16 text-base-content/30 mb-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2" />
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2" />
|
||||||
</svg>
|
</svg>
|
||||||
<h3 className="text-xl font-semibold mb-3">No Event Requests Found</h3>
|
<h3 className="text-xl font-semibold mb-3 text-white">No Event Requests Found</h3>
|
||||||
<p className="text-base-content/60 mb-6 max-w-md">
|
<p className="text-base-content/60 mb-6 max-w-md">
|
||||||
{statusFilter !== 'all' || searchTerm
|
{statusFilter !== 'all' || searchTerm
|
||||||
? 'No event requests match your current filters. Try adjusting your search criteria.'
|
? 'No event requests match your current filters. Try adjusting your search criteria.'
|
||||||
|
@ -331,7 +331,7 @@ const EventRequestManagementTable = ({
|
||||||
</p>
|
</p>
|
||||||
<div className="flex gap-3">
|
<div className="flex gap-3">
|
||||||
<button
|
<button
|
||||||
className="btn btn-outline btn-sm gap-2"
|
className="btn btn-primary btn-outline btn-sm gap-2"
|
||||||
onClick={refreshEventRequests}
|
onClick={refreshEventRequests}
|
||||||
disabled={isRefreshing}
|
disabled={isRefreshing}
|
||||||
>
|
>
|
||||||
|
@ -351,7 +351,7 @@ const EventRequestManagementTable = ({
|
||||||
</button>
|
</button>
|
||||||
{(statusFilter !== 'all' || searchTerm) && (
|
{(statusFilter !== 'all' || searchTerm) && (
|
||||||
<button
|
<button
|
||||||
className="btn btn-outline btn-sm gap-2"
|
className="btn btn-ghost btn-sm gap-2"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setStatusFilter('all');
|
setStatusFilter('all');
|
||||||
setSearchTerm('');
|
setSearchTerm('');
|
||||||
|
@ -378,18 +378,18 @@ const EventRequestManagementTable = ({
|
||||||
style={{ minHeight: "500px" }}
|
style={{ minHeight: "500px" }}
|
||||||
>
|
>
|
||||||
{/* Filters and controls */}
|
{/* Filters and controls */}
|
||||||
<div className="flex flex-col lg:flex-row justify-between items-start lg:items-center gap-4 mb-4">
|
<div className="flex flex-col lg:flex-row justify-between items-start lg:items-center gap-4 p-4 bg-base-300/50 rounded-lg border border-base-100/10 mb-6">
|
||||||
<div className="flex flex-col sm:flex-row items-start sm:items-center gap-4 w-full lg:w-auto">
|
<div className="flex flex-col sm:flex-row items-start sm:items-center gap-4 w-full lg:w-auto">
|
||||||
<div className="form-control w-full sm:w-auto">
|
<div className="form-control w-full sm:w-auto">
|
||||||
<div className="input-group">
|
<div className="input-group">
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Search events..."
|
placeholder="Search events..."
|
||||||
className="input input-bordered w-full sm:w-64"
|
className="input input-bordered focus:border-primary w-full sm:w-64"
|
||||||
value={searchTerm}
|
value={searchTerm}
|
||||||
onChange={(e) => setSearchTerm(e.target.value)}
|
onChange={(e) => setSearchTerm(e.target.value)}
|
||||||
/>
|
/>
|
||||||
<button className="btn btn-square">
|
<button className="btn btn-square bg-primary/10 border-primary/20 text-primary hover:bg-primary/20">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" className="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
<svg xmlns="http://www.w3.org/2000/svg" className="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
|
||||||
</svg>
|
</svg>
|
||||||
|
@ -397,7 +397,7 @@ const EventRequestManagementTable = ({
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<select
|
<select
|
||||||
className="select select-bordered w-full sm:w-auto"
|
className="select select-bordered focus:border-primary w-full sm:w-auto"
|
||||||
value={statusFilter}
|
value={statusFilter}
|
||||||
onChange={(e) => setStatusFilter(e.target.value)}
|
onChange={(e) => setStatusFilter(e.target.value)}
|
||||||
>
|
>
|
||||||
|
@ -412,7 +412,7 @@ const EventRequestManagementTable = ({
|
||||||
{filteredRequests.length} {filteredRequests.length === 1 ? 'request' : 'requests'} found
|
{filteredRequests.length} {filteredRequests.length === 1 ? 'request' : 'requests'} found
|
||||||
</span>
|
</span>
|
||||||
<button
|
<button
|
||||||
className="btn btn-outline btn-sm gap-2"
|
className="btn btn-primary btn-outline btn-sm gap-2"
|
||||||
onClick={refreshEventRequests}
|
onClick={refreshEventRequests}
|
||||||
disabled={isRefreshing}
|
disabled={isRefreshing}
|
||||||
>
|
>
|
||||||
|
@ -435,49 +435,49 @@ const EventRequestManagementTable = ({
|
||||||
|
|
||||||
{/* Event requests table */}
|
{/* Event requests table */}
|
||||||
<div
|
<div
|
||||||
className="rounded-xl shadow-sm overflow-x-auto"
|
className="rounded-xl shadow-sm overflow-x-auto bg-base-100/10 border border-base-100/20"
|
||||||
style={{
|
style={{
|
||||||
maxHeight: "unset",
|
maxHeight: "unset",
|
||||||
height: "auto"
|
height: "auto"
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<table className="table table-zebra w-full">
|
<table className="table table-zebra w-full">
|
||||||
<thead className="bg-base-300/50">
|
<thead className="bg-base-300/50 sticky top-0 z-10">
|
||||||
<tr>
|
<tr>
|
||||||
<th
|
<th
|
||||||
className="cursor-pointer hover:bg-base-300"
|
className="cursor-pointer hover:bg-base-300 transition-colors"
|
||||||
onClick={() => handleSortChange('name')}
|
onClick={() => handleSortChange('name')}
|
||||||
>
|
>
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1">
|
||||||
Event Name
|
Event Name
|
||||||
{sortField === 'name' && (
|
{sortField === 'name' && (
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" className="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
<svg xmlns="http://www.w3.org/2000/svg" className="h-4 w-4 text-primary" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d={sortDirection === 'asc' ? "M5 15l7-7 7 7" : "M19 9l-7 7-7-7"} />
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d={sortDirection === 'asc' ? "M5 15l7-7 7 7" : "M19 9l-7 7-7-7"} />
|
||||||
</svg>
|
</svg>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</th>
|
</th>
|
||||||
<th
|
<th
|
||||||
className="cursor-pointer hover:bg-base-300 hidden md:table-cell"
|
className="cursor-pointer hover:bg-base-300 transition-colors hidden md:table-cell"
|
||||||
onClick={() => handleSortChange('start_date_time')}
|
onClick={() => handleSortChange('start_date_time')}
|
||||||
>
|
>
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1">
|
||||||
Date
|
Date
|
||||||
{sortField === 'start_date_time' && (
|
{sortField === 'start_date_time' && (
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" className="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
<svg xmlns="http://www.w3.org/2000/svg" className="h-4 w-4 text-primary" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d={sortDirection === 'asc' ? "M5 15l7-7 7 7" : "M19 9l-7 7-7-7"} />
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d={sortDirection === 'asc' ? "M5 15l7-7 7 7" : "M19 9l-7 7-7-7"} />
|
||||||
</svg>
|
</svg>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</th>
|
</th>
|
||||||
<th
|
<th
|
||||||
className="cursor-pointer hover:bg-base-300"
|
className="cursor-pointer hover:bg-base-300 transition-colors"
|
||||||
onClick={() => handleSortChange('requested_user')}
|
onClick={() => handleSortChange('requested_user')}
|
||||||
>
|
>
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1">
|
||||||
Requested By
|
Requested By
|
||||||
{sortField === 'requested_user' && (
|
{sortField === 'requested_user' && (
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" className="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
<svg xmlns="http://www.w3.org/2000/svg" className="h-4 w-4 text-primary" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d={sortDirection === 'asc' ? "M5 15l7-7 7 7" : "M19 9l-7 7-7-7"} />
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d={sortDirection === 'asc' ? "M5 15l7-7 7 7" : "M19 9l-7 7-7-7"} />
|
||||||
</svg>
|
</svg>
|
||||||
)}
|
)}
|
||||||
|
@ -486,26 +486,26 @@ const EventRequestManagementTable = ({
|
||||||
<th className="hidden lg:table-cell">PR Materials</th>
|
<th className="hidden lg:table-cell">PR Materials</th>
|
||||||
<th className="hidden lg:table-cell">AS Funding</th>
|
<th className="hidden lg:table-cell">AS Funding</th>
|
||||||
<th
|
<th
|
||||||
className="cursor-pointer hover:bg-base-300 hidden md:table-cell"
|
className="cursor-pointer hover:bg-base-300 transition-colors hidden md:table-cell"
|
||||||
onClick={() => handleSortChange('created')}
|
onClick={() => handleSortChange('created')}
|
||||||
>
|
>
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1">
|
||||||
Submitted
|
Submitted
|
||||||
{sortField === 'created' && (
|
{sortField === 'created' && (
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" className="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
<svg xmlns="http://www.w3.org/2000/svg" className="h-4 w-4 text-primary" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d={sortDirection === 'asc' ? "M5 15l7-7 7 7" : "M19 9l-7 7-7-7"} />
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d={sortDirection === 'asc' ? "M5 15l7-7 7 7" : "M19 9l-7 7-7-7"} />
|
||||||
</svg>
|
</svg>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</th>
|
</th>
|
||||||
<th
|
<th
|
||||||
className="cursor-pointer hover:bg-base-300"
|
className="cursor-pointer hover:bg-base-300 transition-colors"
|
||||||
onClick={() => handleSortChange('status')}
|
onClick={() => handleSortChange('status')}
|
||||||
>
|
>
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1">
|
||||||
Status
|
Status
|
||||||
{sortField === 'status' && (
|
{sortField === 'status' && (
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" className="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
<svg xmlns="http://www.w3.org/2000/svg" className="h-4 w-4 text-primary" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d={sortDirection === 'asc' ? "M5 15l7-7 7 7" : "M19 9l-7 7-7-7"} />
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d={sortDirection === 'asc' ? "M5 15l7-7 7 7" : "M19 9l-7 7-7-7"} />
|
||||||
</svg>
|
</svg>
|
||||||
)}
|
)}
|
||||||
|
@ -516,7 +516,7 @@ const EventRequestManagementTable = ({
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{filteredRequests.map((request) => (
|
{filteredRequests.map((request) => (
|
||||||
<tr key={request.id} className="hover">
|
<tr key={request.id} className="hover transition-colors">
|
||||||
<td className="font-medium">
|
<td className="font-medium">
|
||||||
<div className="truncate max-w-[180px] md:max-w-[250px]" title={request.name}>
|
<div className="truncate max-w-[180px] md:max-w-[250px]" title={request.name}>
|
||||||
{truncateText(request.name, 30)}
|
{truncateText(request.name, 30)}
|
||||||
|
@ -551,20 +551,20 @@ const EventRequestManagementTable = ({
|
||||||
<td className="hidden md:table-cell">{formatDate(request.created)}</td>
|
<td className="hidden md:table-cell">{formatDate(request.created)}</td>
|
||||||
<td>
|
<td>
|
||||||
<span className={`badge ${getStatusBadge(request.status)}`}>
|
<span className={`badge ${getStatusBadge(request.status)}`}>
|
||||||
{request.status || 'Pending'}
|
{request.status?.charAt(0).toUpperCase() + request.status?.slice(1) || 'Pending'}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<button
|
<button
|
||||||
className="btn btn-sm btn-ghost"
|
className="btn btn-sm btn-primary btn-outline btn-sm gap-2"
|
||||||
onClick={() => openDetailModal(request)}
|
onClick={() => openDetailModal(request)}
|
||||||
>
|
>
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" className="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
<svg xmlns="http://www.w3.org/2000/svg" className="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" />
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" />
|
||||||
</svg>
|
</svg>
|
||||||
View Details
|
View
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect, useLayoutEffect } from 'react';
|
||||||
import { motion, AnimatePresence } from 'framer-motion';
|
import { motion, AnimatePresence } from 'framer-motion';
|
||||||
import EventRequestDetails from './EventRequestDetails';
|
import EventRequestDetails from './EventRequestDetails';
|
||||||
import EventRequestManagementTable from './EventRequestManagementTable';
|
import EventRequestManagementTable from './EventRequestManagementTable';
|
||||||
|
@ -132,6 +132,50 @@ const EventRequestModal: React.FC<EventRequestModalProps> = ({ eventRequests })
|
||||||
const [localEventRequests, setLocalEventRequests] = useState<ExtendedEventRequest[]>(eventRequests);
|
const [localEventRequests, setLocalEventRequests] = useState<ExtendedEventRequest[]>(eventRequests);
|
||||||
const [isLoadingUserData, setIsLoadingUserData] = useState(true); // Start as true to show loading immediately
|
const [isLoadingUserData, setIsLoadingUserData] = useState(true); // Start as true to show loading immediately
|
||||||
|
|
||||||
|
// Fix scrollbar flashing when modal opens/closes
|
||||||
|
useLayoutEffect(() => {
|
||||||
|
const originalStyle = window.getComputedStyle(document.body).overflow;
|
||||||
|
const originalPaddingRight = window.getComputedStyle(document.body).paddingRight;
|
||||||
|
|
||||||
|
if (isModalOpen) {
|
||||||
|
// Store scroll position
|
||||||
|
const scrollY = window.scrollY;
|
||||||
|
|
||||||
|
// Measure the scrollbar width
|
||||||
|
const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
|
||||||
|
|
||||||
|
// Add padding to prevent layout shift
|
||||||
|
document.body.style.paddingRight = `${scrollbarWidth}px`;
|
||||||
|
|
||||||
|
// Prevent body scroll
|
||||||
|
document.body.style.overflow = 'hidden';
|
||||||
|
document.body.style.position = 'fixed';
|
||||||
|
document.body.style.top = `-${scrollY}px`;
|
||||||
|
document.body.style.width = '100%';
|
||||||
|
} else {
|
||||||
|
// Restore scrolling
|
||||||
|
const scrollY = document.body.style.top;
|
||||||
|
document.body.style.overflow = originalStyle;
|
||||||
|
document.body.style.position = '';
|
||||||
|
document.body.style.top = '';
|
||||||
|
document.body.style.width = '';
|
||||||
|
document.body.style.paddingRight = originalPaddingRight;
|
||||||
|
|
||||||
|
if (scrollY) {
|
||||||
|
window.scrollTo(0, parseInt(scrollY || '0') * -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
// Clean up
|
||||||
|
document.body.style.overflow = originalStyle;
|
||||||
|
document.body.style.position = '';
|
||||||
|
document.body.style.top = '';
|
||||||
|
document.body.style.width = '';
|
||||||
|
document.body.style.paddingRight = originalPaddingRight;
|
||||||
|
};
|
||||||
|
}, [isModalOpen]);
|
||||||
|
|
||||||
// Function to refresh user data
|
// Function to refresh user data
|
||||||
const refreshUserDataAndUpdate = async (requests: ExtendedEventRequest[] = localEventRequests) => {
|
const refreshUserDataAndUpdate = async (requests: ExtendedEventRequest[] = localEventRequests) => {
|
||||||
setIsLoadingUserData(true);
|
setIsLoadingUserData(true);
|
||||||
|
@ -282,33 +326,14 @@ const EventRequestModal: React.FC<EventRequestModalProps> = ({ eventRequests })
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* Table component placed here */}
|
{/* Table component with modernized UI */}
|
||||||
<div
|
<div
|
||||||
className="bg-base-200 rounded-xl shadow-xl overflow-hidden dashboard-card card-enter event-table-container"
|
className="bg-gradient-to-b from-base-200 to-base-300 rounded-xl shadow-xl overflow-hidden dashboard-card card-enter event-table-container border border-base-300/30"
|
||||||
style={{ animationDelay: ANIMATION_DELAY }}
|
style={{ animationDelay: ANIMATION_DELAY }}
|
||||||
>
|
>
|
||||||
<div className="p-4 md:p-6 h-auto">
|
<div className="p-4 md:p-6 h-auto">
|
||||||
<div className="flex justify-between items-center mb-4">
|
|
||||||
{isLoadingUserData ? (
|
<div id="event-request-table-container" className="relative">
|
||||||
<div className="flex items-center">
|
|
||||||
<div className="loading loading-spinner loading-sm mr-2"></div>
|
|
||||||
<span className="text-sm text-gray-400">Loading user data...</span>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<div></div>
|
|
||||||
)}
|
|
||||||
<button
|
|
||||||
className="btn btn-sm btn-ghost"
|
|
||||||
onClick={() => refreshUserDataAndUpdate()}
|
|
||||||
disabled={isLoadingUserData}
|
|
||||||
>
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" className="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" />
|
|
||||||
</svg>
|
|
||||||
Refresh User Data
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<div id="event-request-table-container">
|
|
||||||
<TableWrapper
|
<TableWrapper
|
||||||
eventRequests={localEventRequests}
|
eventRequests={localEventRequests}
|
||||||
handleSelectRequest={handleSelectRequest}
|
handleSelectRequest={handleSelectRequest}
|
||||||
|
@ -318,20 +343,28 @@ const EventRequestModal: React.FC<EventRequestModalProps> = ({ eventRequests })
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Modal */}
|
{/* Modal with improved styling */}
|
||||||
<AnimatePresence>
|
<AnimatePresence>
|
||||||
{isModalOpen && selectedRequest && (
|
{isModalOpen && selectedRequest && (
|
||||||
<motion.div
|
<motion.div
|
||||||
initial={{ opacity: 0 }}
|
initial={{ opacity: 0 }}
|
||||||
animate={{ opacity: 1 }}
|
animate={{ opacity: 1 }}
|
||||||
exit={{ opacity: 0 }}
|
exit={{ opacity: 0 }}
|
||||||
className="fixed inset-0 bg-black/70 backdrop-blur-sm z-[200] flex items-center justify-center p-4 overflow-y-auto"
|
className="fixed inset-0 bg-black/70 backdrop-blur-sm z-[200]"
|
||||||
>
|
>
|
||||||
<div className="w-full max-w-5xl max-h-[90vh] overflow-y-auto relative">
|
<div className="flex items-center justify-center min-h-screen p-4 overflow-hidden">
|
||||||
<div className="absolute top-4 right-4 z-[201]">
|
<motion.div
|
||||||
|
initial={{ scale: 0.95, opacity: 0 }}
|
||||||
|
animate={{ scale: 1, opacity: 1 }}
|
||||||
|
exit={{ scale: 0.95, opacity: 0 }}
|
||||||
|
transition={{ type: "spring", damping: 25, stiffness: 300 }}
|
||||||
|
className="w-full max-w-5xl max-h-[90vh] overflow-y-auto bg-gradient-to-b from-base-200 to-base-300 rounded-xl shadow-2xl border border-base-100/20 relative"
|
||||||
|
>
|
||||||
|
<div className="sticky top-0 right-0 z-[201] flex justify-between items-center p-4 bg-base-300/80 backdrop-blur-md border-b border-base-100/10">
|
||||||
|
<h2 className="text-xl font-bold text-white">{selectedRequest.name}</h2>
|
||||||
<button
|
<button
|
||||||
onClick={closeModal}
|
onClick={closeModal}
|
||||||
className="btn btn-circle btn-sm bg-base-300/90 hover:bg-base-300"
|
className="btn btn-circle btn-sm bg-base-100/20 hover:bg-base-100/40 border-none text-white"
|
||||||
>
|
>
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" className="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
<svg xmlns="http://www.w3.org/2000/svg" className="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
|
||||||
|
@ -343,6 +376,7 @@ const EventRequestModal: React.FC<EventRequestModalProps> = ({ eventRequests })
|
||||||
onClose={closeModal}
|
onClose={closeModal}
|
||||||
onStatusChange={handleStatusChange}
|
onStatusChange={handleStatusChange}
|
||||||
/>
|
/>
|
||||||
|
</motion.div>
|
||||||
</div>
|
</div>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
)}
|
)}
|
||||||
|
|
Loading…
Reference in a new issue