Skip to content

Commit

Permalink
feat(3973): add data column to event table
Browse files Browse the repository at this point in the history
  • Loading branch information
Kolezhanchik committed Jan 9, 2025
1 parent 076e4b5 commit 75c68a5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
22 changes: 22 additions & 0 deletions app/app/events/all/TableBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ interface Event {
userId: string | null;
createdAt: string;
user: User | null;
data: object;
}

interface TableProps {
Expand Down Expand Up @@ -69,6 +70,26 @@ export default function TableBody({ data }: TableProps) {
<Table.Td>
<Text size="xs">{formatDate(event.createdAt)}</Text>
</Table.Td>
<Table.Td>
{Object.keys(event.data).length !== 0 ? (
<ul>
{Object.entries(event.data).map(([key, value]) => (
<li key={key}>
<Text size="xs" className="font-semibold">
{key}:
</Text>
<Text size="xs" c="dimmed" component="span">
{typeof value === 'object' ? JSON.stringify(value) : value.toString()}
</Text>
</li>
))}
</ul>
) : (
<Text size="xs" c="dimmed">
No data
</Text>
)}
</Table.Td>
</Table.Tr>
))
) : (
Expand All @@ -88,6 +109,7 @@ export default function TableBody({ data }: TableProps) {
<Table.Th>User</Table.Th>
<Table.Th>Position</Table.Th>
<Table.Th>Date</Table.Th>
<Table.Th>Event data</Table.Th>
</Table.Tr>
</Table.Thead>
<Table.Tbody>{rows}</Table.Tbody>
Expand Down
3 changes: 2 additions & 1 deletion app/services/backend/events.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { EventType } from '@prisma/client';
import axios from 'axios';
import { eventSorts } from '@/app/events/all/state';
import { downloadFile } from '@/utils/browser';
Expand Down Expand Up @@ -35,6 +36,6 @@ export async function downloadEvents(data: EventSearchBody) {

export async function searchEvents(data: EventSearchBody): Promise<any> {
const reqData = prepareSearchPayload(data);
const result = await instance.post<{ data: any }>('/search', reqData);
const result = await instance.post<{ data: EventType; totalCount: number }>('/search', reqData);
return result.data;
}
1 change: 1 addition & 0 deletions app/services/db/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export async function searchEvents({
type: true,
userId: true,
createdAt: true,
data: true,
user: {
select: {
firstName: true,
Expand Down

0 comments on commit 75c68a5

Please sign in to comment.