Removed the syncing with firestore
This commit is contained in:
@@ -732,6 +732,15 @@ const App: React.FC = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
// Validate registration deadline
|
||||
if (targetEvent.registrationDeadline) {
|
||||
const deadline = new Date(targetEvent.registrationDeadline);
|
||||
if (new Date() > deadline) {
|
||||
alert("Registration Blocked: The registration deadline for this event has passed.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Try to fetch from Studentusers first, then externalusers
|
||||
let student = null;
|
||||
const { data: internalStudent } = await supabase.from('Studentusers').select('*').eq('id', user.id).single();
|
||||
|
||||
@@ -27,6 +27,22 @@ const CreateEventForm: React.FC<CreateEventFormProps> = ({ onCancel, onSuccess,
|
||||
}
|
||||
};
|
||||
|
||||
const parseDateTimeForInput = (dateStr?: string) => {
|
||||
if (!dateStr) return '';
|
||||
try {
|
||||
const date = new Date(dateStr);
|
||||
if (isNaN(date.getTime())) return '';
|
||||
const yyyy = date.getFullYear();
|
||||
const mm = String(date.getMonth() + 1).padStart(2, '0');
|
||||
const dd = String(date.getDate()).padStart(2, '0');
|
||||
const hh = String(date.getHours()).padStart(2, '0');
|
||||
const min = String(date.getMinutes()).padStart(2, '0');
|
||||
return `${yyyy}-${mm}-${dd}T${hh}:${min}`;
|
||||
} catch {
|
||||
return '';
|
||||
}
|
||||
};
|
||||
|
||||
const mapDBRowToEvent = (row: any): Event => ({
|
||||
...row,
|
||||
registrationDeadline: row.registration_deadline,
|
||||
@@ -88,7 +104,7 @@ const CreateEventForm: React.FC<CreateEventFormProps> = ({ onCancel, onSuccess,
|
||||
coordinator: eventToEdit?.coordinator || '',
|
||||
club: eventToEdit?.club || '',
|
||||
image: eventToEdit?.image || '',
|
||||
registrationDeadline: eventToEdit?.registrationDeadline || '',
|
||||
registrationDeadline: eventToEdit?.registrationDeadline ? parseDateTimeForInput(eventToEdit.registrationDeadline) : '',
|
||||
maxParticipants: eventToEdit?.maxParticipants?.toString() || '',
|
||||
durationDays: eventToEdit?.durationDays?.toString() || '1',
|
||||
event_summary: eventToEdit?.event_summary || '',
|
||||
@@ -347,6 +363,23 @@ const CreateEventForm: React.FC<CreateEventFormProps> = ({ onCancel, onSuccess,
|
||||
return;
|
||||
}
|
||||
|
||||
if (formData.registrationDeadline) {
|
||||
const deadline = new Date(formData.registrationDeadline);
|
||||
if (isNaN(deadline.getTime())) {
|
||||
alert("Please enter a valid registration deadline.");
|
||||
return;
|
||||
}
|
||||
if (!eventToEdit && deadline < new Date()) {
|
||||
alert("Validation Error: Registration deadline cannot be in the past.");
|
||||
return;
|
||||
}
|
||||
const eventStart = new Date(formData.dayConfigs[0]?.date || formData.date);
|
||||
if (!isNaN(eventStart.getTime()) && deadline > eventStart) {
|
||||
alert("Validation Error: Registration deadline cannot be after the event start date.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
setIsSubmitting(true);
|
||||
try {
|
||||
// Keep Base64 string directly in the database, ignoring Firebase/Supabase storage
|
||||
@@ -869,7 +902,7 @@ const CreateEventForm: React.FC<CreateEventFormProps> = ({ onCancel, onSuccess,
|
||||
<div className="bg-slate-50/50 border border-slate-100 rounded-3xl p-8 space-y-8">
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<div className="space-y-2">
|
||||
<label className="text-[9px] font-black text-slate-400 uppercase tracking-widest px-1">Closing Deadline</label>
|
||||
<label className="text-[9px] font-black text-slate-400 uppercase tracking-widest px-1">Registration Closing Deadline</label>
|
||||
<input type="datetime-local" className="w-full bg-white border border-slate-200 rounded-2xl px-6 py-4 text-slate-900 font-bold text-sm outline-none shadow-sm" value={formData.registrationDeadline} onChange={e => setFormData({ ...formData, registrationDeadline: e.target.value })} />
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
|
||||
@@ -193,6 +193,19 @@ const EventCard: React.FC<EventCardProps> = ({ event, isBooked, onToggle, onTrac
|
||||
<i className="far fa-calendar-alt w-4 text-[#f97316]"></i>
|
||||
<span>{event.date}{event.schedule?.[0]?.start_time ? ` • ${event.schedule[0].start_time}` : ''}</span>
|
||||
</div>
|
||||
{event.registrationDeadline && (
|
||||
<div className={`flex items-center gap-4 font-black ${admissionStatus === 'DEADLINE_PASSED' ? 'text-rose-600 animate-pulse' : 'text-emerald-600'}`}>
|
||||
<i className="fas fa-clock w-4 text-[#f97316]"></i>
|
||||
<span>
|
||||
{admissionStatus === 'DEADLINE_PASSED' ? 'Deadline Passed' : 'Register Before'}: {new Date(event.registrationDeadline).toLocaleDateString([], {
|
||||
month: 'short',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit'
|
||||
})}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
{event.durationDays && event.durationDays > 1 && (
|
||||
<div className="flex items-center gap-4">
|
||||
<i className="fas fa-hourglass-half w-4 text-[#f97316]"></i>
|
||||
|
||||
Reference in New Issue
Block a user