forked from Kiranism/next-shadcn-dashboard-starter
-
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
Showing
10 changed files
with
208 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,57 @@ | ||
'use client'; | ||
import { AlertModal } from '@/components/modal/alert-modal'; | ||
import { Button } from '@/components/ui/button'; | ||
import { | ||
DropdownMenu, | ||
DropdownMenuContent, | ||
DropdownMenuItem, | ||
DropdownMenuLabel, | ||
DropdownMenuTrigger | ||
} from '@/components/ui/dropdown-menu'; | ||
import { Product } from '@/constants/data'; | ||
import { Edit, MoreHorizontal, Trash } from 'lucide-react'; | ||
import { useRouter } from 'next/navigation'; | ||
import { useState } from 'react'; | ||
|
||
interface CellActionProps { | ||
data: Product; | ||
} | ||
|
||
export const CellAction: React.FC<CellActionProps> = ({ data }) => { | ||
const [loading, setLoading] = useState(false); | ||
const [open, setOpen] = useState(false); | ||
const router = useRouter(); | ||
|
||
const onConfirm = async () => {}; | ||
|
||
return ( | ||
<> | ||
<AlertModal | ||
isOpen={open} | ||
onClose={() => setOpen(false)} | ||
onConfirm={onConfirm} | ||
loading={loading} | ||
/> | ||
<DropdownMenu modal={false}> | ||
<DropdownMenuTrigger asChild> | ||
<Button variant="ghost" className="h-8 w-8 p-0"> | ||
<span className="sr-only">Open menu</span> | ||
<MoreHorizontal className="h-4 w-4" /> | ||
</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent align="end"> | ||
<DropdownMenuLabel>Actions</DropdownMenuLabel> | ||
|
||
<DropdownMenuItem | ||
onClick={() => router.push(`/dashboard/user/${data.id}`)} | ||
> | ||
<Edit className="mr-2 h-4 w-4" /> Update | ||
</DropdownMenuItem> | ||
<DropdownMenuItem onClick={() => setOpen(true)}> | ||
<Trash className="mr-2 h-4 w-4" /> Delete | ||
</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,45 @@ | ||
'use client'; | ||
import { Product } from '@/constants/data'; | ||
import { ColumnDef } from '@tanstack/react-table'; | ||
import Image from 'next/image'; | ||
import { CellAction } from './cell-action'; | ||
|
||
export const columns: ColumnDef<Product>[] = [ | ||
{ | ||
accessorKey: 'photo_url', | ||
header: 'IMAGE', | ||
cell: ({ row }) => { | ||
return ( | ||
<div className="relative aspect-square"> | ||
<Image | ||
src={row.getValue('photo_url')} | ||
alt={row.getValue('name')} | ||
fill | ||
className="rounded-lg" | ||
/> | ||
</div> | ||
); | ||
} | ||
}, | ||
{ | ||
accessorKey: 'name', | ||
header: 'NAME' | ||
}, | ||
{ | ||
accessorKey: 'category', | ||
header: 'CATEGORY' | ||
}, | ||
{ | ||
accessorKey: 'price', | ||
header: 'PRICE' | ||
}, | ||
{ | ||
accessorKey: 'description', | ||
header: 'DESCRIPTION' | ||
}, | ||
|
||
{ | ||
id: 'actions', | ||
cell: ({ row }) => <CellAction data={row.original} /> | ||
} | ||
]; |
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
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
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.