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
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default function SettingsPage() {
name: 'Web3 Innovation Hackathon',
banner: 'https://example.com/banner.jpg',
description: '<p>Join us for an exciting hackathon...</p>',
category: 'DeFi',
category: ['DeFi' as const],
venueType: 'virtual' as const,
country: '',
state: '',
Expand Down
6 changes: 4 additions & 2 deletions components/organization/hackathons/new/tabs/InfoTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ export default function InfoTab({
banner: initialData?.banner || '',
description: initialData?.description || '',
category: Array.isArray(initialData?.category)
? (initialData.category[0] as string) || ''
: (initialData?.category as string) || '',
? initialData.category
: initialData?.category
? [initialData.category]
: [],
venueType: initialData?.venueType || 'physical',
country: initialData?.country || '',
state: initialData?.state || '',
Expand Down
38 changes: 18 additions & 20 deletions components/organization/hackathons/new/tabs/schemas/infoSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,24 @@ export const infoSchema = z
.max(5000, 'Description must be less than 5000 characters'),

category: z
.string()
.min(1, 'Category is required')
.refine(
val =>
[
'DeFi',
'NFTs',
'DAOs',
'Layer 2',
'Cross-chain',
'Web3 Gaming',
'Social Tokens',
'Infrastructure',
'Privacy',
'Sustainability',
'Real World Assets',
'Other',
].includes(val),
'Please select a valid category'
),
.array(
z.enum([
'DeFi',
'NFTs',
'DAOs',
'Layer 2',
'Cross-chain',
'Web3 Gaming',
'Social Tokens',
'Infrastructure',
'Privacy',
'Sustainability',
'Real World Assets',
'Other',
])
)
.min(1, 'At least one category is required')
.refine(val => val.length > 0, 'Please select at least one category'),

venueType: z.enum(['virtual', 'physical'], {
message: 'Venue type is required',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ export default function GeneralSettingsTab({
name: initialData?.name || '',
banner: initialData?.banner || '',
description: initialData?.description || '',
category: initialData?.category || '',
category: Array.isArray(initialData?.category)
? initialData.category
: initialData?.category
? [initialData.category]
: [],
venueType: initialData?.venueType || 'virtual',
country: initialData?.country || '',
state: initialData?.state || '',
Expand Down
4 changes: 2 additions & 2 deletions lib/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
import Cookies from 'js-cookie';
import { useAuthStore } from '@/lib/stores/auth-store';

// const API_BASE_URL = 'https://staging-api.boundlessfi.xyz/api';
const API_BASE_URL = 'http://localhost:8000/api';
const API_BASE_URL = 'https://staging-api.boundlessfi.xyz/api';
// const API_BASE_URL = 'http://localhost:8000/api';
// const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL;
if (!API_BASE_URL) {
throw new Error('NEXT_PUBLIC_API_URL environment variable is not defined');
Expand Down
12 changes: 10 additions & 2 deletions lib/api/hackathons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ export interface HackathonInformation {
title: string;
banner: string;
description: string;
category: HackathonCategory;
category?: HackathonCategory; // Legacy format (single category)
categories?: HackathonCategory[]; // New format (array of categories)
venue: HackathonVenue;
}

Expand Down Expand Up @@ -698,7 +699,8 @@ interface FlatHackathonData {
// Flat fields that map to nested structure
banner?: string;
description?: string;
category?: string | HackathonCategory;
category?: string | HackathonCategory; // Legacy format
categories?: HackathonCategory[]; // New format
venue?: HackathonVenue;
startDate?: string;
submissionDeadline?: string;
Expand Down Expand Up @@ -769,6 +771,12 @@ const transformHackathonResponse = (
title: flat.title || '',
banner: flat.banner || '',
description: flat.description || '',
// Support both new format (categories) and legacy format (category)
categories: Array.isArray(flat.categories)
? (flat.categories as HackathonCategory[])
: flat.category
? [flat.category as HackathonCategory]
: [HackathonCategory.OTHER],
category: (flat.category as HackathonCategory) || HackathonCategory.OTHER,
venue: flat.venue || {
type: VenueType.VIRTUAL,
Expand Down
4 changes: 3 additions & 1 deletion lib/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
export const config = {
apiUrl: process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8000/api',
apiUrl:
process.env.NEXT_PUBLIC_API_URL ||
'https://staging-api.boundlessfi.xyz/api',
};

export const socialLinks = {
Expand Down
34 changes: 26 additions & 8 deletions lib/utils/hackathon-form-transforms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,30 @@ export const transformToApiFormat = (stepData: {
const judging = stepData.judging;
const collaboration = stepData.collaboration;

// Convert form category array to API format
const categoriesArray: HackathonCategory[] = Array.isArray(info?.category)
? (info.category as HackathonCategory[]).filter(cat =>
Object.values(HackathonCategory).includes(cat)
)
: info?.category && typeof info.category === 'string'
? [info.category as HackathonCategory]
: [];

return {
information: {
title: info?.name || '',
banner: info?.banner || '',
description: info?.description || '',
// Send categories array (new format, recommended)
categories:
categoriesArray.length > 0
? categoriesArray
: [HackathonCategory.OTHER],
// Also include legacy category for backward compatibility (first category)
category:
Array.isArray(info?.category) && info.category.length > 0
? (info.category[0] as HackathonCategory)
: (info?.category as HackathonCategory) || HackathonCategory.OTHER,
categoriesArray.length > 0
? categoriesArray[0]
: HackathonCategory.OTHER,
venue: {
type: (info?.venueType as VenueType) || VenueType.VIRTUAL,
country: info?.country,
Expand Down Expand Up @@ -128,16 +143,19 @@ export const transformFromApiFormat = (draft: HackathonDraft) => {
const judging = draft.judging;
const collaboration = draft.collaboration;

// Handle both new format (categories array) and legacy format (category string)
const categoriesArray: string[] = info?.categories
? info.categories
: info?.category
? [info.category]
: [];

return {
information: {
name: info?.title || '',
banner: info?.banner || '',
description: info?.description || '',
category: Array.isArray(info?.category)
? info.category
: info?.category
? [info.category]
: [],
category: categoriesArray,
venueType: info?.venue?.type || 'physical',
country: info?.venue?.country || '',
state: info?.venue?.state || '',
Expand Down
Loading