create-ej-app 1.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +22 -4
- package/package.json +1 -1
- package/template/{.env.example → advanced/.env.example} +4 -0
- package/template/{components.json → advanced/components.json} +1 -1
- package/template/{package.json → advanced/package.json} +11 -0
- package/template/{prisma → advanced/prisma}/schema.prisma +18 -1
- package/template/{src → advanced/src}/app/(app)/tasks/[id]/actions.ts +46 -4
- package/template/{src → advanced/src}/app/(app)/tasks/[id]/render.tsx +136 -25
- package/template/{src → advanced/src}/app/(app)/tasks/actions.ts +0 -6
- package/template/{src → advanced/src}/app/(app)/tasks/page.tsx +0 -3
- package/template/{src → advanced/src}/app/(app)/tasks/render.tsx +0 -10
- package/template/advanced/src/app/api/upload/route.ts +45 -0
- package/template/{src → advanced/src}/app/layout.tsx +1 -1
- package/template/{src → advanced/src}/env.mjs +10 -2
- package/template/advanced/src/styles/editor.css +61 -0
- package/template/{tailwind.config.ts → advanced/tailwind.config.ts} +1 -1
- package/template/base/.env.example +16 -0
- package/template/base/.eslintrc.cjs +24 -0
- package/template/base/components.json +16 -0
- package/template/base/next.config.mjs +18 -0
- package/template/base/package.json +79 -0
- package/template/base/postcss.config.cjs +6 -0
- package/template/base/prettier.config.ts +11 -0
- package/template/base/prisma/schema.prisma +115 -0
- package/template/base/public/next.svg +1 -0
- package/template/base/src/app/(app)/dashboard/page.tsx +19 -0
- package/template/base/src/app/(app)/layout.tsx +90 -0
- package/template/base/src/app/(app)/settings/actions.ts +18 -0
- package/template/base/src/app/(app)/settings/loading.tsx +28 -0
- package/template/base/src/app/(app)/settings/page.tsx +28 -0
- package/template/base/src/app/(app)/settings/render.tsx +113 -0
- package/template/base/src/app/(app)/tasks/[id]/actions.ts +149 -0
- package/template/base/src/app/(app)/tasks/[id]/page.tsx +25 -0
- package/template/base/src/app/(app)/tasks/[id]/render.tsx +413 -0
- package/template/base/src/app/(app)/tasks/actions.ts +69 -0
- package/template/base/src/app/(app)/tasks/page.tsx +53 -0
- package/template/base/src/app/(app)/tasks/render.tsx +107 -0
- package/template/base/src/app/(app)/users/[id]/actions.ts +83 -0
- package/template/base/src/app/(app)/users/[id]/page.tsx +32 -0
- package/template/base/src/app/(app)/users/[id]/render.tsx +240 -0
- package/template/base/src/app/(app)/users/actions.ts +55 -0
- package/template/base/src/app/(app)/users/page.tsx +49 -0
- package/template/base/src/app/(app)/users/render.tsx +80 -0
- package/template/base/src/app/(auth)/layout.tsx +20 -0
- package/template/base/src/app/(auth)/login/page.tsx +49 -0
- package/template/base/src/app/(auth)/login/user-auth-form.tsx +152 -0
- package/template/base/src/app/(marketing)/layout.tsx +42 -0
- package/template/base/src/app/(marketing)/page.tsx +96 -0
- package/template/base/src/app/api/auth/[...nextauth]/route.ts +7 -0
- package/template/base/src/app/api/upload/route.ts +45 -0
- package/template/base/src/app/favicon.ico +0 -0
- package/template/base/src/app/layout.tsx +32 -0
- package/template/base/src/components/app-nav-command.tsx +160 -0
- package/template/base/src/components/dark-mode-toggle.tsx +43 -0
- package/template/base/src/components/data-table/data-table-column-header.tsx +91 -0
- package/template/base/src/components/data-table/data-table-faceted-filter.tsx +149 -0
- package/template/base/src/components/data-table/data-table-loading.tsx +77 -0
- package/template/base/src/components/data-table/data-table-pagination.tsx +94 -0
- package/template/base/src/components/data-table/data-table-toolbar.tsx +78 -0
- package/template/base/src/components/data-table/data-table-types.ts +17 -0
- package/template/base/src/components/data-table/data-table-view-options.tsx +59 -0
- package/template/base/src/components/data-table/data-table.tsx +301 -0
- package/template/base/src/components/data-table/simple-data-table.tsx +109 -0
- package/template/base/src/components/empty-placeholder.tsx +78 -0
- package/template/base/src/components/heading.tsx +17 -0
- package/template/base/src/components/icons.tsx +83 -0
- package/template/base/src/components/main-nav.tsx +64 -0
- package/template/base/src/components/mobile-nav.tsx +50 -0
- package/template/base/src/components/shell.tsx +13 -0
- package/template/base/src/components/side-nav.tsx +51 -0
- package/template/base/src/components/site-footer.tsx +31 -0
- package/template/base/src/components/system-info.tsx +36 -0
- package/template/base/src/components/theme-provider.tsx +13 -0
- package/template/base/src/components/ui/alert-dialog.tsx +145 -0
- package/template/base/src/components/ui/avatar.tsx +50 -0
- package/template/base/src/components/ui/badge.tsx +36 -0
- package/template/base/src/components/ui/button.tsx +56 -0
- package/template/base/src/components/ui/card.tsx +79 -0
- package/template/base/src/components/ui/checkbox.tsx +30 -0
- package/template/base/src/components/ui/command.tsx +155 -0
- package/template/base/src/components/ui/dialog.tsx +123 -0
- package/template/base/src/components/ui/dropdown-menu.tsx +200 -0
- package/template/base/src/components/ui/form.tsx +176 -0
- package/template/base/src/components/ui/input.tsx +25 -0
- package/template/base/src/components/ui/label.tsx +26 -0
- package/template/base/src/components/ui/popover.tsx +31 -0
- package/template/base/src/components/ui/select.tsx +121 -0
- package/template/base/src/components/ui/separator.tsx +31 -0
- package/template/base/src/components/ui/skeleton.tsx +15 -0
- package/template/base/src/components/ui/table.tsx +114 -0
- package/template/base/src/components/ui/textarea.tsx +24 -0
- package/template/base/src/components/ui/toast.tsx +127 -0
- package/template/base/src/components/ui/toaster.tsx +35 -0
- package/template/base/src/components/ui/use-toast.ts +189 -0
- package/template/base/src/components/user-account-nav.tsx +60 -0
- package/template/base/src/components/user-avatar.tsx +25 -0
- package/template/base/src/env.mjs +75 -0
- package/template/base/src/hooks/use-debounce.ts +17 -0
- package/template/base/src/hooks/use-lock-body.tsx +12 -0
- package/template/base/src/lib/auth.ts +79 -0
- package/template/base/src/lib/cn.ts +4 -0
- package/template/base/src/lib/db.ts +20 -0
- package/template/base/src/lib/delay.ts +2 -0
- package/template/base/src/lib/formatDate.ts +11 -0
- package/template/base/src/lib/generateLabel.ts +5 -0
- package/template/base/src/lib/siteConfig.ts +4 -0
- package/template/base/src/styles/editor.css +61 -0
- package/template/base/src/styles/globals.css +76 -0
- package/template/base/src/types/UnwrapPromise.ts +1 -0
- package/template/base/tailwind.config.ts +79 -0
- package/template/base/tsconfig.json +46 -0
- /package/template/{.eslintrc.cjs → advanced/.eslintrc.cjs} +0 -0
- /package/template/{next.config.mjs → advanced/next.config.mjs} +0 -0
- /package/template/{postcss.config.cjs → advanced/postcss.config.cjs} +0 -0
- /package/template/{prettier.config.ts → advanced/prettier.config.ts} +0 -0
- /package/template/{public → advanced/public}/next.svg +0 -0
- /package/template/{src → advanced/src}/app/(app)/dashboard/page.tsx +0 -0
- /package/template/{src → advanced/src}/app/(app)/layout.tsx +0 -0
- /package/template/{src → advanced/src}/app/(app)/roles/[id]/actions.ts +0 -0
- /package/template/{src → advanced/src}/app/(app)/roles/[id]/page.tsx +0 -0
- /package/template/{src → advanced/src}/app/(app)/roles/[id]/render.tsx +0 -0
- /package/template/{src → advanced/src}/app/(app)/roles/actions.ts +0 -0
- /package/template/{src → advanced/src}/app/(app)/roles/page.tsx +0 -0
- /package/template/{src → advanced/src}/app/(app)/roles/render.tsx +0 -0
- /package/template/{src → advanced/src}/app/(app)/settings/actions.ts +0 -0
- /package/template/{src → advanced/src}/app/(app)/settings/loading.tsx +0 -0
- /package/template/{src → advanced/src}/app/(app)/settings/page.tsx +0 -0
- /package/template/{src → advanced/src}/app/(app)/settings/render.tsx +0 -0
- /package/template/{src → advanced/src}/app/(app)/tasks/[id]/page.tsx +0 -0
- /package/template/{src → advanced/src}/app/(app)/users/[id]/actions.ts +0 -0
- /package/template/{src → advanced/src}/app/(app)/users/[id]/page.tsx +0 -0
- /package/template/{src → advanced/src}/app/(app)/users/[id]/render.tsx +0 -0
- /package/template/{src → advanced/src}/app/(app)/users/actions.ts +0 -0
- /package/template/{src → advanced/src}/app/(app)/users/page.tsx +0 -0
- /package/template/{src → advanced/src}/app/(app)/users/render.tsx +0 -0
- /package/template/{src → advanced/src}/app/(auth)/layout.tsx +0 -0
- /package/template/{src → advanced/src}/app/(auth)/login/page.tsx +0 -0
- /package/template/{src → advanced/src}/app/(auth)/login/user-auth-form.tsx +0 -0
- /package/template/{src → advanced/src}/app/(marketing)/layout.tsx +0 -0
- /package/template/{src → advanced/src}/app/(marketing)/page.tsx +0 -0
- /package/template/{src → advanced/src}/app/api/auth/[...nextauth]/route.ts +0 -0
- /package/template/{src → advanced/src}/app/favicon.ico +0 -0
- /package/template/{src → advanced/src}/components/app-nav-command.tsx +0 -0
- /package/template/{src → advanced/src}/components/dark-mode-toggle.tsx +0 -0
- /package/template/{src → advanced/src}/components/data-table/data-table-column-header.tsx +0 -0
- /package/template/{src → advanced/src}/components/data-table/data-table-faceted-filter.tsx +0 -0
- /package/template/{src → advanced/src}/components/data-table/data-table-loading.tsx +0 -0
- /package/template/{src → advanced/src}/components/data-table/data-table-pagination.tsx +0 -0
- /package/template/{src → advanced/src}/components/data-table/data-table-toolbar.tsx +0 -0
- /package/template/{src → advanced/src}/components/data-table/data-table-types.ts +0 -0
- /package/template/{src → advanced/src}/components/data-table/data-table-view-options.tsx +0 -0
- /package/template/{src → advanced/src}/components/data-table/data-table.tsx +0 -0
- /package/template/{src → advanced/src}/components/data-table/simple-data-table.tsx +0 -0
- /package/template/{src → advanced/src}/components/empty-placeholder.tsx +0 -0
- /package/template/{src → advanced/src}/components/heading.tsx +0 -0
- /package/template/{src → advanced/src}/components/icons.tsx +0 -0
- /package/template/{src → advanced/src}/components/main-nav.tsx +0 -0
- /package/template/{src → advanced/src}/components/mobile-nav.tsx +0 -0
- /package/template/{src → advanced/src}/components/shell.tsx +0 -0
- /package/template/{src → advanced/src}/components/side-nav.tsx +0 -0
- /package/template/{src → advanced/src}/components/site-footer.tsx +0 -0
- /package/template/{src → advanced/src}/components/system-info.tsx +0 -0
- /package/template/{src → advanced/src}/components/theme-provider.tsx +0 -0
- /package/template/{src → advanced/src}/components/ui/alert-dialog.tsx +0 -0
- /package/template/{src → advanced/src}/components/ui/avatar.tsx +0 -0
- /package/template/{src → advanced/src}/components/ui/badge.tsx +0 -0
- /package/template/{src → advanced/src}/components/ui/button.tsx +0 -0
- /package/template/{src → advanced/src}/components/ui/card.tsx +0 -0
- /package/template/{src → advanced/src}/components/ui/checkbox.tsx +0 -0
- /package/template/{src → advanced/src}/components/ui/command.tsx +0 -0
- /package/template/{src → advanced/src}/components/ui/dialog.tsx +0 -0
- /package/template/{src → advanced/src}/components/ui/dropdown-menu.tsx +0 -0
- /package/template/{src → advanced/src}/components/ui/form.tsx +0 -0
- /package/template/{src → advanced/src}/components/ui/input.tsx +0 -0
- /package/template/{src → advanced/src}/components/ui/label.tsx +0 -0
- /package/template/{src → advanced/src}/components/ui/popover.tsx +0 -0
- /package/template/{src → advanced/src}/components/ui/select.tsx +0 -0
- /package/template/{src → advanced/src}/components/ui/separator.tsx +0 -0
- /package/template/{src → advanced/src}/components/ui/skeleton.tsx +0 -0
- /package/template/{src → advanced/src}/components/ui/table.tsx +0 -0
- /package/template/{src → advanced/src}/components/ui/textarea.tsx +0 -0
- /package/template/{src → advanced/src}/components/ui/toast.tsx +0 -0
- /package/template/{src → advanced/src}/components/ui/toaster.tsx +0 -0
- /package/template/{src → advanced/src}/components/ui/use-toast.ts +0 -0
- /package/template/{src → advanced/src}/components/user-account-nav.tsx +0 -0
- /package/template/{src → advanced/src}/components/user-avatar.tsx +0 -0
- /package/template/{src → advanced/src}/hooks/use-debounce.ts +0 -0
- /package/template/{src → advanced/src}/hooks/use-lock-body.tsx +0 -0
- /package/template/{src → advanced/src}/lib/auth.ts +0 -0
- /package/template/{src → advanced/src}/lib/cn.ts +0 -0
- /package/template/{src → advanced/src}/lib/db.ts +0 -0
- /package/template/{src → advanced/src}/lib/delay.ts +0 -0
- /package/template/{src → advanced/src}/lib/formatDate.ts +0 -0
- /package/template/{src → advanced/src}/lib/generateLabel.ts +0 -0
- /package/template/{src → advanced/src}/lib/siteConfig.ts +0 -0
- /package/template/{src/app → advanced/src/styles}/globals.css +0 -0
- /package/template/{src → advanced/src}/types/UnwrapPromise.ts +0 -0
- /package/template/{tsconfig.json → advanced/tsconfig.json} +0 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import Link from 'next/link'
|
|
2
|
+
|
|
3
|
+
import { Icons } from '@/components/icons'
|
|
4
|
+
import { Button } from '@/components/ui/button'
|
|
5
|
+
import { UserAuthForm } from './user-auth-form'
|
|
6
|
+
|
|
7
|
+
const LoginPage = () => {
|
|
8
|
+
return (
|
|
9
|
+
<div className="container flex h-[90vh] w-screen flex-col items-center justify-center">
|
|
10
|
+
<Link href="/" className="absolute left-4 top-4">
|
|
11
|
+
<Button variant="ghost">
|
|
12
|
+
<Icons.chevronLeft className="mr-2 h-4 w-4" />
|
|
13
|
+
Back
|
|
14
|
+
</Button>
|
|
15
|
+
</Link>
|
|
16
|
+
<div className="mx-auto flex w-full flex-col justify-center space-y-6 sm:w-80">
|
|
17
|
+
<div className="flex flex-col space-y-2 text-center">
|
|
18
|
+
<Icons.logo className="mx-auto h-6 w-6" />
|
|
19
|
+
<h1 className="text-2xl font-semibold tracking-tight">
|
|
20
|
+
Welcome back
|
|
21
|
+
</h1>
|
|
22
|
+
<p className="text-sm text-muted-foreground">
|
|
23
|
+
Enter your email to sign in to your account
|
|
24
|
+
</p>
|
|
25
|
+
</div>
|
|
26
|
+
<UserAuthForm />
|
|
27
|
+
<p className="px-8 text-center text-sm text-muted-foreground">
|
|
28
|
+
By clicking continue, you agree to our{' '}
|
|
29
|
+
<Link
|
|
30
|
+
href="/terms"
|
|
31
|
+
className="underline underline-offset-4 hover:text-primary"
|
|
32
|
+
>
|
|
33
|
+
Terms of Service
|
|
34
|
+
</Link>{' '}
|
|
35
|
+
and{' '}
|
|
36
|
+
<Link
|
|
37
|
+
href="/privacy"
|
|
38
|
+
className="underline underline-offset-4 hover:text-primary"
|
|
39
|
+
>
|
|
40
|
+
Privacy Policy
|
|
41
|
+
</Link>
|
|
42
|
+
.
|
|
43
|
+
</p>
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default LoginPage
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { zodResolver } from '@hookform/resolvers/zod'
|
|
4
|
+
import { signIn } from 'next-auth/react'
|
|
5
|
+
import { useSearchParams } from 'next/navigation'
|
|
6
|
+
import { FC, HTMLAttributes, useState } from 'react'
|
|
7
|
+
import { useForm } from 'react-hook-form'
|
|
8
|
+
import { z } from 'zod'
|
|
9
|
+
|
|
10
|
+
import { Icons } from '@/components/icons'
|
|
11
|
+
import { Button } from '@/components/ui/button'
|
|
12
|
+
import { Input } from '@/components/ui/input'
|
|
13
|
+
import { Label } from '@/components/ui/label'
|
|
14
|
+
import { toast } from '@/components/ui/use-toast'
|
|
15
|
+
import { cn } from '@/lib/cn'
|
|
16
|
+
|
|
17
|
+
const userAuthSchema = z.object({
|
|
18
|
+
email: z.string().email()
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
type FormData = z.infer<typeof userAuthSchema>
|
|
22
|
+
|
|
23
|
+
interface UserAuthFormProps extends HTMLAttributes<HTMLDivElement> {}
|
|
24
|
+
|
|
25
|
+
export const UserAuthForm: FC = ({
|
|
26
|
+
className,
|
|
27
|
+
...props
|
|
28
|
+
}: UserAuthFormProps) => {
|
|
29
|
+
const {
|
|
30
|
+
register,
|
|
31
|
+
handleSubmit,
|
|
32
|
+
formState: { errors }
|
|
33
|
+
} = useForm<FormData>({
|
|
34
|
+
resolver: zodResolver(userAuthSchema)
|
|
35
|
+
})
|
|
36
|
+
const [isLoading, setIsLoading] = useState(false)
|
|
37
|
+
const [isGoogleLoading, setIsGoogleLoading] = useState(false)
|
|
38
|
+
const [isGithubLoading, setIsGithubLoading] = useState(false)
|
|
39
|
+
|
|
40
|
+
const searchParams = useSearchParams()
|
|
41
|
+
|
|
42
|
+
async function onSubmit(data: FormData) {
|
|
43
|
+
setIsLoading(true)
|
|
44
|
+
|
|
45
|
+
const signInResult = await signIn('email', {
|
|
46
|
+
email: data.email.toLowerCase(),
|
|
47
|
+
redirect: false,
|
|
48
|
+
callbackUrl: searchParams?.get('from') || '/dashboard'
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
setIsLoading(false)
|
|
52
|
+
|
|
53
|
+
if (!signInResult?.ok) {
|
|
54
|
+
return toast({
|
|
55
|
+
title: 'Something went wrong.',
|
|
56
|
+
description: 'Your sign in request failed. Please try again.',
|
|
57
|
+
variant: 'destructive'
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return toast({
|
|
62
|
+
title: 'Check your email',
|
|
63
|
+
description: 'We sent you a login link. Be sure to check your spam too.'
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<div className={cn('grid gap-6', className)} {...props}>
|
|
69
|
+
<form onSubmit={handleSubmit(onSubmit)}>
|
|
70
|
+
<div className="grid gap-2">
|
|
71
|
+
<div className="grid gap-1">
|
|
72
|
+
<Label className="sr-only" htmlFor="email">
|
|
73
|
+
Email
|
|
74
|
+
</Label>
|
|
75
|
+
<Input
|
|
76
|
+
id="email"
|
|
77
|
+
placeholder="name@example.com"
|
|
78
|
+
type="email"
|
|
79
|
+
autoCapitalize="none"
|
|
80
|
+
autoComplete="email"
|
|
81
|
+
autoCorrect="off"
|
|
82
|
+
disabled={isLoading}
|
|
83
|
+
{...register('email')}
|
|
84
|
+
/>
|
|
85
|
+
{errors?.email && (
|
|
86
|
+
<p className="px-1 text-xs text-red-600">
|
|
87
|
+
{errors.email.message}
|
|
88
|
+
</p>
|
|
89
|
+
)}
|
|
90
|
+
</div>
|
|
91
|
+
<Button
|
|
92
|
+
disabled={isLoading || isGoogleLoading || isGithubLoading}
|
|
93
|
+
type="submit"
|
|
94
|
+
>
|
|
95
|
+
{isLoading && (
|
|
96
|
+
<Icons.spinner className="mr-2 h-4 w-4 animate-spin" />
|
|
97
|
+
)}
|
|
98
|
+
Sign in with Email
|
|
99
|
+
</Button>
|
|
100
|
+
</div>
|
|
101
|
+
</form>
|
|
102
|
+
<div className="relative">
|
|
103
|
+
<div className="absolute inset-0 flex items-center">
|
|
104
|
+
<span className="w-full border-t" />
|
|
105
|
+
</div>
|
|
106
|
+
<div className="relative flex justify-center text-xs uppercase">
|
|
107
|
+
<span className="bg-background px-2 text-muted-foreground">
|
|
108
|
+
Or continue with
|
|
109
|
+
</span>
|
|
110
|
+
</div>
|
|
111
|
+
</div>
|
|
112
|
+
<div className="grid gap-2">
|
|
113
|
+
<Button
|
|
114
|
+
variant="outline"
|
|
115
|
+
onClick={async () => {
|
|
116
|
+
setIsGoogleLoading(true)
|
|
117
|
+
await signIn('google', {
|
|
118
|
+
callbackUrl: searchParams?.get('from') || '/dashboard'
|
|
119
|
+
})
|
|
120
|
+
setIsGoogleLoading(false)
|
|
121
|
+
}}
|
|
122
|
+
disabled={isLoading || isGoogleLoading || isGithubLoading}
|
|
123
|
+
>
|
|
124
|
+
{isGoogleLoading ? (
|
|
125
|
+
<Icons.spinner className="mr-2 h-4 w-4 animate-spin" />
|
|
126
|
+
) : (
|
|
127
|
+
<Icons.google className="mr-2 h-4 w-4" />
|
|
128
|
+
)}
|
|
129
|
+
Google
|
|
130
|
+
</Button>
|
|
131
|
+
<Button
|
|
132
|
+
variant="outline"
|
|
133
|
+
onClick={async () => {
|
|
134
|
+
setIsGithubLoading(true)
|
|
135
|
+
await signIn('github', {
|
|
136
|
+
callbackUrl: searchParams?.get('from') || '/dashboard'
|
|
137
|
+
})
|
|
138
|
+
setIsGithubLoading(false)
|
|
139
|
+
}}
|
|
140
|
+
disabled={isLoading || isGoogleLoading || isGithubLoading}
|
|
141
|
+
>
|
|
142
|
+
{isGithubLoading ? (
|
|
143
|
+
<Icons.spinner className="mr-2 h-4 w-4 animate-spin" />
|
|
144
|
+
) : (
|
|
145
|
+
<Icons.github className="mr-2 h-4 w-4" />
|
|
146
|
+
)}
|
|
147
|
+
Github
|
|
148
|
+
</Button>
|
|
149
|
+
</div>
|
|
150
|
+
</div>
|
|
151
|
+
)
|
|
152
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ReactNode } from 'react'
|
|
2
|
+
|
|
3
|
+
import { Icons } from '@/components/icons'
|
|
4
|
+
import { MainNav } from '@/components/main-nav'
|
|
5
|
+
import { SiteFooter } from '@/components/site-footer'
|
|
6
|
+
import { Button } from '@/components/ui/button'
|
|
7
|
+
import { getAuthSession } from '@/lib/auth'
|
|
8
|
+
import Link from 'next/link'
|
|
9
|
+
|
|
10
|
+
const Layout = async ({ children }: { children: ReactNode }) => {
|
|
11
|
+
const session = await getAuthSession()
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<div className="flex min-h-screen flex-col space-y-4">
|
|
15
|
+
<header className="sticky top-0 z-40 border-b bg-background">
|
|
16
|
+
<div className="container flex h-16 items-center justify-between py-4">
|
|
17
|
+
<MainNav />
|
|
18
|
+
<div className="flex items-center justify-center space-x-4">
|
|
19
|
+
{session?.user ? (
|
|
20
|
+
<Link href="/dashboard">
|
|
21
|
+
<Button size="sm" variant="secondary">
|
|
22
|
+
Dashboard
|
|
23
|
+
</Button>
|
|
24
|
+
</Link>
|
|
25
|
+
) : (
|
|
26
|
+
<Link href="/login">
|
|
27
|
+
<Button size="sm" variant="secondary">
|
|
28
|
+
<Icons.login className="mr-2 h-4 w-4" />
|
|
29
|
+
Sign In
|
|
30
|
+
</Button>
|
|
31
|
+
</Link>
|
|
32
|
+
)}
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
</header>
|
|
36
|
+
<main className="flex-1">{children}</main>
|
|
37
|
+
<SiteFooter className="border-t" />
|
|
38
|
+
</div>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export default Layout
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import Image from 'next/image'
|
|
2
|
+
|
|
3
|
+
const links = [
|
|
4
|
+
{
|
|
5
|
+
href: 'https://nextjs.org',
|
|
6
|
+
title: 'Next.js',
|
|
7
|
+
description: 'Find in-depth information about Next.js features and API.'
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
href: 'https://typescriptlang.org',
|
|
11
|
+
title: 'TypeScript',
|
|
12
|
+
description:
|
|
13
|
+
'Learn about TypeScript and how it helps you write better JavaScript.'
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
href: 'https://prisma.io',
|
|
17
|
+
title: 'Prisma',
|
|
18
|
+
description: 'Prisma is a next-generation ORM for Node.js and TypeScript.'
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
href: 'https://next-auth.js.org',
|
|
22
|
+
title: 'NextAuth.js',
|
|
23
|
+
description:
|
|
24
|
+
'Authentication for Next.js featuring sign in with GitHub and more.'
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
href: 'https://tailwindcss.com',
|
|
28
|
+
title: 'Tailwind CSS',
|
|
29
|
+
description:
|
|
30
|
+
'A utility-first CSS framework for rapidly building custom designs.'
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
href: 'https://shadcn.com',
|
|
34
|
+
title: 'Shadcn UI',
|
|
35
|
+
description: 'An awesome ui component library with tailwindcss.'
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
href: 'https://nextjs.org/docs/app/api-reference/functions/server-actions',
|
|
39
|
+
title: 'Server Actions',
|
|
40
|
+
description: 'Learn about Server Actions and how to use them.'
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
href: 'https://vercel.com/new',
|
|
44
|
+
title: 'Vercel',
|
|
45
|
+
description:
|
|
46
|
+
'Instantly deploy your Next.js site to a shareable URL with Vercel.'
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
const Home = () => {
|
|
51
|
+
return (
|
|
52
|
+
<div className="flex min-h-[80vh] flex-col items-center justify-between">
|
|
53
|
+
<div className="max-w-5xl w-full items-center justify-between font-mono text-sm lg:flex">
|
|
54
|
+
<p className="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">
|
|
55
|
+
Get started by editing
|
|
56
|
+
<code className="font-mono font-bold">src/app/page.tsx</code>
|
|
57
|
+
</p>
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
<div className="mt-12 flex place-items-center before:absolute before:h-[300px] before:w-[240px] 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-[120px] 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]">
|
|
61
|
+
<Image
|
|
62
|
+
className="dark:drop-shadow-[0_0_0.3rem_#ffffff70] dark:invert"
|
|
63
|
+
src="/next.svg"
|
|
64
|
+
alt="Next.js Logo"
|
|
65
|
+
width={180}
|
|
66
|
+
height={37}
|
|
67
|
+
priority
|
|
68
|
+
/>
|
|
69
|
+
</div>
|
|
70
|
+
|
|
71
|
+
<div className="my-8 grid text-center lg:max-w-5xl lg:w-full lg:grid-cols-4 lg:text-left gap-2">
|
|
72
|
+
{links.map((l, i) => (
|
|
73
|
+
<a
|
|
74
|
+
key={i}
|
|
75
|
+
href={l.href}
|
|
76
|
+
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"
|
|
77
|
+
target="_blank"
|
|
78
|
+
rel="noopener noreferrer"
|
|
79
|
+
>
|
|
80
|
+
<h2 className="mb-3 text-2xl font-semibold">
|
|
81
|
+
{l.title + ' '}
|
|
82
|
+
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
|
|
83
|
+
->
|
|
84
|
+
</span>
|
|
85
|
+
</h2>
|
|
86
|
+
<p className="m-0 max-w-[30ch] text-sm opacity-50">
|
|
87
|
+
{l.description}
|
|
88
|
+
</p>
|
|
89
|
+
</a>
|
|
90
|
+
))}
|
|
91
|
+
</div>
|
|
92
|
+
</div>
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export default Home
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { GCPStorageClient } from '@ejekanshjain/cloud-storage'
|
|
2
|
+
import { NextRequest, NextResponse } from 'next/server'
|
|
3
|
+
|
|
4
|
+
import { env } from '@/env.mjs'
|
|
5
|
+
import { getAuthSession } from '@/lib/auth'
|
|
6
|
+
import { prisma } from '@/lib/db'
|
|
7
|
+
|
|
8
|
+
const storageClient = GCPStorageClient({
|
|
9
|
+
projectId: env.FIREBASE_PROJECT_ID!,
|
|
10
|
+
privateKey: env.FIREBASE_PRIVATE_KEY!,
|
|
11
|
+
clientEmail: env.FIREBASE_CLIENT_EMAIL!,
|
|
12
|
+
bucket: env.FIREBASE_STORAGE_BUCKET!,
|
|
13
|
+
defaultMediaPublic: true
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
export async function POST(request: NextRequest) {
|
|
17
|
+
const session = await getAuthSession()
|
|
18
|
+
if (!session)
|
|
19
|
+
return NextResponse.json({
|
|
20
|
+
success: false
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
const data = await request.formData()
|
|
24
|
+
const file: File | null = data.get('file') as unknown as File
|
|
25
|
+
|
|
26
|
+
if (!file) return NextResponse.json({ success: false })
|
|
27
|
+
|
|
28
|
+
const bytes = await file.arrayBuffer()
|
|
29
|
+
const buffer = Buffer.from(bytes)
|
|
30
|
+
|
|
31
|
+
const filename = `${Date.now()}-${Math.random()}-${file.name}`
|
|
32
|
+
const url = await storageClient.addFile({
|
|
33
|
+
filename,
|
|
34
|
+
data: buffer
|
|
35
|
+
})
|
|
36
|
+
const { id } = await prisma.resource.create({
|
|
37
|
+
data: {
|
|
38
|
+
newFilename: filename,
|
|
39
|
+
originalFilename: file.name,
|
|
40
|
+
url
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
return NextResponse.json({ success: true, id, url })
|
|
45
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Analytics } from '@vercel/analytics/react'
|
|
2
|
+
import { Metadata } from 'next'
|
|
3
|
+
import { Inter } from 'next/font/google'
|
|
4
|
+
import { ReactNode } from 'react'
|
|
5
|
+
|
|
6
|
+
import { ThemeProvider } from '@/components/theme-provider'
|
|
7
|
+
import { Toaster } from '@/components/ui/toaster'
|
|
8
|
+
import { siteConfig } from '@/lib/siteConfig'
|
|
9
|
+
import '@/styles/globals.css'
|
|
10
|
+
|
|
11
|
+
const inter = Inter({ subsets: ['latin'] })
|
|
12
|
+
|
|
13
|
+
export const metadata: Metadata = {
|
|
14
|
+
title: siteConfig.name,
|
|
15
|
+
description: siteConfig.description
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const RootLayout = ({ children }: { children: ReactNode }) => {
|
|
19
|
+
return (
|
|
20
|
+
<html lang="en" suppressHydrationWarning>
|
|
21
|
+
<body className={inter.className}>
|
|
22
|
+
<ThemeProvider attribute="class" defaultTheme="system" enableSystem>
|
|
23
|
+
{children}
|
|
24
|
+
<Analytics />
|
|
25
|
+
<Toaster />
|
|
26
|
+
</ThemeProvider>
|
|
27
|
+
</body>
|
|
28
|
+
</html>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default RootLayout
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
// import debounce from 'lodash/debounce'
|
|
4
|
+
import { signOut } from 'next-auth/react'
|
|
5
|
+
import { useTheme } from 'next-themes'
|
|
6
|
+
import { useRouter } from 'next/navigation'
|
|
7
|
+
import { FC, useCallback, useEffect, useState } from 'react'
|
|
8
|
+
|
|
9
|
+
import { Icons } from '@/components/icons'
|
|
10
|
+
import { Button } from '@/components/ui/button'
|
|
11
|
+
import {
|
|
12
|
+
Command,
|
|
13
|
+
CommandDialog,
|
|
14
|
+
CommandEmpty,
|
|
15
|
+
CommandGroup,
|
|
16
|
+
CommandInput,
|
|
17
|
+
CommandItem,
|
|
18
|
+
CommandList,
|
|
19
|
+
CommandSeparator
|
|
20
|
+
} from '@/components/ui/command'
|
|
21
|
+
// import { doSearch, type SearchResult } from '../app/(app)/actions/doSearch'
|
|
22
|
+
|
|
23
|
+
export const AppNavCommand: FC<{
|
|
24
|
+
modules: {
|
|
25
|
+
task: boolean
|
|
26
|
+
}
|
|
27
|
+
}> = ({ modules }) => {
|
|
28
|
+
const [open, setOpen] = useState(false)
|
|
29
|
+
// const [search, setSearch] = useState('')
|
|
30
|
+
// const [searchResults, setSearchResults] = useState<SearchResult[]>([])
|
|
31
|
+
const { setTheme } = useTheme()
|
|
32
|
+
const router = useRouter()
|
|
33
|
+
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
const down = (e: KeyboardEvent) => {
|
|
36
|
+
if (e.key === 'k' && (e.metaKey || e.ctrlKey)) {
|
|
37
|
+
e.preventDefault()
|
|
38
|
+
setOpen(open => !open)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
document.addEventListener('keydown', down)
|
|
43
|
+
return () => document.removeEventListener('keydown', down)
|
|
44
|
+
}, [])
|
|
45
|
+
|
|
46
|
+
// useEffect(() => {
|
|
47
|
+
// if (!search) {
|
|
48
|
+
// setSearchResults([])
|
|
49
|
+
// return
|
|
50
|
+
// }
|
|
51
|
+
// doSearch(search).then(results => setSearchResults(results))
|
|
52
|
+
// }, [search])
|
|
53
|
+
|
|
54
|
+
const runCommand = useCallback((command: () => unknown) => {
|
|
55
|
+
setOpen(false)
|
|
56
|
+
command()
|
|
57
|
+
}, [])
|
|
58
|
+
|
|
59
|
+
// const debouncedSearch = useMemo(
|
|
60
|
+
// () =>
|
|
61
|
+
// debounce((search: string) => {
|
|
62
|
+
// setSearch(search)
|
|
63
|
+
// }, 500),
|
|
64
|
+
// []
|
|
65
|
+
// )
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<>
|
|
69
|
+
<Button
|
|
70
|
+
variant="outline"
|
|
71
|
+
className="relative w-36 justify-start text-sm text-muted-foreground lg:w-64"
|
|
72
|
+
onClick={() => setOpen(true)}
|
|
73
|
+
>
|
|
74
|
+
<span className="truncate">Command Menu</span>
|
|
75
|
+
<kbd className="pointer-events-none absolute right-2 top-2 hidden h-5 select-none items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium opacity-100 lg:flex">
|
|
76
|
+
<span className="text-xs">⌘</span>K
|
|
77
|
+
</kbd>
|
|
78
|
+
</Button>
|
|
79
|
+
<CommandDialog open={open} onOpenChange={setOpen}>
|
|
80
|
+
<Command>
|
|
81
|
+
<CommandInput
|
|
82
|
+
placeholder="Search..."
|
|
83
|
+
// onChangeCapture={e => {
|
|
84
|
+
// debouncedSearch((e.target as any)?.value || '')
|
|
85
|
+
// }}
|
|
86
|
+
/>
|
|
87
|
+
<CommandList>
|
|
88
|
+
<CommandEmpty>No search results found.</CommandEmpty>
|
|
89
|
+
<CommandGroup heading="Suggestions">
|
|
90
|
+
<CommandItem
|
|
91
|
+
onSelect={() => runCommand(() => router.push('/dashboard'))}
|
|
92
|
+
>
|
|
93
|
+
<Icons.dashboard className="mr-2 h-4 w-4" />
|
|
94
|
+
Dashboard
|
|
95
|
+
</CommandItem>
|
|
96
|
+
{modules.task ? (
|
|
97
|
+
<CommandItem
|
|
98
|
+
onSelect={() => runCommand(() => router.push('/tasks'))}
|
|
99
|
+
>
|
|
100
|
+
<Icons.task className="mr-2 h-4 w-4" />
|
|
101
|
+
Tasks
|
|
102
|
+
</CommandItem>
|
|
103
|
+
) : undefined}
|
|
104
|
+
</CommandGroup>
|
|
105
|
+
<CommandGroup heading="Account">
|
|
106
|
+
<CommandItem
|
|
107
|
+
onSelect={() => runCommand(() => router.push('/settings'))}
|
|
108
|
+
>
|
|
109
|
+
<Icons.settings className="mr-2 h-4 w-4" />
|
|
110
|
+
Settings
|
|
111
|
+
</CommandItem>
|
|
112
|
+
<CommandItem
|
|
113
|
+
onSelect={() =>
|
|
114
|
+
runCommand(() =>
|
|
115
|
+
signOut({
|
|
116
|
+
callbackUrl: `${window.location.origin}/login`
|
|
117
|
+
})
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
>
|
|
121
|
+
<Icons.logout className="mr-2 h-4 w-4" />
|
|
122
|
+
Sign Out
|
|
123
|
+
</CommandItem>
|
|
124
|
+
</CommandGroup>
|
|
125
|
+
<CommandSeparator />
|
|
126
|
+
<CommandGroup heading="Theme">
|
|
127
|
+
<CommandItem onSelect={() => runCommand(() => setTheme('light'))}>
|
|
128
|
+
<Icons.sun className="mr-2 h-4 w-4" />
|
|
129
|
+
Light
|
|
130
|
+
</CommandItem>
|
|
131
|
+
<CommandItem onSelect={() => runCommand(() => setTheme('dark'))}>
|
|
132
|
+
<Icons.moon className="mr-2 h-4 w-4" />
|
|
133
|
+
Dark
|
|
134
|
+
</CommandItem>
|
|
135
|
+
<CommandItem
|
|
136
|
+
onSelect={() => runCommand(() => setTheme('system'))}
|
|
137
|
+
>
|
|
138
|
+
<Icons.laptop className="mr-2 h-4 w-4" />
|
|
139
|
+
System
|
|
140
|
+
</CommandItem>
|
|
141
|
+
</CommandGroup>
|
|
142
|
+
{/* {searchResults.length ? (
|
|
143
|
+
<CommandGroup heading="Search Results">
|
|
144
|
+
{searchResults.map((sr, i) => (
|
|
145
|
+
<CommandItem
|
|
146
|
+
key={i}
|
|
147
|
+
onSelect={() => runCommand(() => router.push(sr.link))}
|
|
148
|
+
value={sr.id}
|
|
149
|
+
>
|
|
150
|
+
{sr.title}
|
|
151
|
+
</CommandItem>
|
|
152
|
+
))}
|
|
153
|
+
</CommandGroup>
|
|
154
|
+
) : undefined} */}
|
|
155
|
+
</CommandList>
|
|
156
|
+
</Command>
|
|
157
|
+
</CommandDialog>
|
|
158
|
+
</>
|
|
159
|
+
)
|
|
160
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useTheme } from 'next-themes'
|
|
4
|
+
import { FC } from 'react'
|
|
5
|
+
|
|
6
|
+
import { Icons } from '@/components/icons'
|
|
7
|
+
import { Button } from '@/components/ui/button'
|
|
8
|
+
import {
|
|
9
|
+
DropdownMenu,
|
|
10
|
+
DropdownMenuContent,
|
|
11
|
+
DropdownMenuItem,
|
|
12
|
+
DropdownMenuTrigger
|
|
13
|
+
} from '@/components/ui/dropdown-menu'
|
|
14
|
+
|
|
15
|
+
export const DarkModeToggle: FC = () => {
|
|
16
|
+
const { setTheme } = useTheme()
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<DropdownMenu>
|
|
20
|
+
<DropdownMenuTrigger asChild>
|
|
21
|
+
<Button variant="ghost" size="icon">
|
|
22
|
+
<Icons.sun className="rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" />
|
|
23
|
+
<Icons.moon className="absolute rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" />
|
|
24
|
+
<span className="sr-only">Toggle theme</span>
|
|
25
|
+
</Button>
|
|
26
|
+
</DropdownMenuTrigger>
|
|
27
|
+
<DropdownMenuContent align="end">
|
|
28
|
+
<DropdownMenuItem onClick={() => setTheme('light')}>
|
|
29
|
+
<Icons.sun className="mr-2 h-4 w-4" />
|
|
30
|
+
<span>Light</span>
|
|
31
|
+
</DropdownMenuItem>
|
|
32
|
+
<DropdownMenuItem onClick={() => setTheme('dark')}>
|
|
33
|
+
<Icons.moon className="mr-2 h-4 w-4" />
|
|
34
|
+
<span>Dark</span>
|
|
35
|
+
</DropdownMenuItem>
|
|
36
|
+
<DropdownMenuItem onClick={() => setTheme('system')}>
|
|
37
|
+
<Icons.laptop className="mr-2 h-4 w-4" />
|
|
38
|
+
<span>System</span>
|
|
39
|
+
</DropdownMenuItem>
|
|
40
|
+
</DropdownMenuContent>
|
|
41
|
+
</DropdownMenu>
|
|
42
|
+
)
|
|
43
|
+
}
|