frontend/app/(deploy)/[workspace]/page.tsx

60 lines
1.7 KiB
TypeScript

import { Button } from '@/components/ui/button';
import prisma from '@/lib/prisma';
import { PackagePlus, Plus } from 'lucide-react';
import CreateApplicationForm from './CreateApplicationForm';
import { getSession } from 'next-auth/react';
export default async function Workspace({ params }: { params: { workspace: string } }) {
const applications = await prisma.application.findMany({
where: {
Workspace: {
name: params.workspace,
},
},
});
const session = await getSession();
const account = await prisma.account.findFirst({
where: {
userId: session?.user.id as string,
},
});
fetch('https://api.github.com/users/fayorg/repos', {
headers: {
Authorization: `Bearer ${account?.access_token}`,
},
})
.then((res) => res.json())
.then(console.log);
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>
);
}