Skip to content

Commit 53456fc

Browse files
Merge branch 'screenlink-web-temp' into merge-projects
2 parents b168bc4 + d3f834a commit 53456fc

161 files changed

Lines changed: 12433 additions & 2 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,24 @@ yarn-error.log*
77
pnpm-debug.log*
88
lerna-debug.log*
99

10-
node_modules
10+
# Dependencies
11+
/node_modules
12+
/.pnp
13+
.pnp.js
14+
15+
# Testing
16+
/coverage
17+
18+
# Build directories
1119
dist
1220
dist-ssr
1321
dist-electron
1422
release
23+
/build
24+
25+
# Local environment overrides
1526
*.local
16-
.env
27+
.env*.local
1728

1829
# Editor directories and files
1930
.vscode/*
@@ -25,3 +36,26 @@ release
2536
*.njsproj
2637
*.sln
2738
*.sw?
39+
40+
# Misc & OS generated files
41+
*.pem
42+
*.tsbuildinfo
43+
next-env.d.ts
44+
45+
# Debug logs
46+
.pnpm-debug.log*
47+
48+
# Vercel
49+
.vercel
50+
51+
# Framework-specific
52+
.next/
53+
/out/
54+
55+
# Contentlayer
56+
.contentlayer
57+
58+
# Sentry Config File
59+
.sentryclirc
60+
61+
.env

.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/typescript/lib",
3+
"typescript.enablePromptUseWorkspaceTsdk": true
4+
}

apps/web/CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# CHANGELOG.md
2+
3+
## [1.0.3] - 2023-10-04
4+
5+
- Update Twitter icon
6+
- Update dependencies
7+
8+
## [1.0.1] - 2023-05-06
9+
10+
- Dependencies update
11+
12+
## [1.0.0] - 2023-04-11
13+
14+
First release

apps/web/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.tsx`. 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.ts`.
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.

apps/web/actions/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from './updateUploadTitle';
2+
export * from './navigate';
3+

apps/web/actions/navigate.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
'use server'
2+
3+
import { redirect } from 'next/navigation'
4+
5+
export async function navigate(url: string) {
6+
redirect(url);
7+
}
8+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
'use server';
2+
3+
import { prisma } from '@/app/utils';
4+
import { z } from 'zod';
5+
import { revalidatePath } from 'next/cache';
6+
7+
// Define the schema for the title update payload
8+
const updateTitleSchema = z.object({
9+
id: z.string(),
10+
newTitle: z.string().min(1, "Title cannot be empty"),
11+
});
12+
13+
// Adjust the function signature to match useFormState expectations
14+
export async function updateTitle(params: { id: string, newTitle: string }) {
15+
const result = updateTitleSchema.safeParse(params);
16+
17+
if (!result.success) {
18+
return { success: false, error: 'Validation failed' }; // Handle error case
19+
}
20+
21+
const { id, newTitle } = result.data;
22+
23+
await prisma.upload.update({
24+
where: { id },
25+
data: { sourceTitle: newTitle },
26+
});
27+
28+
await revalidatePath(`/view/${id}`);
29+
30+
return { success: true };
31+
}

apps/web/app/(auth)/AuthForm.tsx

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
"use client";
2+
3+
import { BuiltInProviderType, Provider } from "next-auth/providers";
4+
import {
5+
ClientSafeProvider,
6+
LiteralUnion,
7+
signIn,
8+
useSession,
9+
} from "next-auth/react";
10+
import React from "react";
11+
import {
12+
AiFillGithub,
13+
AiOutlineGoogle,
14+
AiOutlineQuestionCircle,
15+
AiOutlineSlack,
16+
} from "react-icons/ai";
17+
18+
const ICONS: {
19+
[key: string]: React.ComponentType<any>;
20+
} = {
21+
github: AiFillGithub,
22+
google: AiOutlineGoogle,
23+
slack: AiOutlineSlack,
24+
};
25+
26+
const SocialButton = ({
27+
provider,
28+
redirect,
29+
}: {
30+
provider: any;
31+
redirect?: string;
32+
}) => {
33+
const icon =
34+
ICONS[provider.id as keyof typeof ICONS] || AiOutlineQuestionCircle;
35+
return (
36+
<div className="mb-4 w-full" key={provider.name}>
37+
<button
38+
onClick={() => signIn(provider.id, { callbackUrl: redirect ?? "/app" })}
39+
type="button"
40+
className="inline-flex items-center gap-x-1.5 rounded px-2.5 py-2.5 text-base shadow-sm text-white bg-indigo-500 hover:bg-indigo-600 w-full"
41+
>
42+
{React.cloneElement(React.createElement(icon), {
43+
className: "w-5 h-5",
44+
})}
45+
<span className={"ml-4"}>Continue with {provider.name}</span>
46+
</button>
47+
</div>
48+
);
49+
};
50+
51+
export default function AuthForm({
52+
providers,
53+
redirect,
54+
}: {
55+
providers: Record<
56+
LiteralUnion<BuiltInProviderType, string>,
57+
ClientSafeProvider
58+
> | null;
59+
redirect?: string;
60+
}) {
61+
if (!providers) return null;
62+
return (
63+
<div className="flex flex-col">
64+
{Object.values(providers).map((provider: ClientSafeProvider) => {
65+
if (!provider?.name || !provider?.id) return null;
66+
return (
67+
<SocialButton
68+
key={provider.name}
69+
provider={provider}
70+
redirect={redirect}
71+
/>
72+
);
73+
})}
74+
</div>
75+
);
76+
}

apps/web/app/(auth)/layout.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import Image from 'next/image'
2+
import Header from '@/components/ui/header'
3+
import Illustration from '@/public/images/auth-illustration.svg'
4+
5+
export default function AuthLayout({
6+
children,
7+
}: {
8+
children: React.ReactNode
9+
}) {
10+
return (
11+
<>
12+
<Header nav={false} />
13+
14+
<main className="grow">
15+
<section className="relative">
16+
17+
{/* Illustration */}
18+
<div className="hidden md:block absolute left-1/2 -translate-x-1/2 pointer-events-none -z-10" aria-hidden="true">
19+
<Image src={Illustration} className="max-w-none" priority alt="Page Illustration" />
20+
</div>
21+
22+
{children}
23+
24+
</section>
25+
</main>
26+
</>
27+
)
28+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { getProviders } from "next-auth/react";
2+
import Link from "next/link";
3+
import AuthForm from "../AuthForm";
4+
import { getServerSession } from "next-auth";
5+
import { authOptions } from "@/app/api/auth/[...nextauth]/AuthOptions";
6+
import { redirect } from "next/navigation";
7+
import { constructMetadata } from "@/app/utils";
8+
9+
export const metadata = constructMetadata({
10+
description:
11+
"Login to ScreenLink to start recording demos with your screen and camera.",
12+
title: "Sign In - ScreenLink",
13+
});
14+
15+
export default async function SignIn({
16+
searchParams,
17+
}: {
18+
searchParams?: { [key: string]: string | string[] | undefined };
19+
}) {
20+
const session = await getServerSession(authOptions);
21+
22+
// If the user is already logged in, redirect.
23+
// Note: Make sure not to redirect to the same page
24+
// To avoid an infinite loop!
25+
if (session) {
26+
redirect("/app");
27+
}
28+
29+
// Get redirect from query
30+
const redirectTo = searchParams?.redirect
31+
? String(searchParams?.redirect)
32+
: "/app";
33+
34+
return (
35+
<div className="relative max-w-6xl mx-auto px-4 sm:px-6">
36+
<div className="pt-32 pb-12 md:pt-40 md:pb-20">
37+
{/* Page header */}
38+
<div className="max-w-3xl mx-auto text-center pb-12">
39+
<h1 className="h2 font-hkgrotesk">Welcome back!</h1>
40+
</div>
41+
<div className="max-w-sm mx-auto">
42+
{/* Social logins */}
43+
<AuthForm providers={await getProviders()} redirect={redirectTo} />
44+
<div className="text-center mt-6">
45+
<div className="text-sm text-slate-500">
46+
Don't you have an account?{" "}
47+
<Link className="font-medium text-indigo-500" href="/signup">
48+
Get Started
49+
</Link>
50+
</div>
51+
</div>
52+
</div>
53+
</div>
54+
</div>
55+
);
56+
}

0 commit comments

Comments
 (0)