Skip to content

Commit 68a3ccb

Browse files
committed
feat: landing page and dark mode
1 parent 73bd977 commit 68a3ccb

32 files changed

+923
-726
lines changed

app/(protected)/borrows/[id]/page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ export default async function BorrowDetailsPage({
107107
{borrowRes.data.book.title}
108108
</h2>
109109
</Link>
110-
<p className="text-gray-600">{borrowRes.data.book.author}</p>
111-
<p className="text-sm text-gray-500">
110+
<p className="text-foreground/80">{borrowRes.data.book.author}</p>
111+
<p className="text-sm text-foreground/60">
112112
{borrowRes.data.book.code}
113113
</p>
114114
</div>
@@ -325,7 +325,7 @@ export default async function BorrowDetailsPage({
325325
{borrowRes.data.returning ? (
326326
<BtnUndoReturn
327327
variant="outline"
328-
className="w-full"
328+
className="w-full backdrop-blur-md"
329329
borrow={borrowRes.data}
330330
/>
331331
) : (

app/(protected)/memberships/new/page.tsx

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { useForm } from 'react-hook-form'
66
import { z } from 'zod'
77

88
import { cn } from '@/lib/utils'
9-
import { toast } from '@/components/hooks/use-toast'
9+
import { toast } from 'sonner'
1010
import { Button } from '@/components/ui/button'
1111
import {
1212
Command,
@@ -99,17 +99,11 @@ export default function ComboboxForm() {
9999
function onSubmit(data: z.infer<typeof FormSchema>) {
100100
createMembership(data)
101101
.then(() => {
102-
toast({
103-
title: 'Membership Created',
104-
})
102+
toast('Membership Created')
105103
router.push('/memberships')
106104
})
107105
.catch((e) => {
108-
toast({
109-
title: 'Error',
110-
description: e?.error,
111-
variant: 'destructive',
112-
})
106+
toast.error(e?.error)
113107
})
114108
}
115109

@@ -126,10 +120,7 @@ export default function ComboboxForm() {
126120
name: libQ,
127121
}).then((res) => {
128122
if ('error' in res) {
129-
toast({
130-
title: 'Error',
131-
description: res.message,
132-
})
123+
toast.error(res.message)
133124
return
134125
}
135126
setLibs(res.data)

app/(protected)/subscriptions/new/page.tsx

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { useForm } from 'react-hook-form'
66
import { z } from 'zod'
77

88
import { cn } from '@/lib/utils'
9-
import { toast } from '@/components/hooks/use-toast'
9+
import { toast } from 'sonner'
1010
import { Button } from '@/components/ui/button'
1111
import {
1212
Command,
@@ -80,17 +80,11 @@ export default function ComboboxForm() {
8080
createSubscription(data)
8181
.then(console.log)
8282
.then(() => {
83-
toast({
84-
title: 'Purchased Membership',
85-
})
83+
toast('Purchased Membership')
8684
router.push('/subscriptions')
8785
})
8886
.catch((e) => {
89-
toast({
90-
title: 'Error',
91-
description: e?.error,
92-
variant: 'destructive',
93-
})
87+
toast.error(e?.error)
9488
})
9589
}
9690

@@ -107,10 +101,7 @@ export default function ComboboxForm() {
107101
name: userQ,
108102
}).then((res) => {
109103
if ('error' in res) {
110-
toast({
111-
title: 'Error',
112-
description: res.message,
113-
})
104+
toast.error(res.message)
114105
return
115106
}
116107
setUsers(res.data)
@@ -126,10 +117,7 @@ export default function ComboboxForm() {
126117
name: libQ,
127118
}).then((res) => {
128119
if ('error' in res) {
129-
toast({
130-
title: 'Error',
131-
description: res.message,
132-
})
120+
toast.error(res.message)
133121
return
134122
}
135123
setLibs(res.data)
@@ -148,10 +136,7 @@ export default function ComboboxForm() {
148136
library_ids: libID,
149137
}).then((res) => {
150138
if ('error' in res) {
151-
toast({
152-
title: 'Error',
153-
description: res.message,
154-
})
139+
toast.error(res.message)
155140
return
156141
}
157142
setMems(res.data)

app/globals.css

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
/* https://ui.shadcn.com/docs/tailwind-v4 */
7676
:root {
7777
--background: hsl(0 0% 100%);
78-
--foreground: hsl(240 10% 3.9%);
78+
--foreground: hsla(240, 10%, 4%, 0.955);
7979
--card: hsl(0 0% 100%);
8080
--card-foreground: hsl(240 10% 3.9%);
8181
--popover: hsl(0 0% 100%);
@@ -102,10 +102,10 @@
102102
}
103103

104104
.dark {
105-
--background: hsl(20 14.3% 4.1%);
105+
--background: hsl(0 0% 5%);
106106
--foreground: hsl(0 0% 95%);
107-
--card: hsl(24 9.8% 10%);
108-
--card-foreground: hsl(0 0% 95%);
107+
--card: hsl(0 0% 10%);
108+
--card-foreground: hsl(0 0% 85%);
109109
--popover: hsl(0 0% 9%);
110110
--popover-foreground: hsl(0 0% 95%);
111111
--primary: hsl(142.1 70.6% 45.3%);
@@ -116,7 +116,7 @@
116116
--muted-foreground: hsl(240 5% 64.9%);
117117
--accent: hsl(12 6.5% 15.1%);
118118
--accent-foreground: hsl(0 0% 98%);
119-
--destructive: hsl(0 62.8% 30.6%);
119+
--destructive: hsl(0, 64%, 46%);
120120
--destructive-foreground: hsl(0 85.7% 97.3%);
121121
--border: hsl(240 3.7% 15.9%);
122122
--input: hsl(240 3.7% 15.9%);

app/layout.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import type { Metadata, Viewport } from 'next'
22
import { Geist, Geist_Mono } from 'next/font/google'
33
import './globals.css'
4-
import { Toaster } from '@/components/ui/toaster'
4+
import { Toaster } from '@/components/ui/sonner'
55
import { SITE_DESCRIPTION, SITE_NAME } from '@/lib/consts'
6+
import { ThemeProvider } from '@/components/theme-provider'
67

78
const geistSans = Geist({
89
variable: '--font-geist-sans',
@@ -57,12 +58,19 @@ export default function RootLayout({
5758
children: React.ReactNode
5859
}>) {
5960
return (
60-
<html lang="en">
61+
<html lang="en" suppressHydrationWarning>
6162
<body
6263
// container mx-auto px-4
6364
className={`${geistSans.variable} ${geistMono.variable} antialiased mx-auto`}
6465
>
65-
{children}
66+
<ThemeProvider
67+
attribute="class"
68+
defaultTheme="system"
69+
enableSystem
70+
disableTransitionOnChange
71+
>
72+
{children}
73+
</ThemeProvider>
6674
<Toaster />
6775

6876
<script

app/page.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { Button } from '@/components/ui/button'
1414
import { IsLoggedIn } from '@/lib/firebase/firebase'
1515
import Landing from '@/components/landing'
1616
import { logoutAction } from '@/lib/actions/logout'
17+
import { ModeToggle } from '@/components/button-toggle-theme'
1718

1819
const menuItems = [
1920
{ title: 'Dashboard', icon: ChartSpline, href: '/dashboard', level: 3 },
@@ -55,9 +56,12 @@ export default async function LibraryDashboard() {
5556
<div className="max-w-2xl mx-auto space-y-4">
5657
<div className="flex justify-between items-center">
5758
<h1 className="text-2xl font-bold">Librarease</h1>
58-
<Button variant="ghost" onClick={logoutAction}>
59-
Logout
60-
</Button>
59+
<div className="flex items-center gap-2">
60+
<Button variant="ghost" onClick={logoutAction}>
61+
Logout
62+
</Button>
63+
<ModeToggle />
64+
</div>
6165
</div>
6266
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
6367
{menuItems.map((item) => {

components/books/BookForm.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { useForm } from 'react-hook-form'
66
import { z } from 'zod'
77

88
import { cn } from '@/lib/utils'
9-
import { toast } from '@/components/hooks/use-toast'
9+
import { toast } from 'sonner'
1010
import { Button } from '@/components/ui/button'
1111
import {
1212
Command,
@@ -93,10 +93,7 @@ export const BookForm: React.FC<BookFormProps> = ({
9393
name: libQ,
9494
}).then((res) => {
9595
if ('error' in res) {
96-
toast({
97-
title: 'Error',
98-
description: res.message,
99-
})
96+
toast.error(res.message)
10097
return
10198
}
10299
setLibs(res.data)

components/books/book-create-form.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useRouter } from 'next/navigation'
44
import React from 'react'
55
import { BookForm, BookFormValues } from './BookForm'
66
import { createBook } from '@/lib/api/book'
7-
import { toast } from '../hooks/use-toast'
7+
import { toast } from 'sonner'
88

99
const initialData: BookFormValues = {
1010
title: '',
@@ -21,17 +21,11 @@ export const BookCreateForm: React.FC = () => {
2121
createBook(data)
2222
.then(console.log)
2323
.then(() => {
24-
toast({
25-
title: 'Book Registered',
26-
})
24+
toast('Book Registered')
2725
router.push('/books')
2826
})
2927
.catch((e) => {
30-
toast({
31-
title: 'Error',
32-
description: e?.error,
33-
variant: 'destructive',
34-
})
28+
toast.error(e?.error)
3529
})
3630
}
3731

components/borrows/BtnReturnBorrow.tsx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Button } from '../ui/button'
66
import { Lock, Unlock, Loader } from 'lucide-react'
77
import { returnBorrowAction } from '@/lib/actions/return-borrow'
88
import { formatDate } from '@/lib/utils'
9-
import { toast } from '../hooks/use-toast'
9+
import { toast } from 'sonner'
1010

1111
export const BtnReturnBook: React.FC<
1212
React.ComponentProps<typeof Button> & {
@@ -30,11 +30,7 @@ export const BtnReturnBook: React.FC<
3030
setConfirmTimeout(undefined)
3131
const res = await returnBorrowAction(borrow.id)
3232
if ('error' in res) {
33-
toast({
34-
title: 'Failed to return book',
35-
description: res.error,
36-
variant: 'destructive',
37-
})
33+
toast.error(res.error)
3834
return
3935
}
4036
// optimistic update
@@ -44,11 +40,7 @@ export const BtnReturnBook: React.FC<
4440
returned_at: new Date().toISOString(),
4541
} as Borrow['returning'],
4642
}))
47-
toast({
48-
title: 'Success',
49-
description: 'Book returned successfully',
50-
variant: 'default',
51-
})
43+
toast('Book returned successfully')
5244
})
5345
}
5446

components/borrows/BtnUndoReturn.tsx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useTransition, useState } from 'react'
55
import { Button } from '../ui/button'
66
import { Lock, Unlock, Loader } from 'lucide-react'
77
import { undoReturnAction } from '@/lib/actions/undo-return'
8-
import { toast } from '../hooks/use-toast'
8+
import { toast } from 'sonner'
99

1010
export const BtnUndoReturn: React.FC<
1111
React.ComponentProps<typeof Button> & {
@@ -29,23 +29,15 @@ export const BtnUndoReturn: React.FC<
2929
setConfirmTimeout(undefined)
3030
const res = await undoReturnAction(borrow.id)
3131
if ('error' in res) {
32-
toast({
33-
title: 'Failed to undo return book',
34-
description: res.error,
35-
variant: 'destructive',
36-
})
32+
toast.error(res.error)
3733
return
3834
}
3935
// optimistic update
4036
setClientBorrow((prev) => ({
4137
...prev,
4238
returning: undefined,
4339
}))
44-
toast({
45-
title: 'Success',
46-
description: 'Borrow return undone successfully',
47-
variant: 'default',
48-
})
40+
toast('Borrow return undone successfully')
4941
})
5042
}
5143

0 commit comments

Comments
 (0)