add: wip
This commit is contained in:
parent
77f7b60697
commit
957d49c976
|
@ -0,0 +1,72 @@
|
|||
'use client';
|
||||
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem } from '@/components/ui/command';
|
||||
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { Workspace } from '@prisma/client';
|
||||
import { CommandList } from 'cmdk';
|
||||
import { Check, ChevronsUpDown } from 'lucide-react';
|
||||
import { usePathname, useRouter } from 'next/navigation';
|
||||
import React from 'react';
|
||||
|
||||
export default function WorkspaceNavigation({ workspaces }: { workspaces: Pick<Workspace, 'id' | 'name' | 'slug'>[] }) {
|
||||
const pathname = usePathname();
|
||||
|
||||
const [open, setOpen] = React.useState<boolean>(false);
|
||||
const [value, setValue] = React.useState<Pick<Workspace, 'id'> | null>(findSelectedWorkspace());
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
function onWorkspaceSelectionChange(workspace: Pick<Workspace, 'id'>) {
|
||||
router.push(`/${workspaces.find((w) => w.id === workspace.id)?.slug}`);
|
||||
}
|
||||
|
||||
function findSelectedWorkspace(): Pick<Workspace, 'id'> | null {
|
||||
const workspace = pathname.split('/')[1];
|
||||
if (!workspace) return null;
|
||||
const w = workspaces.find((w) => w.slug === workspace);
|
||||
if (!w) return null;
|
||||
return { id: w.id };
|
||||
}
|
||||
|
||||
return (
|
||||
<Popover open={open} onOpenChange={setOpen}>
|
||||
<PopoverTrigger asChild>
|
||||
<Button variant="outline" role="combobox" aria-expanded={open} className="w-[200px] justify-between">
|
||||
{value ? workspaces.find((workspace) => workspace.id === value.id)?.name : 'Select workspace...'}
|
||||
<ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent className="w-[200px] p-0">
|
||||
<Command>
|
||||
<CommandInput placeholder="Search workspace..." />
|
||||
<CommandList>
|
||||
<CommandEmpty>
|
||||
<Button variant="ghost" className="">
|
||||
Create a Workspace
|
||||
</Button>
|
||||
</CommandEmpty>
|
||||
<CommandGroup>
|
||||
{workspaces.map((workspace) => (
|
||||
<CommandItem
|
||||
key={workspace.id}
|
||||
value={workspace.id}
|
||||
keywords={[workspace.name, workspace.slug]}
|
||||
onSelect={(currentValue) => {
|
||||
setValue({ id: currentValue });
|
||||
onWorkspaceSelectionChange({ id: currentValue });
|
||||
setOpen(false);
|
||||
}}
|
||||
>
|
||||
<Check className={cn('mr-2 h-4 w-4', value?.id === workspace.id ? 'opacity-100' : 'opacity-0')} />
|
||||
{workspace.name}
|
||||
</CommandItem>
|
||||
))}
|
||||
</CommandGroup>
|
||||
</CommandList>
|
||||
</Command>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
);
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
'use client';
|
||||
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle, SheetTrigger } from '@/components/ui/sheet';
|
||||
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group';
|
||||
import { Plus } from 'lucide-react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { cn } from '@/lib/utils';
|
||||
import Link from 'next/link';
|
||||
|
||||
export const ServiceProviderList = [
|
||||
{
|
||||
name: 'GitHub',
|
||||
value: 'github',
|
||||
image: 'https://github.githubassets.com/assets/GitHub-Mark-ea2971cee799.png',
|
||||
permission: 'https://github.com/apps/stalin-deploy/installations/new',
|
||||
},
|
||||
{
|
||||
name: 'Registry',
|
||||
value: 'registry',
|
||||
image: '',
|
||||
},
|
||||
{
|
||||
name: 'Github Registry',
|
||||
value: 'github-registry',
|
||||
image: 'https://github.githubassets.com/assets/GitHub-Mark-ea2971cee799.png',
|
||||
},
|
||||
];
|
||||
|
||||
export default function CreateApplicationForm() {
|
||||
const [serviceProvider, setServiceProvider] = useState<string>('github');
|
||||
|
||||
return (
|
||||
<Sheet>
|
||||
<SheetTrigger asChild>
|
||||
<Button className="flex gap-1 justify-center items-center bg-[#3A7BFE]">
|
||||
<Plus />
|
||||
New Application
|
||||
</Button>
|
||||
</SheetTrigger>
|
||||
<SheetContent className="min-w-[500px]">
|
||||
<SheetHeader>
|
||||
<SheetTitle>New Application</SheetTitle>
|
||||
<SheetDescription>Deploy a new application from source</SheetDescription>
|
||||
</SheetHeader>
|
||||
<div>
|
||||
<h3>Select Provider</h3>
|
||||
<RadioGroup defaultValue="github" className="flex flex-col gap-4" onValueChange={setServiceProvider}>
|
||||
{ServiceProviderList.map((provider) => (
|
||||
<div key={provider.value} className={cn('flex flex-row items-center gap-4 border-[1px] rounded-lg py-2 px-4', provider.value == serviceProvider ? 'border-[#3A7BFE]' : 'border-gray-300')}>
|
||||
<RadioGroupItem value={provider.value} id={provider.value} />
|
||||
<label htmlFor={provider.value} className="flex flex-row items-center gap-4">
|
||||
<img src={provider.image} alt={provider.name} className="w-8 h-8 rounded-full" />
|
||||
{provider.name}
|
||||
</label>
|
||||
</div>
|
||||
))}
|
||||
</RadioGroup>
|
||||
{(serviceProvider == 'github' || serviceProvider == 'github-registry') && (
|
||||
<p>
|
||||
Not seeing the repositories you expected here? <Link href={ServiceProviderList.find((s) => s.value == serviceProvider)?.permission || ''}>Edit Your GitHub Permissions</Link>
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</SheetContent>
|
||||
</Sheet>
|
||||
);
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
'use client';
|
||||
|
||||
import { cn } from '@/lib/utils';
|
||||
import { usePathname } from 'next/navigation';
|
||||
|
||||
let links = [
|
||||
{ href: '', label: 'Applications' },
|
||||
{ href: 'databases', label: 'Databases' },
|
||||
{ href: 'registry', label: 'Registry' },
|
||||
{ href: 'settings', label: 'Settings' },
|
||||
];
|
||||
|
||||
export default function Navigation() {
|
||||
let pathname = usePathname();
|
||||
|
||||
return (
|
||||
<nav>
|
||||
<ul className="flex flex-row justify-start mt-4 mb-2 gap-8">
|
||||
{links.map(({ href, label }) => (
|
||||
<li key={label}>
|
||||
<a className={cn('px-3 py-2 rounded-md text-black font-medium text-sm', checkPathname(pathname, href) && 'bg-[#3A7BFE] text-white')} href={setHref(pathname, href)}>
|
||||
{label}
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
|
||||
function checkPathname(pathname: string, href: string): boolean {
|
||||
const route = pathname.split('/')[2] || '';
|
||||
if (route === href) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function setHref(pathname: string, href: string): string {
|
||||
const route = pathname.split('/')[1];
|
||||
if (!route) return '';
|
||||
return `/${route}/${href}`;
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
import { Button } from '@/components/ui/button';
|
||||
import { Database, Plus } from 'lucide-react';
|
||||
|
||||
export default async function Databases() {
|
||||
return (
|
||||
<div className="mt-12">
|
||||
<h1 className="text-3xl font-semibold">Databases</h1>
|
||||
<div className="bg-white py-6 flex flex-col items-center rounded-lg mt-6 gap-4">
|
||||
<Database size={64} className="text-gray-300" />
|
||||
<div className="text-center">
|
||||
<h3 className="font-semibold">No database</h3>
|
||||
<p className="text-gray-700">Get started by creating a new database.</p>
|
||||
</div>
|
||||
<Button className="flex gap-1 justify-center items-center bg-[#3A7BFE]">
|
||||
<Plus />
|
||||
New Database
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
import Navigation from './Navigation';
|
||||
|
||||
export default async function WorkspaceLayout({ children }: Readonly<{ children: React.ReactNode }>) {
|
||||
return (
|
||||
<>
|
||||
<div className="bg-white flex justify-center py-2 pt-4 border-b-2 border-b-gray-200">
|
||||
<div className="container">
|
||||
<div className="border-t-[1px] border-t-gray-200">
|
||||
<Navigation />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="bg-[#ECEFF1] overflow-y-auto flex-grow">
|
||||
<div className="container">{children}</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
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>
|
||||
);
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
import Image from 'next/image';
|
||||
import '../globals.css';
|
||||
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
|
||||
import { redirect } from 'next/navigation';
|
||||
import { getServerSession } from 'next-auth';
|
||||
import prisma from '@/lib/prisma';
|
||||
import WorkspaceNavigation from './WorkspaceNavigation';
|
||||
|
||||
export default async function DashboardLayout({ children }: Readonly<{ children: React.ReactNode }>) {
|
||||
const session = await getServerSession();
|
||||
|
||||
if (!session) {
|
||||
redirect('/sign-in');
|
||||
}
|
||||
|
||||
const workspaces = await prisma.workspace.findMany({
|
||||
where: {
|
||||
ownerId: session.user.id as string,
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="bg-white flex justify-center pt-4">
|
||||
<div className="container">
|
||||
<div className="flex flex-row justify-between items-center">
|
||||
<div>
|
||||
<Image src="/stalin-deploy.png" alt="AkeTechnology" width={200} height={35} />
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
<WorkspaceNavigation workspaces={workspaces} />
|
||||
<Avatar>
|
||||
<AvatarImage src={session.user.image as string} alt={session.user.name as string} />
|
||||
<AvatarFallback>{session.user.name.at(0) as string}</AvatarFallback>
|
||||
</Avatar>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{children}
|
||||
</>
|
||||
);
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
import prisma from '@/lib/prisma';
|
||||
import { getServerSession } from 'next-auth';
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
// This component should never render
|
||||
export default async function NoWorkspace() {
|
||||
const session = await getServerSession();
|
||||
const workspace = await prisma.workspace.findFirst({
|
||||
where: {
|
||||
ownerId: session?.user.id as string,
|
||||
},
|
||||
});
|
||||
|
||||
if (workspace) {
|
||||
redirect(`/${workspace.slug}`);
|
||||
}
|
||||
|
||||
return <div>You don't </div>;
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
'use client';
|
||||
import { SessionProvider } from 'next-auth/react';
|
||||
|
||||
export default function Providers({ children }: { children: React.ReactNode }) {
|
||||
return <SessionProvider>{children}</SessionProvider>;
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
import NextAuth from "next-auth"
|
||||
import { authOptions } from "@/lib/nextauth"
|
||||
|
||||
const handler = NextAuth(authOptions)
|
||||
|
||||
export { handler as GET, handler as POST }
|
|
@ -2,32 +2,75 @@
|
|||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
:root {
|
||||
--foreground-rgb: 0, 0, 0;
|
||||
--background-start-rgb: 214, 219, 220;
|
||||
--background-end-rgb: 255, 255, 255;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
@layer base {
|
||||
:root {
|
||||
--foreground-rgb: 255, 255, 255;
|
||||
--background-start-rgb: 0, 0, 0;
|
||||
--background-end-rgb: 0, 0, 0;
|
||||
--background: 0 0% 100%;
|
||||
--foreground: 222.2 84% 4.9%;
|
||||
|
||||
--card: 0 0% 100%;
|
||||
--card-foreground: 222.2 84% 4.9%;
|
||||
|
||||
--popover: 0 0% 100%;
|
||||
--popover-foreground: 222.2 84% 4.9%;
|
||||
|
||||
--primary: 222.2 47.4% 11.2%;
|
||||
--primary-foreground: 210 40% 98%;
|
||||
|
||||
--secondary: 210 40% 96.1%;
|
||||
--secondary-foreground: 222.2 47.4% 11.2%;
|
||||
|
||||
--muted: 210 40% 96.1%;
|
||||
--muted-foreground: 215.4 16.3% 46.9%;
|
||||
|
||||
--accent: 210 40% 96.1%;
|
||||
--accent-foreground: 222.2 47.4% 11.2%;
|
||||
|
||||
--destructive: 0 84.2% 60.2%;
|
||||
--destructive-foreground: 210 40% 98%;
|
||||
|
||||
--border: 214.3 31.8% 91.4%;
|
||||
--input: 214.3 31.8% 91.4%;
|
||||
--ring: 222.2 84% 4.9%;
|
||||
|
||||
--radius: 0.5rem;
|
||||
}
|
||||
|
||||
.dark {
|
||||
--background: 222.2 84% 4.9%;
|
||||
--foreground: 210 40% 98%;
|
||||
|
||||
--card: 222.2 84% 4.9%;
|
||||
--card-foreground: 210 40% 98%;
|
||||
|
||||
--popover: 222.2 84% 4.9%;
|
||||
--popover-foreground: 210 40% 98%;
|
||||
|
||||
--primary: 210 40% 98%;
|
||||
--primary-foreground: 222.2 47.4% 11.2%;
|
||||
|
||||
--secondary: 217.2 32.6% 17.5%;
|
||||
--secondary-foreground: 210 40% 98%;
|
||||
|
||||
--muted: 217.2 32.6% 17.5%;
|
||||
--muted-foreground: 215 20.2% 65.1%;
|
||||
|
||||
--accent: 217.2 32.6% 17.5%;
|
||||
--accent-foreground: 210 40% 98%;
|
||||
|
||||
--destructive: 0 62.8% 30.6%;
|
||||
--destructive-foreground: 210 40% 98%;
|
||||
|
||||
--border: 217.2 32.6% 17.5%;
|
||||
--input: 217.2 32.6% 17.5%;
|
||||
--ring: 212.7 26.8% 83.9%;
|
||||
}
|
||||
}
|
||||
|
||||
body {
|
||||
color: rgb(var(--foreground-rgb));
|
||||
background: linear-gradient(
|
||||
to bottom,
|
||||
transparent,
|
||||
rgb(var(--background-end-rgb))
|
||||
)
|
||||
rgb(var(--background-start-rgb));
|
||||
}
|
||||
|
||||
@layer utilities {
|
||||
.text-balance {
|
||||
text-wrap: balance;
|
||||
@layer base {
|
||||
* {
|
||||
@apply border-border;
|
||||
}
|
||||
body {
|
||||
@apply bg-background text-foreground;
|
||||
}
|
||||
}
|
|
@ -1,22 +1,22 @@
|
|||
import type { Metadata } from "next";
|
||||
import { Inter } from "next/font/google";
|
||||
import "./globals.css";
|
||||
import type { Metadata } from 'next';
|
||||
import { Inter } from 'next/font/google';
|
||||
import './globals.css';
|
||||
import Providers from './Providers';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const inter = Inter({ subsets: ["latin"] });
|
||||
const inter = Inter({ subsets: ['latin'] });
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Create Next App",
|
||||
description: "Generated by create next app",
|
||||
title: 'Create Next App',
|
||||
description: 'Generated by create next app',
|
||||
};
|
||||
|
||||
export default function RootLayout({
|
||||
children,
|
||||
}: Readonly<{
|
||||
children: React.ReactNode;
|
||||
}>) {
|
||||
return (
|
||||
<html lang="en">
|
||||
<body className={inter.className}>{children}</body>
|
||||
</html>
|
||||
);
|
||||
export default function RootLayout({ children }: Readonly<{ children: React.ReactNode }>) {
|
||||
return (
|
||||
<html lang="en">
|
||||
<body className={cn(inter.className, 'min-h-screen flex flex-col')}>
|
||||
<Providers>{children}</Providers>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
|
|
113
app/page.tsx
113
app/page.tsx
|
@ -1,113 +0,0 @@
|
|||
import Image from "next/image";
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
<main className="flex min-h-screen flex-col items-center justify-between p-24">
|
||||
<div className="z-10 max-w-5xl w-full items-center justify-between font-mono text-sm lg:flex">
|
||||
<p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-auto lg:rounded-xl lg:border lg:bg-gray-200 lg:p-4 lg:dark:bg-zinc-800/30">
|
||||
Get started by editing
|
||||
<code className="font-mono font-bold">app/page.tsx</code>
|
||||
</p>
|
||||
<div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:h-auto lg:w-auto lg:bg-none">
|
||||
<a
|
||||
className="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0"
|
||||
href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
By{" "}
|
||||
<Image
|
||||
src="/vercel.svg"
|
||||
alt="Vercel Logo"
|
||||
className="dark:invert"
|
||||
width={100}
|
||||
height={24}
|
||||
priority
|
||||
/>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="relative flex place-items-center before:absolute before:h-[300px] before:w-full sm:before:w-[480px] before:-translate-x-1/2 before:rounded-full before:bg-gradient-radial before:from-white before:to-transparent before:blur-2xl before:content-[''] after:absolute after:-z-20 after:h-[180px] after:w-full sm:after:w-[240px] after:translate-x-1/3 after:bg-gradient-conic after:from-sky-200 after:via-blue-200 after:blur-2xl after:content-[''] before:dark:bg-gradient-to-br before:dark:from-transparent before:dark:to-blue-700 before:dark:opacity-10 after:dark:from-sky-900 after:dark:via-[#0141ff] after:dark:opacity-40 before:lg:h-[360px] z-[-1]">
|
||||
<Image
|
||||
className="relative dark:drop-shadow-[0_0_0.3rem_#ffffff70] dark:invert"
|
||||
src="/next.svg"
|
||||
alt="Next.js Logo"
|
||||
width={180}
|
||||
height={37}
|
||||
priority
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="mb-32 grid text-center lg:max-w-5xl lg:w-full lg:mb-0 lg:grid-cols-4 lg:text-left">
|
||||
<a
|
||||
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
|
||||
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<h2 className={`mb-3 text-2xl font-semibold`}>
|
||||
Docs{" "}
|
||||
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
|
||||
->
|
||||
</span>
|
||||
</h2>
|
||||
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>
|
||||
Find in-depth information about Next.js features and API.
|
||||
</p>
|
||||
</a>
|
||||
|
||||
<a
|
||||
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
|
||||
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<h2 className={`mb-3 text-2xl font-semibold`}>
|
||||
Learn{" "}
|
||||
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
|
||||
->
|
||||
</span>
|
||||
</h2>
|
||||
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>
|
||||
Learn about Next.js in an interactive course with quizzes!
|
||||
</p>
|
||||
</a>
|
||||
|
||||
<a
|
||||
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
|
||||
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<h2 className={`mb-3 text-2xl font-semibold`}>
|
||||
Templates{" "}
|
||||
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
|
||||
->
|
||||
</span>
|
||||
</h2>
|
||||
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>
|
||||
Explore starter templates for Next.js.
|
||||
</p>
|
||||
</a>
|
||||
|
||||
<a
|
||||
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
|
||||
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<h2 className={`mb-3 text-2xl font-semibold`}>
|
||||
Deploy{" "}
|
||||
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
|
||||
->
|
||||
</span>
|
||||
</h2>
|
||||
<p className={`m-0 max-w-[30ch] text-sm opacity-50 text-balance`}>
|
||||
Instantly deploy your Next.js site to a shareable URL with Vercel.
|
||||
</p>
|
||||
</a>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
export const metadata = {
|
||||
title: 'Next.js',
|
||||
description: 'Generated by Next.js',
|
||||
}
|
||||
|
||||
export default function RootLayout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode
|
||||
}) {
|
||||
return (
|
||||
<html lang="en">
|
||||
<body>{children}</body>
|
||||
</html>
|
||||
)
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
'use client';
|
||||
|
||||
import { signIn, signOut, useSession } from 'next-auth/react';
|
||||
|
||||
export default function SignInPage() {
|
||||
const { data: session } = useSession();
|
||||
if (session) {
|
||||
return (
|
||||
<>
|
||||
Signed in as {session.user?.email} <br />
|
||||
<button onClick={() => signOut()}>Sign out</button>
|
||||
</>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<>
|
||||
Not signed in <br />
|
||||
<button onClick={() => signIn('github')}>Sign in</button>
|
||||
</>
|
||||
);
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
import { PrismaAdapter } from "@auth/prisma-adapter"
|
||||
import NextAuth, { NextAuthOptions, User } from "next-auth"
|
||||
import Github from "next-auth/providers/github"
|
||||
import prisma from "./prisma"
|
||||
import { Adapter } from "next-auth/adapters"
|
||||
|
||||
export const authOptions: NextAuthOptions = {
|
||||
providers: [
|
||||
Github({
|
||||
clientId: process.env.GITHUB_ID as string,
|
||||
clientSecret: process.env.GITHUB_SECRET as string,
|
||||
profile(profile, tokens) {
|
||||
return {
|
||||
id: profile.id,
|
||||
name: profile.name,
|
||||
email: profile.email,
|
||||
image: profile.avatar_url,
|
||||
username: profile.login,
|
||||
} as User;
|
||||
},
|
||||
}),
|
||||
],
|
||||
adapter: PrismaAdapter(prisma) as Adapter,
|
||||
pages: {
|
||||
signIn: "/sign-in",
|
||||
},
|
||||
session: {
|
||||
strategy: "jwt",
|
||||
},
|
||||
callbacks: {
|
||||
session: ({ session, token }) => {
|
||||
return {
|
||||
...session,
|
||||
user: {
|
||||
...session.user,
|
||||
id: token.id,
|
||||
username: token.username,
|
||||
},
|
||||
};
|
||||
},
|
||||
jwt: ({ token, user }) => {
|
||||
if (user) {
|
||||
const u = user as unknown as any;
|
||||
return {
|
||||
...token,
|
||||
id: u.id,
|
||||
username: u.username,
|
||||
};
|
||||
}
|
||||
return token;
|
||||
},
|
||||
},
|
||||
events: {
|
||||
createUser: async ({ user }) => {
|
||||
await prisma.workspace.create({
|
||||
data: {
|
||||
name: user.username + "'s Personal",
|
||||
ownerId: user.id,
|
||||
slug: user.username.toLowerCase(),
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
import { PrismaClient } from '@prisma/client'
|
||||
|
||||
const prismaClientSingleton = () => {
|
||||
return new PrismaClient()
|
||||
}
|
||||
|
||||
declare global {
|
||||
var prismaGlobal: undefined | ReturnType<typeof prismaClientSingleton>
|
||||
}
|
||||
|
||||
const prisma = globalThis.prismaGlobal ?? prismaClientSingleton()
|
||||
|
||||
export default prisma
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') globalThis.prismaGlobal = prisma
|
|
@ -0,0 +1,6 @@
|
|||
import { type ClassValue, clsx } from "clsx"
|
||||
import { twMerge } from "tailwind-merge"
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs))
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,83 @@
|
|||
// This is your Prisma schema file,
|
||||
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
||||
|
||||
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
|
||||
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "mysql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model Account {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
type String
|
||||
provider String
|
||||
providerAccountId String
|
||||
refresh_token String? @db.Text
|
||||
refresh_token_expires_in Int?
|
||||
access_token String? @db.Text
|
||||
expires_at Int?
|
||||
token_type String?
|
||||
scope String?
|
||||
id_token String? @db.Text
|
||||
session_state String?
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([provider, providerAccountId])
|
||||
}
|
||||
|
||||
model Session {
|
||||
id String @id @default(cuid())
|
||||
sessionToken String @unique
|
||||
userId String
|
||||
expires DateTime
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id @default(cuid())
|
||||
name String?
|
||||
username String @unique
|
||||
email String? @unique
|
||||
emailVerified DateTime?
|
||||
image String?
|
||||
accounts Account[]
|
||||
sessions Session[]
|
||||
Workspace Workspace[]
|
||||
}
|
||||
|
||||
model VerificationToken {
|
||||
identifier String
|
||||
token String @unique
|
||||
expires DateTime
|
||||
|
||||
@@unique([identifier, token])
|
||||
}
|
||||
|
||||
model Workspace {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
slug String @unique
|
||||
description String?
|
||||
owner User @relation(fields: [ownerId], references: [id])
|
||||
ownerId String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
Application Application[]
|
||||
}
|
||||
|
||||
model Application {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
Workspace Workspace @relation(fields: [workspaceId], references: [id])
|
||||
workspaceId String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 394 80"><path fill="#000" d="M262 0h68.5v12.7h-27.2v66.6h-13.6V12.7H262V0ZM149 0v12.7H94v20.4h44.3v12.6H94v21h55v12.6H80.5V0h68.7zm34.3 0h-17.8l63.8 79.4h17.9l-32-39.7 32-39.6h-17.9l-23 28.6-23-28.6zm18.3 56.7-9-11-27.1 33.7h17.8l18.3-22.7z"/><path fill="#000" d="M81 79.3 17 0H0v79.3h13.6V17l50.2 62.3H81Zm252.6-.4c-1 0-1.8-.4-2.5-1s-1.1-1.6-1.1-2.6.3-1.8 1-2.5 1.6-1 2.6-1 1.8.3 2.5 1a3.4 3.4 0 0 1 .6 4.3 3.7 3.7 0 0 1-3 1.8zm23.2-33.5h6v23.3c0 2.1-.4 4-1.3 5.5a9.1 9.1 0 0 1-3.8 3.5c-1.6.8-3.5 1.3-5.7 1.3-2 0-3.7-.4-5.3-1s-2.8-1.8-3.7-3.2c-.9-1.3-1.4-3-1.4-5h6c.1.8.3 1.6.7 2.2s1 1.2 1.6 1.5c.7.4 1.5.5 2.4.5 1 0 1.8-.2 2.4-.6a4 4 0 0 0 1.6-1.8c.3-.8.5-1.8.5-3V45.5zm30.9 9.1a4.4 4.4 0 0 0-2-3.3 7.5 7.5 0 0 0-4.3-1.1c-1.3 0-2.4.2-3.3.5-.9.4-1.6 1-2 1.6a3.5 3.5 0 0 0-.3 4c.3.5.7.9 1.3 1.2l1.8 1 2 .5 3.2.8c1.3.3 2.5.7 3.7 1.2a13 13 0 0 1 3.2 1.8 8.1 8.1 0 0 1 3 6.5c0 2-.5 3.7-1.5 5.1a10 10 0 0 1-4.4 3.5c-1.8.8-4.1 1.2-6.8 1.2-2.6 0-4.9-.4-6.8-1.2-2-.8-3.4-2-4.5-3.5a10 10 0 0 1-1.7-5.6h6a5 5 0 0 0 3.5 4.6c1 .4 2.2.6 3.4.6 1.3 0 2.5-.2 3.5-.6 1-.4 1.8-1 2.4-1.7a4 4 0 0 0 .8-2.4c0-.9-.2-1.6-.7-2.2a11 11 0 0 0-2.1-1.4l-3.2-1-3.8-1c-2.8-.7-5-1.7-6.6-3.2a7.2 7.2 0 0 1-2.4-5.7 8 8 0 0 1 1.7-5 10 10 0 0 1 4.3-3.5c2-.8 4-1.2 6.4-1.2 2.3 0 4.4.4 6.2 1.2 1.8.8 3.2 2 4.3 3.4 1 1.4 1.5 3 1.5 5h-5.8z"/></svg>
|
Before Width: | Height: | Size: 1.3 KiB |
|
@ -1 +0,0 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 283 64"><path fill="black" d="M141 16c-11 0-19 7-19 18s9 18 20 18c7 0 13-3 16-7l-7-5c-2 3-6 4-9 4-5 0-9-3-10-7h28v-3c0-11-8-18-19-18zm-9 15c1-4 4-7 9-7s8 3 9 7h-18zm117-15c-11 0-19 7-19 18s9 18 20 18c6 0 12-3 16-7l-8-5c-2 3-5 4-8 4-5 0-9-3-11-7h28l1-3c0-11-8-18-19-18zm-10 15c2-4 5-7 10-7s8 3 9 7h-19zm-39 3c0 6 4 10 10 10 4 0 7-2 9-5l8 5c-3 5-9 8-17 8-11 0-19-7-19-18s8-18 19-18c8 0 14 3 17 8l-8 5c-2-3-5-5-9-5-6 0-10 4-10 10zm83-29v46h-9V5h9zM37 0l37 64H0L37 0zm92 5-27 48L74 5h10l18 30 17-30h10zm59 12v10l-3-1c-6 0-10 4-10 10v15h-9V17h9v9c0-5 6-9 13-9z"/></svg>
|
Before Width: | Height: | Size: 629 B |
|
@ -0,0 +1,21 @@
|
|||
import { DefaultSession } from "next-auth";
|
||||
|
||||
declare module "next-auth" {
|
||||
interface Session extends DefaultSession {
|
||||
user: {
|
||||
id: string;
|
||||
name: string;
|
||||
username: string;
|
||||
email: string;
|
||||
image: string;
|
||||
};
|
||||
}
|
||||
|
||||
interface User {
|
||||
id: string;
|
||||
name: string;
|
||||
username: string;
|
||||
email: string;
|
||||
image: string;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue