-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add filter for event table and refactor
- Loading branch information
1 parent
85dcf4a
commit 16eba2c
Showing
22 changed files
with
293 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 34 additions & 7 deletions
41
apps/analytics/app/_components/analytics/EventsTable/EventsTable.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...s/errors/ErrorsTable/StackTraceDialog.tsx → ...nalytics/EventsTable/StackTraceDialog.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
apps/analytics/app/_components/analytics/EventsTable/TableFilter.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
"use client"; | ||
|
||
import { Button } from "~/components/ui/button"; | ||
import { Checkbox } from "~/components/ui/checkbox"; | ||
import { | ||
DropdownMenu, | ||
DropdownMenuContent, | ||
DropdownMenuLabel, | ||
DropdownMenuSeparator, | ||
DropdownMenuTrigger, | ||
} from "~/components/ui/dropdown-menu"; | ||
import { EventType } from "./EventsTable"; | ||
import { useEffect, useState, type Dispatch, type SetStateAction } from "react"; | ||
|
||
type TableFilterProps = { | ||
eventTypes: EventType[]; | ||
setEventTypes: Dispatch<SetStateAction<EventType[]>>; | ||
}; | ||
|
||
const TableFilter = ({ eventTypes, setEventTypes }: TableFilterProps) => { | ||
const [allSelected, setAllSelected] = useState(true); | ||
|
||
useEffect(() => { | ||
const updatedEventTypes = eventTypes.map((t) => ({ | ||
...t, | ||
isSelected: allSelected, | ||
})); | ||
setEventTypes(updatedEventTypes); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [allSelected]); | ||
|
||
const handleCheckedChange = (value: boolean, currentType: string) => { | ||
const updatedEventTypes = eventTypes.map((t) => { | ||
if (t.text === currentType) { | ||
return { ...t, isSelected: value }; | ||
} | ||
return t; | ||
}); | ||
|
||
// If all event types are selected, set allSelected to true | ||
if (updatedEventTypes.every((t) => t.isSelected)) { | ||
setAllSelected(true); | ||
return; | ||
} | ||
|
||
// If no event types are selected, set allSelected to false | ||
if (updatedEventTypes.every((t) => !t.isSelected)) { | ||
setAllSelected(false); | ||
return; | ||
} | ||
|
||
setEventTypes(updatedEventTypes); | ||
}; | ||
|
||
return ( | ||
<DropdownMenu> | ||
<DropdownMenuTrigger asChild> | ||
<Button variant="outline">Event Types</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent className="w-52 ml-12"> | ||
<DropdownMenuLabel>Select events</DropdownMenuLabel> | ||
<DropdownMenuSeparator /> | ||
|
||
<div className="space-y-3"> | ||
<label className="text-sm flex items-center gap-3 pl-2 transition-colors hover:bg-muted p-1 rounded-md"> | ||
<Checkbox | ||
checked={allSelected} | ||
onCheckedChange={(val) => setAllSelected(Boolean(val))} | ||
/> | ||
<span>All</span> | ||
</label> | ||
|
||
{eventTypes.map((type) => ( | ||
<label | ||
key={type.text} | ||
className="text-sm flex items-center gap-3 pl-2 transition-colors hover:bg-muted p-1 rounded-md" | ||
> | ||
<Checkbox | ||
checked={type.isSelected} | ||
onCheckedChange={(val) => | ||
handleCheckedChange(Boolean(val), type.text) | ||
} | ||
/> | ||
<span>{type.text}</span> | ||
</label> | ||
))} | ||
</div> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
); | ||
}; | ||
|
||
export default TableFilter; |
15 changes: 15 additions & 0 deletions
15
apps/analytics/app/_components/analytics/cards/TotalDataExported.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { getTotalInterviewsStarted } from "~/utils/getTotalInterviewsStarted"; | ||
import { SummaryCard } from "~/components/SummaryCard"; | ||
|
||
const TotalDataExported = async () => { | ||
const totalInterviewsStarted = await getTotalInterviewsStarted(); | ||
return ( | ||
<SummaryCard | ||
title="Data Exported" | ||
value={totalInterviewsStarted} | ||
description="Total data exported across all instances of Fresco" | ||
/> | ||
); | ||
}; | ||
|
||
export default TotalDataExported; |
15 changes: 15 additions & 0 deletions
15
apps/analytics/app/_components/analytics/cards/TotalErrorsCard.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { SummaryCard } from "~/components/SummaryCard"; | ||
import { getTotalErrors } from "~/utils/getTotalErrors"; | ||
|
||
const TotalErrorsCard = async () => { | ||
const totalErrors = await getTotalErrors(); | ||
return ( | ||
<SummaryCard | ||
title="Number of Errors" | ||
value={totalErrors} | ||
description="Total number of errors sent from all instances of Fresco" | ||
/> | ||
); | ||
}; | ||
|
||
export default TotalErrorsCard; |
56 changes: 0 additions & 56 deletions
56
apps/analytics/app/_components/errors/ErrorsTable/Columns.tsx
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
apps/analytics/app/_components/errors/ErrorsTable/ErrorsTable.tsx
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
apps/analytics/app/_components/errors/cards/TotalErrorsCard.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.