Skip to content

Commit 5a95aee

Browse files
authored
Hackathon analytics (#381)
* fix: modify api.ts * fix: remove google auth buttom * fix: fixes responsive fixes on organization * fix: minor fixes * fix: modify create organization * fix: modify create organization * fix: fix organization permission * fix: merge into main * feat: hackathon overview page * feat: hackathon overview page * feat: implement participant overview * feat: implement participant overview * feat: implement resources tab * feat: implement the submission tab * feat: implement comment tab * fix: implement provider for hackathon * fix: implement provider for hackathon * fix: minor fixes * fix: hackathon banner * fix: hackathon banner * fix: fix organization page * fix: fix organization page * fix: use transform * fix: add tagline * fix: add tagline * fix: minor fixes * fix: minor fixes * fix: fix timeline and prizes * fix: correct timeline events * fix: implement registration deadline policy * fix: implement registration deadline policy * feat: implement leave hackathon * feat: implement leave hackathon * fix: delete hackathon * fix: implement invite participants * fix: implement participant profile viewing * feat: fetch participants team * fix: redesign hackathon banner * fix: fix hackthon card * fix: fix search bar in blog page * fix: fix search bar in blog page * fix: fix search bar in blog page * fix: fix error in fetching team posts * feat: implement create team, get my team * feat: implement create team, get my team * feat: implement hackathon project submission flow * feat: implement voting for submission * fix: team formation updates * fix: implement team invitation * feat: hackathon submissions bulk actions, ranking and ui refinements * fix: implement empty state for hackathons page * feat: Implement submission visibility and explore submissions * feat: Implement winners tab for hackathon winners display * feat: implement hackathon analytics * fix: fix coderabbit corrections * fix: fix coderabbit corrections * fix: fix coderabbit corrections * fix: fix organization settings data persistence, hackathondrafts and population
1 parent 498f96e commit 5a95aee

6 files changed

Lines changed: 46 additions & 27 deletions

File tree

app/(landing)/organizations/[id]/hackathons/[hackathonId]/page.tsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ export default function HackathonPage() {
2929
autoFetch: false,
3030
});
3131

32-
const { analytics, loading: analyticsLoading } = useHackathonAnalytics(
33-
organizationId,
34-
hackathonId
35-
);
32+
const {
33+
analytics,
34+
loading: analyticsLoading,
35+
error: analyticsError,
36+
} = useHackathonAnalytics(organizationId, hackathonId);
3637

