2025-04-07 23:47:06 -07:00
|
|
|
"use client";
|
|
|
|
|
import { IconBrandGoogleFilled } from "@tabler/icons-react";
|
2025-09-30 20:27:34 -07:00
|
|
|
import { motion } from "motion/react";
|
feat(i18n): Add next-intl framework with full bilingual support (EN/ZH)
- Implement next-intl framework for scalable i18n
- Add complete Chinese (Simplified) localization
- Support 400+ translated strings across all pages
- Add language switcher with persistent preference
- Zero breaking changes to existing functionality
Framework additions:
- i18n routing and middleware
- LocaleContext for client-side state
- LanguageSwitcher component
- Translation files (en.json, zh.json)
Translated components:
- Homepage: Hero, features, CTA, navbar
- Auth: Login, register
- Dashboard: Main page, layout
- Connectors: Management, add page (all categories)
- Documents: Upload, manage, filters
- Settings: LLM configs, role assignments
- Onboarding: Add provider, assign roles
- Logs: Task logs viewer
Adding a new language now requires only:
1. Create messages/<locale>.json
2. Add locale to i18n/routing.ts
2025-10-26 14:05:46 +08:00
|
|
|
import { useTranslations } from "next-intl";
|
2025-04-07 23:47:06 -07:00
|
|
|
import { Logo } from "@/components/Logo";
|
2026-01-02 00:25:02 -08:00
|
|
|
import { trackLoginAttempt } from "@/lib/posthog/events";
|
2025-05-21 20:56:23 -07:00
|
|
|
import { AmbientBackground } from "./AmbientBackground";
|
2025-04-07 23:47:06 -07:00
|
|
|
|
|
|
|
|
export function GoogleLoginButton() {
|
2025-10-27 20:30:10 -07:00
|
|
|
const t = useTranslations("auth");
|
|
|
|
|
|
2025-07-27 10:05:37 -07:00
|
|
|
const handleGoogleLogin = () => {
|
2025-12-25 13:53:41 -08:00
|
|
|
// Track Google login attempt
|
|
|
|
|
trackLoginAttempt("google");
|
|
|
|
|
|
2026-01-02 00:25:02 -08:00
|
|
|
// IMPORTANT: Use the redirect-based authorize endpoint for cross-origin OAuth
|
2026-01-02 01:10:16 -08:00
|
|
|
// This fixes CSRF cookie issues in Firefox/Safari where cookies set via
|
2026-01-02 00:25:02 -08:00
|
|
|
// cross-origin fetch requests may not be sent on subsequent redirects.
|
|
|
|
|
// The authorize-redirect endpoint does a server-side redirect to Google
|
|
|
|
|
// and sets the CSRF cookie properly for same-site context.
|
|
|
|
|
window.location.href = `${process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL}/auth/google/authorize-redirect`;
|
2025-07-27 10:05:37 -07:00
|
|
|
};
|
|
|
|
|
return (
|
|
|
|
|
<div className="relative w-full overflow-hidden">
|
|
|
|
|
<AmbientBackground />
|
2025-12-29 00:11:21 +05:30
|
|
|
<div className="mx-auto flex h-screen max-w-lg flex-col items-center justify-center px-6 md:px-0">
|
|
|
|
|
<Logo className="h-16 w-16 md:h-32 md:w-32 rounded-full my-4 md:my-8 transition-all" />
|
2025-11-16 15:54:54 -08:00
|
|
|
{/* <h1 className="my-8 text-xl font-bold text-neutral-800 dark:text-neutral-100 md:text-4xl">
|
|
|
|
|
Login
|
|
|
|
|
</h1> */}
|
2025-11-03 16:00:58 -08:00
|
|
|
{/*
|
2025-07-27 10:05:37 -07:00
|
|
|
<motion.div
|
|
|
|
|
initial={{ opacity: 0, y: -5 }}
|
|
|
|
|
animate={{ opacity: 1, y: 0 }}
|
|
|
|
|
transition={{ duration: 0.3 }}
|
|
|
|
|
className="mb-4 w-full overflow-hidden rounded-lg border border-yellow-200 bg-yellow-50 text-yellow-900 shadow-sm dark:border-yellow-900/30 dark:bg-yellow-900/20 dark:text-yellow-200"
|
|
|
|
|
>
|
|
|
|
|
<motion.div
|
|
|
|
|
className="flex items-center gap-2 p-4"
|
|
|
|
|
initial={{ x: -5 }}
|
|
|
|
|
animate={{ x: 0 }}
|
|
|
|
|
transition={{ delay: 0.1, duration: 0.2 }}
|
|
|
|
|
>
|
|
|
|
|
<svg
|
|
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
|
width="16"
|
|
|
|
|
height="16"
|
|
|
|
|
viewBox="0 0 24 24"
|
|
|
|
|
fill="none"
|
|
|
|
|
stroke="currentColor"
|
|
|
|
|
strokeWidth="2"
|
|
|
|
|
strokeLinecap="round"
|
|
|
|
|
strokeLinejoin="round"
|
|
|
|
|
className="flex-shrink-0"
|
|
|
|
|
>
|
2025-07-27 10:49:14 -07:00
|
|
|
<title>Google Logo</title>
|
2025-07-27 10:05:37 -07:00
|
|
|
<path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z" />
|
|
|
|
|
<line x1="12" y1="9" x2="12" y2="13" />
|
|
|
|
|
<line x1="12" y1="17" x2="12.01" y2="17" />
|
|
|
|
|
</svg>
|
|
|
|
|
<div className="ml-1">
|
|
|
|
|
<p className="text-sm font-medium">
|
2025-10-27 20:30:10 -07:00
|
|
|
{t("cloud_dev_notice")}{" "}
|
2025-07-27 10:05:37 -07:00
|
|
|
<a
|
|
|
|
|
href="/docs"
|
|
|
|
|
className="text-blue-600 underline dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300"
|
|
|
|
|
>
|
2025-10-27 20:30:10 -07:00
|
|
|
{t("docs")}
|
2025-07-27 10:05:37 -07:00
|
|
|
</a>{" "}
|
2025-10-27 20:30:10 -07:00
|
|
|
{t("cloud_dev_self_hosted")}
|
2025-07-27 10:05:37 -07:00
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
</motion.div>
|
2025-10-31 02:39:01 -07:00
|
|
|
</motion.div> */}
|
2025-07-27 10:05:37 -07:00
|
|
|
|
|
|
|
|
<motion.button
|
|
|
|
|
whileHover={{ scale: 1.02 }}
|
|
|
|
|
whileTap={{ scale: 0.98 }}
|
2025-12-29 00:11:21 +05:30
|
|
|
className="group/btn relative flex w-full items-center justify-center space-x-2 rounded-lg bg-white px-6 py-3 md:py-4 text-neutral-700 shadow-lg transition-all duration-200 hover:shadow-xl dark:bg-neutral-800 dark:text-neutral-200"
|
2025-07-27 10:05:37 -07:00
|
|
|
onClick={handleGoogleLogin}
|
|
|
|
|
>
|
|
|
|
|
<div className="absolute inset-0 h-full w-full transform opacity-0 transition duration-200 group-hover/btn:opacity-100">
|
|
|
|
|
<div className="absolute -left-px -top-px h-4 w-4 rounded-tl-lg border-l-2 border-t-2 border-blue-500 bg-transparent transition-all duration-200 group-hover/btn:-left-2 group-hover/btn:-top-2"></div>
|
|
|
|
|
<div className="absolute -right-px -top-px h-4 w-4 rounded-tr-lg border-r-2 border-t-2 border-blue-500 bg-transparent transition-all duration-200 group-hover/btn:-right-2 group-hover/btn:-top-2"></div>
|
|
|
|
|
<div className="absolute -bottom-px -left-px h-4 w-4 rounded-bl-lg border-b-2 border-l-2 border-blue-500 bg-transparent transition-all duration-200 group-hover/btn:-bottom-2 group-hover/btn:-left-2"></div>
|
|
|
|
|
<div className="absolute -bottom-px -right-px h-4 w-4 rounded-br-lg border-b-2 border-r-2 border-blue-500 bg-transparent transition-all duration-200 group-hover/btn:-bottom-2 group-hover/btn:-right-2"></div>
|
|
|
|
|
</div>
|
|
|
|
|
<IconBrandGoogleFilled className="h-5 w-5 text-neutral-700 dark:text-neutral-200" />
|
2025-10-27 20:30:10 -07:00
|
|
|
<span className="text-base font-medium">{t("continue_with_google")}</span>
|
2025-07-27 10:05:37 -07:00
|
|
|
</motion.button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|