import { Button } from '@/components/ui/button';
import prisma from '@/lib/prisma';
import { PackagePlus, Plus } from 'lucide-react';
import CreateApplicationForm from './CreateApplicationForm';

export default async function Workspace({ params }: { params: { workspace: string } }) {
	const applications = await prisma.application.findMany({
		where: {
			Workspace: {
				name: params.workspace,
			},
		},
	});

	if (applications.length == 0) {
		return (
			<div className="mt-12">
				<h1 className="text-3xl font-semibold">Applications</h1>
				<div className="bg-white py-6 flex flex-col items-center rounded-lg mt-6 gap-4">
					<PackagePlus size={64} className="text-gray-300" />
					<div className="text-center">
						<h3 className="font-semibold">No applications</h3>
						<p className="text-gray-700">Get started by creating a new app.</p>
					</div>
					<CreateApplicationForm />
				</div>
			</div>
		);
	}

	return (
		<div className="mt-12">
			<div className="flex flex-row justify-between">
				<h1 className="text-3xl font-semibold">Applications</h1>
				<Button className="flex gap-1 justify-center items-center bg-[#3A7BFE]">
					<Plus />
					New Application
				</Button>
			</div>
			<div className="bg-white py-6 flex flex-col items-center rounded-lg mt-6 gap-4"></div>
		</div>
	);
}
