Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion app/(landing)/hackathons/preview/[orgId]/[draftId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,15 @@ export default function DraftPreviewPage({ params }: PreviewPageProps) {
timezone: draft.data.timeline?.timezone || 'UTC',

startDate: draft.data.timeline?.startDate || '',
endDate: draft.data.timeline?.winnerAnnouncementDate || '',
endDate:
draft.data.timeline?.winnersAnnouncedAt ||
draft.data.timeline?.winnerAnnouncementDate ||
draft.data.timeline?.judgingEnd ||
draft.data.timeline?.judgingDate ||
draft.data.timeline?.judgingStart ||
draft.data.timeline?.submissionDeadline ||
draft.data.timeline?.startDate ||
'',
submissionDeadline: draft.data.timeline?.submissionDeadline || '',
registrationDeadline:
draft.data.participation?.registrationDeadline || '',
Expand Down
10 changes: 7 additions & 3 deletions app/(landing)/organizations/[id]/hackathons/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ const calculateDraftCompletion = (draft: HackathonDraft): number => {
draft.data.information?.categories,
draft.data.timeline?.startDate,
draft.data.timeline?.submissionDeadline,
draft.data.timeline?.judgingDate,
draft.data.timeline?.winnerAnnouncementDate,
draft.data.timeline?.judgingStart || draft.data.timeline?.judgingDate,
draft.data.timeline?.timezone,
draft.data.participation?.participantType,
draft.data.rewards?.prizeTiers?.length,
Expand Down Expand Up @@ -402,7 +401,12 @@ export default function HackathonsPage() {
? (hackathon as HackathonDraft).data.timeline
?.submissionDeadline ||
(hackathon as HackathonDraft).data.timeline
?.winnerAnnouncementDate
?.winnersAnnouncedAt ||
(hackathon as HackathonDraft).data.timeline
?.winnerAnnouncementDate ||
(hackathon as HackathonDraft).data.timeline?.judgingEnd ||
(hackathon as HackathonDraft).data.timeline?.judgingDate ||
(hackathon as HackathonDraft).data.timeline?.judgingStart
: (hackathon as Hackathon).submissionDeadline ||
(hackathon as Hackathon).endDate;
const totalPrize = isDraft
Expand Down
6 changes: 3 additions & 3 deletions app/sitemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getBlogPosts } from '@/lib/api/blog';
import { getHackathons } from '@/lib/api/hackathons';
import { getCrowdfundingProjects } from '@/features/projects/api';
import type { BlogPost } from '@/types/blog';
import type { Hackathon } from '@/types/hackathon/core';
import type { Hackathon as HackathonAPI } from '@/lib/api/hackathons';
import type { Crowdfunding } from '@/features/projects/types';

// Constants
Expand Down Expand Up @@ -173,14 +173,14 @@ async function fetchHackathonsSitemap(): Promise<MetadataRoute.Sitemap> {
}

return response.data.hackathons
.filter((hackathon: Hackathon) => {
.filter((hackathon: HackathonAPI) => {
// Validate required fields
if (!hackathon.slug) {
return false;
}
return true;
})
.map((hackathon: Hackathon) => ({
.map((hackathon: HackathonAPI) => ({
url: `${SITE_URL}/hackathons/${hackathon.slug}`,
lastModified: new Date(
hackathon.updatedAt || hackathon.publishedAt || new Date()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export default function NewHackathonTab({
onDraftLoadedRef.current = onDraftLoaded;
}, [onDraftLoaded]);

const { isPublishing, publish } = useHackathonPublish({
const { isPublishing, publish, publishResponse } = useHackathonPublish({
organizationId: derivedOrgId || '',
stepData,
draftId: draftId || '',
Expand Down Expand Up @@ -323,6 +323,7 @@ export default function NewHackathonTab({
isSavingDraft={isSavingDraft}
organizationId={derivedOrgId}
draftId={draftId}
publishResponse={publishResponse}
/>
</TabsContent>
</div>
Expand Down
19 changes: 14 additions & 5 deletions components/organization/hackathons/new/tabs/ReviewTab.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useState, useEffect } from 'react';
import { InfoFormData } from './schemas/infoSchema';
import { TimelineFormData } from './schemas/timelineSchema';
import { ParticipantFormData } from './schemas/participantSchema';
Expand All @@ -22,6 +22,7 @@ import { SectionRenderer } from './components/review/SectionRenderer';
import { usePrizePoolCalculations } from '@/hooks/use-prize-pool-calculations';
import { REVIEW_SECTION_CONFIG } from './constants/review-sections';
import { toast } from 'sonner';
import type { PublishResponseData } from '@/hooks/use-hackathon-publish';

interface ReviewTabProps {
allData: {
Expand All @@ -37,9 +38,9 @@ interface ReviewTabProps {
onSaveDraft?: () => Promise<void>;
isLoading?: boolean;
isSavingDraft?: boolean;
hackathonUrl?: string;
organizationId?: string;
draftId?: string | null;
publishResponse?: PublishResponseData | null;
}

export default function ReviewTab({
Expand All @@ -49,9 +50,9 @@ export default function ReviewTab({
onSaveDraft,
isLoading = false,
isSavingDraft = false,
hackathonUrl,
organizationId,
draftId,
publishResponse,
}: ReviewTabProps) {
const [showDraftModal, setShowDraftModal] = useState(false);
const [showPublishedModal, setShowPublishedModal] = useState(false);
Expand All @@ -60,11 +61,18 @@ export default function ReviewTab({
const { totalPrizePool, platformFee, totalFunding } =
usePrizePoolCalculations(allData.rewards);

// Show published modal only when we have a successful publish response
useEffect(() => {
if (publishResponse) {
setShowPublishedModal(true);
}
}, [publishResponse]);

const handlePublish = async () => {
try {
if (onPublish) {
await onPublish();
setShowPublishedModal(true);
// Modal will be shown automatically when publishResponse is set via useEffect
}
} catch {
// Error is handled in the hook, so we don't need to show another toast
Expand Down Expand Up @@ -154,7 +162,8 @@ export default function ReviewTab({
<HackathonPublishedModal
open={showPublishedModal}
onOpenChange={setShowPublishedModal}
hackathonUrl={hackathonUrl}
publishResponse={publishResponse}
organizationId={organizationId}
/>
</div>
);
Expand Down
Loading
Loading