blob: c60bf17fe4efe5f7ebaf3494a47af28959392b5f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
"use client"
import React from "react"
import {CircleDollarSign, SquareStack} from "lucide-react"
import {NavMain} from "@/components/nav-main"
import {
Sidebar,
SidebarContent,
SidebarGroup,
SidebarGroupContent,
SidebarGroupLabel,
SidebarHeader,
SidebarMenu,
SidebarMenuButton,
SidebarMenuItem,
} from "@/components/ui/sidebar"
import {useAppDispatch, useAppSelector} from "@/hooks.ts";
import {App} from "@/models/app.ts"
import {setPage} from "@/models/appSlice.ts";
import {Badge} from "@/components/ui/badge.tsx";
import {useSelector} from "react-redux";
import {selectCashoutMethods} from "@/models/cashoutMethodSlice.ts";
import {selectTransactionHistory} from "@/models/transactionHistorySlice.ts";
export function AppSidebar({...props}: React.ComponentProps<typeof Sidebar>) {
const app: App = useAppSelector(state => state.app)
const dispatch = useAppDispatch()
const cashoutMethods = useSelector(selectCashoutMethods)
const transactionHistory = useSelector(selectTransactionHistory)
return (
<Sidebar collapsible="offcanvas" {...props}>
<SidebarHeader>
<SidebarMenu>
<SidebarMenuItem key="panel_name">
<SidebarMenuButton
asChild
className="data-[slot=sidebar-menu-button]:!p-1.5"
>
<span className="text-base font-semibold">{app.panelName}</span>
</SidebarMenuButton>
</SidebarMenuItem>
</SidebarMenu>
</SidebarHeader>
<SidebarContent>
<NavMain></NavMain>
</SidebarContent>
<SidebarContent>
<SidebarGroup>
<SidebarGroupLabel>Redemption</SidebarGroupLabel>
<SidebarGroupContent>
<SidebarMenu>
<SidebarMenuItem
key="cashout_methods"
className="cursor-pointer"
>
<SidebarMenuButton asChild>
<a
onClick={() => dispatch(setPage("cashout_methods"))}
>
<CircleDollarSign/>
<span>
Methods <Badge
className="absolute top-2 right-2 h-5 min-w-5 rounded-full px-1 font-mono tabular-nums cursor-pointer"
variant="outline"
title={`${cashoutMethods.length.toLocaleString()} cashout methods available`}
>{cashoutMethods.length.toLocaleString()}</Badge>
</span> </a>
</SidebarMenuButton>
</SidebarMenuItem>
<SidebarMenuItem
key="transaction_hisotry"
className="cursor-pointer"
>
<SidebarMenuButton asChild>
<a
onClick={() => dispatch(setPage("transaction_history"))}
>
<SquareStack/>
<span>History <Badge
className="absolute top-2 right-2 h-5 min-w-5 rounded-full px-1 font-mono tabular-nums cursor-pointer"
variant="outline"
>{transactionHistory.length.toLocaleString()}</Badge></span>
</a>
</SidebarMenuButton>
</SidebarMenuItem>
</SidebarMenu>
</SidebarGroupContent>
</SidebarGroup>
</SidebarContent>
</Sidebar>
)
}
|