-
-
- Engage In Our Community Resources
-
+
+

-
+
+
+
+
+
+
+
Temple Beth-El Beit Midrash
+
+
- Welcome
+ Welcome
- {user && {`user.firstName`}}
+ {user && {user.firstName}}
-
- Anim aute id magna aliqua ad ad non deserunt sunt. Qui irure qui lorem cupidatat
- commodo. Elit sunt amet fugiat veniam occaecat fugiat.
-
+
+
+ Never refuse to lend books to anyone who cannot afford to purchase them, but lend
+ books only to those who can be trusted to return them.
+
+
+
- ibn Tibbon
+
@@ -66,9 +101,7 @@ export default async function HomePage() {
Search
-
- {initBrowseBooks && }
-
+
{user && }
{initBrowseBooks && }
@@ -76,13 +109,6 @@ export default async function HomePage() {
Search
-
-
)
}
diff --git a/src/app/(frontend)/serverCalls/requestHold.ts b/src/app/(frontend)/serverCalls/requestHold.ts
index c8ce006..89fe748 100644
--- a/src/app/(frontend)/serverCalls/requestHold.ts
+++ b/src/app/(frontend)/serverCalls/requestHold.ts
@@ -1,5 +1,5 @@
'use server'
-
+import { headers as nextHeaders } from 'next/headers'
import { getPayload } from "payload"
import configPromise from '@payload-config'
@@ -10,11 +10,19 @@ type Props = {
const requestHold = async (props: Props) => {
const payload = await getPayload({ config: configPromise })
+ const headers = await nextHeaders()
+ const authResponse = await payload.auth({ headers })
+ console.log(authResponse.user);
+
+ if (!authResponse.user?.id) return
+
const requestHoldResponse = await payload.create({
collection: 'holdRequests',
data: {
repository: props.repositoryId,
book: props.bookId,
+ userRequested: authResponse.user.id,
+ dateRequested: new Date().toUTCString(),
},
})
diff --git a/src/collections/Users.ts b/src/collections/Users.ts
index cd71f32..25f9832 100644
--- a/src/collections/Users.ts
+++ b/src/collections/Users.ts
@@ -14,6 +14,14 @@ export const Users: CollectionConfig = {
type: 'select',
options: ['admin', 'user'],
saveToJWT: true
- }
+ },
+ {
+ name: 'firstName',
+ type: 'text',
+ },
+ {
+ name: 'lastName',
+ type: 'text',
+ },
],
}
diff --git a/src/components/Feed/UserFeed.tsx b/src/components/Feed/UserFeed.tsx
new file mode 100644
index 0000000..155dcf3
--- /dev/null
+++ b/src/components/Feed/UserFeed.tsx
@@ -0,0 +1,121 @@
+import type { Book, Copy, HoldRequest, Repository, User } from '@/payload-types'
+import { getPayload, PaginatedDocs } from 'payload'
+import config from '@/payload.config'
+import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '../ui/card'
+import Image from 'next/image'
+import { BorderTrail } from 'components/motion-primitives/border-trail'
+import clsx from 'clsx'
+
+const stats = [
+ { name: 'Outbound Loans', stat: '13' },
+ { name: 'Active Holds', stat: '6' },
+ { name: 'Hold Requests', stat: '3', shouldHighlight: true },
+]
+
+type Props = {
+ user?: User
+}
+const UserFeed = async (props: Props) => {
+ const { user } = props
+ const isLoggedIn = !!user
+
+ const payloadConfig = await config
+ const payload = await getPayload({ config: payloadConfig })
+
+ const holdRequests = (await payload.find({
+ collection: 'holdRequests',
+ limit: 6,
+ depth: 3,
+ select: {
+ copy: true,
+ dateRequested: true,
+ repository: true,
+ book: true,
+ },
+ where: {
+ userRequested: {
+ equals: user?.id,
+ },
+ },
+ })) as PaginatedDocs
+
+ return (
+
+
+
Outbound Activity
+
+ {stats.map((item) => (
+
+ {!!item.shouldHighlight && (
+
+ )}
+
- {item.name}
+ -
+ {item.stat}
+
+
+ ))}
+
+
+
+
+
Inbound Activity
+
+
Your Holds
+
+ {holdRequests.docs?.map((h) => {
+ const book = h.book as Book
+ const repository = h.repository as Repository
+
+ const formatedDateRequested = h.dateRequested
+ ? new Date(h.dateRequested).toDateString()
+ : ''
+
+ return (
+ -
+
+
+ {book.title}
+ {repository.abbreviation}
+
+
+
+
+
+ Requested:
+ {formatedDateRequested}
+
+
+
+ )
+ })}
+
+
+
+
+ )
+}
+
+export default UserFeed
diff --git a/src/components/ui/card.tsx b/src/components/ui/card.tsx
new file mode 100644
index 0000000..6b2e2ab
--- /dev/null
+++ b/src/components/ui/card.tsx
@@ -0,0 +1,78 @@
+import * as React from 'react'
+
+import { cn } from '@/lib/utils'
+
+function Card({ className, ...props }: React.ComponentProps<'div'>) {
+ return (
+
+ )
+}
+
+function CardHeader({ className, ...props }: React.ComponentProps<'div'>) {
+ return (
+
+ )
+}
+
+function CardTitle({ className, ...props }: React.ComponentProps<'div'>) {
+ return (
+
+ )
+}
+
+function CardDescription({ className, ...props }: React.ComponentProps<'div'>) {
+ return (
+
+ )
+}
+
+function CardAction({ className, ...props }: React.ComponentProps<'div'>) {
+ return (
+
+ )
+}
+
+function CardContent({ className, ...props }: React.ComponentProps<'div'>) {
+ return
+}
+
+function CardFooter({ className, ...props }: React.ComponentProps<'div'>) {
+ return (
+
+ )
+}
+
+export { Card, CardHeader, CardFooter, CardTitle, CardAction, CardDescription, CardContent }
diff --git a/src/payload-types.ts b/src/payload-types.ts
index dff600a..126820b 100644
--- a/src/payload-types.ts
+++ b/src/payload-types.ts
@@ -156,6 +156,8 @@ export interface UserAuthOperations {
export interface User {
id: number;
role?: ('admin' | 'user') | null;
+ firstName?: string | null;
+ lastName?: string | null;
updatedAt: string;
createdAt: string;
email: string;
@@ -458,6 +460,8 @@ export interface PayloadMigration {
*/
export interface UsersSelect {
role?: T;
+ firstName?: T;
+ lastName?: T;
updatedAt?: T;
createdAt?: T;
email?: T;