refactor: restructure landing page with component extraction and fix Server Component hooks
- Extract reusable components: EnterOrSignInButton, paragraphFormatFactory, getProviders - Fix React hooks usage: remove useMemo from async Server Components - Update landing page content for Croatian and English translations - Reorganize terms/policy pages into locale-aware directories - Update PageFooter to use locale-aware links and make component async 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
38
app/ui/EnterOrSignInButton.tsx
Normal file
38
app/ui/EnterOrSignInButton.tsx
Normal file
@@ -0,0 +1,38 @@
|
||||
import { FC } from 'react';
|
||||
|
||||
import { SignInButton } from '@/app/ui/SignInButton';
|
||||
import Image from 'next/image';
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import Link from 'next/link';
|
||||
import { paragraphFormatFactory } from '../lib/paragraphFormatFactory';
|
||||
import { AuthProvider } from '../lib/getProviders';
|
||||
|
||||
export const EnterOrSignInButton: FC<{ session: any, locale: string, providers: AuthProvider[] }> = async ({ session, locale, providers }) => {
|
||||
const paragraphFormat = paragraphFormatFactory(locale);
|
||||
|
||||
const t = await getTranslations("login-page");
|
||||
|
||||
return (
|
||||
<>
|
||||
<span className="flex justify-center mt-4">
|
||||
{
|
||||
session ? (
|
||||
<Link
|
||||
href={`/${locale}/home`}
|
||||
className="btn btn-neutral btn-lg"
|
||||
>
|
||||
<Image src="/icon2.png" alt="logo" width={32} height={32} />
|
||||
{t("main-card.go-to-app")}
|
||||
</Link>
|
||||
) : (
|
||||
Object.values(providers).map((provider) => (
|
||||
<div key={provider.name}>
|
||||
<SignInButton provider={provider} />
|
||||
</div>
|
||||
))
|
||||
)
|
||||
}
|
||||
</span>
|
||||
{t.rich("disclaimer", paragraphFormat)}
|
||||
</>);
|
||||
};
|
||||
@@ -2,10 +2,12 @@ import Image from "next/image";
|
||||
import Link from "next/link";
|
||||
import React from "react";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { getLocale } from "next-intl/server";
|
||||
|
||||
export const PageFooter: React.FC = () => {
|
||||
export const PageFooter: React.FC = async () => {
|
||||
|
||||
const t = useTranslations("PageFooter");
|
||||
const locale = await getLocale();
|
||||
|
||||
return(
|
||||
<div className="bg-base-100 text-base-content mt-10">
|
||||
@@ -17,8 +19,8 @@ export const PageFooter: React.FC = () => {
|
||||
</div>
|
||||
<p className="text-base-content/70 mb-5">{t('app-description')}</p>
|
||||
<Link href="/home" className="link link-hover">{t('links.home')}</Link>
|
||||
<Link href="/policy/" className="link link-hover">{t('links.privacy-policy')}</Link>
|
||||
<Link href="/terms/" className="link link-hover">{t('links.terms-of-service')}</Link>
|
||||
<Link href={`/${locale}/privacy-policy/`} className="link link-hover">{t('links.privacy-policy')}</Link>
|
||||
<Link href={`/${locale}/terms-of-service/`} className="link link-hover">{t('links.terms-of-service')}</Link>
|
||||
</div>
|
||||
<div>
|
||||
<span className="footer-title opacity-70">documents</span>
|
||||
|
||||
Reference in New Issue
Block a user