'use client'
import React, { useEffect, useRef, useState } from 'react'
import { useRouter } from "next/navigation";
import { cn } from '@/lib/utils'
import { ExternalLink } from '@/components/external-link'
import Link from "next/link";
import { Container } from "@/components/landing/container";
import { FadeIn } from "@/components/landing/fade-in";
import { NewsletterForm } from "@/components/landing/newsletter";
import service from '@/lib/http/service';
import { useLocalStorage } from '@/lib/hooks/use-local-storage';
import { UserData } from './user-menu';
import toast from 'react-hot-toast';
import { Button, Form, Input } from 'antd';
import LanguageChanger from './LanguageChanger';
import { useTranslation } from 'react-i18next';
// import { socialMediaProfiles } from "@/components/landing/social-media";
export function FooterText({ className, ...props }: React.ComponentProps<'p'>) {
return (
Made by{' '}
Markeljan
{' '}
with{' '}
Vercel AI
.
)
}
export function Footer({ className, ...props }: React.ComponentProps<'p'>) {
const inputRef = useRef(null)
const [input, setInput] = useState("");
const [isLoading, setIsLoading] = React.useState(false);
const [isSubscribe, setIsSubscribe] = React.useState(false);
const [form] = Form.useForm();
const [clientReady, setClientReady] = useState(false);
const router = useRouter();
const { t, i18n } = useTranslation()
const language = i18n.language
// To disable submit button at the beginning.
useEffect(() => {
setClientReady(true);
}, []);
const onFinish = async (values: any) => {
console.log('Finish:', values);
if (isLoading) return
setIsLoading(true);
await service.post('/api/v1/customer/subscribe', {
"first_name": values.first_name,
"email": values.email,
language,
"tags": [
"#AI",
"#Blockchain",
"#ChatGPT"
]
}, {
headers: {
// 'Authorization': token
}
}).then(function (result: any) {
setTimeout(() => {
setIsLoading(false);
setIsSubscribe(true)
}, 800);
console.log("result:", result)
if (result && result.header.code != 0) {
toast.error(result.header.message)
return
}
toast.success(t('footer.subscribe_success'))
}).catch((err) => {
setIsLoading(false);
console.log(err);
});
};
const [userData, setUserData] = useLocalStorage(
'UserData',
{
auth_token: "",
id: 1,
login_ip: "",
login_time: 0,
role: "",
user_name: "",
version: ""
} as UserData
)
interface WindowSize {
windowWidth: number;
windowHeight: number;
}
const [windowSize, setWindowSize] = useState({
windowWidth: 0,
windowHeight: 0
});
useEffect(() => {
// 确保仅在客户端执行
if (typeof window !== "undefined") {
const handleResize = () => {
setWindowSize({
windowWidth: window.innerWidth,
windowHeight: window.innerHeight
});
};
// 初始执行一次
handleResize();
// 监听 window resize 事件
window.addEventListener("resize", handleResize);
return () => {
// 清理事件监听
window.removeEventListener("resize", handleResize);
};
}
}, []);
return (
{/*
*/}
{/*
*/}
{t("footer.h3")}
{!userData.auth_token ?
{() => (
)}
:
{t("footer.thank_subscription")}
}
{
!userData.auth_token && (isSubscribe
?
{t("footer.p_ok")}
:
{t("footer.p")}
)
}
)
}
// const navigation = [
// {
// title: "Company",
// links: [
// { title: "About", href: "/about" },
// { title: "Blog", href: "/blog" },
// { title: "Careers", href: "/careers" },
// { title: "Changelog", href: "/changelog" },
// {
// title: "Analytics",
// href: "https://us.posthog.com/shared/HwZNjaKOLtgtpj6djuSo3fgOqrQm0Q?whitelabel",
// },
// {
// title: "Source Code",
// href: "https://github.com/unkeyed/unkey",
// },
// {
// title: "Documentation",
// href: "https://unkey.dev/docs",
// },
// ],
// },
// {
// title: "Legal",
// links: [
// { title: "Privacy Policy", href: "/policies/privacy" },
// { title: "Terms", href: "/policies/terms" },
// ],
// },
// {
// title: "Connect",
// links: [
// // ...socialMediaProfiles,
// {
// title:
,
// href: "https://cal.com/team/unkey/unkey-chat??utm_source=banner&utm_campaign=oss",
// },
// ],
// },
// ];
// function Navigation() {
// return (
//
// );
// }
export function Footer_bak() {
return (
{/*
© Unkeyed, Inc. {new Date().getFullYear()}
*/}
);
}