-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4550cf4
commit a1870d2
Showing
24 changed files
with
1,482 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
import ArrowUpDown from "@/components/icons/ArrowUpDown"; | ||
//import GitHub from "@/components/icons/GitHub"; | ||
import LiveLink from "@/components/icons/LiveLink"; | ||
import MoreVertical from "@/components/icons/MoreVertical"; | ||
import { Button } from "@/components/ui/button"; | ||
import { Checkbox } from "@/components/ui/checkbox"; | ||
import { | ||
DropdownMenu, | ||
DropdownMenuContent, | ||
DropdownMenuItem, | ||
DropdownMenuLabel, | ||
DropdownMenuSeparator, | ||
DropdownMenuTrigger, | ||
} from "@/components/ui/dropdown-menu"; | ||
|
||
export const PaperColumns = [ | ||
{ | ||
id: "select", | ||
header: ({ table }) => ( | ||
<Checkbox | ||
checked={ | ||
table.getIsAllPageRowsSelected() || | ||
(table.getIsSomePageRowsSelected() && "indeterminate") | ||
} | ||
onCheckedChange={(value) => table.toggleAllPageRowsSelected(!!value)} | ||
aria-label="Select all" | ||
className="translate-y-[2px]" | ||
/> | ||
), | ||
cell: ({ row }) => ( | ||
<Checkbox | ||
checked={row.getIsSelected()} | ||
onCheckedChange={(value) => row.toggleSelected(!!value)} | ||
aria-label="Select row" | ||
className="translate-y-[2px]" | ||
/> | ||
), | ||
enableSorting: false, | ||
enableHiding: false, | ||
}, | ||
{ | ||
accessorKey: "uploader", | ||
header: ({ column }) => ( | ||
<Button | ||
variant="ghost" | ||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")} | ||
className="p-0 hover:bg-transparent" | ||
> | ||
Uploader | ||
<ArrowUpDown /> | ||
</Button> | ||
), | ||
}, | ||
{ | ||
accessorKey: "title", | ||
header: ({ column }) => ( | ||
<Button | ||
variant="ghost" | ||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")} | ||
className="p-0 hover:bg-transparent" | ||
> | ||
Title | ||
<ArrowUpDown /> | ||
</Button> | ||
), | ||
}, | ||
{ | ||
accessorKey: "fileUrl", | ||
header: () => "Notes", | ||
cell: ({ row }) => ( | ||
<a href={row.original.fileUrl} target="_blank" rel="noopener noreferrer"> | ||
<LiveLink /> | ||
</a> | ||
), | ||
}, | ||
{ | ||
accessorKey: "viewCount", | ||
header: ({ column }) => ( | ||
<Button | ||
variant="ghost" | ||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")} | ||
className="p-0 hover:bg-transparent" | ||
> | ||
View Count | ||
<ArrowUpDown /> | ||
</Button> | ||
), | ||
}, | ||
{ | ||
accessorKey: "tags", | ||
header: "Tags", | ||
cell: ({ row }) => row.original.tags.join(", "), | ||
}, | ||
{ | ||
accessorKey: "status", | ||
header: ({ column }) => ( | ||
<Button | ||
variant="ghost" | ||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")} | ||
className="p-0 hover:bg-transparent" | ||
> | ||
Status | ||
<ArrowUpDown /> | ||
</Button> | ||
), | ||
cell: ({ row }) => ( | ||
<span | ||
className={`capitalize ${row.original.status === "approved" ? "text-green-500" : "text-yellow-500"}`} | ||
> | ||
{row.original.status} | ||
</span> | ||
), | ||
}, | ||
{ | ||
id: "actions", | ||
cell: ({ row }) => { | ||
const project = row.original; | ||
|
||
const toggleStatus = () => { | ||
// Toggle the status | ||
// const newStatus = | ||
project.status === "approved" ? "pending" : "approved"; | ||
|
||
// You would normally call an API or update the status in your data source here | ||
// For example: updateProjectStatus(project.id, newStatus); | ||
}; | ||
|
||
return ( | ||
<DropdownMenu> | ||
<DropdownMenuTrigger asChild> | ||
<Button variant="ghost" className="w-8 h-8 p-0"> | ||
<span className="sr-only">Open menu</span> | ||
<MoreVertical /> | ||
</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent align="end"> | ||
<DropdownMenuLabel>Actions</DropdownMenuLabel> | ||
|
||
<DropdownMenuItem>Edit</DropdownMenuItem> | ||
<DropdownMenuItem>Delete</DropdownMenuItem> | ||
<DropdownMenuSeparator /> | ||
<DropdownMenuItem onClick={toggleStatus}> | ||
{project.status === "approved" ? "Make Pending" : "Approve"} | ||
</DropdownMenuItem> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
); | ||
}, | ||
}, | ||
]; |
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,18 @@ | ||
import DataTable from "@/components/ui/data-table"; | ||
import { adminNotesData } from "@/data/notes"; | ||
import { PaperColumns } from "./PaperColumns"; | ||
|
||
const PaperTable = () => { | ||
return ( | ||
<div className="flex flex-col space-y-8"> | ||
<div> | ||
<h2 className="text-2xl font-bold tracking-tight">Papers</h2> | ||
<p className="text-muted-foreground">Here's the list of papers!</p> | ||
</div> | ||
|
||
<DataTable data={adminNotesData} columns={PaperColumns} /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default PaperTable; |
131 changes: 131 additions & 0 deletions
131
client/src/components/admin/research/ResearchColumns.jsx
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,131 @@ | ||
import ArrowUpDown from "@/components/icons/ArrowUpDown"; | ||
//import GitHub from "@/components/icons/GitHub"; | ||
import LiveLink from "@/components/icons/LiveLink"; | ||
import MoreVertical from "@/components/icons/MoreVertical"; | ||
import { Button } from "@/components/ui/button"; | ||
import { Checkbox } from "@/components/ui/checkbox"; | ||
import { | ||
DropdownMenu, | ||
DropdownMenuContent, | ||
DropdownMenuItem, | ||
DropdownMenuLabel, | ||
DropdownMenuSeparator, | ||
DropdownMenuTrigger, | ||
} from "@/components/ui/dropdown-menu"; | ||
|
||
export const ResearchColumns = [ | ||
{ | ||
id: "select", | ||
header: ({ table }) => ( | ||
<Checkbox | ||
checked={ | ||
table.getIsAllPageRowsSelected() || | ||
(table.getIsSomePageRowsSelected() && "indeterminate") | ||
} | ||
onCheckedChange={(value) => table.toggleAllPageRowsSelected(!!value)} | ||
aria-label="Select all" | ||
className="translate-y-[2px]" | ||
/> | ||
), | ||
cell: ({ row }) => ( | ||
<Checkbox | ||
checked={row.getIsSelected()} | ||
onCheckedChange={(value) => row.toggleSelected(!!value)} | ||
aria-label="Select row" | ||
className="translate-y-[2px]" | ||
/> | ||
), | ||
enableSorting: false, | ||
enableHiding: false, | ||
}, | ||
{ | ||
accessorKey: "uploader", | ||
header: ({ column }) => ( | ||
<Button | ||
variant="ghost" | ||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")} | ||
className="p-0 hover:bg-transparent" | ||
> | ||
Uploader | ||
<ArrowUpDown /> | ||
</Button> | ||
), | ||
}, | ||
{ | ||
accessorKey: "title", | ||
header: ({ column }) => ( | ||
<Button | ||
variant="ghost" | ||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")} | ||
className="p-0 hover:bg-transparent" | ||
> | ||
Title | ||
<ArrowUpDown /> | ||
</Button> | ||
), | ||
}, | ||
{ | ||
accessorKey: "fileUrl", | ||
header: () => "Notes", | ||
cell: ({ row }) => ( | ||
<a href={row.original.fileUrl} target="_blank" rel="noopener noreferrer"> | ||
<LiveLink /> | ||
</a> | ||
), | ||
}, | ||
{ | ||
accessorKey: "viewCount", | ||
header: ({ column }) => ( | ||
<Button | ||
variant="ghost" | ||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")} | ||
className="p-0 hover:bg-transparent" | ||
> | ||
View Count | ||
<ArrowUpDown /> | ||
</Button> | ||
), | ||
}, | ||
{ | ||
accessorKey: "tags", | ||
header: "Tags", | ||
cell: ({ row }) => row.original.tags.join(", "), | ||
}, | ||
|
||
{ | ||
id: "actions", | ||
cell: ({ row }) => { | ||
const project = row.original; | ||
|
||
const toggleStatus = () => { | ||
// Toggle the status | ||
// const newStatus = | ||
project.status === "approved" ? "pending" : "approved"; | ||
|
||
// You would normally call an API or update the status in your data source here | ||
// For example: updateProjectStatus(project.id, newStatus); | ||
}; | ||
|
||
return ( | ||
<DropdownMenu> | ||
<DropdownMenuTrigger asChild> | ||
<Button variant="ghost" className="w-8 h-8 p-0"> | ||
<span className="sr-only">Open menu</span> | ||
<MoreVertical /> | ||
</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent align="end"> | ||
<DropdownMenuLabel>Actions</DropdownMenuLabel> | ||
|
||
<DropdownMenuItem>Edit</DropdownMenuItem> | ||
<DropdownMenuItem>Delete</DropdownMenuItem> | ||
<DropdownMenuSeparator /> | ||
<DropdownMenuItem onClick={toggleStatus}> | ||
{project.status === "approved" ? "Make Pending" : "Approve"} | ||
</DropdownMenuItem> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
); | ||
}, | ||
}, | ||
]; |
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,20 @@ | ||
import DataTable from "@/components/ui/data-table"; | ||
|
||
import { researchData } from "@/data/researchPaper"; | ||
|
||
import { ResearchColumns } from "./ResearchColumns"; | ||
|
||
const ResearchTable = () => { | ||
return ( | ||
<div className="flex flex-col space-y-8"> | ||
<div> | ||
<h2 className="text-2xl font-bold tracking-tight">Research Papers</h2> | ||
<p className="text-muted-foreground">Here's the list of papers!</p> | ||
</div> | ||
|
||
<DataTable data={researchData} columns={ResearchColumns} /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ResearchTable; |
Oops, something went wrong.