Skip to content

Commit fd85908

Browse files
formatting
1 parent 91ca0e6 commit fd85908

File tree

25 files changed

+333
-158
lines changed

25 files changed

+333
-158
lines changed

frontend/src/components/Pagination.tsx

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ interface PaginationProps {
66
totalItems: number;
77
}
88

9-
const Pagination = ({ currentPage, totalPages, onPageChange, itemsPerPage, totalItems }: PaginationProps) => {
9+
const Pagination = ({
10+
currentPage,
11+
totalPages,
12+
onPageChange,
13+
itemsPerPage,
14+
totalItems,
15+
}: PaginationProps) => {
1016
const startItem = (currentPage - 1) * itemsPerPage + 1;
1117
const endItem = Math.min(currentPage * itemsPerPage, totalItems);
1218

@@ -42,48 +48,55 @@ const Pagination = ({ currentPage, totalPages, onPageChange, itemsPerPage, total
4248
if (totalPages <= 1) return null;
4349

4450
return (
45-
<div className="flex items-center justify-between px-4 py-3 bg-white border-t border-gray-200 sm:px-6">
46-
<div className="flex justify-between flex-1 sm:hidden">
51+
<div className='flex items-center justify-between px-4 py-3 bg-white border-t border-gray-200 sm:px-6'>
52+
<div className='flex justify-between flex-1 sm:hidden'>
4753
<button
4854
onClick={() => onPageChange(currentPage - 1)}
4955
disabled={currentPage === 1}
50-
className="relative inline-flex items-center px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed"
56+
className='relative inline-flex items-center px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed'
5157
>
5258
Previous
5359
</button>
5460
<button
5561
onClick={() => onPageChange(currentPage + 1)}
5662
disabled={currentPage === totalPages}
57-
className="relative inline-flex items-center px-4 py-2 ml-3 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed"
63+
className='relative inline-flex items-center px-4 py-2 ml-3 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed'
5864
>
5965
Next
6066
</button>
6167
</div>
62-
<div className="hidden sm:flex sm:flex-1 sm:items-center sm:justify-between">
68+
<div className='hidden sm:flex sm:flex-1 sm:items-center sm:justify-between'>
6369
<div>
64-
<p className="text-sm text-gray-700">
65-
Showing <span className="font-medium">{startItem}</span> to{' '}
66-
<span className="font-medium">{endItem}</span> of{' '}
67-
<span className="font-medium">{totalItems}</span> results
70+
<p className='text-sm text-gray-700'>
71+
Showing <span className='font-medium'>{startItem}</span> to{' '}
72+
<span className='font-medium'>{endItem}</span> of{' '}
73+
<span className='font-medium'>{totalItems}</span> results
6874
</p>
6975
</div>
7076
<div>
71-
<nav className="relative z-0 inline-flex -space-x-px rounded-md shadow-sm" aria-label="Pagination">
77+
<nav
78+
className='relative z-0 inline-flex -space-x-px rounded-md shadow-sm'
79+
aria-label='Pagination'
80+
>
7281
<button
7382
onClick={() => onPageChange(currentPage - 1)}
7483
disabled={currentPage === 1}
75-
className="relative inline-flex items-center px-2 py-2 text-sm font-medium text-gray-500 bg-white border border-gray-300 rounded-l-md hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed"
84+
className='relative inline-flex items-center px-2 py-2 text-sm font-medium text-gray-500 bg-white border border-gray-300 rounded-l-md hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed'
7685
>
77-
<span className="sr-only">Previous</span>
78-
<svg className="w-5 h-5" fill="currentColor" viewBox="0 0 20 20">
79-
<path fillRule="evenodd" d="M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z" clipRule="evenodd" />
86+
<span className='sr-only'>Previous</span>
87+
<svg className='w-5 h-5' fill='currentColor' viewBox='0 0 20 20'>
88+
<path
89+
fillRule='evenodd'
90+
d='M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z'
91+
clipRule='evenodd'
92+
/>
8093
</svg>
8194
</button>
8295
{getPageNumbers().map((page, index) =>
8396
page === '...' ? (
8497
<span
8598
key={`ellipsis-${index}`}
86-
className="relative inline-flex items-center px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300"
99+
className='relative inline-flex items-center px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300'
87100
>
88101
...
89102
</span>
@@ -104,11 +117,15 @@ const Pagination = ({ currentPage, totalPages, onPageChange, itemsPerPage, total
104117
<button
105118
onClick={() => onPageChange(currentPage + 1)}
106119
disabled={currentPage === totalPages}
107-
className="relative inline-flex items-center px-2 py-2 text-sm font-medium text-gray-500 bg-white border border-gray-300 rounded-r-md hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed"
120+
className='relative inline-flex items-center px-2 py-2 text-sm font-medium text-gray-500 bg-white border border-gray-300 rounded-r-md hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed'
108121
>
109-
<span className="sr-only">Next</span>
110-
<svg className="w-5 h-5" fill="currentColor" viewBox="0 0 20 20">
111-
<path fillRule="evenodd" d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" clipRule="evenodd" />
122+
<span className='sr-only'>Next</span>
123+
<svg className='w-5 h-5' fill='currentColor' viewBox='0 0 20 20'>
124+
<path
125+
fillRule='evenodd'
126+
d='M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z'
127+
clipRule='evenodd'
128+
/>
112129
</svg>
113130
</button>
114131
</nav>

frontend/src/hooks/queries/useAnnouncements.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ export const useAnnouncements = (page = 1, limit = 100) => {
66
return useQuery({
77
queryKey: ['announcements', { page, limit }],
88
queryFn: async () => {
9-
const response = await axios.get(`${API_BASE_URL}/api/announcements?page=${page}&limit=${limit}`);
9+
const response = await axios.get(
10+
`${API_BASE_URL}/api/announcements?page=${page}&limit=${limit}`
11+
);
1012
return response.data.data || response.data;
1113
},
1214
staleTime: 5 * 60 * 1000,

frontend/src/hooks/queries/useDashboardData.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ export const useDashboardData = () => {
3838
enabled: !!orgId,
3939
});
4040

41-
const isLoading = results.some((r) => r.isLoading);
42-
const isError = results.some((r) => r.isError);
41+
const isLoading = results.some(r => r.isLoading);
42+
const isError = results.some(r => r.isError);
4343

4444
return {
4545
orgProfile,

frontend/src/hooks/queries/useEmailHistory.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ export const useEmailHistory = (page = 1, limit = 50) => {
88
return useQuery({
99
queryKey: ['email-history', { page, limit }],
1010
queryFn: async () => {
11-
const response = await api.get(`/api/email-notifications/history?page=${page}&limit=${limit}`);
11+
const response = await api.get(
12+
`/api/email-notifications/history?page=${page}&limit=${limit}`
13+
);
1214
const data = response.data || response;
1315
const emailsArray = Array.isArray(data) ? data : [];
1416
const total = response.total || response.pagination?.total || emailsArray.length;

frontend/src/hooks/queries/useOrgAnnouncements.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ export const useOrgAnnouncements = (page = 1, limit = 50) => {
1010
const response = await api.get(`/api/announcements?page=${page}&limit=${limit}`);
1111
const data = response.data || response;
1212
const announcementsArray = Array.isArray(data) ? data : [];
13-
const publishedAnnouncements = announcementsArray.filter((announcement: any) => announcement.isPublished);
13+
const publishedAnnouncements = announcementsArray.filter(
14+
(announcement: any) => announcement.isPublished
15+
);
1416

1517
return {
1618
data: publishedAnnouncements,

frontend/src/hooks/useApi.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@ export const useApi = () => {
2828

2929
return {
3030
get: (url: string) => request(url, { method: 'GET' }),
31-
post: (url: string, data?: any) =>
32-
request(url, { method: 'POST', body: JSON.stringify(data) }),
33-
put: (url: string, data?: any) =>
34-
request(url, { method: 'PUT', body: JSON.stringify(data) }),
31+
post: (url: string, data?: any) => request(url, { method: 'POST', body: JSON.stringify(data) }),
32+
put: (url: string, data?: any) => request(url, { method: 'PUT', body: JSON.stringify(data) }),
3533
delete: (url: string) => request(url, { method: 'DELETE' }),
3634
};
3735
};

frontend/src/pages/Admin/AlertsPage/Alerts.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,18 @@ const AdminAlerts = () => {
4444
const [currentPage, setCurrentPage] = useState(1);
4545
const itemsPerPage = 50;
4646

47-
const { data: alertsData, isLoading: loading, error: alertsError } = useAdminAlerts(currentPage, itemsPerPage);
47+
const {
48+
data: alertsData,
49+
isLoading: loading,
50+
error: alertsError,
51+
} = useAdminAlerts(currentPage, itemsPerPage);
4852
const { createAlert, updateAlert, deleteAlert } = useAlertMutations();
4953

5054
const alertsResponse = alertsData || {};
5155
const alerts = alertsResponse.data || alertsResponse;
5256
const alertsArray: Alert[] = Array.isArray(alerts) ? alerts : [];
53-
const totalAlerts = alertsResponse.total || alertsResponse.pagination?.total || alertsArray.length;
57+
const totalAlerts =
58+
alertsResponse.total || alertsResponse.pagination?.total || alertsArray.length;
5459
const error = alertsError ? 'Failed to fetch alerts' : '';
5560

5661
type SortField = 'title' | 'priority' | 'publishedDate' | 'createdAt';
@@ -153,9 +158,7 @@ const AdminAlerts = () => {
153158
onConfirm: async () => {
154159
try {
155160
setIsDeleting(true);
156-
await Promise.all(
157-
selectedAlertIds.map(id => deleteAlert.mutateAsync(id))
158-
);
161+
await Promise.all(selectedAlertIds.map(id => deleteAlert.mutateAsync(id)));
159162

160163
setSelectedAlertIds([]);
161164
setToast({

frontend/src/pages/Admin/AnnouncementsPage/Announcements.tsx

Lines changed: 48 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,21 @@ const AdminAnnouncements = () => {
4848
const [currentPage, setCurrentPage] = useState(1);
4949
const itemsPerPage = 50;
5050

51-
const { data: announcementsData, isLoading: loading, error: announcementsError } = useAdminAnnouncements(currentPage, itemsPerPage);
52-
const { createAnnouncement, updateAnnouncement, deleteAnnouncement, publishAnnouncement } = useAnnouncementMutations();
51+
const {
52+
data: announcementsData,
53+
isLoading: loading,
54+
error: announcementsError,
55+
} = useAdminAnnouncements(currentPage, itemsPerPage);
56+
const { createAnnouncement, updateAnnouncement, deleteAnnouncement, publishAnnouncement } =
57+
useAnnouncementMutations();
5358

5459
const announcementsResponse = announcementsData || {};
5560
const announcements = announcementsResponse.data || announcementsResponse;
5661
const announcementsArray: Announcement[] = Array.isArray(announcements) ? announcements : [];
57-
const totalAnnouncements = announcementsResponse.total || announcementsResponse.pagination?.total || announcementsArray.length;
62+
const totalAnnouncements =
63+
announcementsResponse.total ||
64+
announcementsResponse.pagination?.total ||
65+
announcementsArray.length;
5866
const error = announcementsError ? 'Failed to fetch announcements' : '';
5967

6068
type SortField = 'title' | 'publishedDate' | 'tags' | 'createdAt';
@@ -326,9 +334,7 @@ const AdminAnnouncements = () => {
326334
onConfirm: async () => {
327335
try {
328336
setIsDeleting(true);
329-
await Promise.all(
330-
selectedAnnouncementIds.map(id => deleteAnnouncement.mutateAsync(id))
331-
);
337+
await Promise.all(selectedAnnouncementIds.map(id => deleteAnnouncement.mutateAsync(id)));
332338

333339
setSelectedAnnouncementIds([]);
334340
setToast({
@@ -385,7 +391,9 @@ const AdminAnnouncements = () => {
385391
const searchedAnnouncements = filtered.filter(a => {
386392
const matchesTags =
387393
tagsFilter.length === 0 ||
388-
tagsFilter.some(tagName => a.tags?.some((announcementTag: Tag) => announcementTag.name === tagName));
394+
tagsFilter.some(tagName =>
395+
a.tags?.some((announcementTag: Tag) => announcementTag.name === tagName)
396+
);
389397

390398
const q = searchQuery.toLowerCase();
391399
return (
@@ -396,35 +404,37 @@ const AdminAnnouncements = () => {
396404
);
397405
});
398406

399-
const sortedAnnouncements = [...searchedAnnouncements].sort((a: Announcement, b: Announcement) => {
400-
let aValue: any;
401-
let bValue: any;
402-
403-
switch (sortField) {
404-
case 'title':
405-
aValue = a.title.toLowerCase();
406-
bValue = b.title.toLowerCase();
407-
break;
408-
case 'publishedDate':
409-
aValue = a.publishedDate ? new Date(a.publishedDate).getTime() : 0;
410-
bValue = b.publishedDate ? new Date(b.publishedDate).getTime() : 0;
411-
break;
412-
case 'tags':
413-
aValue = a.tags?.length || 0;
414-
bValue = b.tags?.length || 0;
415-
break;
416-
case 'createdAt':
417-
aValue = new Date(a.createdAt).getTime();
418-
bValue = new Date(b.createdAt).getTime();
419-
break;
420-
default:
421-
return 0;
422-
}
407+
const sortedAnnouncements = [...searchedAnnouncements].sort(
408+
(a: Announcement, b: Announcement) => {
409+
let aValue: any;
410+
let bValue: any;
423411

424-
if (aValue < bValue) return sortDirection === 'asc' ? -1 : 1;
425-
if (aValue > bValue) return sortDirection === 'asc' ? 1 : -1;
426-
return 0;
427-
});
412+
switch (sortField) {
413+
case 'title':
414+
aValue = a.title.toLowerCase();
415+
bValue = b.title.toLowerCase();
416+
break;
417+
case 'publishedDate':
418+
aValue = a.publishedDate ? new Date(a.publishedDate).getTime() : 0;
419+
bValue = b.publishedDate ? new Date(b.publishedDate).getTime() : 0;
420+
break;
421+
case 'tags':
422+
aValue = a.tags?.length || 0;
423+
bValue = b.tags?.length || 0;
424+
break;
425+
case 'createdAt':
426+
aValue = new Date(a.createdAt).getTime();
427+
bValue = new Date(b.createdAt).getTime();
428+
break;
429+
default:
430+
return 0;
431+
}
432+
433+
if (aValue < bValue) return sortDirection === 'asc' ? -1 : 1;
434+
if (aValue > bValue) return sortDirection === 'asc' ? 1 : -1;
435+
return 0;
436+
}
437+
);
428438

429439
const handleSort = (field: SortField) => {
430440
if (sortField === field) {
@@ -640,7 +650,9 @@ const AdminAnnouncements = () => {
640650
}
641651
onChange={e => {
642652
if (e.target.checked) {
643-
setSelectedAnnouncementIds(sortedAnnouncements.map((a: Announcement) => a.id));
653+
setSelectedAnnouncementIds(
654+
sortedAnnouncements.map((a: Announcement) => a.id)
655+
);
644656
} else {
645657
setSelectedAnnouncementIds([]);
646658
}

frontend/src/pages/Admin/BlogsPage/Blogs.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ const AdminBlogs = () => {
5151
const [currentPage, setCurrentPage] = useState(1);
5252
const itemsPerPage = 50;
5353

54-
const { data: blogsData, isLoading: loading, error: blogsError } = useAdminBlogs(currentPage, itemsPerPage);
54+
const {
55+
data: blogsData,
56+
isLoading: loading,
57+
error: blogsError,
58+
} = useAdminBlogs(currentPage, itemsPerPage);
5559
const { createBlog, updateBlog, deleteBlog } = useBlogMutations();
5660

5761
const blogsResponse = blogsData || {};
@@ -213,9 +217,7 @@ const AdminBlogs = () => {
213217
onConfirm: async () => {
214218
try {
215219
setIsDeleting(true);
216-
await Promise.all(
217-
selectedBlogIds.map(id => deleteBlog.mutateAsync(id))
218-
);
220+
await Promise.all(selectedBlogIds.map(id => deleteBlog.mutateAsync(id)));
219221

220222
setSelectedBlogIds([]);
221223
setToast({

frontend/src/pages/Admin/CustomEmailPage/CustomEmail.tsx

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ const CustomEmail = () => {
5858
const [scheduledDateTime, setScheduledDateTime] = useState('');
5959

6060
const { data: organizationsData, isLoading: loading } = useAdminOrganizations(1, 1000);
61-
const { data: emailHistoryData, isLoading: historyLoading } = useEmailHistory(currentPage, itemsPerPage);
61+
const { data: emailHistoryData, isLoading: historyLoading } = useEmailHistory(
62+
currentPage,
63+
itemsPerPage
64+
);
6265
const { sendEmail } = useEmailMutations();
6366

6467
const organizationsResponse = organizationsData || {};
@@ -71,7 +74,9 @@ const CustomEmail = () => {
7174
const availableTags = Array.from(
7275
new Set(
7376
organizationsArray.flatMap((org: Organization) =>
74-
org.tags && Array.isArray(org.tags) ? org.tags.filter((tag): tag is string => typeof tag === 'string') : []
77+
org.tags && Array.isArray(org.tags)
78+
? org.tags.filter((tag): tag is string => typeof tag === 'string')
79+
: []
7580
)
7681
)
7782
).sort();
@@ -684,14 +689,16 @@ const CustomEmail = () => {
684689
</h4>
685690
<div className='bg-gray-50 p-4 rounded-md max-h-48 overflow-y-auto'>
686691
<div className='flex flex-wrap gap-2'>
687-
{email.recipientEmails.map((recipientEmail: string, index: number) => (
688-
<span
689-
key={index}
690-
className='px-2 py-1 bg-white border border-gray-200 rounded text-sm text-gray-600'
691-
>
692-
{recipientEmail}
693-
</span>
694-
))}
692+
{email.recipientEmails.map(
693+
(recipientEmail: string, index: number) => (
694+
<span
695+
key={index}
696+
className='px-2 py-1 bg-white border border-gray-200 rounded text-sm text-gray-600'
697+
>
698+
{recipientEmail}
699+
</span>
700+
)
701+
)}
695702
</div>
696703
</div>
697704
</div>

0 commit comments

Comments
 (0)