Skip to content

Commit 8089688

Browse files
committed
PEER-219: Add Attempt UI
Signed-off-by: SeeuSim <[email protected]>
1 parent e2f12bd commit 8089688

File tree

5 files changed

+65
-2
lines changed

5 files changed

+65
-2
lines changed

frontend/src/components/blocks/interview/question-attempts/attempt-details.tsx

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './main';
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import type { FC, PropsWithChildren } from 'react';
2+
3+
import {
4+
Dialog,
5+
DialogContent,
6+
DialogDescription,
7+
DialogFooter,
8+
DialogHeader,
9+
DialogTitle,
10+
DialogTrigger,
11+
} from '@/components/ui/dialog';
12+
import { IQuestionAttempt } from '@/types/question-types';
13+
14+
type AttemptDetailsPaneProps = {
15+
triggerText: string;
16+
} & IQuestionAttempt;
17+
18+
export const AttemptDetailsDialog: FC<PropsWithChildren<AttemptDetailsPaneProps>> = ({
19+
children,
20+
triggerText,
21+
code,
22+
language,
23+
attemptId,
24+
}) => {
25+
return (
26+
<Dialog>
27+
{children ? (
28+
<DialogTrigger>{children}</DialogTrigger>
29+
) : (
30+
<DialogTrigger>{triggerText}</DialogTrigger>
31+
)}
32+
<DialogContent>
33+
<DialogHeader>
34+
<DialogTitle>
35+
Attempt&nbsp;<span className='font-mono'>{attemptId}</span>
36+
</DialogTitle>
37+
</DialogHeader>
38+
<DialogDescription />
39+
<DialogFooter />
40+
</DialogContent>
41+
</Dialog>
42+
);
43+
};

frontend/src/components/blocks/interview/question-attempts/columns.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,38 @@
11
import { ColumnDef } from '@tanstack/react-table';
22

33
import { Badge } from '@/components/ui/badge';
4+
import { Button } from '@/components/ui/button';
45
import { DataTableSortableHeader } from '@/components/ui/data-table';
6+
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
57
import { IQuestionAttempt } from '@/types/question-types';
68

9+
import { AttemptDetailsDialog } from './attempt-details';
10+
711
export const columns: Array<ColumnDef<IQuestionAttempt>> = [
812
{
913
accessorKey: 'attemptId',
1014
header: 'ID',
1115
},
1216
{
1317
accessorKey: 'timestamp',
14-
header: ({ column }) => <DataTableSortableHeader column={column} title='Attempted' />,
18+
header: ({ column }) => (
19+
<DataTableSortableHeader column={column} title='Attempted' className='ml-4' />
20+
),
1521
cell({ row }) {
1622
const attemptedTime = row.getValue('timestamp') as string;
17-
return <div>{new Date(attemptedTime).toLocaleString()}</div>;
23+
const label = new Date(attemptedTime).toLocaleString();
24+
return (
25+
<AttemptDetailsDialog triggerText={label} {...row.original}>
26+
<TooltipProvider delayDuration={100}>
27+
<Tooltip>
28+
<TooltipTrigger>
29+
<Button variant='link'>{label}</Button>
30+
</TooltipTrigger>
31+
<TooltipContent>View Details</TooltipContent>
32+
</Tooltip>
33+
</TooltipProvider>
34+
</AttemptDetailsDialog>
35+
);
1836
},
1937
},
2038
{

frontend/src/types/question-types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export type IQuestionAttempt = {
5959
attemptId: string;
6060
code: string;
6161
language: string;
62+
timestamp: string;
6263
userId1: string;
6364
userId2?: string;
6465
};

0 commit comments

Comments
 (0)