diff --git a/app/(landing)/hackathons/[slug]/page.tsx b/app/(landing)/hackathons/[slug]/page.tsx index 64533e606..60c8b8872 100644 --- a/app/(landing)/hackathons/[slug]/page.tsx +++ b/app/(landing)/hackathons/[slug]/page.tsx @@ -10,9 +10,9 @@ import { HackathonBanner } from '@/components/hackathons/hackathonBanner'; import { HackathonNavTabs } from '@/components/hackathons/hackathonNavTabs'; import { HackathonOverview } from '@/components/hackathons/overview/hackathonOverview'; import { HackathonParticipants } from '@/components/hackathons/participants/hackathonParticipant'; -import { HackathonResources } from '@/components/hackathons/resources/resources'; +// import { HackathonResources } from '@/components/hackathons/resources/resources'; import SubmissionTab from '@/components/hackathons/submissions/submissionTab'; -import { HackathonDiscussions } from '@/components/hackathons/discussion/comment'; +// import { HackathonDiscussions } from '@/components/hackathons/discussion/comment'; import { TeamFormationTab } from '@/components/hackathons/team-formation/TeamFormationTab'; import LoadingScreen from '@/components/landing-page/project/CreateProjectModal/LoadingScreen'; import { useTimelineEvents } from '@/hooks/hackathon/use-timeline-events'; @@ -33,18 +33,29 @@ export default function HackathonPage() { includeEndDate: false, dateFormat: { month: 'short', day: 'numeric', year: 'numeric' }, }); - const hackathonTabs = useMemo(() => { + const hasParticipants = participants.length > 0; + // const hasSubmissions = submissions.filter(p => p.status === 'Approved').length > 0; + const tabs = [ { id: 'overview', label: 'Overview' }, - { id: 'participants', label: 'Participants', badge: participants.length }, - { id: 'resources', label: 'Resources' }, + ...(hasParticipants + ? [ + { + id: 'participants', + label: 'Participants', + badge: participants.length, + }, + ] + : []), + // { id: 'resources', label: 'Resources' }, + { id: 'submission', label: 'Submissions', badge: submissions.filter(p => p.status === 'Approved').length, }, - { id: 'discussions', label: 'Discussions' }, + // { id: 'discussions', label: 'Discussions' }, ]; const participantType = currentHackathon?.participation?.participantType; @@ -77,7 +88,14 @@ export default function HackathonPage() { autoCheck: !!hackathonId, }); - const isEnded = currentHackathon?.status === 'ended'; + const isEnded = useMemo(() => { + if (!currentHackathon?.deadline) return false; + + const deadline = new Date(currentHackathon.deadline); + const now = new Date(); + + return now > deadline; + }, [currentHackathon?.deadline]); // Check if team formation is available const isTeamHackathon = @@ -180,6 +198,12 @@ export default function HackathonPage() { hackathonSlugOrId={hackathonId} organizationId={undefined} onSuccess={handleRegisterSuccess} + participantType={ + (currentHackathon?.participantType as + | 'team' + | 'individual' + | 'team_or_individual') ?? 'individual' + } /> )} @@ -202,19 +226,23 @@ export default function HackathonPage() { /> )} - {activeTab === 'participants' && } - - {activeTab === 'resources' && ( - + {activeTab === 'participants' && participants.length > 0 && ( + )} + {/* {activeTab === 'resources' && ( + + )} */} {activeTab === 'submission' && ( - + )} - {activeTab === 'discussions' && ( + {/* {activeTab === 'discussions' && ( - )} + )} */} {activeTab === 'team-formation' && ( diff --git a/app/(landing)/organizations/[id]/hackathons/[hackathonId]/page.tsx b/app/(landing)/organizations/[id]/hackathons/[hackathonId]/page.tsx index 8bf40e6ac..6727dd3a0 100644 --- a/app/(landing)/organizations/[id]/hackathons/[hackathonId]/page.tsx +++ b/app/(landing)/organizations/[id]/hackathons/[hackathonId]/page.tsx @@ -66,11 +66,11 @@ export default function HackathonPage() {

{currentHackathon?.title || 'Hackathon Dashboard'}

