Skip to content

Commit 0fbf30e

Browse files
author
Oleksandr Pavlov
committed
init
0 parents  commit 0fbf30e

39 files changed

+8001
-0
lines changed

.env.local

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
DATABASE_HOST=aws.connect.psdb.cloud
2+
DATABASE_USERNAME=whu3tsatlg5jz4cqdvjc
3+
DATABASE_PASSWORD=pscale_pw_nfDvXRL8Myb8cCcSsJOOXrACG460d8MkM4XjNLllYyo
4+
5+
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_aW1tb3J0YWwtdGFoci0wLmNsZXJrLmFjY291bnRzLmRldiQ
6+
CLERK_SECRET_KEY=sk_test_sJqhJbstKY5f1Ol0y3qdutRsaKkOhNQwUtlaZTusbR

.eslintrc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "next/core-web-vitals"
3+
}

.gitignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
*.pem
21+
22+
# debug
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
.pnpm-debug.log*
27+
28+
# local env files
29+
#.env*.local
30+
31+
# vercel
32+
.vercel

.prettierrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"arrowParens": "avoid",
3+
"singleQuote": true,
4+
"jsxSingleQuote": true,
5+
"tabWidth": 2,
6+
"trailingComma": "none",
7+
"semi": false,
8+
"proseWrap": "always",
9+
"printWidth": 80,
10+
"plugins": ["prettier-plugin-tailwindcss"]
11+
}

