Skip to content

Commit 4bee346

Browse files
committed
feat: terms & privacy pages
1 parent b98751c commit 4bee346

File tree

12 files changed

+152
-21
lines changed

12 files changed

+152
-21
lines changed

app/(protected)/dashboard/page.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,11 @@ export default async function DashboardPage({
133133

134134
<div className="grid my-4 grid-cols-1 gap-4 md:grid-cols-2">
135135
<LibrarySelector
136-
libs={libsRes.data}
136+
libs={libsRes.data.filter((lib) =>
137+
claims.librarease.admin_libs
138+
.concat(claims.librarease.staff_libs)
139+
.includes(lib.id)
140+
)}
137141
lib={library_id}
138142
onChangeAction={onLibraryChange}
139143
/>
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import {
2+
Breadcrumb,
3+
BreadcrumbItem,
4+
BreadcrumbLink,
5+
BreadcrumbList,
6+
BreadcrumbPage,
7+
BreadcrumbSeparator,
8+
} from '@/components/ui/breadcrumb'
9+
import Link from 'next/link'
10+
import { Verify } from '@/lib/firebase/firebase'
11+
import { Badge } from '@/components/ui/badge'
12+
import { getSubscriptionStatus } from '@/lib/utils'
13+
import { Carduser } from '@/components/users/CardUser'
14+
import { Cardsubscription } from '@/components/subscriptions/CardSubscription'
15+
import { CardMembership } from '@/components/memberships/CardMembership'
16+
import { getSubscription } from '@/lib/api/subscription'
17+
18+
export default async function SubscriptionDetailsPage({
19+
params,
20+
}: {
21+
params: Promise<{ id: string }>
22+
}) {
23+
const { id } = await params
24+
25+
await Verify({ from: `/subscriptions/${id}` })
26+
27+
const [subsRes] = await Promise.all([getSubscription({ id })])
28+
29+
if ('error' in subsRes) {
30+
console.log({ libRes: subsRes })
31+
return <div>{JSON.stringify(subsRes.message)}</div>
32+
}
33+
34+
// const cookieStore = await cookies()
35+
// const sessionName = process.env.SESSION_COOKIE_NAME as string
36+
// const session = cookieStore.get(sessionName)
37+
38+
return (
39+
<div className="space-y-4">
40+
<h1 className="text-2xl font-semibold">{subsRes.data.user.name}</h1>
41+
<div className="flex justify-between items-center">
42+
<Breadcrumb>
43+
<BreadcrumbList>
44+
<BreadcrumbItem>
45+
<Link href="/" passHref legacyBehavior>
46+
<BreadcrumbLink>Home</BreadcrumbLink>
47+
</Link>
48+
</BreadcrumbItem>
49+
<BreadcrumbSeparator />
50+
<BreadcrumbItem>
51+
<Link href="/subscriptions" passHref legacyBehavior>
52+
<BreadcrumbLink>Subscriptions</BreadcrumbLink>
53+
</Link>
54+
</BreadcrumbItem>
55+
<BreadcrumbSeparator />
56+
<BreadcrumbItem>
57+
<BreadcrumbPage>{subsRes.data.user.name}</BreadcrumbPage>
58+
</BreadcrumbItem>
59+
</BreadcrumbList>
60+
</Breadcrumb>
61+
62+
<Badge
63+
variant={
64+
getSubscriptionStatus(subsRes.data) === 'active'
65+
? 'default'
66+
: 'secondary'
67+
}
68+
className="uppercase h-8 min-w-24 justify-center"
69+
>
70+
{getSubscriptionStatus(subsRes.data)}
71+
</Badge>
72+
</div>
73+
74+
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
75+
<Carduser user={subsRes.data.user} />
76+
<Cardsubscription subscription={subsRes.data} />
77+
<CardMembership membership={subsRes.data.membership} />
78+
</div>
79+
</div>
80+
)
81+
}

app/(protected)/subscriptions/page.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ export default async function Subscriptions({
116116
<TableBody>
117117
{res.data.map((s) => (
118118
<TableRow key={s.id}>
119-
<TableCell>{s.user?.name}</TableCell>
119+
<TableCell>
120+
<Link href={`subscriptions/${s.id}`}>{s.user?.name}</Link>
121+
</TableCell>
120122
<TableCell>{s.membership?.name}</TableCell>
121123
<TableCell>{s.membership?.library?.name}</TableCell>
122124
<TableCell>

app/globals.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,4 @@ body {
9090
--chart-4: 280 65% 60%;
9191
--chart-5: 340 75% 55%;
9292
}
93-
}
93+
}

app/page.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,23 +61,25 @@ export default async function LibraryDashboard() {
6161
: 2
6262

6363
return (
64-
<main className="min-h-screen bg-white p-8">
64+
<main className="min-h-screen p-8">
6565
<div className="max-w-2xl mx-auto">
6666
<h1 className="text-2xl font-bold mb-8">Librarease</h1>
6767
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
6868
{menuItems.map((item) => {
6969
if (item.level > userLvl) return null
7070
const Icon = item.icon
7171
return (
72-
<Link key={item.href} href={item.href}>
73-
<Button
74-
variant="outline"
75-
className="w-full h-24 flex flex-col items-center justify-center gap-2 hover:bg-slate-50 hover:text-primary"
76-
>
72+
<Button
73+
key={item.href}
74+
variant="outline"
75+
className="w-full h-24 flex flex-col items-center justify-center gap-2"
76+
asChild
77+
>
78+
<Link href={item.href}>
7779
<Icon className="w-6 h-6" />
7880
<span>{item.title}</span>
79-
</Button>
80-
</Link>
81+
</Link>
82+
</Button>
8183
)
8284
})}
8385
</div>

app/privacy/page.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { getPrivacyDoc } from '@/lib/api/docs'
2+
3+
export default async function PrivacyPage() {
4+
const doc = await getPrivacyDoc()
5+
return <div className="prose" dangerouslySetInnerHTML={{ __html: doc }} />
6+
}

app/terms/page.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { getTermsDoc } from '@/lib/api/docs'
2+
3+
export default async function TermsPage() {
4+
const doc = await getTermsDoc()
5+
return <div className="prose" dangerouslySetInnerHTML={{ __html: doc }} />
6+
}

components/borrows/CardBorrow.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ export const CardBorrow: React.FC<{ borrow: BorrowDetail }> = ({ borrow }) => {
2222
<div className="grid grid-cols-3">
2323
<dt className="font-medium">Borrowed At:</dt>
2424
<dd className="col-span-2">
25-
{format(new Date(borrow.borrowed_at), 'dd-M-yy hh:mm a')}
25+
{format(new Date(borrow.borrowed_at), 'MMM d, yyyy hh:mm a')}
2626
{!borrow.returning &&
2727
` (${formatDistanceToNowStrict(new Date(borrow.borrowed_at), { addSuffix: true })})`}
2828
</dd>
2929
</div>
3030
<div className="grid grid-cols-3">
3131
<dt className="font-medium">Due At:</dt>
3232
<dd className="col-span-2">
33-
{format(new Date(borrow.due_at), 'dd-M-yy hh:mm a')}
33+
{format(new Date(borrow.due_at), 'MMM d, yyyy hh:mm a')}
3434
{!borrow.returning &&
3535
` (${formatDistanceToNowStrict(new Date(borrow.due_at), { addSuffix: true })})`}
3636
</dd>
@@ -43,7 +43,7 @@ export const CardBorrow: React.FC<{ borrow: BorrowDetail }> = ({ borrow }) => {
4343
<dd className="col-span-2">
4444
{format(
4545
new Date(borrow.returning.returned_at),
46-
'dd-M-yy hh:mm a'
46+
'MMM d, yyyy hh:mm a'
4747
)}
4848
</dd>
4949
</div>

components/landing.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,16 @@ export default function LandingPage() {
178178
© {new Date().getFullYear()} Librarease. All rights reserved.
179179
</p>
180180
<nav className="sm:ml-auto flex gap-4 sm:gap-6">
181-
<Link className="text-xs hover:underline underline-offset-4" href="#">
181+
<Link
182+
className="text-xs hover:underline underline-offset-4"
183+
href="terms"
184+
>
182185
Terms of Service
183186
</Link>
184-
<Link className="text-xs hover:underline underline-offset-4" href="#">
187+
<Link
188+
className="text-xs hover:underline underline-offset-4"
189+
href="privacy"
190+
>
185191
Privacy
186192
</Link>
187193
</nav>

components/subscriptions/CardSubscription.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
} from '@/lib/utils'
88
import { formatDistanceToNowStrict } from 'date-fns'
99
import { Badge } from '../ui/badge'
10+
import Link from 'next/link'
1011

1112
export const Cardsubscription: React.FC<{ subscription: Subscription }> = ({
1213
subscription,
@@ -15,7 +16,9 @@ export const Cardsubscription: React.FC<{ subscription: Subscription }> = ({
1516
<Card>
1617
<CardHeader>
1718
<div className="flex justify-between items-center">
18-
<CardTitle className="text-lg line-clamp-2">Subscription</CardTitle>
19+
<CardTitle className="text-lg line-clamp-2">
20+
<Link href={`/subscriptions/${subscription.id}`}>Subscription</Link>
21+
</CardTitle>
1922

2023
<Badge
2124
variant={

0 commit comments

Comments
 (0)