Skip to content

Commit e1c216c

Browse files
authored
UI fixes (#480)
* fix: improve timeline input , ui improvement and fixes for participation tab * fix: implement 2fa for email and password login * fix: fix conflict * fix: fix submission form * fix: fix hackathon submission and participant page * fix: fix hackathon submission and participant page * fix: fix auto refresh ib submission page * fix: hackathon submission fixes * fix: fix coderabbit corrections * fix: fix coderabbit corrections * chore: write boundless on x challenge blog * fix: remove blog * fix: my project dashbaord count and extend hackathon deadline * fix: my project dashbaord count and extend hackathon deadline * fix: fix auto validate wallet address and user nav * fix: fix notification badge * fix: fix coderabbit corrections * fix: fix pagination in organization participants page
1 parent a5f4370 commit e1c216c

2 files changed

Lines changed: 34 additions & 27 deletions

File tree

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

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ const ParticipantsPage: React.FC = () => {
5353
const hackathonId = params.hackathonId as string;
5454

5555
const [view, setView] = useState<'table' | 'grid'>('table');
56+
const [pageSize, setPageSize] = useState(PAGE_SIZE);
5657
const [filters, setFilters] = useState<FilterState>({
5758
search: '',
5859
status: 'all',
@@ -63,9 +64,9 @@ const ParticipantsPage: React.FC = () => {
6364
() => ({
6465
organizationId,
6566
autoFetch: false,
66-
pageSize: PAGE_SIZE, // Grid looks better with multiples of 3/4
67+
pageSize, // Use dynamic page size
6768
}),
68-
[organizationId]
69+
[organizationId, pageSize]
6970
);
7071

7172
const {
@@ -110,7 +111,7 @@ const ParticipantsPage: React.FC = () => {
110111
fetchParticipants(
111112
actualHackathonId,
112113
1,
113-
PAGE_SIZE,
114+
pageSize,
114115
mapFiltersToParams(filters, debouncedSearch)
115116
);
116117
}
@@ -120,6 +121,7 @@ const ParticipantsPage: React.FC = () => {
120121
debouncedSearch,
121122
filters.status,
122123
filters.type,
124+
pageSize,
123125
]);
124126

125127
// Statistics
@@ -161,12 +163,12 @@ const ParticipantsPage: React.FC = () => {
161163
}, [organizationId, actualHackathonId]);
162164

163165
// Handlers
164-
const handlePageChange = (page: number) => {
166+
const handlePageChange = (page: number, limit?: number) => {
165167
if (actualHackathonId) {
166168
fetchParticipants(
167169
actualHackathonId,
168170
page,
169-
PAGE_SIZE,
171+
limit ?? pageSize,
170172
mapFiltersToParams(filters, debouncedSearch)
171173
);
172174
}
@@ -220,7 +222,7 @@ const ParticipantsPage: React.FC = () => {
220222
fetchParticipants(
221223
actualHackathonId,
222224
participantsPagination.currentPage,
223-
PAGE_SIZE,
225+
pageSize,
224226
mapFiltersToParams(filters, debouncedSearch)
225227
);
226228
}
@@ -241,16 +243,17 @@ const ParticipantsPage: React.FC = () => {
241243
},
242244
onPaginationChange: updater => {
243245
if (typeof updater === 'function') {
244-
const newState = (
245-
updater as (old: { pageIndex: number; pageSize: number }) => {
246-
pageIndex: number;
247-
pageSize: number;
248-
}
249-
)({
246+
const newState = updater({
250247
pageIndex: participantsPagination.currentPage - 1,
251248
pageSize: participantsPagination.itemsPerPage,
252249
});
253-
handlePageChange(newState.pageIndex + 1);
250+
251+
if (newState.pageSize !== participantsPagination.itemsPerPage) {
252+
setPageSize(newState.pageSize);
253+
handlePageChange(1, newState.pageSize);
254+
} else {
255+
handlePageChange(newState.pageIndex + 1);
256+
}
254257
}
255258
},
256259
});

hooks/use-hackathons.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -228,17 +228,19 @@ export function useHackathons(
228228
organizationId, // Add organization filter
229229
});
230230

231+
const pagination = (response.data?.pagination ||
232+
response.meta?.pagination) as any;
231233
setHackathons(response.data?.hackathons || []);
232234
setHackathonsPagination({
233-
currentPage: response.data?.pagination.page || 1,
234-
totalPages: response.data?.pagination.totalPages || 1,
235-
totalItems: response.data?.pagination.total || 0,
236-
itemsPerPage: response.data?.pagination.limit || pageSize,
237-
hasNext: response.data?.pagination.hasNext || false,
238-
hasPrev: response.data?.pagination.hasPrev || false,
235+
currentPage: pagination?.page || 1,
236+
totalPages: pagination?.totalPages || 1,
237+
totalItems: pagination?.total || 0,
238+
itemsPerPage: pagination?.limit || pageSize,
239+
hasNext: !!pagination?.hasNext,
240+
hasPrev: !!pagination?.hasPrev,
239241
});
240242
// Update ref immediately
241-
hackathonsPageRef.current = response.data?.pagination.page || 1;
243+
hackathonsPageRef.current = pagination?.page || 1;
242244
} catch (error) {
243245
const errorMessage =
244246
error instanceof Error ? error.message : 'Failed to fetch hackathons';
@@ -575,16 +577,18 @@ export function useHackathons(
575577
filters ?? initialParticipantFilters
576578
);
577579

580+
const pagination = (response.data?.pagination ||
581+
response.meta?.pagination) as any;
578582
setParticipants(response.data?.participants || []);
579583
setParticipantsPagination({
580-
currentPage: response.data?.pagination.page || 1,
581-
totalPages: response.data?.pagination.totalPages || 1,
582-
totalItems: response.data?.pagination.total || 0,
583-
itemsPerPage: response.data?.pagination.limit || pageSize,
584-
hasNext: response.data?.pagination.hasNext || false,
585-
hasPrev: response.data?.pagination.hasPrev || false,
584+
currentPage: pagination?.page || 1,
585+
totalPages: pagination?.totalPages || 1,
586+
totalItems: pagination?.total || 0,
587+
itemsPerPage: pagination?.limit || pageSize,
588+
hasNext: !!pagination?.hasNext,
589+
hasPrev: !!pagination?.hasPrev,
586590
});
587-
participantsPageRef.current = response.data?.pagination.page || 1;
591+
participantsPageRef.current = pagination?.page || 1;
588592
} catch (error) {
589593
const errorMessage =
590594
error instanceof Error

0 commit comments

Comments
 (0)