.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"typescript.tsdk": "node_modules\\.pnpm\\[email protected]\\node_modules\\typescript\\lib",
3+
"typescript.enablePromptUseWorkspaceTsdk": true
4+
}

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
2+
3+
## Getting Started
4+
5+
First, run the development server:
6+
7+
```bash
8+
npm run dev
9+
# or
10+
yarn dev
11+
# or
12+
pnpm dev
13+
```
14+
15+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
16+
17+
You can start editing the page by modifying `app/page.js`. The page auto-updates as you edit the file.
18+
19+
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.js`.
20+
21+
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
22+
23+
This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.
24+
25+
## Learn More
26+
27+
To learn more about Next.js, take a look at the following resources:
28+
29+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
30+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
31+
32+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
33+
34+
## Deploy on Vercel
35+
36+
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
37+
38+
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.

app/admin/layout.tsx

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { ClerkProvider, SignedIn, SignedOut } from '@clerk/nextjs'
2+
import Image from 'next/image'
3+
import Footer from '@/components/layout/footer'
4+
import Header from '@/components/layout/header'
5+
import { Inter } from 'next/font/google'
6+
import '../globals.css'
7+
import { Analytics } from '@vercel/analytics/react';
8+
9+
const inter = Inter({
10+
subsets: ['latin']
11+
})
12+
13+
export const metadata = {
14+
title: 'Alex Pavlov',
15+
description: 'Created by Alex Pavlov'
16+
}
17+
18+
const AdminLayout = ({ children }: {
19+
children: React.ReactNode;
20+
}) => {
21+
return (
22+
<ClerkProvider>
23+
<html
24+
lang='en'
25+
className={`${inter.className} h-full scroll-smooth antialiased`}
26+
>
27+
<body className='flex h-full flex-col text-stone-400'>
28+
29+
<SignedIn>
30+
</SignedIn>
31+
32+
33+
<Header />
34+
<main className='grow'>{children}</main>
35+
<Analytics />
36+
</body>
37+
</html>
38+
</ClerkProvider>
39+
)
40+
}
41+
42+
export default AdminLayout

app/admin/page.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import Posts from '@/app/components/posts'
2+
import Link from 'next/link';
3+
4+
const AdminPage = async () => {
5+
return <>
6+
<div className='container'>
7+
<Link href='/projects/create' className='bg-green-600 color p-3 text-white'>Create a new project</Link>
8+
{/* @ts-expect-error Server Component */}
9+
<Posts />
10+
</div>
11+
</>
12+
}
13+
14+
export default AdminPage;
15+

app/admin/sign-in/page.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { SignIn } from '@clerk/nextjs'
2+
3+
const Page = async ({ searchParams }: { searchParams: { redirectUrl: string } }) => {
4+
const { redirectUrl } = searchParams
5+
6+
return (
7+
<section className='py-24'>
8+
<div className='container'>
9+
<div className='flex justify-center'>
10+
<SignIn redirectUrl={redirectUrl || '/'} />
11+
</div>
12+
</div>
13+
</section>
14+
)
15+
}
16+
17+
export default Page

app/admin/sign-up/page.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { SignUp } from '@clerk/nextjs'
2+
3+
const Page = async () => {
4+
return (
5+
<section className='py-24'>
6+
<div className='container'>
7+
<div className='flex justify-center'>
8+
<SignUp />
9+
</div>
10+
</div>
11+
</section>
12+
)
13+
}
14+
15+
export default Page

app/api/hello/route.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { NextResponse } from 'next/server'
2+
import { currentUser } from '@clerk/nextjs'
3+
4+
export async function GET() {
5+
const user = await currentUser()
6+
7+
if (!user) {
8+
return NextResponse.json({ message: 'You are not logged in.' })
9+
}
10+
11+
return NextResponse.json({ name: user.firstName })
12+
}

app/backend/database/actions.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'use server';
2+
3+
import { auth } from '@clerk/nextjs'
4+
import { posts } from '../../../db/schema';;
5+
import db from './db';
6+
7+
// import { connect } from '@planetscale/database'
8+
// const config = {
9+
// host: process.env.PLANETSCALE_DB_HOST,
10+
// username: process.env.PLANETSCALE_DB_USERNAME,
11+
// password: process.env.PLANETSCALE_DB_PASSWORD
12+
// }
13+
14+
// const conn = connect(config);
15+
16+
17+
export async function getPosts() {
18+
const { userId } = auth();
19+
return await db.select().from(posts);
20+
}

app/backend/database/db.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { drizzle } from "drizzle-orm/planetscale-serverless";
2+
3+
import { connect } from '@planetscale/database'
4+
const config = {
5+
host: process.env.PLANETSCALE_DB_HOST,
6+
username: process.env.PLANETSCALE_DB_USERNAME,
7+
password: process.env.PLANETSCALE_DB_PASSWORD
8+
}
9+
10+
const conn = connect(config);
11+
12+
const db = drizzle(conn);
13+
14+
export default db;

app/components/layout/footer.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const Footer = () => {
2+
return (
3+
<footer className='z-10 py-10 text-stone-400'>
4+
<div className='container'>
5+
<h5 className='text-lg'>Alex Pavlov</h5>
6+
<p className='mt-4 text-sm text-stone-400'>
7+
&copy; {new Date().getFullYear()} PavlovTech
8+
</p>
9+
</div>
10+
</footer>
11+
)
12+
}
13+
14+
export default Footer

app/components/layout/header.tsx

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
'use client'
2+
3+
import { useState } from 'react'
4+
5+
import Link from 'next/link'
6+
7+
import { SignInButton, UserButton, SignedIn, SignedOut } from '@clerk/nextjs'
8+
9+
const Header = () => {
10+
//const { data: cart, isLoading } = useSWR('cart', getCart)
11+
//const [cartSliderIsOpen, setCartSliderIsOpen] = useState(false)
12+
13+
return (
14+
<>
15+
<header className='z-10 py-10 text-stone-400'>
16+
<nav className='container flex items-center justify-between'>
17+
{/* Logo */}
18+
<div>
19+
<Link
20+
href='/'
21+
className='text-2xl font-bold uppercase tracking-widest'
22+
>
23+
Pipelined
24+
</Link>
25+
</div>
26+
27+
{/* Nav links */}
28+
<ul className='flex items-center gap-10'>
29+
30+
<SignedIn>
31+
<li className='text-sm font-medium uppercase tracking-wider'>
32+
<Link href='/projects'>Posts</Link>
33+
</li>
34+
</SignedIn>
35+
</ul>
36+
37+
<div className='flex items-center justify-between gap-6'>
38+
<SignedIn>
39+
<UserButton />
40+
</SignedIn>
41+
<SignedOut>
42+
<SignInButton mode='modal'>
43+
<button className='rounded border border-gray-400 px-3 py-0.5'>
44+
Sign in
45+
</button>
46+
</SignInButton>
47+
</SignedOut>
48+
</div>
49+
</nav>
50+
</header>
51+
</>
52+
)
53+
}
54+
55+
export default Header

app/components/post.tsx

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import { redirect } from 'next/navigation'
2+
import { revalidatePath, revalidateTag } from 'next/cache'
3+
import { NewPost, Post } from '@/db/models'
4+
5+
const Post = async({ id }: { id?: number | undefined }) => {
6+
//const router = useRouter()
7+
8+
let project: Post | undefined = undefined;
9+
10+
11+
const createView = !id;
12+
13+
async function updateInDatabase(formData: any) {
14+
'use server';
15+
16+
//await updateProject(formDataToProject(formData, id!));
17+
redirect('/posts');
18+
}
19+
20+
async function saveToDatabase(formData: any) {
21+
'use server';
22+
redirect('/projects');
23+
}
24+
25+
return (
26+
<div className='container'>
27+
<form
28+
className='w-full max-w-sm'
29+
action={(createView ? saveToDatabase : updateInDatabase) as any}
30+
>
31+
32+
<div className='md:flex md:items-center'>
33+
<div className='md:w-1/3'></div>
34+
<div className='md:w-2/3'>
35+
<button
36+
type='submit'
37+
className='focus:shadow-outline rounded bg-purple-500 px-4 py-2 font-bold text-white shadow hover:bg-purple-400 focus:outline-none'
38+
>
39+
Submit
40+
</button>
41+
</div>
42+
</div>
43+
</form>
44+
</div>
45+
)
46+
}
47+
48+
49+
// const formDataToProject = (formData: any, id?: number): NewProject | Project => {
50+
// const project = Object.fromEntries(formData);
51+
52+
// return {
53+
// id: id!,
54+
// userId: '',
55+
// projectId: project.projectId!,
56+
// projectName: project.projectName!,
57+
// collectionUrl: project.collectionUrl!,
58+
// pat: project.pat!
59+
// }
60+
// }
61+
62+
export default Post;

0 commit comments

Comments
 (0)