3738
useEffect(() => {
3839
if (organizationId && hackathonId) {
@@ -113,6 +114,18 @@ export default function HackathonPage() {
113114
Analytics
114115
</h2>
115116
</div>
117+
{analyticsError && (
118+
<Alert
119+
variant='destructive'
120+
className='mb-6 border-red-900/20 bg-red-950/20'
121+
>
122+
<AlertCircle className='h-4 w-4' />
123+
<AlertTitle>Unable to load analytics</AlertTitle>
124+
<AlertDescription className='text-sm text-gray-400'>
125+
{analyticsError}
126+
</AlertDescription>
127+
</Alert>
128+
)}
116129
<HackathonStatistics
117130
statistics={statistics}
118131
loading={analyticsLoading}

components/organization/OrganizationSettings.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@ interface OrganizationSettingsProps {
1414
organizationId?: string;
1515
initialData?: {
1616
name?: string;
17+
slug?: string;
1718
logo?: string;
18-
tagline?: string;
19-
about?: string;
19+
metadata?: {
20+
tagline?: string;
21+
about?: string;
22+
};
2023
};
2124
isCreating?: boolean;
2225
}

components/organization/hackathons/new/NewHackathonTab.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ export default function NewHackathonTab({
213213

214214
if (isLoadingDraft) {
215215
return (
216-
<div className='bg-background-main-bg flex flex-1 items-center justify-center text-white'>
216+
<div className='bg-background-main-bg flex min-h-[60vh] flex-1 items-center justify-center text-white'>
217217
<div className='flex flex-col items-center gap-4'>
218218
<div className='border-primary h-8 w-8 animate-spin rounded-full border-2 border-t-transparent' />
219219
<span className='text-sm text-gray-400'>Loading draft...</span>
@@ -224,7 +224,7 @@ export default function NewHackathonTab({
224224

225225
if (currentError) {
226226
return (
227-
<div className='bg-background-main-bg flex flex-1 items-center justify-center text-white'>
227+
<div className='bg-background-main-bg flex min-h-[60vh] flex-1 items-center justify-center text-white'>
228228
<div className='flex flex-col items-center gap-4'>
229229
<span className='text-sm text-red-400'>{currentError}</span>
230230
</div>

components/organization/tabs/ProfileTab.tsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,18 +172,23 @@ export default function ProfileTab({
172172
const previousOrgId = previousOrgIdRef.current;
173173

174174
if (currentOrgId && currentOrgId !== previousOrgId) {
175+
// Find links either top-level or in metadata
176+
const activeLinks =
177+
activeOrg.links || (activeOrg as any).metadata?.links;
178+
175179
setFormData({
176180
name: activeOrg.name || '',
177181
slug: activeOrg.slug || '',
178182
logo: activeOrg.logo || '',
179183
metadata: {
180-
tagline: activeOrg.metadata?.tagline || '',
181-
about: activeOrg.metadata?.about || '',
184+
tagline:
185+
activeOrg.tagline || (activeOrg as any).metadata?.tagline || '',
186+
about: activeOrg.about || (activeOrg as any).metadata?.about || '',
182187
links: {
183-
website: activeOrg.metadata?.links?.website || '',
184-
x: activeOrg.metadata?.links?.x || '',
185-
github: activeOrg.metadata?.links?.github || '',
186-
others: activeOrg.metadata?.links?.others || '',
188+
website: activeLinks?.website || '',
189+
x: activeLinks?.x || '',
190+
github: activeLinks?.github || '',
191+
others: activeLinks?.others || '',
187192
},
188193
},
189194
});
@@ -576,7 +581,7 @@ export default function ProfileTab({
576581
</label>
577582

578583
<div className='flex items-start gap-2 rounded-lg bg-zinc-900/30 p-3 text-xs text-zinc-500'>
579-
<AlertCircle className='h-4 w-4 flex-shrink-0 text-zinc-600' />
584+
<AlertCircle className='h-4 w-4 shrink-0 text-zinc-600' />
580585
<div className='space-y-1'>
581586
<p>JPEG or PNG, max 2MB</p>
582587
<p>Recommended: 480 × 480 px</p>
@@ -625,7 +630,7 @@ export default function ProfileTab({
625630
<div className='space-y-3 pt-2'>
626631
{hasUserChanges && !isCreating && (
627632
<div className='flex items-center gap-2 rounded-lg border border-amber-900/50 bg-amber-500/5 px-3 py-2 text-sm text-amber-500'>
628-
<div className='h-2 w-2 flex-shrink-0 rounded-full bg-amber-500' />
633+
<div className='h-2 w-2 shrink-0 rounded-full bg-amber-500' />
629634
<span>You have unsaved changes</span>
630635
</div>
631636
)}

hooks/use-hackathons.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,8 @@ export function useHackathons(
280280
totalPages: response.meta.pagination.totalPages,
281281
totalItems: response.meta.pagination.total,
282282
itemsPerPage: response.meta.pagination.limit,
283-
hasNext: false, // Not provided in this pagination structure
284-
hasPrev: false, // Not provided in this pagination structure
283+
hasNext: false,
284+
hasPrev: false,
285285
}
286286
: {
287287
currentPage: 1,
@@ -415,16 +415,14 @@ export function useHackathons(
415415
data,
416416
autoSave
417417
);
418-
if (response.data && response.data.data) {
418+
if (response.data) {
419419
setDrafts(prev =>
420-
prev.map(draft =>
421-
draft.id === draftId ? response.data!.data : draft
422-
)
420+
prev.map(draft => (draft.id === draftId ? response.data! : draft))
423421
);
424422
if (currentDraft?.id === draftId) {
425-
setCurrentDraft(response.data.data);
423+
setCurrentDraft(response.data);
426424
}
427-
return response.data.data;
425+
return response.data;
428426
} else {
429427
throw new Error('No draft data received');
430428
}

lib/api/hackathons.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,7 +1158,7 @@ export const updateDraftStep = async (
11581158
data: any,
11591159
autoSave?: boolean
11601160
) => {
1161-
const res = await api.patch<ApiResponse<UpdateDraftResponse>>(
1161+
const res = await api.patch<UpdateDraftResponse>(
11621162
`/organizations/${organizationId}/hackathons/draft/${draftId}`,
11631163
{
11641164
step,
@@ -1191,11 +1191,11 @@ export const getDraft = async (
11911191
organizationId: string,
11921192
draftId: string
11931193
): Promise<GetDraftResponse> => {
1194-
const res = await api.get<ApiResponse<GetDraftResponse>>(
1194+
const res = await api.get<GetDraftResponse>(
11951195
`/organizations/${organizationId}/hackathons/draft/${draftId}`
11961196
);
11971197

1198-
return res.data.data as GetDraftResponse;
1198+
return res.data;
11991199
};
12001200

12011201
/**

0 commit comments

Comments
 (0)