Skip to content

Commit 35b4d06

Browse files
authored
Merge pull request #907 from HiEventsDev/develop
2 parents e2c7e43 + 912c301 commit 35b4d06

File tree

3 files changed

+50
-54
lines changed

3 files changed

+50
-54
lines changed

frontend/src/components/common/AttendeeTable/index.tsx

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -77,26 +77,6 @@ export const AttendeeTable = ({attendees, openCreateModal}: AttendeeTableProps)
7777
});
7878
}
7979

80-
if (attendees.length === 0) {
81-
return <NoResultsSplash
82-
heading={t`No Attendees to show`}
83-
imageHref={'/blank-slate/attendees.svg'}
84-
subHeading={(
85-
<>
86-
<p>
87-
{t`Your attendees will appear here once they have registered for your event. You can also manually add attendees.`}
88-
</p>
89-
<Button
90-
size={'xs'}
91-
leftSection={<IconPlus/>}
92-
color={'green'}
93-
onClick={() => openCreateModal()}>{t`Manually add an Attendee`}
94-
</Button>
95-
</>
96-
)}
97-
/>
98-
}
99-
10080
const handleCancel = (attendee: Attendee) => {
10181
const message = attendee.status === 'CANCELLED'
10282
? t`Are you sure you want to activate this attendee?`
@@ -414,6 +394,26 @@ export const AttendeeTable = ({attendees, openCreateModal}: AttendeeTableProps)
414394
[emailPopoverId, event, hasCheckInLists]
415395
);
416396

397+
if (attendees.length === 0) {
398+
return <NoResultsSplash
399+
heading={t`No Attendees to show`}
400+
imageHref={'/blank-slate/attendees.svg'}
401+
subHeading={(
402+
<>
403+
<p>
404+
{t`Your attendees will appear here once they have registered for your event. You can also manually add attendees.`}
405+
</p>
406+
<Button
407+
size={'xs'}
408+
leftSection={<IconPlus/>}
409+
color={'green'}
410+
onClick={() => openCreateModal()}>{t`Manually add an Attendee`}
411+
</Button>
412+
</>
413+
)}
414+
/>
415+
}
416+
417417
return (
418418
<>
419419
<TanStackTable

frontend/src/components/common/OrdersTable/index.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,6 @@ export const OrdersTable = ({orders, event}: OrdersTableProps) => {
6868
viewModal.open();
6969
}));
7070

71-
if (orders.length === 0) {
72-
return <NoResultsSplash
73-
imageHref={'/blank-slate/orders.svg'}
74-
heading={t`No orders to show`}
75-
subHeading={(
76-
<p>
77-
{t`Your orders will appear here once they start rolling in.`}
78-
</p>
79-
)}
80-
/>
81-
}
82-
8371
const handleModalClick = (orderId: IdParam, modal: { open: () => void }) => {
8472
setOrderId(orderId);
8573
modal.open();
@@ -453,6 +441,18 @@ export const OrdersTable = ({orders, event}: OrdersTableProps) => {
453441
[event.id, emailPopoverId]
454442
);
455443

444+
if (orders.length === 0) {
445+
return <NoResultsSplash
446+
imageHref={'/blank-slate/orders.svg'}
447+
heading={t`No orders to show`}
448+
subHeading={(
449+
<p>
450+
{t`Your orders will appear here once they start rolling in.`}
451+
</p>
452+
)}
453+
/>
454+
}
455+
456456
return (
457457
<>
458458
<TanStackTable

frontend/src/hooks/useFilterQueryParamSync.ts

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
import { useCallback, useMemo } from 'react';
2-
import { useSearchParams } from 'react-router';
3-
import { QueryFilters } from "../types";
1+
import {useCallback, useEffect, useState} from 'react';
2+
import {useSearchParams} from 'react-router';
3+
import {QueryFilters} from "../types";
44

5-
type FilterCondition = {
6-
operator: string;
7-
value: string | string[];
8-
};
9-
10-
const debounce = <T extends (...args: any[]) => void>(func: T, delay: number) => {
5+
const debounce = (func: Function, delay: number) => {
116
let timerId: ReturnType<typeof setTimeout>;
12-
return (...args: Parameters<T>) => {
7+
return (...args: any[]) => {
138
if (timerId) clearTimeout(timerId);
149
timerId = setTimeout(() => func(...args), delay);
1510
};
@@ -20,31 +15,32 @@ export const useFilterQueryParamSync = (): [
2015
(updates: Partial<QueryFilters>, replace?: boolean) => void
2116
] => {
2217
const [searchParams, setSearchParams] = useSearchParams();
18+
const [queryParams, setQueryParams] = useState<Partial<QueryFilters>>({});
2319

24-
const queryParams = useMemo(() => {
25-
const parsedParams: Partial<QueryFilters> & Record<string, any> = {};
20+
useEffect(() => {
21+
const parsedParams: Partial<QueryFilters> = {};
2622

2723
searchParams.forEach((value, key) => {
2824
if (key.startsWith('filterFields[')) {
2925
const match = key.match(/^filterFields\[(.+)\]\[(.+)\]$/);
3026
if (match) {
31-
const [, fieldName, operator] = match;
32-
27+
const [_, fieldName, operator] = match;
3328
if (!parsedParams.filterFields) {
3429
parsedParams.filterFields = {};
3530
}
36-
37-
(parsedParams.filterFields as Record<string, FilterCondition>)[fieldName] = {
31+
// @ts-ignore
32+
parsedParams.filterFields[fieldName] = {
3833
operator,
3934
value: value.includes(',') ? value.split(',') : value
4035
};
4136
}
4237
} else {
38+
// @ts-ignore - Handle non-filterFields params
4339
parsedParams[key] = value;
4440
}
4541
});
4642

47-
return parsedParams;
43+
setQueryParams(parsedParams);
4844
}, [searchParams]);
4945

5046
const debouncedSetSearchParams = useCallback(
@@ -56,22 +52,22 @@ export const useFilterQueryParamSync = (): [
5652

5753
const updateSearchParams = useCallback(
5854
(updates: Partial<QueryFilters>, replace: boolean = false) => {
59-
// Create new params based on current URL state
6055
const newParams = replace ? new URLSearchParams() : new URLSearchParams(searchParams);
6156

57+
// Clear existing filter fields if replacing
6258
if (replace) {
63-
// Clean up existing filter fields
64-
Array.from(newParams.keys()).forEach((key) => {
59+
searchParams.forEach((_, key) => {
6560
if (key.startsWith('filterFields[')) {
6661
newParams.delete(key);
6762
}
6863
});
6964
}
7065

66+
// Update params
7167
Object.entries(updates).forEach(([key, value]) => {
7268
if (key === 'filterFields' && value) {
7369
Object.entries(value).forEach(([field, condition]) => {
74-
if (condition && typeof condition === 'object' && 'operator' in condition) {
70+
if (condition) {
7571
const paramKey = `filterFields[${field}][${condition.operator}]`;
7672
if (Array.isArray(condition.value)) {
7773
newParams.set(paramKey, condition.value.join(','));
@@ -80,7 +76,7 @@ export const useFilterQueryParamSync = (): [
8076
}
8177
}
8278
});
83-
} else if (value !== undefined && value !== null) {
79+
} else if (value !== undefined) {
8480
newParams.set(key, String(value));
8581
}
8682
});

0 commit comments

Comments
 (0)