From 8bcd226bdb4eb3468df0590dbe6d3d8d68b2acbd Mon Sep 17 00:00:00 2001 From: Deepanshu Mishra Date: Mon, 23 Jun 2025 22:51:34 +0530 Subject: Added google auth and some auth page ui optimisations --- apps/web/src/components/header.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'apps/web/src/components/header.tsx') diff --git a/apps/web/src/components/header.tsx b/apps/web/src/components/header.tsx index 004863d9..109d022e 100644 --- a/apps/web/src/components/header.tsx +++ b/apps/web/src/components/header.tsx @@ -5,8 +5,10 @@ import Image from "next/image"; import { Button } from "./ui/button"; import { ArrowRight } from "lucide-react"; import { HeaderBase } from "./header-base"; +import { useSession } from "@/lib/auth-client"; export function Header() { + const { data: session } = useSession(); const leftContent = ( OpenCut Logo @@ -21,7 +23,7 @@ export function Header() { GitHub - +
- Or continue with + + Or continue with +
@@ -144,14 +151,21 @@ export default function LoginPage() { - - -
}> + + + + } + >
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 index 3d125a07..d1feece2 100644 --- a/apps/web/src/app/(auth)/signup/page.tsx +++ b/apps/web/src/app/(auth)/signup/page.tsx @@ -44,7 +44,7 @@ function SignUpForm() { return; } - router.push("/auth/login"); + router.push("/login"); }; const handleGoogleSignUp = async () => { @@ -80,7 +80,12 @@ function SignUpForm() { size="lg" disabled={isAnyLoading} > - {isGoogleLoading ? : ()} Continue with Google + {isGoogleLoading ? ( + + ) : ( + + )}{" "} + Continue with Google
@@ -88,7 +93,9 @@ function SignUpForm() {
- Or continue with + + Or continue with +
@@ -135,7 +142,11 @@ function SignUpForm() { className="w-full h-11" size="lg" > - {isEmailLoading ? : "Create account"} + {isEmailLoading ? ( + + ) : ( + "Create account" + )} @@ -157,20 +168,29 @@ export default function SignUpPage() { - Create your account + + Create your account + Get started with your free account today - - - }> + + + + } + >
Already have an account?{" "} - + Sign in
diff --git a/apps/web/src/components/header.tsx b/apps/web/src/components/header.tsx index 109d022e..2ccc53fa 100644 --- a/apps/web/src/components/header.tsx +++ b/apps/web/src/components/header.tsx @@ -23,7 +23,7 @@ export function Header() { GitHub - + diff --git a/apps/web/src/components/landing/hero.tsx b/apps/web/src/components/landing/hero.tsx index f2c70f5d..b2320030 100644 --- a/apps/web/src/components/landing/hero.tsx +++ b/apps/web/src/components/landing/hero.tsx @@ -7,6 +7,7 @@ import { ArrowRight } from "lucide-react"; import Link from "next/link"; import { useState } from "react"; import { useToast } from "@/hooks/use-toast"; +import { ghStars } from "@/lib/fetchGhStars"; interface HeroProps { signupCount: number; @@ -16,6 +17,7 @@ export function Hero({ signupCount }: HeroProps) { const [email, setEmail] = useState(""); const [isSubmitting, setIsSubmitting] = useState(false); const { toast } = useToast(); + const stars = ghStars(); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); @@ -152,7 +154,7 @@ export function Hero({ signupCount }: HeroProps) { href="https://github.com/OpenCut-app/OpenCut" className="text-foreground underline" > - GitHub + GitHub {stars}+ diff --git a/apps/web/src/lib/fetchGhStars.ts b/apps/web/src/lib/fetchGhStars.ts new file mode 100644 index 00000000..de3e2e80 --- /dev/null +++ b/apps/web/src/lib/fetchGhStars.ts @@ -0,0 +1,20 @@ +async function getStars(): Promise { + const res = await fetch("https://api.github.com/repos/OpenCut-app/OpenCut", { + // Cache for 1 hour (3600 seconds) + next: { revalidate: 3600 }, + }); + + const data = await res.json(); + const count = data.stargazers_count; + + if (count >= 1_000_000) + return (count / 1_000_000).toFixed(1).replace(/\.0$/, "") + "M"; + if (count >= 1_000) + return (count / 1_000).toFixed(1).replace(/\.0$/, "") + "k"; + return count.toString(); +} + +export async function ghStars() { + const stars = await getStars(); + return stars; +} -- cgit v1.3.1 From 57e42e2c4539949e93b71f1125e0c0eecb2fb5e8 Mon Sep 17 00:00:00 2001 From: Dipanshu Rawat <144578298+Jaydeeprawat17@users.noreply.github.com> Date: Tue, 24 Jun 2025 02:06:55 +0530 Subject: ref: fetch api function --- apps/web/src/components/header.tsx | 21 +++++++++++++--- apps/web/src/components/landing/hero.tsx | 21 ++++++++++++---- apps/web/src/lib/fetchGhStars.ts | 41 +++++++++++++++++++------------- 3 files changed, 60 insertions(+), 23 deletions(-) (limited to 'apps/web/src/components/header.tsx') diff --git a/apps/web/src/components/header.tsx b/apps/web/src/components/header.tsx index cada527f..82e0bc55 100644 --- a/apps/web/src/components/header.tsx +++ b/apps/web/src/components/header.tsx @@ -6,12 +6,27 @@ import { Button } from "./ui/button"; import { ArrowRight } from "lucide-react"; import { HeaderBase } from "./header-base"; import { useSession } from "@/lib/auth-client"; -import { ghStars } from "@/lib/fetchGhStars"; +import { getStars } from "@/lib/fetchGhStars"; import { Star } from "lucide-react"; +import { useEffect, useState } from "react"; export function Header() { - const stars = ghStars(); const { data: session } = useSession(); + const [star, setStar] = useState(""); + + useEffect(() => { + const fetchStars = async () => { + try { + const data = await getStars(); + setStar(data); + } catch (err) { + console.error("Failed to fetch GitHub stars", err); + } + }; + + fetchStars(); + }, []); + const leftContent = ( OpenCut Logo @@ -28,7 +43,7 @@ export function Header() { > GitHub - {stars}+ + {star}+ diff --git a/apps/web/src/components/landing/hero.tsx b/apps/web/src/components/landing/hero.tsx index b2320030..5d9f3f10 100644 --- a/apps/web/src/components/landing/hero.tsx +++ b/apps/web/src/components/landing/hero.tsx @@ -5,19 +5,32 @@ import { Button } from "../ui/button"; import { Input } from "../ui/input"; import { ArrowRight } from "lucide-react"; import Link from "next/link"; -import { useState } from "react"; +import { useEffect, useState } from "react"; import { useToast } from "@/hooks/use-toast"; -import { ghStars } from "@/lib/fetchGhStars"; +import { getStars } from "@/lib/fetchGhStars"; interface HeroProps { signupCount: number; } export function Hero({ signupCount }: HeroProps) { + const [star, setStar] = useState(); const [email, setEmail] = useState(""); const [isSubmitting, setIsSubmitting] = useState(false); const { toast } = useToast(); - const stars = ghStars(); + + useEffect(() => { + const fetchStars = async () => { + try { + const data = await getStars(); + setStar(data); + } catch (err) { + console.error("Failed to fetch GitHub stars", err); + } + }; + + fetchStars(); + }, []); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); @@ -154,7 +167,7 @@ export function Hero({ signupCount }: HeroProps) { href="https://github.com/OpenCut-app/OpenCut" className="text-foreground underline" > - GitHub {stars}+ + GitHub {star}+ diff --git a/apps/web/src/lib/fetchGhStars.ts b/apps/web/src/lib/fetchGhStars.ts index de3e2e80..e0236840 100644 --- a/apps/web/src/lib/fetchGhStars.ts +++ b/apps/web/src/lib/fetchGhStars.ts @@ -1,20 +1,29 @@ -async function getStars(): Promise { - const res = await fetch("https://api.github.com/repos/OpenCut-app/OpenCut", { - // Cache for 1 hour (3600 seconds) - next: { revalidate: 3600 }, - }); +export async function getStars(): Promise { + try { + const res = await fetch( + "https://api.github.com/repos/OpenCut-app/OpenCut", + { + next: { revalidate: 3600 }, + } + ); - const data = await res.json(); - const count = data.stargazers_count; + if (!res.ok) { + throw new Error(`GitHub API error: ${res.status} ${res.statusText}`); + } + const data = await res.json(); + const count = data.stargazers_count; - if (count >= 1_000_000) - return (count / 1_000_000).toFixed(1).replace(/\.0$/, "") + "M"; - if (count >= 1_000) - return (count / 1_000).toFixed(1).replace(/\.0$/, "") + "k"; - return count.toString(); -} + if (typeof count !== "number") { + throw new Error("Invalid stargazers_count from GitHub API"); + } -export async function ghStars() { - const stars = await getStars(); - return stars; + if (count >= 1_000_000) + return (count / 1_000_000).toFixed(1).replace(/\.0$/, "") + "M"; + if (count >= 1_000) + return (count / 1_000).toFixed(1).replace(/\.0$/, "") + "k"; + return count.toString(); + } catch (error) { + console.error("Failed to fetch GitHub stars:", error); + return "1.5k"; + } } -- cgit v1.3.1 From d25e1eaa1d83617cecba822ac0fb24fe61bb3a08 Mon Sep 17 00:00:00 2001 From: Hyteq Date: Tue, 24 Jun 2025 11:29:15 +0300 Subject: feat: migrated packages properly, using packages in web app --- apps/web/package.json | 2 ++ apps/web/src/app/api/auth/[...all]/route.ts | 2 +- apps/web/src/components/auth-form.tsx | 2 +- apps/web/src/components/header.tsx | 2 +- apps/web/src/lib/auth-client.ts | 4 ---- apps/web/src/lib/auth.ts | 29 ---------------------------- bun.lockb | Bin 200656 -> 201960 bytes 7 files changed, 5 insertions(+), 36 deletions(-) delete mode 100644 apps/web/src/lib/auth-client.ts delete mode 100644 apps/web/src/lib/auth.ts (limited to 'apps/web/src/components/header.tsx') diff --git a/apps/web/package.json b/apps/web/package.json index b66a8eeb..ed08734e 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -19,6 +19,8 @@ "@ffmpeg/util": "^0.12.2", "@hello-pangea/dnd": "^18.0.1", "@hookform/resolvers": "^3.9.1", + "@opencut/auth": "workspace:*", + "@opencut/db": "workspace:*", "@types/pg": "^8.15.4", "@upstash/ratelimit": "^2.0.5", "@upstash/redis": "^1.35.0", diff --git a/apps/web/src/app/api/auth/[...all]/route.ts b/apps/web/src/app/api/auth/[...all]/route.ts index 1fb57443..393fb7e7 100644 --- a/apps/web/src/app/api/auth/[...all]/route.ts +++ b/apps/web/src/app/api/auth/[...all]/route.ts @@ -1,4 +1,4 @@ -import { auth } from "@/lib/auth"; +import { auth } from "@opencut/auth/server"; import { toNextJsHandler } from "better-auth/next-js"; export const { POST, GET } = toNextJsHandler(auth); \ No newline at end of file diff --git a/apps/web/src/components/auth-form.tsx b/apps/web/src/components/auth-form.tsx index 3dd56036..72bddd3d 100644 --- a/apps/web/src/components/auth-form.tsx +++ b/apps/web/src/components/auth-form.tsx @@ -1,7 +1,7 @@ "use client"; import { useRouter } from "next/navigation"; -import { signUp, signIn } from "@/lib/auth-client"; +import { signUp, signIn } from "@opencut/auth/client"; import { Button } from "@/components/ui/button"; import { Card, diff --git a/apps/web/src/components/header.tsx b/apps/web/src/components/header.tsx index 9f842b24..d1e0518f 100644 --- a/apps/web/src/components/header.tsx +++ b/apps/web/src/components/header.tsx @@ -5,7 +5,7 @@ import Image from "next/image"; import { Button } from "./ui/button"; import { ArrowRight } from "lucide-react"; import { HeaderBase } from "./header-base"; -import { useSession } from "@/lib/auth-client"; +import { useSession } from "@opencut/auth/client"; import { getStars } from "@/lib/fetchGhStars"; import { Star } from "lucide-react"; import { useEffect, useState } from "react"; diff --git a/apps/web/src/lib/auth-client.ts b/apps/web/src/lib/auth-client.ts deleted file mode 100644 index 1ab4e636..00000000 --- a/apps/web/src/lib/auth-client.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { createAuthClient } from "better-auth/react"; -export const { signIn, signUp, useSession } = createAuthClient({ - baseURL: process.env.NEXT_PUBLIC_BETTER_AUTH_URL!, -}); diff --git a/apps/web/src/lib/auth.ts b/apps/web/src/lib/auth.ts deleted file mode 100644 index d0175c97..00000000 --- a/apps/web/src/lib/auth.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { betterAuth } from "better-auth"; -import { drizzleAdapter } from "better-auth/adapters/drizzle"; -import { db } from "./db"; - -export const auth = betterAuth({ - database: drizzleAdapter(db, { - provider: "pg", - usePlural: true, - }), - secret: process.env.BETTER_AUTH_SECRET!, - user: { - deleteUser: { - enabled: true, - }, - }, - emailAndPassword: { - enabled: true, - }, - socialProviders: { - google: { - clientId: process.env.GOOGLE_CLIENT_ID as string, - clientSecret: process.env.GOOGLE_CLIENT_SECRET as string, - }, - }, - appName: "OpenCut", - trustedOrigins: ["http://localhost:3000"], -}); - -export type Auth = typeof auth; diff --git a/bun.lockb b/bun.lockb index 2f51e8f2..2871b5e6 100644 Binary files a/bun.lockb and b/bun.lockb differ -- cgit v1.3.1 From b9e1dcf23e29e0adb08119b92f91e81db23ebb26 Mon Sep 17 00:00:00 2001 From: Maze Winther Date: Tue, 24 Jun 2025 10:32:19 +0200 Subject: refactor: change button variant from 'ghost' to 'text' across multiple components for consistency --- apps/web/src/app/(auth)/login/page.tsx | 2 +- apps/web/src/app/(auth)/signup/page.tsx | 2 +- apps/web/src/components/auth-form.tsx | 2 +- apps/web/src/components/editor/preview-panel.tsx | 2 +- apps/web/src/components/editor/timeline.tsx | 18 +++++++++--------- apps/web/src/components/header.tsx | 2 +- apps/web/src/components/ui/button.tsx | 2 +- apps/web/src/components/ui/calendar.tsx | 2 +- apps/web/src/components/ui/input.tsx | 2 +- apps/web/src/components/ui/pagination.tsx | 2 +- apps/web/src/components/ui/sidebar.tsx | 2 +- 11 files changed, 19 insertions(+), 19 deletions(-) (limited to 'apps/web/src/components/header.tsx') diff --git a/apps/web/src/app/(auth)/login/page.tsx b/apps/web/src/app/(auth)/login/page.tsx index 5f37ced9..9935e153 100644 --- a/apps/web/src/app/(auth)/login/page.tsx +++ b/apps/web/src/app/(auth)/login/page.tsx @@ -137,7 +137,7 @@ export default function LoginPage() { return (
@@ -558,7 +558,7 @@ export function Timeline() { - @@ -567,7 +567,7 @@ export function Timeline() { - @@ -576,7 +576,7 @@ export function Timeline() { - @@ -585,7 +585,7 @@ export function Timeline() { - @@ -594,7 +594,7 @@ export function Timeline() { - @@ -603,7 +603,7 @@ export function Timeline() { - @@ -1625,7 +1625,7 @@ function TimelineTrackContent({ {/* Clip options menu */}