blob: ed30766ca8dee4c17cf177f0b24fab11abdedaca (
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
|
import { LogIn, LogOut, Clock } from "lucide-react"
import { Button } from "@/components/ui/button"
import { Auth_get_user } from "@/lib/auth"
import { Auth_tinyauth_public_endpoint } from "@/lib/auth_shared"
import Link from "next/link"
export async function AuthButtons() {
const user = await Auth_get_user()
if (user.isLoggedIn) {
return (
<div className="flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3">
<span className="text-sm text-muted-foreground">{user.email}</span>
<div className="flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3">
<Link href="/history" className="w-full sm:w-auto">
<Button variant="outline" size="sm" className="w-full sm:w-auto">
<Clock className="mr-2 h-4 w-4" />
History
</Button>
</Link>
<form action="/logout" method="post" className="w-full sm:w-auto">
<Button type="submit" variant="outline" className="w-full sm:w-auto">
<LogOut className="mr-2 h-4 w-4" />
Logout
</Button>
</form>
</div>
</div>
)
}
const authUrl = `${Auth_tinyauth_public_endpoint()}/login`
return (
<div className="flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3">
<Link href="/history" className="w-full sm:w-auto">
<Button variant="outline" size="sm" className="w-full sm:w-auto">
<Clock className="mr-2 h-4 w-4" />
History
</Button>
</Link>
<Button asChild className="w-full sm:w-auto">
<a href={authUrl}>
<LogIn className="mr-2 h-4 w-4" />
Login
</a>
</Button>
</div>
)
}
|