mirror of
https://github.com/i701/sarlink-portal.git
synced 2025-02-22 13:42:00 +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.
57 lines
1.6 KiB
TypeScript
57 lines
1.6 KiB
TypeScript
'use client'
|
|
import { Button } from "@/components/ui/button"
|
|
import {
|
|
Popover,
|
|
PopoverContent,
|
|
PopoverTrigger,
|
|
} from "@/components/ui/popover"
|
|
import { authClient } from "@/lib/auth-client";
|
|
import { Loader2, User as UserIcon } from "lucide-react"
|
|
import { useRouter } from "next/navigation"
|
|
import { useState } from "react"
|
|
|
|
export function AccountPopover() {
|
|
const session = authClient.useSession();
|
|
const [loading, setLoading] = useState(false)
|
|
const router = useRouter()
|
|
|
|
if (session.isPending) {
|
|
<Button variant={"outline"} disabled>
|
|
<Loader2 className="animate-spin" />
|
|
</Button>
|
|
}
|
|
return (
|
|
|
|
<Popover>
|
|
<PopoverTrigger asChild>
|
|
<Button className="w-fit px-2" variant="outline">
|
|
<UserIcon />
|
|
</Button>
|
|
</PopoverTrigger>
|
|
<PopoverContent className="w-fit">
|
|
<div className="grid gap-4">
|
|
<div className="space-y-2">
|
|
<h4 className="font-medium leading-none">{session.data?.user?.name}</h4>
|
|
<p className="text-sm text-muted-foreground">
|
|
{session.data?.user?.phoneNumber}
|
|
</p>
|
|
</div>
|
|
<Button disabled={loading} onClick={async () => {
|
|
setLoading(true)
|
|
await authClient.signOut({
|
|
fetchOptions: {
|
|
onSuccess: () => {
|
|
router.push("/login"); // redirect to login page
|
|
},
|
|
},
|
|
})
|
|
setLoading(false)
|
|
}}>
|
|
{loading ? <Loader2 className="animate-spin" /> : "Logout"}
|
|
</Button>
|
|
</div>
|
|
</PopoverContent>
|
|
</Popover>
|
|
)
|
|
}
|