- {currentHackathon?.information?.description && ( + {/* {currentHackathon?.information?.description && (

{currentHackathon.information.description}

- )} + )} */} diff --git a/components/hackathons/HackathonsPageHero.tsx b/components/hackathons/HackathonsPageHero.tsx index 880692390..3790f4354 100644 --- a/components/hackathons/HackathonsPageHero.tsx +++ b/components/hackathons/HackathonsPageHero.tsx @@ -41,7 +41,7 @@ export default function HackathonsPageHero() { }; const handleCreateHackathon = () => { - router.push('/hackathons/create'); + router.push('/organizations'); }; return ( diff --git a/components/hackathons/hackathonBanner.tsx b/components/hackathons/hackathonBanner.tsx index f12b8776d..2ae7873ae 100644 --- a/components/hackathons/hackathonBanner.tsx +++ b/components/hackathons/hackathonBanner.tsx @@ -6,6 +6,8 @@ import { Button } from '@/components/ui/button'; import { formatDate } from '@/lib/utils'; import { useEffect, useState, useRef } from 'react'; import { FileText, Users, ArrowRight } from 'lucide-react'; +import { useAuthStatus } from '@/hooks/use-auth'; +import { useRouter } from 'next/navigation'; // import { sanitizeHtml } from '@/lib/utils/renderHtml'; interface HackathonBannerProps { @@ -139,6 +141,9 @@ export function HackathonBanner({ total: 0, }); + const { isAuthenticated } = useAuthStatus(); + const router = useRouter(); + const getStatusColor = () => { switch (status) { case 'Ongoing': @@ -157,6 +162,10 @@ export function HackathonBanner({ } }; + const handleRedirectToAuthScreen = () => { + router.push('/auth?mode=signin'); + }; + const getDeadlineInfo = () => { const days = timeRemaining.days; @@ -333,30 +342,59 @@ export function HackathonBanner({ )} {/* Action Buttons */} - {!isEnded && ( -
- {!isRegistered && onJoinClick && ( - - )} + {/* Action Buttons */} +
+ {/* Hackathon Ended → Disabled button */} + {isEnded && ( + + )} - {isRegistered && !hasSubmitted && onSubmitClick && ( - - )} + {/* Hackathon Ongoing → Not registered → Join */} + {!isEnded && !isRegistered && onJoinClick && ( + + )} + + {/* Hackathon Ongoing → Registered → Leave */} + {!isEnded && isRegistered && ( + + )} + + {/* Submit Project */} + {!isEnded && isRegistered && !hasSubmitted && onSubmitClick && ( + + )} - {isRegistered && hasSubmitted && onViewSubmissionClick && ( + {/* View Submission */} + {!isEnded && + isRegistered && + hasSubmitted && + onViewSubmissionClick && (
- )} +
diff --git a/components/hackathons/overview/RegisterHackathonModal.tsx b/components/hackathons/overview/RegisterHackathonModal.tsx index 72f0f24e1..99e57c597 100644 --- a/components/hackathons/overview/RegisterHackathonModal.tsx +++ b/components/hackathons/overview/RegisterHackathonModal.tsx @@ -24,10 +24,9 @@ import { Input } from '@/components/ui/input'; import { Button } from '@/components/ui/button'; import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group'; import { Label } from '@/components/ui/label'; -import { Users, User } from 'lucide-react'; +import { Users, User, Loader2 } from 'lucide-react'; import { useRegisterHackathon } from '@/hooks/hackathon/use-register-hackathon'; import { toast } from 'sonner'; -import { Loader2 } from 'lucide-react'; const registerSchema = z .object({ @@ -55,6 +54,7 @@ interface RegisterHackathonModalProps { onOpenChange: (open: boolean) => void; hackathonSlugOrId: string; organizationId?: string; + participantType: 'individual' | 'team' | 'team_or_individual'; onSuccess?: () => void; } @@ -63,6 +63,7 @@ export function RegisterHackathonModal({ onOpenChange, hackathonSlugOrId, organizationId, + participantType, onSuccess, }: RegisterHackathonModalProps) { const [teamMemberEmail, setTeamMemberEmail] = useState(''); @@ -78,21 +79,22 @@ export function RegisterHackathonModal({ const form = useForm({ resolver: zodResolver(registerSchema), defaultValues: { - participationType: 'individual', + participationType: participantType === 'team' ? 'team' : 'individual', teamName: '', teamMembers: [], }, }); - const participationType = form.watch('participationType'); + const selectedType = form.watch('participationType'); const handleAddTeamMember = () => { if ( teamMemberEmail.trim() && !teamMembers.includes(teamMemberEmail.trim()) ) { - setTeamMembers([...teamMembers, teamMemberEmail.trim()]); - form.setValue('teamMembers', [...teamMembers, teamMemberEmail.trim()]); + const updated = [...teamMembers, teamMemberEmail.trim()]; + setTeamMembers(updated); + form.setValue('teamMembers', updated); setTeamMemberEmail(''); } }; @@ -119,7 +121,7 @@ export function RegisterHackathonModal({ setTeamMemberEmail(''); onSuccess?.(); } catch { - // Error is already handled in the hook + // Error handled in hook } }; @@ -130,65 +132,79 @@ export function RegisterHackathonModal({ Register for Hackathon - - Choose how you want to participate in this hackathon - + {participantType === 'team_or_individual' && ( + + Choose how you want to participate in this hackathon + + )} + {participantType === 'individual' && ( + + Register to participate in this hackathon + + )} + {participantType === 'team' && ( + + Register your team for this hackathon + + )}
- ( - - - -
- -