tasko/app/(platform)/(dashboard)/board/[boardId]/page.tsx

51 lines
1,014 B
TypeScript
Raw Normal View History

2024-03-21 21:15:27 +00:00
import { auth } from '@clerk/nextjs/server';
2024-02-16 01:49:19 +00:00
import { redirect } from 'next/navigation';
2024-02-15 02:30:10 +00:00
2024-02-16 01:49:19 +00:00
import { db } from '@/lib/db';
import { ListContainer } from './_components/list-container';
import { BoardRoomWrapper } from './_components/board-room-wrapper';
2024-02-15 02:30:10 +00:00
interface BoardIdPageProps {
params: Promise<{
2024-02-15 02:30:10 +00:00
boardId: string;
}>;
2024-02-15 02:30:10 +00:00
}
const BoardIdPage = async (props: BoardIdPageProps) => {
const params = await props.params;
const { orgId } = await auth();
2024-02-15 02:30:10 +00:00
if (!orgId) {
2024-02-16 01:49:19 +00:00
redirect('/select-org');
2024-02-15 02:30:10 +00:00
}
const lists = await db.list.findMany({
where: {
boardId: params.boardId,
board: {
orgId,
},
},
include: {
cards: {
orderBy: {
2024-02-16 01:49:19 +00:00
order: 'asc',
2024-02-15 02:30:10 +00:00
},
},
},
orderBy: {
2024-02-16 01:49:19 +00:00
order: 'asc',
2024-02-15 02:30:10 +00:00
},
});
return (
<BoardRoomWrapper>
<div className='h-full overflow-x-auto p-4'>
<ListContainer boardId={params.boardId} data={lists} />
</div>
</BoardRoomWrapper>
2024-02-16 01:49:19 +00:00
);
2024-02-15 02:30:10 +00:00
};
export default BoardIdPage;