- Modified createList to assign ownerId to authenticated user - Updated getLists to filter by user access (owner or collaborator) - Added ownership checks to updateList (owner or editor can update) - Added ownership checks to deleteList (only owner can delete) - Implemented access control for all item operations (create, update, delete, toggle) - Updated getItem, searchItems, and getItemsByFilter to enforce access control - Added dynamic rendering to pages that use authentication - Cascade deletion already handled by database schema (onDelete: Cascade) Requirements: 4.1, 4.2, 4.3, 4.5
40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
import { getLists } from '@/lib/actions'
|
|
import ListCard from '@/components/ListCard'
|
|
import NewListButton from '@/components/NewListButton'
|
|
import GlobalSearch from '@/components/GlobalSearch'
|
|
import EmptyState from '@/components/EmptyState'
|
|
|
|
export const dynamic = 'force-dynamic'
|
|
|
|
export default async function Home() {
|
|
const lists = await getLists()
|
|
|
|
return (
|
|
<main className="container mx-auto px-4 sm:px-6 py-6 sm:py-8 max-w-7xl">
|
|
<div className="flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4 mb-6 sm:mb-8">
|
|
<h1 className="text-2xl sm:text-3xl lg:text-4xl font-bold text-gray-900">Ultimate Lists</h1>
|
|
<NewListButton />
|
|
</div>
|
|
|
|
{/* Global Search */}
|
|
<div className="mb-6 sm:mb-8">
|
|
<GlobalSearch />
|
|
</div>
|
|
|
|
{lists.length === 0 ? (
|
|
<EmptyState
|
|
icon="list"
|
|
title="No lists yet"
|
|
description="Create your first list to start organizing your tasks"
|
|
action={<NewListButton />}
|
|
/>
|
|
) : (
|
|
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4 sm:gap-6 animate-fade-in">
|
|
{lists.map((list) => (
|
|
<ListCard key={list.id} list={list} />
|
|
))}
|
|
</div>
|
|
)}
|
|
</main>
|
|
)
|
|
} |