diff --git a/README.md b/README.md index 99db5b7..3ccb2b0 100644 --- a/README.md +++ b/README.md @@ -15,13 +15,37 @@ A free, open-source video editor for web, desktop, and mobile. - Real-time preview - No watermarks or subscriptions -## Development +## Project Structure -```bash -cd apps/web -npm install -npm run dev -``` +- `apps/web/` – Main Next.js web application +- `src/components/` – UI and editor components +- `src/hooks/` – Custom React hooks +- `src/lib/` – Utility and API logic +- `src/stores/` – State management (Zustand, etc.) +- `src/types/` – TypeScript types + +## Getting Started + +1. **Clone the repository:** + ```bash + git clone + cd OpenCut + ``` +2. **Install dependencies:** + ```bash + cd apps/web + npm install + # or, with Bun + bun install + ``` +3. **Run the development server:** + ```bash + npm run dev + # or, with Bun + bun run dev + ``` +4. **Open in browser:** + Visit [http://localhost:3000](http://localhost:3000) ## Contributing diff --git a/apps/web/src/app/auth/login/page.tsx b/apps/web/src/app/auth/login/page.tsx new file mode 100644 index 0000000..5eadb85 --- /dev/null +++ b/apps/web/src/app/auth/login/page.tsx @@ -0,0 +1,98 @@ +"use client"; + +import { useSearchParams, useRouter } from "next/navigation"; +import { authClient } from "@/lib/auth-client"; +import { Button } from "@/components/ui/button"; +import { + Card, + CardContent, + CardDescription, + CardHeader, + CardTitle, +} from "@/components/ui/card"; +import { Suspense, useState } from "react"; +import { Input } from "@/components/ui/input"; +import { Label } from "@/components/ui/label"; +import Link from "next/link"; +import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; + +function LoginForm() { + const searchParams = useSearchParams(); + const router = useRouter(); + const redirectUrl = searchParams.get("redirect"); + const [email, setEmail] = useState(""); + const [password, setPassword] = useState(""); + const [error, setError] = useState(null); + + const handleLogin = async () => { + setError(null); + const { error } = await authClient.signIn.email({ + email, + password, + }); + + if (error) { + setError(error.message || "An unexpected error occurred."); + return; + } + + router.push(redirectUrl || "/"); + }; + + return ( +
+ {error && ( + + Error + {error} + + )} +
+ + setEmail(e.target.value)} + /> +
+
+ + setPassword(e.target.value)} + /> +
+ +
+ ); +} + +export default function LoginPage() { + return ( +
+ + + Login + + Enter your email and password to login. + + + + Loading...
}> + + +
+ Don't have an account?{" "} + + Sign up + +
+ + + + ); +} diff --git a/apps/web/src/app/auth/signup/page.tsx b/apps/web/src/app/auth/signup/page.tsx new file mode 100644 index 0000000..f328851 --- /dev/null +++ b/apps/web/src/app/auth/signup/page.tsx @@ -0,0 +1,108 @@ +"use client"; + +import { useSearchParams, useRouter } from "next/navigation"; +import { authClient } from "@/lib/auth-client"; +import { Button } from "@/components/ui/button"; +import { + Card, + CardContent, + CardDescription, + CardHeader, + CardTitle, +} from "@/components/ui/card"; +import { Suspense, useState } from "react"; +import { Input } from "@/components/ui/input"; +import { Label } from "@/components/ui/label"; +import Link from "next/link"; +import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; + +function SignUpForm() { + const searchParams = useSearchParams(); + const router = useRouter(); + const redirectUrl = searchParams.get("redirect"); + const [name, setName] = useState(""); + const [email, setEmail] = useState(""); + const [password, setPassword] = useState(""); + const [error, setError] = useState(null); + + const handleSignUp = async () => { + setError(null); + const { error } = await authClient.signUp.email({ + name, + email, + password, + }); + + if (error) { + setError(error.message || "An unexpected error occurred."); + return; + } + + router.push(redirectUrl || "/"); + }; + + return ( +
+ {error && ( + + Error + {error} + + )} +
+ + setName(e.target.value)} + /> +
+
+ + setEmail(e.target.value)} + /> +
+
+ + setPassword(e.target.value)} + /> +
+ +
+ ); +} + +export default function SignUpPage() { + return ( +
+ + + Sign Up + Create an account to get started. + + + Loading...
}> + + +
+ Already have an account?{" "} + + Login + +
+ + + + ); +} diff --git a/apps/web/src/lib/auth.ts b/apps/web/src/lib/auth.ts index d381e6a..4cfaa6f 100644 --- a/apps/web/src/lib/auth.ts +++ b/apps/web/src/lib/auth.ts @@ -14,7 +14,7 @@ export const auth = betterAuth({ }, }, emailAndPassword: { - enabled: false, + enabled: true, }, appName: "OpenCut", trustedOrigins: ["http://localhost:3000"],