mirror of
https://github.com/i701/sarlink-portal.git
synced 2025-02-22 08:22:01 +00:00
- Introduced wallet payment option in verifyPayment function to allow users to pay using their wallet balance. - Added new BlockDeviceDialog component for managing device blocking and unblocking actions. - Updated DeviceCard component to display device status and integrate blocking functionality. - Refactored DevicesTable to utilize DeviceCard for better UI representation of devices. - Implemented Wallet component to manage wallet balance and top-up functionality. - Enhanced API routes and Prisma schema to support wallet transactions and device blocking reasons. - Improved overall user experience with responsive design adjustments and new UI elements. These changes improve user control over payments and device management, enhancing the overall functionality of the application.
160 lines
3.5 KiB
TypeScript
160 lines
3.5 KiB
TypeScript
import {
|
|
Calculator,
|
|
ChevronRight,
|
|
Coins,
|
|
CreditCard,
|
|
Handshake,
|
|
MonitorSpeaker,
|
|
Smartphone,
|
|
UsersRound,
|
|
Wallet2Icon,
|
|
} from "lucide-react";
|
|
|
|
import {
|
|
Collapsible,
|
|
CollapsibleContent,
|
|
CollapsibleTrigger,
|
|
} from "@/components/ui/collapsible";
|
|
import {
|
|
Sidebar,
|
|
SidebarContent,
|
|
SidebarGroup,
|
|
SidebarGroupContent,
|
|
SidebarGroupLabel,
|
|
SidebarHeader,
|
|
SidebarMenu,
|
|
SidebarMenuButton,
|
|
SidebarMenuItem,
|
|
SidebarRail,
|
|
} from "@/components/ui/sidebar";
|
|
import Link from "next/link";
|
|
|
|
const data = {
|
|
navMain: [
|
|
{
|
|
title: "MENU",
|
|
url: "#",
|
|
requiredRoles: ["ADMIN", "USER"],
|
|
items: [
|
|
{
|
|
title: "Devices",
|
|
url: "/devices",
|
|
icon: <Smartphone size={16} />,
|
|
},
|
|
{
|
|
title: "Payments",
|
|
url: "/payments",
|
|
icon: <CreditCard size={16} />,
|
|
},
|
|
{
|
|
title: "Parental Control",
|
|
url: "/parental-control",
|
|
icon: <CreditCard size={16} />,
|
|
},
|
|
{
|
|
title: "Agreements",
|
|
url: "/agreements",
|
|
icon: <Handshake size={16} />,
|
|
},
|
|
{
|
|
title: "Wallet",
|
|
url: "/wallet",
|
|
icon: <Wallet2Icon size={16} />,
|
|
},
|
|
],
|
|
},
|
|
{
|
|
title: "ADMIN CONTROL",
|
|
url: "#",
|
|
requiredRoles: ["ADMIN"],
|
|
items: [
|
|
{
|
|
title: "Users",
|
|
url: "/users",
|
|
icon: <UsersRound size={16} />,
|
|
},
|
|
{
|
|
title: "User Devices",
|
|
url: "/user-devices",
|
|
icon: <MonitorSpeaker size={16} />,
|
|
},
|
|
{
|
|
title: "User Payments",
|
|
url: "/user-payments",
|
|
icon: <Coins size={16} />,
|
|
},
|
|
{
|
|
title: "Price Calculator",
|
|
url: "/price-calculator",
|
|
icon: <Calculator size={16} />,
|
|
},
|
|
],
|
|
},
|
|
],
|
|
};
|
|
|
|
export function AppSidebar({
|
|
role,
|
|
...props
|
|
}: React.ComponentProps<typeof Sidebar> & { role: string }) {
|
|
return (
|
|
<Sidebar {...props} className="z-50">
|
|
<SidebarHeader>
|
|
<h4 className="p-2 rounded title-bg border text-center uppercase ">
|
|
Sar Link Portal
|
|
</h4>
|
|
</SidebarHeader>
|
|
<SidebarContent className="gap-0">
|
|
{data.navMain
|
|
.filter(
|
|
(item) =>
|
|
!item.requiredRoles || item.requiredRoles.includes(role || ""),
|
|
)
|
|
.map((item) => {
|
|
if (item.requiredRoles?.includes(role)) {
|
|
return (
|
|
<Collapsible
|
|
key={item.title}
|
|
title={item.title}
|
|
defaultOpen
|
|
className="group/collapsible"
|
|
>
|
|
<SidebarGroup>
|
|
<SidebarGroupLabel
|
|
asChild
|
|
className="group/label text-sm text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"
|
|
>
|
|
<CollapsibleTrigger>
|
|
{item.title}{" "}
|
|
<ChevronRight className="ml-auto transition-transform group-data-[state=open]/collapsible:rotate-90" />
|
|
</CollapsibleTrigger>
|
|
</SidebarGroupLabel>
|
|
<CollapsibleContent>
|
|
<SidebarGroupContent>
|
|
<SidebarMenu>
|
|
{item.items.map((item) => (
|
|
<SidebarMenuItem key={item.title}>
|
|
<SidebarMenuButton className="py-6" asChild>
|
|
<Link className="text-md" href={item.url}>
|
|
{item.icon}
|
|
<span className="opacity-70 ml-2">
|
|
{item.title}
|
|
</span>
|
|
</Link>
|
|
</SidebarMenuButton>
|
|
</SidebarMenuItem>
|
|
))}
|
|
</SidebarMenu>
|
|
</SidebarGroupContent>
|
|
</CollapsibleContent>
|
|
</SidebarGroup>
|
|
</Collapsible>
|
|
);
|
|
}
|
|
})}
|
|
</SidebarContent>
|
|
<SidebarRail />
|
|
</Sidebar>
|
|
);
|
|
}
|