init project portal web
This commit is contained in:
38
components/module/action-table/index.tsx
Normal file
38
components/module/action-table/index.tsx
Normal file
@ -0,0 +1,38 @@
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { Input } from "@/components/ui/input"
|
||||
import { Download, Filter, Plus, Upload } from "lucide-react"
|
||||
|
||||
interface Props {
|
||||
onClickNew: () => void
|
||||
}
|
||||
|
||||
const ActionTable = ({
|
||||
onClickNew
|
||||
}: Props) => {
|
||||
return (
|
||||
<div className="flex gap-3 items-center mx-8 mt-4">
|
||||
<Button className="max-w-[74.5px]" variant="default" onClick={onClickNew}>
|
||||
<Plus/>
|
||||
New
|
||||
</Button>
|
||||
<Button className="bg-[#299CDB]" variant="default">
|
||||
<Download/>
|
||||
Import
|
||||
</Button>
|
||||
<Button className="bg-[#E57000]" variant="default">
|
||||
<Upload/>
|
||||
Export
|
||||
</Button>
|
||||
<Input
|
||||
className="border-primary"
|
||||
placeholder="Search for customer, email, phone, status or something.."
|
||||
/>
|
||||
<Button className="bg-[#405189]" variant="default">
|
||||
<Filter/>
|
||||
Filter
|
||||
</Button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default ActionTable
|
||||
81
components/module/app-bar/index.tsx
Normal file
81
components/module/app-bar/index.tsx
Normal file
@ -0,0 +1,81 @@
|
||||
"use client"
|
||||
import { loginRepository } from "@/lib/login/data/repository"
|
||||
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@radix-ui/react-dropdown-menu"
|
||||
import { useMutation } from "@tanstack/react-query"
|
||||
import QueryWrapper from "../query-wrapper"
|
||||
import { useRouter } from "next/navigation"
|
||||
import logo_2 from "@/images/Telkomcel.png"
|
||||
import ava from "@/images/ava.png"
|
||||
import Image from "next/image"
|
||||
import { useEffect, useState } from "react"
|
||||
|
||||
interface Props {
|
||||
useLogo: boolean
|
||||
}
|
||||
|
||||
const Content = ({
|
||||
useLogo
|
||||
}: Props) => {
|
||||
const [username, setUserName] = useState("");
|
||||
const router = useRouter()
|
||||
const mutation = useMutation({
|
||||
mutationFn: () => loginRepository.logout(),
|
||||
onSuccess: () => {
|
||||
router.push("/onboard/login")
|
||||
},
|
||||
onError: () => {
|
||||
console.log('error')
|
||||
},
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
fetch("/api/cookies")
|
||||
.then((res) => res.json())
|
||||
.then((data) => setUserName(data.credential.username));
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="flex justify-between items-center py-5 px-10 bg-white relative w-full">
|
||||
{useLogo ? <div className="flex gap-2">
|
||||
<div className="max-w-60">
|
||||
<Image src={logo_2} alt="logo_2" priority={false}/>
|
||||
</div>
|
||||
</div> : <div/>}
|
||||
<div>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<div className="flex items-center gap-2 cursor-pointer">
|
||||
<div className="text-end">
|
||||
<h4 className="text-black-80 text-base">Welcome,</h4>
|
||||
<h4 className="text-black-100 uppercase">{username}</h4>
|
||||
</div>
|
||||
<Image src={ava} alt="ava" className="cursor-pointer" />
|
||||
</div>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent className="w-56 bg-white mr-8 shadow-md rounded-md transition-transform data-[state=open]:animate-fadeIn data-[state=closed]:animate-fadeOut text-black-70 hover:text-black-50">
|
||||
<DropdownMenuItem className="hover:bg-gray-300 border-none outline-none px-2">
|
||||
<button className="w-full flex justify-start">
|
||||
Profile
|
||||
</button>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem className="hover:bg-gray-300 border-none outline-none px-2">
|
||||
<button className="w-full flex justify-start" onClick={() => mutation.mutate()}>
|
||||
Logout
|
||||
</button>
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const AppBar = ({useLogo = true}: {useLogo: boolean}) => {
|
||||
return (
|
||||
<QueryWrapper>
|
||||
<Content useLogo={useLogo}/>
|
||||
</QueryWrapper>
|
||||
)
|
||||
}
|
||||
|
||||
export default AppBar
|
||||
28
components/module/backdrop/index.tsx
Normal file
28
components/module/backdrop/index.tsx
Normal file
@ -0,0 +1,28 @@
|
||||
import { ReactNode } from "react"
|
||||
|
||||
interface BackdropProps {
|
||||
isOpen: boolean
|
||||
onClose?: () => void
|
||||
children: ReactNode
|
||||
}
|
||||
|
||||
const Backdrop = ({ isOpen, onClose, children }: BackdropProps) => {
|
||||
if (!isOpen) return null
|
||||
|
||||
return (
|
||||
<div className="fixed inset-0 z-50 bg-black-50/70 blur-md flex items-center justify-center">
|
||||
{/* Backdrop layer */}
|
||||
<div
|
||||
className="absolute inset-0"
|
||||
onClick={onClose}
|
||||
/>
|
||||
|
||||
{/* Dialog content */}
|
||||
<div className="relative z-10">
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Backdrop
|
||||
97
components/module/data-table-pagination/index.tsx
Normal file
97
components/module/data-table-pagination/index.tsx
Normal file
@ -0,0 +1,97 @@
|
||||
import { Table } from "@tanstack/react-table"
|
||||
import {
|
||||
ChevronLeft,
|
||||
ChevronRight,
|
||||
ChevronsLeft,
|
||||
ChevronsRight,
|
||||
} from "lucide-react"
|
||||
|
||||
import { Button } from "@/components/ui/button"
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select"
|
||||
|
||||
interface DataTablePaginationProps<TData> {
|
||||
table: Table<TData>
|
||||
}
|
||||
|
||||
export function DataTablePagination<TData>({
|
||||
table,
|
||||
}: DataTablePaginationProps<TData>) {
|
||||
return (
|
||||
<div className="flex items-center justify-between px-2">
|
||||
<div className="flex-1 text-sm text-muted-foreground">
|
||||
{table.getFilteredSelectedRowModel().rows.length} of{" "}
|
||||
{table.getFilteredRowModel().rows.length} row(s) selected.
|
||||
</div>
|
||||
<div className="flex items-center space-x-6 lg:space-x-8">
|
||||
<div className="flex items-center space-x-2">
|
||||
<p className="text-sm font-medium">Rows per page</p>
|
||||
<Select
|
||||
value={`${table.getState().pagination.pageSize}`}
|
||||
onValueChange={(value) => {
|
||||
table.setPageSize(Number(value))
|
||||
}}
|
||||
>
|
||||
<SelectTrigger className="h-8 w-[70px]">
|
||||
<SelectValue placeholder={table.getState().pagination.pageSize} />
|
||||
</SelectTrigger>
|
||||
<SelectContent side="top">
|
||||
{[10, 20, 30, 40, 50].map((pageSize) => (
|
||||
<SelectItem key={pageSize} value={`${pageSize}`}>
|
||||
{pageSize}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<div className="flex w-[100px] items-center justify-center text-sm font-medium">
|
||||
Page {table.getState().pagination.pageIndex + 1} of{" "}
|
||||
{table.getPageCount()}
|
||||
</div>
|
||||
<div className="flex items-center space-x-2">
|
||||
<Button
|
||||
variant="outline"
|
||||
className="hidden h-8 w-8 p-0 lg:flex"
|
||||
onClick={() => table.setPageIndex(0)}
|
||||
disabled={!table.getCanPreviousPage()}
|
||||
>
|
||||
<span className="sr-only">Go to first page</span>
|
||||
<ChevronsLeft />
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
className="h-8 w-8 p-0"
|
||||
onClick={() => table.previousPage()}
|
||||
disabled={!table.getCanPreviousPage()}
|
||||
>
|
||||
<span className="sr-only">Go to previous page</span>
|
||||
<ChevronLeft />
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
className="h-8 w-8 p-0"
|
||||
onClick={() => table.nextPage()}
|
||||
disabled={!table.getCanNextPage()}
|
||||
>
|
||||
<span className="sr-only">Go to next page</span>
|
||||
<ChevronRight />
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
className="hidden h-8 w-8 p-0 lg:flex"
|
||||
onClick={() => table.setPageIndex(table.getPageCount() - 1)}
|
||||
disabled={!table.getCanNextPage()}
|
||||
>
|
||||
<span className="sr-only">Go to last page</span>
|
||||
<ChevronsRight />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
150
components/module/data-table/index.tsx
Normal file
150
components/module/data-table/index.tsx
Normal file
@ -0,0 +1,150 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
ColumnDef,
|
||||
flexRender,
|
||||
getCoreRowModel,
|
||||
getPaginationRowModel,
|
||||
useReactTable,
|
||||
} from "@tanstack/react-table"
|
||||
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "@/components/ui/table"
|
||||
import { DataTablePagination } from "../data-table-pagination";
|
||||
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@/components/ui/alert-dialog";
|
||||
|
||||
interface PaginationState {
|
||||
pageIndex: number
|
||||
pageSize: number
|
||||
pageCount: number
|
||||
setPageIndex: (page: number) => void
|
||||
setPageSize: (size: number) => void
|
||||
}
|
||||
|
||||
interface AlertDialogState {
|
||||
isOpen: boolean
|
||||
title?: string
|
||||
description?: string
|
||||
confirmText?: string
|
||||
cancelText?: string
|
||||
setOpen: (isOpen: boolean) => void
|
||||
onConfirm: () => void
|
||||
onCancel: () => void
|
||||
}
|
||||
|
||||
interface DataTableProps<TData, TValue> {
|
||||
columns: ColumnDef<TData, TValue>[]
|
||||
data: TData[]
|
||||
pagination?: PaginationState,
|
||||
alertDialog?: AlertDialogState,
|
||||
}
|
||||
|
||||
const DataTable = <TData, TValue>({
|
||||
data,
|
||||
columns,
|
||||
pagination,
|
||||
alertDialog
|
||||
}: DataTableProps<TData, TValue>) => {
|
||||
const table = useReactTable({
|
||||
data,
|
||||
columns,
|
||||
pageCount: pagination?.pageCount,
|
||||
state: {
|
||||
pagination: {
|
||||
pageIndex: pagination?.pageIndex ?? 0,
|
||||
pageSize: pagination?.pageSize ?? 10,
|
||||
},
|
||||
},
|
||||
onPaginationChange: (updater) => {
|
||||
if (!pagination) return;
|
||||
const next = typeof updater === 'function'
|
||||
? updater({ pageIndex: pagination.pageIndex, pageSize: pagination.pageSize })
|
||||
: updater;
|
||||
pagination.setPageIndex(next.pageIndex)
|
||||
pagination.setPageSize(next.pageSize)
|
||||
},
|
||||
manualPagination: true,
|
||||
getCoreRowModel: getCoreRowModel(),
|
||||
getPaginationRowModel: getPaginationRowModel(),
|
||||
})
|
||||
|
||||
return (
|
||||
<div className="mx-8 space-y-4">
|
||||
<div className="rounded-md mt-4">
|
||||
<Table className="border-separate border-spacing-0">
|
||||
<TableHeader className="bg-primary rounded-lg">
|
||||
{table.getHeaderGroups().map((headerGroup) => (
|
||||
<TableRow key={headerGroup.id}>
|
||||
{headerGroup.headers.map((header, index) => {
|
||||
const isFirst = index === 0;
|
||||
const isLast = index === headerGroup.headers.length - 1;
|
||||
return (
|
||||
<TableHead
|
||||
key={header.id}
|
||||
className={`text-white ${isFirst ? "rounded-tl-md" : ""} ${isLast ? "rounded-tr-md" : ""}`}
|
||||
>
|
||||
{header.isPlaceholder
|
||||
? null
|
||||
: flexRender(
|
||||
header.column.columnDef.header,
|
||||
header.getContext()
|
||||
)}
|
||||
</TableHead>
|
||||
)
|
||||
})}
|
||||
</TableRow>
|
||||
))}
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{table.getRowModel().rows?.length ? (
|
||||
table.getRowModel().rows.map((row) => (
|
||||
<TableRow
|
||||
key={row.id}
|
||||
data-state={row.getIsSelected() && "selected"}
|
||||
>
|
||||
{row.getVisibleCells().map((cell) => (
|
||||
<TableCell key={cell.id} className="border-b border-[#00879E]">
|
||||
{flexRender(cell.column.columnDef.cell, cell.getContext())}
|
||||
</TableCell>
|
||||
))}
|
||||
</TableRow>
|
||||
))
|
||||
) : (
|
||||
<TableRow>
|
||||
<TableCell colSpan={columns.length} className="h-24 text-center">
|
||||
No results.
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
)}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
<DataTablePagination table={table} />
|
||||
<AlertDialog open={alertDialog?.isOpen} onOpenChange={alertDialog?.setOpen}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
This action cannot be undone. This will permanently remove your data
|
||||
from our servers.
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel onClick={alertDialog?.onCancel}>Cancel</AlertDialogCancel>
|
||||
<AlertDialogAction onClick={alertDialog?.onConfirm}>Continue</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
|
||||
</div>
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
export default DataTable
|
||||
49
components/module/date-picker/index.tsx
Normal file
49
components/module/date-picker/index.tsx
Normal file
@ -0,0 +1,49 @@
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { Calendar } from "@/components/ui/calendar"
|
||||
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"
|
||||
import { cn } from "@/lib/utils"
|
||||
import { format } from "date-fns"
|
||||
import { CalendarIcon } from "lucide-react"
|
||||
import React from "react"
|
||||
|
||||
export function DatePicker({
|
||||
value,
|
||||
onChange,
|
||||
placeholder = "Select Date",
|
||||
}: {
|
||||
value?: Date,
|
||||
placeholder?: string,
|
||||
onChange?: (date: Date | undefined) => void
|
||||
}) {
|
||||
const [date, setDate] = React.useState<Date | undefined>(value)
|
||||
|
||||
React.useEffect(() => {
|
||||
if (onChange) onChange(date)
|
||||
}, [date])
|
||||
|
||||
return (
|
||||
<Popover modal={true}>
|
||||
<PopoverTrigger asChild>
|
||||
<Button
|
||||
variant={"outline"}
|
||||
className={cn(
|
||||
"w-full justify-start text-left font-normal",
|
||||
!date && "text-muted-foreground"
|
||||
)}
|
||||
>
|
||||
<CalendarIcon className="mr-2 h-4 w-4" />
|
||||
{date ? format(date, "PPP") : <span>{placeholder}</span>}
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent className="w-auto p-0" align="start">
|
||||
<Calendar
|
||||
mode="single"
|
||||
selected={date}
|
||||
onSelect={setDate}
|
||||
initialFocus
|
||||
/>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
)
|
||||
}
|
||||
|
||||
201
components/module/dropdown/index.tsx
Normal file
201
components/module/dropdown/index.tsx
Normal file
@ -0,0 +1,201 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu"
|
||||
import { Check, ChevronRight, Circle } from "lucide-react"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const DropdownMenu = DropdownMenuPrimitive.Root
|
||||
|
||||
const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger
|
||||
|
||||
const DropdownMenuGroup = DropdownMenuPrimitive.Group
|
||||
|
||||
const DropdownMenuPortal = DropdownMenuPrimitive.Portal
|
||||
|
||||
const DropdownMenuSub = DropdownMenuPrimitive.Sub
|
||||
|
||||
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup
|
||||
|
||||
const DropdownMenuSubTrigger = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {
|
||||
inset?: boolean
|
||||
}
|
||||
>(({ className, inset, children, ...props }, ref) => (
|
||||
<DropdownMenuPrimitive.SubTrigger
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
||||
inset && "pl-8",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<ChevronRight className="ml-auto" />
|
||||
</DropdownMenuPrimitive.SubTrigger>
|
||||
))
|
||||
DropdownMenuSubTrigger.displayName =
|
||||
DropdownMenuPrimitive.SubTrigger.displayName
|
||||
|
||||
const DropdownMenuSubContent = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<DropdownMenuPrimitive.SubContent
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
DropdownMenuSubContent.displayName =
|
||||
DropdownMenuPrimitive.SubContent.displayName
|
||||
|
||||
const DropdownMenuContent = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>
|
||||
>(({ className, sideOffset = 4, ...props }, ref) => (
|
||||
<DropdownMenuPrimitive.Portal>
|
||||
<DropdownMenuPrimitive.Content
|
||||
ref={ref}
|
||||
sideOffset={sideOffset}
|
||||
className={cn(
|
||||
"z-50 max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md",
|
||||
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
</DropdownMenuPrimitive.Portal>
|
||||
))
|
||||
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName
|
||||
|
||||
const DropdownMenuItem = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.Item>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
|
||||
inset?: boolean
|
||||
}
|
||||
>(({ className, inset, ...props }, ref) => (
|
||||
<DropdownMenuPrimitive.Item
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0",
|
||||
inset && "pl-8",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName
|
||||
|
||||
const DropdownMenuCheckboxItem = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>
|
||||
>(({ className, children, checked, ...props }, ref) => (
|
||||
<DropdownMenuPrimitive.CheckboxItem
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
||||
className
|
||||
)}
|
||||
checked={checked}
|
||||
{...props}
|
||||
>
|
||||
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
||||
<DropdownMenuPrimitive.ItemIndicator>
|
||||
<Check className="h-4 w-4" />
|
||||
</DropdownMenuPrimitive.ItemIndicator>
|
||||
</span>
|
||||
{children}
|
||||
</DropdownMenuPrimitive.CheckboxItem>
|
||||
))
|
||||
DropdownMenuCheckboxItem.displayName =
|
||||
DropdownMenuPrimitive.CheckboxItem.displayName
|
||||
|
||||
const DropdownMenuRadioItem = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>
|
||||
>(({ className, children, ...props }, ref) => (
|
||||
<DropdownMenuPrimitive.RadioItem
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
||||
<DropdownMenuPrimitive.ItemIndicator>
|
||||
<Circle className="h-2 w-2 fill-current" />
|
||||
</DropdownMenuPrimitive.ItemIndicator>
|
||||
</span>
|
||||
{children}
|
||||
</DropdownMenuPrimitive.RadioItem>
|
||||
))
|
||||
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName
|
||||
|
||||
const DropdownMenuLabel = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.Label>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {
|
||||
inset?: boolean
|
||||
}
|
||||
>(({ className, inset, ...props }, ref) => (
|
||||
<DropdownMenuPrimitive.Label
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"px-2 py-1.5 text-sm font-semibold",
|
||||
inset && "pl-8",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName
|
||||
|
||||
const DropdownMenuSeparator = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<DropdownMenuPrimitive.Separator
|
||||
ref={ref}
|
||||
className={cn("-mx-1 my-1 h-px bg-muted", className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName
|
||||
|
||||
const DropdownMenuShortcut = ({
|
||||
className,
|
||||
...props
|
||||
}: React.HTMLAttributes<HTMLSpanElement>) => {
|
||||
return (
|
||||
<span
|
||||
className={cn("ml-auto text-xs tracking-widest opacity-60", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
DropdownMenuShortcut.displayName = "DropdownMenuShortcut"
|
||||
|
||||
export {
|
||||
DropdownMenu,
|
||||
DropdownMenuTrigger,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuCheckboxItem,
|
||||
DropdownMenuRadioItem,
|
||||
DropdownMenuLabel,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuShortcut,
|
||||
DropdownMenuGroup,
|
||||
DropdownMenuPortal,
|
||||
DropdownMenuSub,
|
||||
DropdownMenuSubContent,
|
||||
DropdownMenuSubTrigger,
|
||||
DropdownMenuRadioGroup,
|
||||
}
|
||||
27
components/module/input-password/index.tsx
Normal file
27
components/module/input-password/index.tsx
Normal file
@ -0,0 +1,27 @@
|
||||
import { useState } from "react";
|
||||
import { Eye, EyeOff } from "lucide-react";
|
||||
import { Input } from "@/components/ui/input";
|
||||
|
||||
interface Props extends React.InputHTMLAttributes<HTMLInputElement> {}
|
||||
|
||||
const InputPassword = ({ ...props }: Props) => {
|
||||
const [showPassword, setShowPassword] = useState(false);
|
||||
|
||||
return (
|
||||
<div className="relative w-full">
|
||||
<Input
|
||||
type={showPassword ? "text" : "password"}
|
||||
{...props}
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
className="absolute inset-y-0 right-3 flex items-center text-gray-500"
|
||||
onClick={() => setShowPassword((prev) => !prev)}
|
||||
>
|
||||
{showPassword ? <EyeOff size={20} /> : <Eye size={20} />}
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default InputPassword;
|
||||
10
components/module/query-wrapper/index.tsx
Normal file
10
components/module/query-wrapper/index.tsx
Normal file
@ -0,0 +1,10 @@
|
||||
'use client';
|
||||
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
||||
// import { useState } from 'react';
|
||||
|
||||
export default function QueryWrapper({ children }: { children: React.ReactNode }) {
|
||||
const queryClient = new QueryClient()
|
||||
|
||||
return <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>;
|
||||
}
|
||||
78
components/module/sidebar/price-plan-sidebar/index.tsx
Normal file
78
components/module/sidebar/price-plan-sidebar/index.tsx
Normal file
@ -0,0 +1,78 @@
|
||||
"use client"
|
||||
|
||||
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible"
|
||||
import { Sidebar, SidebarGroup, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarMenu, SidebarMenuButton, SidebarMenuItem } from "@/components/ui/sidebar"
|
||||
import { ChevronDown, DollarSign, LayoutDashboard } from "lucide-react"
|
||||
import mainLogo from "@/images/logo.png"
|
||||
import Image from "next/image"
|
||||
import QueryWrapper from "@/components/module/query-wrapper"
|
||||
import { useMenuPricePlan } from "./view-model"
|
||||
import Link from "next/link"
|
||||
|
||||
const Content = () => {
|
||||
const vm = useMenuPricePlan()
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Sidebar>
|
||||
<SidebarHeader className="mb-12">
|
||||
<div className="flex gap-2 items-center mx-auto">
|
||||
<Image src={mainLogo} alt="main-logo" width={42} height={42} />
|
||||
<h1 className="text-2xl">NetworkPro</h1>
|
||||
</div>
|
||||
</SidebarHeader>
|
||||
<SidebarMenu>
|
||||
<SidebarMenuItem className="px-2">
|
||||
<SidebarMenuButton>
|
||||
<Link href="/" className="flex items-center gap-2 w-full text-white/60">
|
||||
<LayoutDashboard size={14}/>
|
||||
<span className="text-lg font-light">Dashboard</span>
|
||||
</Link>
|
||||
</SidebarMenuButton>
|
||||
</SidebarMenuItem>
|
||||
</SidebarMenu>
|
||||
{vm.getData().map((item, idx) => (
|
||||
<Collapsible defaultOpen className="group/collapsible" key={item.getParentName() + idx}>
|
||||
<SidebarGroup>
|
||||
<SidebarGroupLabel asChild>
|
||||
<CollapsibleTrigger className="flex items-center gap-1 text-white">
|
||||
<DollarSign size={16} />
|
||||
<span className="text-lg font-light">
|
||||
{item.getParentName() === "S" ? "Subscribe" : item.getParentName()}
|
||||
</span>
|
||||
<ChevronDown className="ml-auto transition-transform group-data-[state=open]/collapsible:rotate-180" />
|
||||
</CollapsibleTrigger>
|
||||
</SidebarGroupLabel>
|
||||
</SidebarGroup>
|
||||
<CollapsibleContent className="px-6">
|
||||
<SidebarGroupContent>
|
||||
<SidebarMenu>
|
||||
{item.getPricePlanTypeDto().map((item) => (
|
||||
<SidebarMenuItem key={item.id}>
|
||||
<SidebarMenuButton asChild>
|
||||
<Link href="#" className=" text-base text-white/70 hover:text-black-80">
|
||||
-
|
||||
<span>{item.pricePlanTypeName}</span>
|
||||
</Link>
|
||||
</SidebarMenuButton>
|
||||
</SidebarMenuItem>
|
||||
))}
|
||||
</SidebarMenu>
|
||||
</SidebarGroupContent>
|
||||
</CollapsibleContent>
|
||||
</Collapsible>
|
||||
))}
|
||||
</Sidebar>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const PricePlanSidebar = () => {
|
||||
return (
|
||||
<QueryWrapper>
|
||||
<Content />
|
||||
</QueryWrapper>
|
||||
)
|
||||
}
|
||||
|
||||
export default PricePlanSidebar
|
||||
@ -0,0 +1,19 @@
|
||||
import CommonData from "@/lib/helper/query-data"
|
||||
import { pricePlanRepository } from "@/lib/price-plan/data/repository"
|
||||
import { PricePlanMenuModel } from "@/lib/price-plan/model/menu-model"
|
||||
import { useQuery } from "@tanstack/react-query"
|
||||
|
||||
export const useMenuPricePlan = () => {
|
||||
const query = useQuery({
|
||||
queryKey: ["priceplan-menu"],
|
||||
queryFn: pricePlanRepository.getMenuList,
|
||||
})
|
||||
|
||||
return new CommonData<PricePlanMenuModel[], any>({
|
||||
isLoading: query.isLoading,
|
||||
isError: query.isError,
|
||||
error: query.error,
|
||||
data: query.data ? PricePlanMenuModel.fromJSON(query.data) : [],
|
||||
extra: null
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user