Removed the syncing with firestore

This commit is contained in:
2026-06-19 13:53:36 +05:30
parent ee81ca9228
commit 9a575a126a
7 changed files with 60 additions and 6 deletions

View File

@@ -414,8 +414,7 @@ export const StudentDashboard: React.FC = () => {
if (isLoading) { if (isLoading) {
return ( return (
<div className="min-h-screen bg-slate-50 flex flex-col items-center justify-center"> <div className="min-h-screen bg-slate-50 flex flex-col items-center justify-center">
<div className="animate-spin rounded-full h-12 w-12 border-b-2 border-[#f97316] mb-4"></div> <div className="animate-spin rounded-full h-12 w-12 border-b-2 border-[#f97316]"></div>
<p className="text-xs font-black uppercase tracking-widest text-slate-400">Syncing with Firestore Database...</p>
</div> </div>
); );
} }

View File

@@ -439,7 +439,7 @@ export const StudentRegistrationsView: React.FC = () => {
disabled={isProcessing} disabled={isProcessing}
className="px-6 py-2.5 bg-brand-navy text-white rounded-xl font-black text-[10px] uppercase tracking-widest hover:scale-[1.02] transition-all shadow-md" className="px-6 py-2.5 bg-brand-navy text-white rounded-xl font-black text-[10px] uppercase tracking-widest hover:scale-[1.02] transition-all shadow-md"
> >
{isProcessing ? 'Syncing...' : 'Save Attendance'} {isProcessing ? 'Saving...' : 'Save Attendance'}
</button> </button>
</div> </div>

View File

@@ -499,7 +499,7 @@ const StatusTrackerView: React.FC<StatusTrackerViewProps> = ({ event, registrati
isUploading ? 'bg-gray-200 text-gray-400 cursor-wait' : 'bg-[#1A202C] text-white hover:bg-black' isUploading ? 'bg-gray-200 text-gray-400 cursor-wait' : 'bg-[#1A202C] text-white hover:bg-black'
}`} }`}
> >
{isUploading ? <><i className="fas fa-spinner fa-spin"></i> SYNCING...</> : {isUploading ? <><i className="fas fa-spinner fa-spin"></i> UPLOADING...</> :
liveCertStatus === 'APPROVED' ? <><i className="fas fa-check-double"></i> VERIFIED</> : liveCertStatus === 'APPROVED' ? <><i className="fas fa-check-double"></i> VERIFIED</> :
liveCertUrl ? <><i className="fas fa-clock"></i> RE-UPLOAD PROOF</> : liveCertUrl ? <><i className="fas fa-clock"></i> RE-UPLOAD PROOF</> :
<><i className="fas fa-cloud-arrow-up"></i> UPLOAD PROOF</>} <><i className="fas fa-cloud-arrow-up"></i> UPLOAD PROOF</>}

View File

@@ -732,6 +732,15 @@ const App: React.FC = () => {
return; 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 // Try to fetch from Studentusers first, then externalusers
let student = null; let student = null;
const { data: internalStudent } = await supabase.from('Studentusers').select('*').eq('id', user.id).single(); const { data: internalStudent } = await supabase.from('Studentusers').select('*').eq('id', user.id).single();

View File

@@ -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 => ({ const mapDBRowToEvent = (row: any): Event => ({
...row, ...row,
registrationDeadline: row.registration_deadline, registrationDeadline: row.registration_deadline,
@@ -88,7 +104,7 @@ const CreateEventForm: React.FC<CreateEventFormProps> = ({ onCancel, onSuccess,
coordinator: eventToEdit?.coordinator || '', coordinator: eventToEdit?.coordinator || '',
club: eventToEdit?.club || '', club: eventToEdit?.club || '',
image: eventToEdit?.image || '', image: eventToEdit?.image || '',
registrationDeadline: eventToEdit?.registrationDeadline || '', registrationDeadline: eventToEdit?.registrationDeadline ? parseDateTimeForInput(eventToEdit.registrationDeadline) : '',
maxParticipants: eventToEdit?.maxParticipants?.toString() || '', maxParticipants: eventToEdit?.maxParticipants?.toString() || '',
durationDays: eventToEdit?.durationDays?.toString() || '1', durationDays: eventToEdit?.durationDays?.toString() || '1',
event_summary: eventToEdit?.event_summary || '', event_summary: eventToEdit?.event_summary || '',
@@ -347,6 +363,23 @@ const CreateEventForm: React.FC<CreateEventFormProps> = ({ onCancel, onSuccess,
return; 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); setIsSubmitting(true);
try { try {
// Keep Base64 string directly in the database, ignoring Firebase/Supabase storage // 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="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="grid grid-cols-1 md:grid-cols-2 gap-6">
<div className="space-y-2"> <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 })} /> <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>
<div className="space-y-2"> <div className="space-y-2">

View File

@@ -193,6 +193,19 @@ const EventCard: React.FC<EventCardProps> = ({ event, isBooked, onToggle, onTrac
<i className="far fa-calendar-alt w-4 text-[#f97316]"></i> <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> <span>{event.date}{event.schedule?.[0]?.start_time ? `${event.schedule[0].start_time}` : ''}</span>
</div> </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 && ( {event.durationDays && event.durationDays > 1 && (
<div className="flex items-center gap-4"> <div className="flex items-center gap-4">
<i className="fas fa-hourglass-half w-4 text-[#f97316]"></i> <i className="fas fa-hourglass-half w-4 text-[#f97316]"></i>

BIN
image.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB