feat/0.2:add theme setting and about page setting and support use email and password login
This commit is contained in:
1 parent
58292b0e6e
commit
ca2b732952
85 files changed
+5797
-816
No files matched your search
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect } from "react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { I18nextProvider } from "react-i18next";
|
||||
import i18n, { i18nPromise } from "@/shared/lib/i18n";
|
||||
|
||||
@@ -11,25 +11,30 @@ interface ClientI18nProviderProps {
|
||||
export const ClientI18nProvider: React.FC<ClientI18nProviderProps> = ({
|
||||
children,
|
||||
}) => {
|
||||
const [isInitialized, setIsInitialized] = useState(false);
|
||||
|
||||
const initAll = async () => {
|
||||
if (i18n.isInitialized) return
|
||||
await i18nPromise;
|
||||
const storedLang = localStorage.getItem("i18nextLng");
|
||||
// only switch when the stored language is different from the current language
|
||||
if (storedLang && storedLang !== i18n.language) {
|
||||
await i18n.changeLanguage(storedLang);
|
||||
if (!i18n.isInitialized) {
|
||||
await i18nPromise;
|
||||
const storedLang = localStorage.getItem("i18nextLng");
|
||||
// only switch when the stored language is different from the current language
|
||||
if (storedLang && storedLang !== i18n.language) {
|
||||
await i18n.changeLanguage(storedLang);
|
||||
}
|
||||
}
|
||||
setIsInitialized(true);
|
||||
};
|
||||
useEffect(() => {
|
||||
initAll();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div style={{
|
||||
opacity: 1,
|
||||
transition: 'opacity 0.2s ease-in-out'
|
||||
}}>
|
||||
<div
|
||||
style={{
|
||||
opacity: isInitialized ? 1 : 0,
|
||||
transition: "opacity 0.2s ease-in-out",
|
||||
}}
|
||||
>
|
||||
<I18nextProvider i18n={i18n}>{children}</I18nextProvider>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -9,12 +9,11 @@ import { PlatformConfigResponse } from "@/shared/types/system";
|
||||
|
||||
export default function ClientRootProviders({
|
||||
children,
|
||||
initConfig
|
||||
initConfig,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
initConfig: PlatformConfigResponse;
|
||||
initConfig?: PlatformConfigResponse;
|
||||
}) {
|
||||
|
||||
return (
|
||||
<ClientI18nProvider>
|
||||
<PlatformConfigProvider initConfig={initConfig}>
|
||||
|
||||
@@ -2,23 +2,18 @@
|
||||
|
||||
import React from "react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import {
|
||||
Button,
|
||||
Divider,
|
||||
Link,
|
||||
} from "@nextui-org/react";
|
||||
import {
|
||||
LogOut,
|
||||
} from "lucide-react";
|
||||
import { Button, Divider, Link } from "@nextui-org/react";
|
||||
import { LogOut } from "lucide-react";
|
||||
import { DashboardSidebarProps } from "@/shared/types/dashboard";
|
||||
import { DynamicLogo } from "@/shared/components/DynamicLogo";
|
||||
|
||||
|
||||
const DashboardSidebar: React.FC<DashboardSidebarProps> = ({
|
||||
activeTab,
|
||||
onTabNavigate,
|
||||
onLogout,
|
||||
sidebarItems, userProfilePanel
|
||||
bottomPanel,
|
||||
sidebarItems,
|
||||
userProfilePanel,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
@@ -29,10 +24,7 @@ const DashboardSidebar: React.FC<DashboardSidebarProps> = ({
|
||||
<div className="mb-8 flex flex-col gap-2">
|
||||
<div className="flex justify-between items-center gap-2">
|
||||
<Link href={process.env.NEXT_PUBLIC_DOMAIN || "/"}>
|
||||
<DynamicLogo
|
||||
alt="Platform Logo"
|
||||
className="h-[20px]"
|
||||
/>
|
||||
<DynamicLogo alt="Platform Logo" className="h-[20px]" />
|
||||
</Link>
|
||||
</div>
|
||||
<p className="text-default-600 text-sm">
|
||||
@@ -64,16 +56,20 @@ const DashboardSidebar: React.FC<DashboardSidebarProps> = ({
|
||||
|
||||
<Divider className="my-6" />
|
||||
|
||||
{/* Logout */}
|
||||
<Button
|
||||
variant="light"
|
||||
color="danger"
|
||||
startContent={<LogOut className="w-4 h-4" />}
|
||||
className="w-full justify-start"
|
||||
onPress={onLogout}
|
||||
>
|
||||
{t("Log Out")}
|
||||
</Button>
|
||||
<div className="space-y-2">
|
||||
{bottomPanel}
|
||||
|
||||
{/* Logout */}
|
||||
<Button
|
||||
variant="light"
|
||||
color="danger"
|
||||
startContent={<LogOut className="w-4 h-4" />}
|
||||
className="w-full justify-start"
|
||||
onPress={onLogout}
|
||||
>
|
||||
{t("Log Out")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -2,14 +2,18 @@
|
||||
import React from "react";
|
||||
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
|
||||
import { Link } from "@nextui-org/react";
|
||||
|
||||
export function Footer() {
|
||||
interface FooterProps {
|
||||
showPoweredBy?: boolean;
|
||||
}
|
||||
export function Footer({ showPoweredBy=true }: FooterProps) {
|
||||
const { platformConfig } = usePlatformConfig();
|
||||
|
||||
return (
|
||||
<footer className="py-4 px-4 sm:px-6 text-center sm:text-end max-w-7xl mx-auto text-xs">
|
||||
<span className="mr-1">© 2025 {platformConfig?.name}. All rights reserved.</span>
|
||||
<Link className="text-xs" href="https://xpack.ai">Powered By XPack.AI</Link>
|
||||
{showPoweredBy && (
|
||||
<Link className="text-xs" href="https://xpack.ai">Powered By XPack.AI</Link>
|
||||
)}
|
||||
</footer>
|
||||
);
|
||||
}
|
||||
@@ -15,22 +15,23 @@ import { useAuth } from "@/shared/lib/useAuth";
|
||||
import { ArrowRightIcon } from "lucide-react";
|
||||
import { DynamicLogo } from "@/shared/components/DynamicLogo";
|
||||
import Link from "next/link";
|
||||
export type NavigationItem = {
|
||||
label: string;
|
||||
href: string;
|
||||
target?: string;
|
||||
};
|
||||
|
||||
interface NavigationProps {
|
||||
items?: {
|
||||
label: string;
|
||||
href: string;
|
||||
}[];
|
||||
items?: NavigationItem[];
|
||||
langNode?: React.ReactNode;
|
||||
}
|
||||
|
||||
// Client-side wrapper for interactive functionality
|
||||
function NavigationClient({ items = [] }: NavigationProps) {
|
||||
function NavigationClient({ items = [], langNode }: NavigationProps) {
|
||||
const [isMenuOpen, setIsMenuOpen] = useState(false);
|
||||
const { t } = useTranslation();
|
||||
const { handleLogin } = useAuth();
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* Main Navigation */}
|
||||
@@ -53,10 +54,7 @@ function NavigationClient({ items = [] }: NavigationProps) {
|
||||
<div className="flex justify-start bg-transparent w-max">
|
||||
{/* Logo using dynamic platform config */}
|
||||
<Link href="/">
|
||||
<DynamicLogo
|
||||
alt="Platform Logo"
|
||||
className="h-[20px]"
|
||||
/>
|
||||
<DynamicLogo alt="Platform Logo" className="h-[20px]" />
|
||||
</Link>
|
||||
<Link
|
||||
href="https://xpack.ai/techblog"
|
||||
@@ -72,6 +70,8 @@ function NavigationClient({ items = [] }: NavigationProps) {
|
||||
color="foreground"
|
||||
href={item.href}
|
||||
className="font-medium text-foreground-600 hover:text-foreground transition-colors px-2 py-1"
|
||||
target={item?.target || "_self"}
|
||||
prefetch={!item.target}
|
||||
>
|
||||
{t(item.label)}
|
||||
</Link>
|
||||
@@ -82,7 +82,7 @@ function NavigationClient({ items = [] }: NavigationProps) {
|
||||
|
||||
{/* Right Side Actions */}
|
||||
<NavbarContent justify="end" className="items-center gap-2 sm:gap-4">
|
||||
|
||||
{langNode}
|
||||
|
||||
{/* Desktop Auth Button */}
|
||||
<div className="hidden sm:block">
|
||||
@@ -118,6 +118,8 @@ function NavigationClient({ items = [] }: NavigationProps) {
|
||||
color="foreground"
|
||||
href={item.href}
|
||||
className="w-full py-2 font-medium text-sm"
|
||||
target={item?.target || "_self"}
|
||||
prefetch={!item.target}
|
||||
>
|
||||
{t(item.label)}
|
||||
</Link>
|
||||
|
||||
@@ -2,20 +2,23 @@ import React, { useState, useEffect, useRef } from "react";
|
||||
import { Input, Button } from "@nextui-org/react";
|
||||
import { Search } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { _DefaultPlatformConfig, usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
|
||||
import {
|
||||
_DefaultPlatformConfig,
|
||||
usePlatformConfig,
|
||||
} from "@/shared/contexts/PlatformConfigContext";
|
||||
|
||||
interface HeroSectionProps {
|
||||
searchQuery: string;
|
||||
onSearchChange: (value: string) => void;
|
||||
onSearch?: () => void;
|
||||
searchSuggestions?: string[];
|
||||
}
|
||||
|
||||
|
||||
|
||||
export const HeroSection: React.FC<HeroSectionProps> = ({
|
||||
searchQuery,
|
||||
onSearchChange,
|
||||
onSearch,
|
||||
searchSuggestions = [],
|
||||
}) => {
|
||||
const { platformConfig } = usePlatformConfig();
|
||||
const { t } = useTranslation();
|
||||
@@ -24,22 +27,13 @@ export const HeroSection: React.FC<HeroSectionProps> = ({
|
||||
const [currentSuggestionIndex, setCurrentSuggestionIndex] = useState(0);
|
||||
const [isTyping, setIsTyping] = useState(true);
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
const searchSuggestions = [
|
||||
t("get latest documentation for libraries"),
|
||||
t("execute terminal commands safely"),
|
||||
t("find latest scientific research papers"),
|
||||
t("tools to enhance thinking and reasoning"),
|
||||
t("find flight tickets and airbnb listings"),
|
||||
t("automate web browser interactions"),
|
||||
t("send messages and receive notifications")
|
||||
];
|
||||
|
||||
useEffect(() => {
|
||||
if (isFocused || searchQuery) {
|
||||
return;
|
||||
}
|
||||
|
||||
const currentSuggestion = searchSuggestions[currentSuggestionIndex];
|
||||
const currentSuggestion = t(searchSuggestions[currentSuggestionIndex]);
|
||||
let timeoutId: NodeJS.Timeout;
|
||||
|
||||
if (isTyping) {
|
||||
@@ -62,7 +56,9 @@ export const HeroSection: React.FC<HeroSectionProps> = ({
|
||||
}, 50);
|
||||
} else {
|
||||
// deleting completed, switch to next suggestion
|
||||
setCurrentSuggestionIndex((prev) => (prev + 1) % searchSuggestions.length);
|
||||
setCurrentSuggestionIndex(
|
||||
(prev) => (prev + 1) % searchSuggestions.length
|
||||
);
|
||||
setIsTyping(true);
|
||||
}
|
||||
}
|
||||
@@ -71,7 +67,7 @@ export const HeroSection: React.FC<HeroSectionProps> = ({
|
||||
}, [animatedText, currentSuggestionIndex, isTyping, isFocused, searchQuery]);
|
||||
|
||||
const handleKeyPress = (e: React.KeyboardEvent) => {
|
||||
if (e.key === 'Enter') {
|
||||
if (e.key === "Enter") {
|
||||
onSearch?.();
|
||||
}
|
||||
};
|
||||
@@ -84,10 +80,14 @@ export const HeroSection: React.FC<HeroSectionProps> = ({
|
||||
<div className="relative overflow-hidden mx-auto p-6 py-24 max-w-7xl">
|
||||
<div className="text-center mb-12">
|
||||
<h1 className="text-5xl lg:text-6xl font-bold mb-6 leading-tight text-primary">
|
||||
{platformConfig.headline || t(_DefaultPlatformConfig.headline || "")}
|
||||
{t(platformConfig.headline || _DefaultPlatformConfig.headline || "")}
|
||||
</h1>
|
||||
<p className="text-2xl font-medium max-w-3xl mx-auto leading-relaxed">
|
||||
{platformConfig.subheadline || t(_DefaultPlatformConfig.subheadline || "")}
|
||||
{t(
|
||||
platformConfig.subheadline ||
|
||||
_DefaultPlatformConfig.subheadline ||
|
||||
""
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -96,7 +96,13 @@ export const HeroSection: React.FC<HeroSectionProps> = ({
|
||||
<Input
|
||||
ref={inputRef}
|
||||
size="lg"
|
||||
placeholder={isFocused || searchQuery ? "" : animatedText}
|
||||
placeholder={
|
||||
isFocused || searchQuery
|
||||
? ""
|
||||
: searchSuggestions.length > 0
|
||||
? animatedText
|
||||
: t("Search services...")
|
||||
}
|
||||
value={searchQuery}
|
||||
onChange={(e) => onSearchChange(e.target.value)}
|
||||
onFocus={() => setIsFocused(true)}
|
||||
@@ -124,4 +130,4 @@ export const HeroSection: React.FC<HeroSectionProps> = ({
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
};
|
||||
@@ -7,44 +7,44 @@ import { Zap } from "lucide-react";
|
||||
import React from "react";
|
||||
|
||||
interface PriceProps {
|
||||
price?: string;
|
||||
charge_type: ChargeType;
|
||||
price?: string;
|
||||
charge_type?: ChargeType;
|
||||
}
|
||||
|
||||
export const Price: React.FC<PriceProps> = ({
|
||||
price,
|
||||
charge_type
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
export const Price: React.FC<PriceProps> = ({ price, charge_type }) => {
|
||||
const { t } = useTranslation();
|
||||
if (!charge_type) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (charge_type === ChargeType.Free) {
|
||||
return (
|
||||
<Chip size="sm" variant="flat" color="default">
|
||||
{t('Free')}
|
||||
</Chip>
|
||||
);
|
||||
}
|
||||
if (charge_type === ChargeType.Free) {
|
||||
return (
|
||||
<Chip size="sm" variant="flat" color="default">
|
||||
{t("Free")}
|
||||
</Chip>
|
||||
);
|
||||
}
|
||||
|
||||
const priceText = parseFloat(price || '0');
|
||||
const priceText = parseFloat(price || "0");
|
||||
|
||||
if (charge_type === ChargeType.PerCall) {
|
||||
return (
|
||||
<div className="flex items-center gap-1">
|
||||
<span className="text-sm font-medium text-green-600">
|
||||
${priceText.toFixed(2)}
|
||||
</span>
|
||||
<span className="text-xs text-gray-500">/{t('Per Call')}</span>
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<div className="flex items-center gap-1">
|
||||
<Zap className="w-3 h-3 text-blue-600" />
|
||||
<span className="text-sm font-medium text-blue-600">
|
||||
${priceText.toFixed(2)}
|
||||
</span>
|
||||
<span className="text-xs text-gray-500">/{t('token')}</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
if (charge_type === ChargeType.PerCall) {
|
||||
return (
|
||||
<div className="flex items-center gap-1">
|
||||
<span className="text-sm font-medium text-green-600">
|
||||
${priceText.toFixed(2)}
|
||||
</span>
|
||||
<span className="text-xs text-gray-500">/{t("Per Call")}</span>
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<div className="flex items-center gap-1">
|
||||
<Zap className="w-3 h-3 text-blue-600" />
|
||||
<span className="text-sm font-medium text-blue-600">
|
||||
${priceText.toFixed(2)}
|
||||
</span>
|
||||
<span className="text-xs text-gray-500">/{t("token")}</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
};
|
||||
@@ -2,11 +2,7 @@
|
||||
|
||||
import React from "react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import {
|
||||
Card,
|
||||
CardBody,
|
||||
Chip,
|
||||
} from "@nextui-org/react";
|
||||
import { Card, CardBody, Chip } from "@nextui-org/react";
|
||||
import { ChargeType, ServiceData } from "@/shared/types/marketplace";
|
||||
import Link from "next/link";
|
||||
import { Price } from "./Price";
|
||||
@@ -15,7 +11,7 @@ interface ProductHeaderProps {
|
||||
product: ServiceData;
|
||||
breadcrumbs?: {
|
||||
link: string;
|
||||
name: string
|
||||
name: string;
|
||||
}[];
|
||||
}
|
||||
|
||||
@@ -48,9 +44,7 @@ export const ProductHeader: React.FC<ProductHeaderProps> = ({
|
||||
{/* Header with title and price */}
|
||||
<div className="flex items-start justify-between mb-4">
|
||||
<div className="flex-1">
|
||||
<h1 className="text-3xl font-bold mb-2">
|
||||
{product.name}
|
||||
</h1>
|
||||
<h1 className="text-3xl font-bold mb-2">{product.name}</h1>
|
||||
|
||||
{/* Tags */}
|
||||
{product.tags && product.tags.length > 0 && (
|
||||
@@ -73,16 +67,16 @@ export const ProductHeader: React.FC<ProductHeaderProps> = ({
|
||||
{product.short_description || t("No description available")}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{/* Price section */}
|
||||
<div className="flex gap-2 items-center">
|
||||
<b className="text-xs">{t("Price")}:</b>
|
||||
<Price price={product.price} charge_type={product.charge_type || ChargeType.Free} />
|
||||
|
||||
</div>
|
||||
{product.charge_type && (
|
||||
<div className="flex gap-2 items-center">
|
||||
<b className="text-xs">{t("Price")}:</b>
|
||||
<Price price={product.price} charge_type={product.charge_type} />
|
||||
</div>
|
||||
)}
|
||||
</CardBody>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
};
|
||||
@@ -16,7 +16,7 @@ export const ProductOverview: React.FC<ProductOverviewProps> = ({
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<Card shadow="none">
|
||||
<Card shadow="none" className="bg-transparent">
|
||||
<CardBody className="space-y-4">
|
||||
<div className="leading-relaxed prose prose-sm max-w-none">
|
||||
{product.long_description ? (
|
||||
@@ -28,4 +28,4 @@ export const ProductOverview: React.FC<ProductOverviewProps> = ({
|
||||
</CardBody>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
};
|
||||
@@ -35,8 +35,6 @@ export const ServiceCard: React.FC<ServiceCardProps> = ({ service }) => {
|
||||
<p className="text-xs text-gray-600 mb-4 line-clamp-2 leading-relaxed">
|
||||
{service.short_description || t("No description available")}
|
||||
</p>
|
||||
|
||||
|
||||
</CardBody>
|
||||
{/* Footer with tools count */}
|
||||
<CardFooter>
|
||||
@@ -50,7 +48,7 @@ export const ServiceCard: React.FC<ServiceCardProps> = ({ service }) => {
|
||||
{t("{{count}} Tools", { count: service.tools.length })}
|
||||
</Chip>
|
||||
<div className="flex flex-col gap-1">
|
||||
<Price price={service.price} charge_type={service.charge_type || ChargeType.Free} />
|
||||
<Price price={service.price} charge_type={service.charge_type} />
|
||||
</div>
|
||||
</div>
|
||||
</CardFooter>
|
||||
|
||||
Reference in new issue
Block a user