feat/0.2:add theme setting and about page setting and support use email and password login

This commit is contained in:
lethe committed 2025-07-24 10:28:42 +08:00
1 parent 58292b0e6e
commit ca2b732952
85 files changed
+5797 -816

No files matched your search

@@ -0,0 +1,42 @@
"use client";
import React from "react";
import ReactMarkdown from "react-markdown";
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
import { Card, CardBody } from "@nextui-org/react";
import { useTranslation } from "@/shared/lib/useTranslation";
export const AboutContent: React.FC = () => {
const { platformConfig } = usePlatformConfig();
const { t } = useTranslation();
return (
<Card shadow="none" className="bg-transparent">
<CardBody className="space-y-4">
<h1 className="text-3xl font-bold mb-6">{t("About Us")}</h1>
<div className="leading-relaxed prose prose-sm max-w-none">
{platformConfig.about_page ? (
<ReactMarkdown>{platformConfig.about_page}</ReactMarkdown>
) : (
<ReactMarkdown>
{`
${t("**XPack** is a lightweight, open-source marketplace framework for MCP (Model Context Protocol) services.")}
${t("It allows you to transform any OpenAPI into a monetizable MCP service and build your own API store in just minutes.")}
${t("✨ With XPack, you can:")}
${t("- ✅ **One-click OpenAPI → MCP service config**")}
${t("- 🧾 **SEO-friendly homepage + mcp service page**")}
${t("- 💳 **Built-in billing (per-call)**")}
${t("- 👥 **User account management**")}
${t("- 🛠 **Support Stripe Payment**")}
${t("- 🔐 **Support Email & Google OAuth Sign in**")}
${t("Everything is open-source and licensed under **Apache 2.0** — ready for commercial use.")}`}
</ReactMarkdown>
)}
</div>
</CardBody>
</Card>
);
};
@@ -0,0 +1,159 @@
"use client";
import React, { useState } from "react";
import {
Modal,
ModalContent,
ModalHeader,
ModalBody,
ModalFooter,
Button,
Input,
} from "@nextui-org/react";
import { Eye, EyeOff } from "lucide-react";
import { useTranslation } from "react-i18next";
import toast from "react-hot-toast";
import { useGlobalStore } from "@/shared/store/global";
import { useSharedStore } from "@/shared/store/share";
interface ChangePasswordModalProps {
isOpen: boolean;
onClose: () => void;
}
export const ChangePasswordModal: React.FC<ChangePasswordModalProps> = ({
isOpen,
onClose,
}) => {
const { t } = useTranslation();
const [newPassword, setNewPassword] = useState("");
const [confirmPassword, setConfirmPassword] = useState("");
const [showNewPassword, setShowNewPassword] = useState(false);
const [showConfirmPassword, setShowConfirmPassword] = useState(false);
const { changePassword } = useGlobalStore();
const { setUserToken } = useSharedStore();
const handleClose = () => {
setNewPassword("");
setConfirmPassword("");
setShowNewPassword(false);
setShowConfirmPassword(false);
onClose();
};
const handleSubmit = async () => {
// 验证表单
if (!newPassword.trim()) {
toast.error(t("Please enter new password"));
return;
}
if (newPassword.length < 8) {
toast.error(t("Password must be at least 8 characters long"));
return;
}
if (newPassword !== confirmPassword) {
toast.error(t("New passwords do not match"));
return;
}
const result = await changePassword(newPassword);
if (result.success) {
toast.success(t("Password changed successfully"));
setUserToken(result.data.user_token || "");
handleClose();
return;
}
toast.error(result.error_message || t("Failed to change password"));
};
const isFormValid =
newPassword.trim() !== "" &&
confirmPassword.trim() !== "" &&
newPassword === confirmPassword &&
newPassword.length >= 8;
return (
<Modal isOpen={isOpen} onClose={handleClose} size="md">
<ModalContent>
<ModalHeader className="flex flex-col gap-1">
{t("Change Password")}
</ModalHeader>
<ModalBody>
<div className="space-y-4">
{/* New Password */}
<Input
label={t("New Password")}
placeholder={t("Enter new password")}
type={showNewPassword ? "text" : "password"}
value={newPassword}
onChange={(e) => setNewPassword(e.target.value)}
description={t("Password must be at least 8 characters long")}
endContent={
<button
type="button"
onClick={() => setShowNewPassword(!showNewPassword)}
className="focus:outline-none"
>
{showNewPassword ? (
<EyeOff className="w-4 h-4 text-gray-400" />
) : (
<Eye className="w-4 h-4 text-gray-400" />
)}
</button>
}
isRequired
/>
{/* Confirm New Password */}
<Input
label={t("Confirm New Password")}
placeholder={t("Confirm new password")}
type={showConfirmPassword ? "text" : "password"}
value={confirmPassword}
onChange={(e) => setConfirmPassword(e.target.value)}
color={
confirmPassword && newPassword !== confirmPassword
? "danger"
: "default"
}
errorMessage={
confirmPassword && newPassword !== confirmPassword
? t("Passwords do not match")
: undefined
}
endContent={
<button
type="button"
onClick={() => setShowConfirmPassword(!showConfirmPassword)}
className="focus:outline-none"
>
{showConfirmPassword ? (
<EyeOff className="w-4 h-4 text-gray-400" />
) : (
<Eye className="w-4 h-4 text-gray-400" />
)}
</button>
}
isRequired
/>
</div>
</ModalBody>
<ModalFooter>
<Button color="default" variant="light" onPress={handleClose}>
{t("Cancel")}
</Button>
<Button
color="primary"
onPress={handleSubmit}
isDisabled={!isFormValid}
>
{t("Confirm")}
</Button>
</ModalFooter>
</ModalContent>
</Modal>
);
};
@@ -0,0 +1,106 @@
"use client";
import React from "react";
import { EmailConfigForm } from "@/components/login-setting/EmailConfigForm";
import { GoogleAuthConfigForm } from "@/components/login-setting/GoogleAuthConfigForm";
import { useSystemConfigManagement } from "@/hooks/useSystemConfigManagement";
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
import { LoginConfig, GoogleAuthConfig } from "@/shared/types/system";
import { TabKey } from "@/shared/types/dashboard";
import { useTranslation } from "@/shared/lib/useTranslation";
import { toast } from "react-hot-toast";
interface LoginSettingsContentProps {
onTabNavigate?: (tab: TabKey) => void;
}
export const LoginSettingsContent: React.FC<LoginSettingsContentProps> = ({
onTabNavigate,
}) => {
const { t } = useTranslation();
const { updateClientConfig } = usePlatformConfig();
const {
// login config
loginConfig,
loginLoading,
saveLoginConfig,
// email config
emailConfig,
// platform config
platformConfig,
} = useSystemConfigManagement();
// 验证至少有一种登录方式启用
const validateLoginMethods = (config: LoginConfig): boolean => {
const isGoogleEnabled =
config.google?.is_enabled && config.google?.client_id;
const isEmailEnabled = config.email?.is_enabled;
const enabledCount = [isGoogleEnabled, isEmailEnabled].filter(
Boolean
).length;
if (enabledCount === 0) {
toast.error(t("At least one login method must be enabled"));
return false;
}
return true;
};
// save login config
const handleSaveLoginConfig = async (config: LoginConfig) => {
if (!validateLoginMethods(config)) {
return;
}
const result = await saveLoginConfig(config);
if (!result) return;
updateClientConfig({
platform: platformConfig,
login: config,
});
};
// save google auth config
const handleSaveGoogleAuthConfig = async (config: GoogleAuthConfig) => {
const updatedLoginConfig = {
...loginConfig,
google: config,
};
if (!validateLoginMethods(updatedLoginConfig)) {
return;
}
const result = await saveLoginConfig(updatedLoginConfig);
if (!result) return;
updateClientConfig({
platform: platformConfig,
login: updatedLoginConfig,
});
};
return (
<div className="space-y-6 w-full">
{/* email config */}
<EmailConfigForm
config={loginConfig}
emailConfig={emailConfig}
onSave={handleSaveLoginConfig}
isLoading={loginLoading}
onTabNavigate={onTabNavigate}
/>
{/* google auth config */}
<GoogleAuthConfigForm
config={loginConfig.google}
onSave={handleSaveGoogleAuthConfig}
isLoading={loginLoading}
/>
</div>
);
};
+198 -158
View File
@@ -14,179 +14,219 @@ import { useAdminLogin } from "@/hooks/useAdminLogin";
import { MCPServicesManagement } from "@/components/mcp-services/MCPServicesManagement";
import UserManagement from "@/components/user-management/UserManagement";
import RevenueManagement from "@/components/revenue-management/RevenueManagement";
import { Cog, CreditCard, DollarSign, Home, Settings, Users } from "lucide-react";
import {
Cog,
CreditCard,
DollarSign,
Home,
Settings,
Users,
LogIn,
} from "lucide-react";
import { LoginSettingsContent } from "@/components/console/LoginSettingsContent";
import { Button } from "@nextui-org/react";
import { FaDiscord } from "react-icons/fa";
const ConsoleContent: React.FC = () => {
const { t } = useTranslation();
const router = useRouter();
const searchParams = useSearchParams();
const [admin_token] = useAdminStore((state) => [state.admin_token]);
const { t } = useTranslation();
const router = useRouter();
const searchParams = useSearchParams();
const [admin_token] = useAdminStore((state) => [state.admin_token]);
const getInitialTab = (): TabKey => {
const tabFromUrl = searchParams.get("tab") as TabKey;
if (
tabFromUrl &&
[
"mcp-services",
"user-management",
"revenue-management",
"payment-channels",
"system-settings",
].includes(tabFromUrl)
) {
return tabFromUrl;
}
return "console";
};
const getInitialTab = (): TabKey => {
const tabFromUrl = searchParams.get("tab") as TabKey;
if (
tabFromUrl &&
[
"mcp-services",
"user-management",
"revenue-management",
"payment-channels",
"login-settings",
"system-settings",
].includes(tabFromUrl)
) {
return tabFromUrl;
}
return TabKey.CONSOLE;
};
const [activeTab, setActiveTab] = useState<TabKey>(getInitialTab);
const sidebarItems: SidebarItem[] = [
{
key: "console",
icon: <Home className="w-5 h-5" />,
label: t("Dashboard"),
description: t("Overview and analytics"),
},
{
key: "mcp-services",
icon: <Settings className="w-5 h-5" />,
label: t("MCP Services"),
description: t("Manage MCP services and API tools"),
},
{
key: "user-management",
icon: <Users className="w-5 h-5" />,
label: t("User Management"),
description: t("Manage registered users"),
},
{
key: "revenue-management",
icon: <DollarSign className="w-5 h-5" />,
label: t("Revenue Management"),
description: t("View user recharge history"),
},
{
key: "payment-channels",
icon: <CreditCard className="w-5 h-5" />,
label: t("Payment Channels"),
description: t("Configure payment channels"),
},
{
key: "system-settings",
icon: <Cog className="w-5 h-5" />,
label: t("System Settings"),
description: t("Platform basic configuration"),
},
];
const [activeTab, setActiveTab] = useState<TabKey>(getInitialTab);
const sidebarItems: SidebarItem[] = [
{
key: TabKey.CONSOLE,
icon: <Home className="w-5 h-5" />,
label: t("Dashboard"),
description: t("Overview and analytics"),
},
{
key: TabKey.MCP_SERVICES,
icon: <Settings className="w-5 h-5" />,
label: t("MCP Services"),
description: t("Manage MCP services and API tools"),
},
{
key: TabKey.USER_MANAGEMENT,
icon: <Users className="w-5 h-5" />,
label: t("User Management"),
description: t("Manage registered users"),
},
{
key: TabKey.REVENUE_MANAGEMENT,
icon: <DollarSign className="w-5 h-5" />,
label: t("Revenue Management"),
description: t("View user recharge history"),
},
{
key: TabKey.PAYMENT_CHANNELS,
icon: <CreditCard className="w-5 h-5" />,
label: t("Payment Channels"),
description: t("Configure payment channels"),
},
{
key: TabKey.LOGIN_SETTINGS,
icon: <LogIn className="w-5 h-5" />,
label: t("Login Settings"),
description: t("Configure authentication methods"),
},
{
key: TabKey.SYSTEM_SETTINGS,
icon: <Cog className="w-5 h-5" />,
label: t("System Settings"),
description: t("Platform basic configuration"),
},
];
// If admin is not logged in, redirect to admin login page
useEffect(() => {
if (!admin_token) {
router.push("/admin");
}
}, [admin_token, router]);
// If admin is not logged in, redirect to admin login page
useEffect(() => {
if (!admin_token) {
router.push("/admin-signin");
}
}, [admin_token, router]);
const handleTabNavigate = (tab: TabKey) => {
setActiveTab(tab);
// update url params
if (tab === TabKey.CONSOLE) {
// when switch to dashboard, clear all query params, only keep base path
router.push("/console", { scroll: false });
} else {
// other tabs set corresponding tab params
const params = new URLSearchParams();
params.set("tab", tab);
router.push(`/console?${params.toString()}`, { scroll: false });
}
};
const handleTabNavigate = (tab: TabKey) => {
setActiveTab(tab);
// update url params
if (tab === "console") {
// when switch to dashboard, clear all query params, only keep base path
router.push("/console", { scroll: false });
} else {
// other tabs set corresponding tab params
const params = new URLSearchParams();
params.set("tab", tab);
router.push(`/console?${params.toString()}`, { scroll: false });
}
};
const { adminLogout } = useAdminLogin();
const { adminLogout } = useAdminLogin();
const handleLogout = () => {
// use admin logout method
adminLogout();
};
const handleLogout = () => {
// use admin logout method
adminLogout();
};
// render different content based on activeTab
const renderContent = () => {
switch (activeTab) {
case TabKey.MCP_SERVICES:
return <MCPServicesManagement />;
case TabKey.USER_MANAGEMENT:
return (
<div className="h-full overflow-auto">
<UserManagement />
</div>
);
case TabKey.REVENUE_MANAGEMENT:
return (
<div className="h-full overflow-auto">
<RevenueManagement />
</div>
);
case TabKey.PAYMENT_CHANNELS:
return (
<DashboardDemoContent
title={t("Payment Channels")}
description={t("Configure payment channels")}
>
<PaymentChannelsContent />
</DashboardDemoContent>
);
case "login-settings":
return (
<DashboardDemoContent
title={t("Login Settings")}
description={t("Configure authentication methods")}
>
<LoginSettingsContent onTabNavigate={handleTabNavigate} />
</DashboardDemoContent>
);
case "system-settings":
return (
<DashboardDemoContent
title={t("System Settings")}
description={t("Platform basic configuration")}
>
<SystemSettingsContent />
</DashboardDemoContent>
);
default:
return (
<DashboardDemoContent
title={t("Admin Dashboard")}
description={t("Platform management and analytics")}
>
<ConsoleStats />
</DashboardDemoContent>
);
}
};
// render different content based on activeTab
const renderContent = () => {
switch (activeTab) {
case "mcp-services":
return <MCPServicesManagement />;
case "user-management":
return (
<div className="h-full overflow-auto">
<UserManagement />
</div>
);
case "revenue-management":
return (
<div className="h-full overflow-auto">
<RevenueManagement />
</div>
);
case "payment-channels":
return (
<DashboardDemoContent
title={t("Payment Channels")}
description={t("Configure payment channels")}
>
<PaymentChannelsContent />
</DashboardDemoContent>
);
case "system-settings":
return (
<DashboardDemoContent
title={t("System Settings")}
description={t("Platform basic configuration")}
>
<SystemSettingsContent />
</DashboardDemoContent>
);
default:
return (
<DashboardDemoContent
title={t("Admin Dashboard")}
description={t("Platform management and analytics")}
>
<ConsoleStats />
</DashboardDemoContent>
);
}
};
return (
<div className="min-h-screen bg-background">
<div className="flex">
{/* Sidebar */}
<DashboardSidebar
activeTab={activeTab}
onTabNavigate={handleTabNavigate}
onLogout={handleLogout}
sidebarItems={sidebarItems}
bottomPanel={
<Button
variant="light"
startContent={<FaDiscord className="w-5 h-5" />}
className="w-full justify-start h-auto p-3"
onPress={() => {
window.open("https://discord.gg/cyZfcdCXkW", "_blank");
}}
>
<div className="flex justify-between items-center w-full">
<span className="font-medium">{t("Discord")}</span>
</div>
</Button>
}
/>
return (
<div className="min-h-screen bg-background">
<div className="flex">
{/* Sidebar */}
<DashboardSidebar
activeTab={activeTab}
onTabNavigate={handleTabNavigate}
onLogout={handleLogout}
sidebarItems={sidebarItems}
/>
{/* Main Content */}
<div className="flex-1 h-screen overflow-y-auto">{renderContent()}</div>
</div>
</div>
);
{/* Main Content */}
<div className="flex-1 h-screen overflow-y-auto">{renderContent()}</div>
</div>
</div>
);
};
const ConsoleMain: React.FC = () => {
const { t } = useTranslation();
const { t } = useTranslation();
return (
<Suspense
fallback={
<div className="min-h-screen bg-background flex items-center justify-center">
{t("Loading...")}
</div>
}
>
<ConsoleContent />
</Suspense>
);
return (
<Suspense
fallback={
<div className="min-h-screen bg-background flex items-center justify-center">
{t("Loading...")}
</div>
}
>
<ConsoleContent />
</Suspense>
);
};
export default ConsoleMain;
@@ -1,16 +1,17 @@
'use client';
"use client";
import React from 'react';
import { PlatformConfigForm } from '@/components/system-setting/PlatformConfigForm';
import { AdminConfigForm } from '@/components/system-setting/AdminConfigForm';
import { EmailConfigForm } from '@/components/system-setting/EmailConfigForm';
import { GoogleAuthConfigForm } from '@/components/system-setting/GoogleAuthConfigForm';
import { useSystemConfigManagement } from '@/hooks/useSystemConfigManagement';
import { usePlatformConfig } from '@/shared/contexts/PlatformConfigContext';
import i18n from '@/shared/lib/i18n';
import React, { useState } from "react";
import { PlatformConfigForm } from "@/components/system-setting/PlatformConfigForm";
import { AdminConfigForm } from "@/components/system-setting/AdminConfigForm";
import { EmailConfigForm } from "@/components/system-setting/EmailConfigForm";
import { useSystemConfigManagement } from "@/hooks/useSystemConfigManagement";
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
import { Theme } from "@/shared/types/system";
import i18n from "@/shared/lib/i18n";
export const SystemSettingsContent: React.FC = () => {
const { updateClientConfig } = usePlatformConfig();
const [isAboutLoading, setIsAboutLoading] = useState(false);
const {
// platform config
@@ -28,11 +29,8 @@ export const SystemSettingsContent: React.FC = () => {
emailLoading,
saveEmailConfig,
// google auth config
googleAuthConfig,
googleAuthLoading,
saveGoogleAuthConfig,
// image upload
uploadImage,
} = useSystemConfigManagement();
// save admin config
@@ -45,22 +43,10 @@ export const SystemSettingsContent: React.FC = () => {
await saveEmailConfig(config);
};
// save google auth config
const handleSaveGoogleAuthConfig = async (config: typeof googleAuthConfig) => {
const result = await saveGoogleAuthConfig(config);
if (!result) return
updateClientConfig({
platform: platformConfig,
login: {
google: config,
},
});
};
// save platform config
const handleSavePlatformConfig = async (config: typeof platformConfig) => {
const result = await savePlatformConfig(config);
if (!result) return
if (!result) return;
updateClientConfig({
platform: config,
});
@@ -69,6 +55,27 @@ export const SystemSettingsContent: React.FC = () => {
}
};
// handle theme change
const handleThemeChange = async (theme: Theme) => {
const updatedConfig = { ...platformConfig, theme };
const result = await savePlatformConfig(updatedConfig, "theme");
if (!result) return;
updateClientConfig({
platform: updatedConfig,
});
};
// handle about save
const handleAboutSave = async (aboutContent: string) => {
setIsAboutLoading(true);
const updatedConfig = { ...platformConfig, about_page: aboutContent };
const result = await savePlatformConfig(updatedConfig, "about");
setIsAboutLoading(false);
if (!result) return;
updateClientConfig({
platform: updatedConfig,
});
};
return (
<div className="space-y-6 w-full">
@@ -76,7 +83,11 @@ export const SystemSettingsContent: React.FC = () => {
<PlatformConfigForm
config={platformConfig}
onSave={handleSavePlatformConfig}
onThemeChange={handleThemeChange}
onAboutSave={handleAboutSave}
isLoading={platformLoading}
isAboutLoading={isAboutLoading}
onImageUpload={uploadImage}
/>
{/* admin config */}
@@ -92,15 +103,8 @@ export const SystemSettingsContent: React.FC = () => {
onSave={handleSaveEmailConfig}
isLoading={emailLoading}
/>
{/* google auth config */}
<GoogleAuthConfigForm
config={googleAuthConfig}
onSave={handleSaveGoogleAuthConfig}
isLoading={googleAuthLoading}
/>
</div>
);
};
export default SystemSettingsContent;
export default SystemSettingsContent;
+44 -28
View File
@@ -6,22 +6,26 @@ import { useGlobalStore } from "@/shared/store/global";
import DashboardSidebar from "@/shared/components/DashboardSidebar";
import { SidebarItem, TabKey } from "@/shared/types/dashboard";
import { useSharedStore } from "@/shared/store/share";
import { formatCurrency } from '@/shared/utils/currency';
import { formatCurrency } from "@/shared/utils/currency";
// Import dashboard content components
import DashboardOverview from "@/components/dashboard/DashboardOverview";
import WalletManagement from "@/components/wallet/WalletManagement";
import { Home, Wallet } from "lucide-react";
import { Home, Key, Wallet } from "lucide-react";
import { Avatar, Card, CardBody, Button, Divider } from "@nextui-org/react";
import { RechargeModal } from "@/shared/components/modal/RechargeModal";
import { useTranslation } from "@/shared/lib/useTranslation";
import { ChangePasswordModal } from "@/components/common/ChangePasswordModal";
const DashboardContent: React.FC = () => {
const { t } = useTranslation();
const router = useRouter();
const searchParams = useSearchParams();
const [user_token, user] = useSharedStore((state) => [state.user_token, state.user]);
const [user_token, user] = useSharedStore((state) => [
state.user_token,
state.user,
]);
const [logOut, useGetUser] = useGlobalStore((state) => [
state.logOut,
@@ -33,20 +37,23 @@ const DashboardContent: React.FC = () => {
const [isRechargeModalOpen, setIsRechargeModalOpen] = useState(false);
const getInitialTab = (): TabKey => {
const tabFromUrl = searchParams.get("tab") as TabKey;
if (
tabFromUrl &&
[
"overview",
"wallet"
].includes(tabFromUrl)
) {
if (tabFromUrl && [TabKey.OVERVIEW, TabKey.WALLET].includes(tabFromUrl)) {
return tabFromUrl;
}
return "overview";
return TabKey.OVERVIEW;
};
const [activeTab, setActiveTab] = useState<TabKey>(getInitialTab);
const [isChangePasswordModalOpen, setIsChangePasswordModalOpen] =
React.useState(false);
const handleChangePassword = () => {
setIsChangePasswordModalOpen(true);
};
const handleChangePasswordClose = () => {
setIsChangePasswordModalOpen(false);
};
useEffect(() => {
if (!data) return;
if (data.code === "1000001") {
@@ -55,8 +62,6 @@ const DashboardContent: React.FC = () => {
}
}, [data]);
// If user is not logged in, redirect to login page
useEffect(() => {
if (!user_token) {
@@ -64,7 +69,6 @@ const DashboardContent: React.FC = () => {
}
}, [user_token]);
const handleLogout = () => {
// use global store logout method
logOut();
@@ -78,24 +82,17 @@ const DashboardContent: React.FC = () => {
const sidebarItems: SidebarItem[] = [
{
key: "overview",
key: TabKey.OVERVIEW,
icon: <Home className="w-5 h-5" />,
label: "Dashboard",
description: "Manage your integration and auth key",
},
// {
// key: "wallet",
// icon: <Wallet className="w-5 h-5" />,
// label: "My Wallet",
// description: "Manage your balance and recharge history",
// },
];
const handleTabNavigate = (tab: TabKey) => {
setActiveTab(tab);
// update url params
if (tab === "overview") {
if (tab === TabKey.OVERVIEW) {
// when switch to dashboard, clear all query params, only keep base path
router.push("/dashboard", { scroll: false });
} else {
@@ -115,6 +112,17 @@ const DashboardContent: React.FC = () => {
onTabNavigate={handleTabNavigate}
onLogout={handleLogout}
sidebarItems={sidebarItems}
bottomPanel={
<Button
variant="light"
color="default"
startContent={<Key className="w-4 h-4" />}
className="w-full justify-start mb-2"
onPress={handleChangePassword}
>
{t("Change Password")}
</Button>
}
userProfilePanel={
user && (
<div className="mb-6 space-y-3">
@@ -142,7 +150,11 @@ const DashboardContent: React.FC = () => {
<div className="flex justify-between text-xs">
<div className="flex gap-2 items-center">
<Wallet size={16} />
<span>{t("Balance: {{amount}}", { amount: formatCurrency(user?.wallet?.balance || 0) })}</span>
<span>
{t("Balance: {{amount}}", {
amount: formatCurrency(user?.wallet?.balance || 0),
})}
</span>
</div>
<Button
@@ -156,7 +168,6 @@ const DashboardContent: React.FC = () => {
</div>
</CardBody>
</Card>
</div>
)
}
@@ -164,8 +175,8 @@ const DashboardContent: React.FC = () => {
{/* Main Content */}
<div className="flex-1 h-screen overflow-y-auto">
{activeTab === "overview" && <DashboardOverview />}
{activeTab === "wallet" && (
{activeTab === TabKey.OVERVIEW && <DashboardOverview />}
{activeTab === TabKey.WALLET && (
<WalletManagement onRecharge={() => setIsRechargeModalOpen(true)} />
)}
</div>
@@ -176,6 +187,11 @@ const DashboardContent: React.FC = () => {
isOpen={isRechargeModalOpen}
onClose={() => setIsRechargeModalOpen(false)}
/>
{/* Change Password Modal */}
<ChangePasswordModal
isOpen={isChangePasswordModalOpen}
onClose={handleChangePasswordClose}
/>
</div>
);
};
@@ -194,4 +210,4 @@ const DashboardMain: React.FC = () => {
);
};
export default DashboardMain;
export default DashboardMain;
@@ -0,0 +1,210 @@
"use client";
import React, { useEffect, useState } from "react";
import {
Switch,
AccordionItem,
Accordion,
Select,
SelectItem,
Button,
Alert,
Link,
} from "@nextui-org/react";
import { useTranslation } from "@/shared/lib/useTranslation";
import { EmailMode, LoginConfig } from "@/shared/types/system";
import { EmailConfig } from "@/types/system";
import { TabKey } from "@/shared/types/dashboard";
interface EmailConfigFormProps {
config: LoginConfig;
emailConfig: EmailConfig;
onSave: (config: LoginConfig) => Promise<void>;
isLoading?: boolean;
onTabNavigate?: (tab: TabKey) => void;
}
export const EmailConfigForm: React.FC<EmailConfigFormProps> = ({
config,
emailConfig,
onSave,
isLoading = false,
onTabNavigate,
}) => {
const { t } = useTranslation();
const [formData, setFormData] = useState<LoginConfig>(config);
useEffect(() => {
setFormData(config);
}, [config]);
const handleToggleEnabled = async (enabled: boolean) => {
const updatedConfig = {
...config,
email: {
...config.email,
is_enabled: enabled,
mode: config.email?.mode || EmailMode.PASSWORD,
},
};
// when toggle the switch, save directly, same as GoogleAuthConfigForm
await onSave(updatedConfig);
};
const handleModeChange = (mode: EmailMode) => {
// no longer save directly, but update the local state
setFormData((prev) => ({
...prev,
email: {
...prev.email,
is_enabled: prev.email?.is_enabled || false,
mode,
},
}));
};
const handleSave = async () => {
await onSave(formData);
};
const isEmailConfigured = !!emailConfig?.smtp_host;
const isCaptchaMode = formData.email?.mode === EmailMode.CAPTCHA;
const isEmailEnabled = formData.email?.is_enabled || false;
return (
<Accordion
variant="splitted"
itemClasses={{
base: "shadow-none border-1",
}}
defaultExpandedKeys={["email-login"]}
className="px-0"
>
<AccordionItem
key="email-login"
title={
<div className="flex items-center gap-3">
<div className="flex flex-col">
<h3 className="text-lg font-semibold">{t("Email Login")}</h3>
<p className="text-sm text-gray-500">
{t("Configure email-based authentication")}
</p>
</div>
</div>
}
>
<div className="space-y-4">
{/* enable email login */}
<div className="flex items-center justify-between p-4 bg-gray-50 rounded-lg">
<div className="flex flex-col gap-1">
<span className="text-sm font-medium">
{t("Enable Email Login")}
</span>
<span className="text-xs text-gray-500">
{t("Allow users to sign in with email")}
</span>
</div>
<Switch
isSelected={isEmailEnabled}
onValueChange={handleToggleEnabled}
color="primary"
size="sm"
isDisabled={isLoading || (isCaptchaMode && !isEmailConfigured)}
/>
</div>
{/* authentication mode selection */}
<div className="p-4 bg-gray-50 rounded-lg">
<div className="flex flex-col gap-3">
<div className="flex flex-col gap-1">
<span className="text-sm font-medium">
{t("Authentication Mode")}
</span>
<span className="text-xs text-gray-500">
{t("Choose how users authenticate with email")}
</span>
</div>
<Select
selectedKeys={[formData.email?.mode || EmailMode.PASSWORD]}
onSelectionChange={(keys) => {
const mode = Array.from(keys)[0] as EmailMode;
handleModeChange(mode);
}}
size="sm"
isDisabled={isLoading || !isEmailEnabled}
renderValue={() => {
const selectedKey =
formData.email?.mode || EmailMode.PASSWORD;
if (selectedKey === EmailMode.PASSWORD)
return t("Email/Password");
return t(
selectedKey === EmailMode.CAPTCHA
? "Email/Verification Code"
: "Email/Password"
);
}}
>
<SelectItem key={EmailMode.PASSWORD} value={EmailMode.PASSWORD}>
<div className="flex flex-col">
<span className="text-sm font-medium">
{t("Email/Password")}
</span>
<span className="text-xs text-gray-500">
{t("Traditional email and password authentication")}
</span>
</div>
</SelectItem>
<SelectItem key={EmailMode.CAPTCHA} value={EmailMode.CAPTCHA}>
<div className="flex flex-col">
<span className="text-sm font-medium">
{t("Email/Verification Code")}
</span>
<span className="text-xs text-gray-500">
{t("Passwordless login with email verification code")}
</span>
</div>
</SelectItem>
</Select>
</div>
</div>
{/* email configuration hint - only show in captcha mode */}
{isEmailEnabled && isCaptchaMode && !isEmailConfigured && (
<Alert color="warning" variant="flat" className="mb-4">
<div className="flex gap-2">
<span>
{t(
"Email service is not configured. Please configure email settings first."
)}
</span>
<Link
className="text-sm underline cursor-pointer"
onPress={() => {
onTabNavigate?.(TabKey.SYSTEM_SETTINGS);
}}
>
{t("Go to Settings")}
</Link>
</div>
</Alert>
)}
{/* save button - only show in enabled state */}
{isEmailEnabled && (
<div className="flex gap-3 py-4">
<Button
color="primary"
variant="solid"
onPress={handleSave}
isLoading={isLoading}
size="sm"
>
{t("Save")}
</Button>
</div>
)}
</div>
</AccordionItem>
</Accordion>
);
};
@@ -0,0 +1,161 @@
"use client";
import React, { useEffect, useState } from "react";
import {
Input,
Button,
Switch,
AccordionItem,
Accordion,
} from "@nextui-org/react";
import { Eye, EyeOff } from "lucide-react";
import { useTranslation } from "@/shared/lib/useTranslation";
import { getGoogleRedirectUri } from "@/hooks/useLogin";
import { GoogleAuthConfig } from "@/shared/types/system";
interface GoogleAuthConfigFormProps {
config: GoogleAuthConfig;
onSave: (config: GoogleAuthConfig) => void;
isLoading?: boolean;
}
export const GoogleAuthConfigForm: React.FC<GoogleAuthConfigFormProps> = ({
config,
onSave,
isLoading = false,
}) => {
const { t } = useTranslation();
const [formData, setFormData] = useState<GoogleAuthConfig>(config);
const [showClientSecret, setShowClientSecret] = useState(false);
useEffect(() => {
setFormData(config);
}, [config]);
const handleInputChange = (
field: keyof GoogleAuthConfig,
value: string | boolean
) => {
setFormData((prev) => ({
...prev,
[field]: value,
}));
};
const handleSave = () => {
onSave(formData);
};
const isFormValid = formData.client_id.trim() !== "";
return (
<Accordion
variant="splitted"
itemClasses={{
base: "shadow-none border-1",
}}
defaultExpandedKeys={["google-auth-config"]}
className="px-0"
>
<AccordionItem
key="google-auth-config"
title={
<div className="flex flex-col justify-between">
<h3 className="text-lg font-semibold">
{t("Google Login Settings")}
</h3>
<p className="text-sm text-gray-500">
{t("Configure Google OAuth integration")}
</p>
</div>
}
>
<div className="space-y-4">
{/* enable google login */}
<div className="flex items-center justify-between p-4 bg-gray-50 rounded-lg">
<div className="flex flex-col gap-1">
<span className="text-sm font-medium">
{t("Enable Google Login")}
</span>
<span className="text-xs text-gray-500">
{t("Allow users to sign in with Google")}
</span>
</div>
<Switch
isSelected={formData.is_enabled}
onValueChange={(value) => {
onSave({
...formData,
is_enabled: value,
});
}}
color="primary"
size="sm"
/>
</div>
{/* Google Client ID */}
<Input
label={t("Google Client ID")}
placeholder={t("OAuth 2.0 Client ID from Google Cloud Console")}
value={formData.client_id}
onChange={(e) => handleInputChange("client_id", e.target.value)}
isRequired
isDisabled={!formData.is_enabled}
/>
{/* Google Client Secret */}
<Input
label={t("Google Client Secret")}
placeholder={t(
"OAuth 2.0 Client Secret (optional, for server-side verification)"
)}
value={formData.client_secret || ""}
onChange={(e) => handleInputChange("client_secret", e.target.value)}
type={showClientSecret ? "text" : "password"}
endContent={
<button
type="button"
onClick={() => setShowClientSecret(!showClientSecret)}
className="focus:outline-none"
disabled={!formData.is_enabled}
>
{showClientSecret ? (
<EyeOff className="w-4 h-4 text-gray-400" />
) : (
<Eye className="w-4 h-4 text-gray-400" />
)}
</button>
}
isDisabled={!formData.is_enabled}
/>
{/* Redirect URI */}
<Input
label={t("Redirect URI")}
placeholder="https://yourdomain.com/auth/google/callback"
description={t(
"Authorized redirect URI configured in Google Cloud Console"
)}
value={getGoogleRedirectUri()}
isDisabled={true}
/>
</div>
{/* Action Buttons */}
{formData.is_enabled && (
<div className="flex gap-3 py-4">
<Button
color="primary"
variant="solid"
onPress={handleSave}
isLoading={isLoading}
isDisabled={!isFormValid}
size="sm"
>
{t("Save")}
</Button>
</div>
)}
</AccordionItem>
</Accordion>
);
};
@@ -1,136 +0,0 @@
'use client';
import React, { useEffect, useState } from 'react';
import { Input, Button, Switch, AccordionItem, Accordion } from '@nextui-org/react';
import { Eye, EyeOff } from 'lucide-react';
import { useTranslation } from "@/shared/lib/useTranslation";
import { getGoogleRedirectUri } from '@/hooks/useLogin';
import { GoogleAuthConfig } from '@/shared/types/system';
interface GoogleAuthConfigFormProps {
config: GoogleAuthConfig;
onSave: (config: GoogleAuthConfig) => void;
isLoading?: boolean;
}
export const GoogleAuthConfigForm: React.FC<GoogleAuthConfigFormProps> = ({
config,
onSave,
isLoading = false,
}) => {
const { t } = useTranslation();
const [formData, setFormData] = useState<GoogleAuthConfig>(config);
const [showClientSecret, setShowClientSecret] = useState(false);
useEffect(() => {
setFormData(config);
}, [config]);
const handleInputChange = (field: keyof GoogleAuthConfig, value: string | boolean) => {
setFormData(prev => ({
...prev,
[field]: value
}));
};
const handleSave = () => {
onSave(formData);
};
const isFormValid = formData.client_id.trim() !== '';
return (
<Accordion variant='splitted' itemClasses={{
base: 'shadow-none border-1',
}} defaultExpandedKeys={['google-auth-config']} className='px-0'>
<AccordionItem key="google-auth-config" title={
<div className="flex flex-col justify-between">
<h3 className="text-lg font-semibold">{t('Google Login Settings')}</h3>
<p className="text-sm text-gray-500">{t('Configure Google OAuth integration')}</p>
</div>
}>
<div className="space-y-4">
{/* enable google login */}
<div className="flex items-center justify-between p-4 bg-gray-50 rounded-lg">
<div className="flex flex-col gap-1">
<span className="text-sm font-medium">{t('Enable Google Login')}</span>
<span className="text-xs text-gray-500">{t('Allow users to sign in with Google')}</span>
</div>
<Switch
isSelected={formData.is_enabled}
onValueChange={(value) => {
handleInputChange('is_enabled', value);
onSave({
...formData,
is_enabled: value
});
}}
color="primary"
size='sm'
/>
</div>
{/* Google Client ID */}
<Input
label={t('Google Client ID')}
placeholder={t('OAuth 2.0 Client ID from Google Cloud Console')}
value={formData.client_id}
onChange={(e) => handleInputChange('client_id', e.target.value)}
isRequired
isDisabled={!formData.is_enabled}
/>
{/* Google Client Secret */}
<Input
label={t('Google Client Secret')}
placeholder={t('OAuth 2.0 Client Secret (optional, for server-side verification)')}
value={formData.client_secret || ''}
onChange={(e) => handleInputChange('client_secret', e.target.value)}
type={showClientSecret ? "text" : "password"}
endContent={
<button
type="button"
onClick={() => setShowClientSecret(!showClientSecret)}
className="focus:outline-none"
disabled={!formData.is_enabled}
>
{showClientSecret ? (
<EyeOff className="w-4 h-4 text-gray-400" />
) : (
<Eye className="w-4 h-4 text-gray-400" />
)}
</button>
}
isDisabled={!formData.is_enabled}
/>
{/* Redirect URI */}
<Input
label={t('Redirect URI')}
placeholder="https://yourdomain.com/auth/google/callback"
description={t('Authorized redirect URI configured in Google Cloud Console')}
value={getGoogleRedirectUri()}
isDisabled={true}
/>
</div>
{/* Action Buttons */}
{
formData.is_enabled && (
<div className="flex gap-3 py-4">
<Button
color="primary"
variant="solid"
onPress={handleSave}
isLoading={isLoading}
isDisabled={!isFormValid}
size='sm'
>
{t('Save')}
</Button>
</div>
)
}
</AccordionItem>
</Accordion>
);
};
@@ -1,21 +1,41 @@
'use client';
"use client";
import React, { useState, useEffect } from 'react';
import { Input, Button, AccordionItem, Accordion, Select, SelectItem } from '@nextui-org/react';
import { PlatformConfig } from '@/shared/types/system';
import React, { useState, useEffect } from "react";
import { calculateFileSha256 } from "@/shared/utils/crypto";
import {
Input,
Button,
AccordionItem,
Accordion,
Select,
SelectItem,
} from "@nextui-org/react";
import MDEditor, { commands } from "@uiw/react-md-editor";
import { PlatformConfig, Theme } from "@/shared/types/system";
import { useTranslation } from "@/shared/lib/useTranslation";
import { SUPPORTED_LANGUAGES } from '@/shared/lib/i18n';
import { SUPPORTED_LANGUAGES } from "@/shared/lib/i18n";
import { ThemeSelector } from "./ThemeSelector";
import "@uiw/react-md-editor/markdown-editor.css";
import "@uiw/react-markdown-preview/markdown.css";
interface PlatformConfigFormProps {
config: PlatformConfig;
onSave: (config: PlatformConfig) => void;
onThemeChange?: (theme: Theme) => Promise<void>;
onAboutSave?: (aboutContent: string) => Promise<void>;
onImageUpload?: (file: File, sha256?: string) => Promise<string>;
isLoading?: boolean;
isAboutLoading?: boolean;
}
export const PlatformConfigForm: React.FC<PlatformConfigFormProps> = ({
config,
onSave,
onThemeChange,
onAboutSave,
onImageUpload,
isLoading = false,
isAboutLoading = false,
}) => {
const { t } = useTranslation();
const [formData, setFormData] = useState<PlatformConfig>(config);
@@ -26,9 +46,9 @@ export const PlatformConfigForm: React.FC<PlatformConfigFormProps> = ({
}, [config]);
const handleInputChange = (field: keyof PlatformConfig, value: string) => {
setFormData(prev => ({
setFormData((prev) => ({
...prev,
[field]: value
[field]: value,
}));
};
@@ -36,122 +56,277 @@ export const PlatformConfigForm: React.FC<PlatformConfigFormProps> = ({
onSave(formData);
};
const isFormValid = formData.name.trim() !== '' && formData.currency?.trim() !== '';
const handleThemeChange = async (theme: Theme) => {
handleInputChange("theme", theme);
onThemeChange?.(theme);
};
const handleAboutSave = async () => {
onAboutSave?.(formData.about_page || "");
};
const handleImageUpload = async (file: File): Promise<string> => {
try {
// 计算文件的 SHA256 哈希值
const sha256 = await calculateFileSha256(file);
return await onImageUpload!(file, sha256);
} catch (error) {
console.error("Image upload failed:", error);
throw error;
}
};
return (
<Accordion variant='splitted' itemClasses={{
base: 'shadow-none border-1',
}} defaultExpandedKeys={['platform-config']} className='px-0'>
<AccordionItem key="platform-config" title={
<div className="flex flex-col justify-between">
<h3 className="text-lg font-semibold">{t('Platform Information')}</h3>
<p className="text-sm text-gray-500">{t('Configure platform logo, name, titles, language')}</p>
</div>
}>
<div className="space-y-4">
{/* platform name */}
<Input
label={t('Platform Name')}
placeholder={t('Enter platform name')}
description={t('The name displayed across the platform')}
value={formData.name}
onChange={(e) => handleInputChange('name', e.target.value)}
isRequired
/>
<div className="space-y-4">
{/* Platform Information Accordion */}
<Accordion
variant="splitted"
itemClasses={{
base: "shadow-none border-1",
}}
defaultExpandedKeys={["platform-config"]}
className="px-0"
>
<AccordionItem
key="platform-config"
title={
<div className="flex flex-col justify-between">
<h3 className="text-lg font-semibold">
{t("Platform Information")}
</h3>
<p className="text-sm text-gray-500">
{t("Configure platform logo, name, titles, and language")}
</p>
</div>
}
>
<div className="space-y-4">
{/* platform name */}
<Input
label={t("Platform Name")}
placeholder={t("Enter platform name")}
description={t("The name displayed across the platform")}
value={formData.name}
onChange={(e) => handleInputChange("name", e.target.value)}
/>
{/* platform logo */}
<Input
label={t('Platform Logo URL')}
placeholder="https://example.com/logo.png"
description={t('URL of the platform logo image (optional)')}
value={formData.logo || ''}
onChange={(e) => handleInputChange('logo', e.target.value)}
/>
{/* platform logo */}
<Input
label={t("Platform Logo URL")}
placeholder="https://example.com/logo.png"
description={t("URL of the platform logo image (optional)")}
value={formData.logo || ""}
onChange={(e) => handleInputChange("logo", e.target.value)}
/>
{/* website title */}
<Input
label={t('Website Title')}
placeholder={t('Enter website title')}
description={t('The title displayed in browser tab and search results')}
value={formData.website_title || ''}
onChange={(e) => handleInputChange('website_title', e.target.value)}
/>
{/* homepage headline */}
<Input
label={t('Headline')}
placeholder={t('Enter homepage headline')}
description={t('Main headline displayed on the homepage')}
value={formData.headline || ''}
onChange={(e) => handleInputChange('headline', e.target.value)}
/>
{/* homepage subheadline */}
<Input
label={t('Subheadline')}
placeholder={t('Enter homepage subheadline')}
description={t('Secondary headline displayed below the main headline')}
value={formData.subheadline || ''}
onChange={(e) => handleInputChange('subheadline', e.target.value)}
/>
{/* platform language */}
<Select
label={t('Platform Language')}
placeholder={t('Select platform language')}
selectedKeys={formData.language ? [formData.language] : ['en']}
onSelectionChange={(keys) => {
const selectedKey = Array.from(keys)[0] as string;
if (selectedKey) {
handleInputChange('language', selectedKey);
{/* website title */}
<Input
label={t("Website Title")}
placeholder={t("Enter website title")}
description={t(
"The title displayed in browser tab and search results"
)}
value={formData.website_title || ""}
onChange={(e) =>
handleInputChange("website_title", e.target.value)
}
}}
>
{SUPPORTED_LANGUAGES.map((language) => (
<SelectItem key={language.name} value={language.name}>
{language.label}
</SelectItem>
))}
</Select>
/>
{/* comming soon:currency unit */}
{/* <Select
label={t('Currency Unit')}
placeholder={t('Select currency')}
description={t('Default currency for the platform')}
selectedKeys={formData.currency ? [formData.currency] : []}
onSelectionChange={(keys) => {
const selectedKey = Array.from(keys)[0] as string;
if (selectedKey) {
handleInputChange('currency', selectedKey);
{/* homepage headline */}
<Input
label={t("Headline")}
placeholder={t("Enter homepage headline")}
description={t("Main headline displayed on the homepage")}
value={formData.headline || ""}
onChange={(e) => handleInputChange("headline", e.target.value)}
/>
{/* homepage subheadline */}
<Input
label={t("Subheadline")}
placeholder={t("Enter homepage subheadline")}
description={t(
"Secondary headline displayed below the main headline"
)}
value={formData.subheadline || ""}
onChange={(e) => handleInputChange("subheadline", e.target.value)}
/>
{/* platform language */}
<Select
label={t("Platform Language")}
placeholder={t("Select platform language")}
selectedKeys={formData.language ? [formData.language] : ["en"]}
onSelectionChange={(keys) => {
const selectedKey = Array.from(keys)[0] as string;
if (selectedKey) {
handleInputChange("language", selectedKey);
}
}}
>
{SUPPORTED_LANGUAGES.map((language) => (
<SelectItem key={language.name} value={language.name}>
{language.label}
</SelectItem>
))}
</Select>
</div>
{/* Action Buttons */}
<div className="flex gap-3 py-4">
<Button
color="primary"
variant="solid"
onPress={handleSave}
isLoading={isLoading}
size="sm"
>
{t("Save")}
</Button>
</div>
</AccordionItem>
</Accordion>
{/* About Page Accordion */}
<Accordion
variant="splitted"
itemClasses={{
base: "shadow-none border-1",
}}
className="px-0"
>
<AccordionItem
key="about-config"
title={
<div className="flex flex-col justify-between">
<h3 className="text-lg font-semibold">
{t("About Page Content")}
</h3>
<p className="text-sm text-gray-500">
{t("Configure about page content")}
</p>
</div>
}
>
<div className="space-y-4">
<MDEditor
value={formData.about_page || ""}
onChange={(value?: string) =>
handleInputChange("about_page", value || "")
}
}}
isRequired
>
{getCurrencyOptions().map((currency) => (
<SelectItem key={currency.value} value={currency.value}>
{currency.label}
</SelectItem>
))}
</Select> */}
</div>
preview="live"
hideToolbar={false}
visibleDragbar={false}
data-color-mode="light"
textareaProps={{
placeholder: t("Enter about page content (supports Markdown)"),
style: {
fontSize: 14,
lineHeight: 1.6,
fontFamily:
'ui-monospace, SFMono-Regular, "SF Mono", Monaco, Consolas, "Liberation Mono", "Courier New", monospace',
},
}}
height={300}
commands={[
// 默认命令
commands.bold,
commands.italic,
commands.strikethrough,
commands.hr,
commands.title,
commands.divider,
commands.link,
commands.quote,
commands.code,
commands.codeBlock,
commands.comment,
commands.divider,
commands.unorderedListCommand,
commands.orderedListCommand,
commands.checkedListCommand,
commands.divider,
// 自定义图片上传命令
{
name: "image-upload",
keyCommand: "image-upload",
buttonProps: {
"aria-label": "Upload image",
title: "Upload image",
},
icon: (
<svg width="12" height="12" viewBox="0 0 20 20">
<path
fill="currentColor"
d="M15 9c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm4-7H1c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zM2 17l4.5-6 3.5 4.51 2.5-3.01L17 17H2z"
/>
</svg>
),
execute: (state, api) => {
const input = document.createElement("input");
input.type = "file";
input.accept = "image/*";
input.onchange = async (e) => {
const file = (e.target as HTMLInputElement).files?.[0];
if (file) {
try {
const dataUrl = await handleImageUpload(file);
const imageMarkdown = `![${file.name}](${window.location.origin}${dataUrl})`;
api.replaceSelection(imageMarkdown);
} catch (error) {
console.error("Image upload failed:", error);
}
}
};
input.click();
},
},
]}
/>
</div>
{/* Action Buttons */}
<div className="flex gap-3 py-4">
<Button
color="primary"
variant="solid"
onPress={handleSave}
isLoading={isLoading}
isDisabled={!isFormValid}
size='sm'
>
{t('Save')}
</Button>
{/* About Save Button */}
<div className="flex gap-3 py-4">
<Button
color="primary"
variant="solid"
onPress={handleAboutSave}
isLoading={isAboutLoading}
size="sm"
>
{t("Save")}
</Button>
</div>
</AccordionItem>
</Accordion>
</div>
</AccordionItem>
</Accordion>
{/* Theme Accordion */}
<Accordion
variant="splitted"
itemClasses={{
base: "shadow-none border-1",
}}
className="px-0"
>
<AccordionItem
key="theme-config"
title={
<div className="flex flex-col justify-between">
<h3 className="text-lg font-semibold">{t("Theme")}</h3>
<p className="text-sm text-gray-500">
{t("Choose your preferred theme style")}
</p>
</div>
}
>
<div className="space-y-4">
<ThemeSelector
value={formData.theme || Theme.DEFAULT}
onChange={handleThemeChange}
/>
</div>
</AccordionItem>
</Accordion>
</div>
);
};
};
@@ -0,0 +1,5 @@
.xpack-theme-card-panel-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
max-width: 100%;
}
@@ -0,0 +1,111 @@
"use client";
import React from "react";
import { Card, CardBody, CardFooter } from "@nextui-org/react";
import { Theme } from "@/shared/types/system";
import DefaultDemo from "../theme/default/Demo";
import ModernDemo from "../theme/modern/Demo";
import ClassicDemo from "../theme/classic/Demo";
import CreativeDemo from "../theme/creative/Demo";
import TemuDemo from "../theme/temu/Demo";
import "./ThemeCardPanel.css";
import { useTranslation } from "react-i18next";
// Available theme options
export const THEME_OPTIONS = [
{
value: Theme.DEFAULT,
label: "Default",
description: "Standard layout with clean and simple design",
component: DefaultDemo,
},
{
value: Theme.MODERN,
label: "Modern",
description: "Clean and minimalist design with modern UI elements",
component: ModernDemo,
},
{
value: Theme.CLASSIC,
label: "Classic",
description: "Traditional layout with professional appearance",
component: ClassicDemo,
},
{
value: Theme.CREATIVE,
label: "Creative",
description: "Bold and artistic design with vibrant colors",
component: CreativeDemo,
},
{
value: Theme.TEMU,
label: "Temu",
description: "E-commerce style with vibrant orange gradient background",
component: TemuDemo,
},
] as const;
interface ThemeSelectorProps {
value: Theme;
onChange: (theme: Theme) => void;
}
export const ThemeSelector: React.FC<ThemeSelectorProps> = ({
value,
onChange,
}) => {
const { t } = useTranslation();
return (
<div className="xpack-theme-card-panel-grid gap-4">
{THEME_OPTIONS.map((theme) => {
const DemoComponent = theme.component;
const isSelected = value === theme.value;
return (
<Card
key={theme.value}
isPressable
onPress={() => onChange(theme.value)}
className={`transition-all duration-200 border-1 hover:border-blue-300 ${
isSelected
? "border-blue-200 ring-1 ring-blue-200"
: "border-gray-200"
}`}
shadow="none"
radius="lg"
>
<CardBody className="p-0">
{/* Theme Preview */}
<div className="border-b-1">
<div className="aspect-video w-full">
<DemoComponent />
</div>
</div>
</CardBody>
<CardFooter>
{/* Theme Info */}
<div className="space-y-2 w-full text-left">
<div className="flex items-center justify-between">
<h4 className="font-semibold text-gray-900">
{t(theme.label)}
</h4>
<div
className={`h-4 w-4 rounded-full border-2 transition-colors duration-200 ${
isSelected
? "border-blue-500 bg-blue-500"
: "border-gray-300"
}`}
>
{isSelected && (
<div className="h-full w-full rounded-full bg-white scale-50"></div>
)}
</div>
</div>
<p className="text-sm text-gray-600">{t(theme.description)}</p>
</div>
</CardFooter>
</Card>
);
})}
</div>
);
};
@@ -0,0 +1,43 @@
"use client";
import React from "react";
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
import { Theme } from "@/shared/types/system";
import { About as ModernAbout } from "@/components/theme/modern/About";
import { About as ClassicAbout } from "@/components/theme/classic/About";
import { About as CreativeAbout } from "@/components/theme/creative/About";
import { About as TemuAbout } from "@/components/theme/temu/About";
import { Navigation } from "@/shared/components/Navigation";
import { Footer } from "@/shared/components/Footer";
import { NavigationItems } from "@/components/theme/Theme.const";
import { AboutContent } from "@/components/about/AboutContent";
export const AboutThemeSelector: React.FC = () => {
const { platformConfig } = usePlatformConfig();
const currentTheme = platformConfig.theme || Theme.DEFAULT;
// Render the About page based on the current theme
switch (currentTheme) {
case Theme.MODERN:
return <ModernAbout navItems={NavigationItems} />;
case Theme.CLASSIC:
return <ClassicAbout navItems={NavigationItems} />;
case Theme.CREATIVE:
return <CreativeAbout navItems={NavigationItems} />;
case Theme.TEMU:
return <TemuAbout navItems={NavigationItems} />;
case Theme.DEFAULT:
default:
return (
<div className="min-h-screen bg-background flex flex-col justify-between">
<Navigation items={NavigationItems} />
<main className="flex-1 max-w-7xl mx-auto px-4 py-8">
<AboutContent />
</main>
<div>
<Footer />
</div>
</div>
);
}
};
@@ -0,0 +1,87 @@
"use client";
import React, { useEffect, useState } from "react";
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
import { Theme } from "@/shared/types/system";
import { Detail as ModernDetail } from "./modern/Detail";
import { Detail as ClassicDetail } from "./classic/Detail";
import { Detail as CreativeDetail } from "./creative/Detail";
import { Detail as TemuDetail } from "./temu/Detail";
import { ServiceData } from "@/shared/types/marketplace";
import { ProductDetailClient } from "@/shared/components/marketplace/ProductDetail";
import { Navigation } from "@/shared/components/Navigation";
import { Footer } from "@/shared/components/Footer";
import { NavigationItems } from "./Theme.const";
interface ProductDetailThemeSelectorProps {
product: ServiceData;
breadcrumbs?: {
link: string;
name: string;
}[];
}
export const ProductDetailThemeSelector: React.FC<
ProductDetailThemeSelectorProps
> = ({ product, breadcrumbs }) => {
const { platformConfig } = usePlatformConfig();
const currentTheme = platformConfig.theme || Theme.DEFAULT;
const [url, setUrl] = useState<string>(process.env.NEXT_PUBLIC_MCP_URL || "");
useEffect(() => {
if (url || !product.slug_name) return;
setUrl(`${window.location.origin}/mcp/${product.slug_name}`);
}, [product.slug_name]);
//Render the About page based on the current theme
switch (currentTheme) {
case Theme.MODERN:
return (
<ModernDetail
product={product}
breadcrumbs={breadcrumbs}
url={url}
navItems={NavigationItems}
/>
);
case Theme.CLASSIC:
return (
<ClassicDetail
product={product}
breadcrumbs={breadcrumbs}
url={url}
navItems={NavigationItems}
/>
);
case Theme.CREATIVE:
return (
<CreativeDetail
product={product}
breadcrumbs={breadcrumbs}
url={url}
navItems={NavigationItems}
/>
);
case Theme.TEMU:
return (
<TemuDetail
product={product}
breadcrumbs={breadcrumbs}
url={url}
navItems={NavigationItems}
/>
);
case Theme.DEFAULT:
default:
return (
<div className="min-h-screen bg-background flex flex-col justify-between">
<Navigation items={NavigationItems} />
<main className="flex-1">
<ProductDetailClient product={product} />
</main>
<div>
<Footer />
</div>
</div>
);
}
};
@@ -0,0 +1,12 @@
import { NavigationItem } from "@/shared/components/Navigation";
export const NavigationItems: NavigationItem[] = [
{
label: "Home",
href: "/",
},
{
label: "About",
href: "/about",
},
];
@@ -0,0 +1,200 @@
"use client";
import React, { useState, useEffect } from "react";
import { useRouter } from "next/navigation";
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
import { Theme } from "@/shared/types/system";
import { Home as ModernHome } from "./modern/Home";
import { Home as ClassicHome } from "./classic/Home";
import { Home as CreativeHome } from "./creative/Home";
import { Home as TemuHome } from "./temu/Home";
import { ServiceData } from "@/shared/types/marketplace";
import { fetchServices } from "@/services/marketplaceService";
import { Navigation } from "@/shared/components/Navigation";
import { MarketplaceMain } from "../marketplace/Main";
import { Footer } from "@/shared/components/Footer";
import { NavigationItems } from "./Theme.const";
interface ThemeSelectorProps {
initialServices: ServiceData[];
initialTotal: number;
initialPage: number;
initialSearch: string;
pageSize: number;
error: string | null;
}
export const ThemeSelector: React.FC<ThemeSelectorProps> = ({
initialServices,
initialTotal,
initialPage,
initialSearch,
pageSize,
error,
}) => {
const router = useRouter();
const { platformConfig } = usePlatformConfig();
const currentTheme = platformConfig.theme || Theme.DEFAULT;
// state management for services, search query, pagination, and loading state
const [searchQuery, setSearchQuery] = useState(initialSearch);
const [services, setServices] = useState<ServiceData[]>(initialServices);
const [currentPage, setCurrentPage] = useState(initialPage);
const [total, setTotal] = useState(initialTotal);
const [loading, setLoading] = useState(false);
// search suggestion
const searchSuggestions = ["Search services..."];
// loading service data
const loadServices = async (page: number, search: string) => {
try {
setLoading(true);
const result = await fetchServices({
page,
page_size: pageSize,
keyword: search,
});
setServices(result.data.services);
setTotal(result.page.total);
setCurrentPage(page);
} catch (error) {
console.error("Failed to load services:", error);
} finally {
setLoading(false);
}
};
// when search and page change,scrolling to the page top
useEffect(() => {
window.scrollTo({ top: 0, behavior: "smooth" });
}, [currentPage, searchQuery]);
// update url param
const updateURL = (page: number, search: string) => {
const params = new URLSearchParams();
if (page > 1) {
params.set("page", page.toString());
}
if (search.trim()) {
params.set("search", search.trim());
}
const queryString = params.toString();
const newURL = queryString ? `?${queryString}` : window.location.pathname;
router.push(newURL);
};
// page change handler
const handlePageChange = (page: number) => {
updateURL(page, searchQuery);
loadServices(page, searchQuery);
};
// search submit handler
const handleSearch = () => {
updateURL(1, searchQuery);
loadServices(1, searchQuery);
};
// search input change handler
const handleSearchChange = (value: string) => {
setSearchQuery(value);
};
// render the theme page based on the current theme
switch (currentTheme) {
case Theme.MODERN:
return (
<ModernHome
searchQuery={searchQuery}
services={services}
currentPage={currentPage}
total={total}
pageSize={pageSize}
loading={loading}
error={error}
onSearchChange={handleSearchChange}
onSearch={handleSearch}
onPageChange={handlePageChange}
searchSuggestions={searchSuggestions}
navItems={NavigationItems}
/>
);
case Theme.CLASSIC:
return (
<ClassicHome
searchQuery={searchQuery}
services={services}
currentPage={currentPage}
total={total}
pageSize={pageSize}
loading={loading}
error={error}
onSearchChange={handleSearchChange}
onSearch={handleSearch}
onPageChange={handlePageChange}
searchSuggestions={searchSuggestions}
navItems={NavigationItems}
/>
);
case Theme.CREATIVE:
return (
<CreativeHome
searchQuery={searchQuery}
services={services}
currentPage={currentPage}
total={total}
pageSize={pageSize}
loading={loading}
error={error}
onSearchChange={handleSearchChange}
onSearch={handleSearch}
onPageChange={handlePageChange}
searchSuggestions={searchSuggestions}
navItems={NavigationItems}
/>
);
case Theme.TEMU:
return (
<TemuHome
searchQuery={searchQuery}
services={services}
currentPage={currentPage}
total={total}
pageSize={pageSize}
loading={loading}
error={error}
onSearchChange={handleSearchChange}
onSearch={handleSearch}
onPageChange={handlePageChange}
searchSuggestions={searchSuggestions}
navItems={NavigationItems}
/>
);
case Theme.DEFAULT:
default:
return (
<div className="min-h-screen bg-background flex flex-col justify-between">
<Navigation items={NavigationItems} />
<main className="flex-1">
<MarketplaceMain
initialServices={services}
initialTotal={total}
initialPage={currentPage}
initialSearch={searchQuery}
pageSize={pageSize}
error={error}
/>
</main>
<div>
<Footer />
</div>
</div>
);
}
};
@@ -0,0 +1,34 @@
"use client";
import React from "react";
import { Card, CardBody } from "@nextui-org/react";
import { AboutContent } from "@/components/about/AboutContent";
import { Navigation } from "./Navigation";
import { Footer } from "./Footer";
import { NavigationItem } from "@/shared/components/Navigation";
interface AboutProps {
navItems?: NavigationItem[];
}
export const About: React.FC<AboutProps> = ({ navItems = [] }) => {
return (
<div className="min-h-screen flex flex-col justify-between">
<div className="bg-gradient-to-b from-gray-800 to-gray-900 text-white">
<Navigation items={navItems} />
</div>
<main className="flex-1 bg-gray-100 mt-20">
<div className="max-w-7xl mx-auto px-6 py-12">
<Card className="border border-gray-200 shadow-md rounded-md">
<CardBody className="p-8">
<AboutContent />
</CardBody>
</Card>
</div>
</main>
<Footer />
</div>
);
};
@@ -0,0 +1,92 @@
import React from "react";
const ClassicDemo: React.FC = () => {
return (
<div className="w-full h-full bg-gray-50 relative overflow-hidden">
{/* Header */}
<div className="bg-slate-800 text-white px-4 py-2">
<div className="flex items-center justify-between">
<div className="flex items-center space-x-2">
<div className="w-6 h-6 bg-red-600 rounded-sm"></div>
<span className="text-sm font-bold">PLATFORM</span>
</div>
<div className="flex space-x-2">
<div className="w-1.5 h-1.5 bg-white rounded-sm"></div>
<div className="w-1.5 h-1.5 bg-white rounded-sm"></div>
<div className="w-1.5 h-1.5 bg-white rounded-sm"></div>
</div>
</div>
</div>
{/* Navigation */}
<div className="bg-gray-100 border-b border-gray-300 px-4 py-1">
<div className="flex space-x-4">
<div className="text-xs text-gray-700 font-medium">Home</div>
<div className="text-xs text-gray-500">Services</div>
<div className="text-xs text-gray-500">About</div>
</div>
</div>
{/* Hero Section */}
<div className="px-4 py-6 bg-white border-b border-gray-200">
<div className="text-center">
<h1 className="text-lg font-bold text-slate-800 mb-1">
Professional Platform
</h1>
<p className="text-xs text-gray-600 mb-3">
Traditional & Reliable Business Solution
</p>
{/* CTA Button */}
<div className="inline-block bg-red-600 text-white text-xs px-4 py-2 rounded-sm shadow-md font-medium">
Learn More
</div>
</div>
</div>
{/* Content Section */}
<div className="px-4 py-4 bg-gray-50">
<div className="grid grid-cols-1 gap-3">
{/* Service Item */}
<div className="bg-white border border-gray-200 rounded-sm p-3 shadow-sm">
<div className="flex items-start space-x-3">
<div className="w-4 h-4 bg-slate-600 rounded-sm mt-0.5"></div>
<div className="flex-1">
<div className="text-xs font-semibold text-slate-800 mb-1">
Business Service
</div>
<div className="text-xs text-gray-600">
Professional solutions for enterprise
</div>
</div>
</div>
</div>
{/* Service Item */}
<div className="bg-white border border-gray-200 rounded-sm p-3 shadow-sm">
<div className="flex items-start space-x-3">
<div className="w-4 h-4 bg-red-600 rounded-sm mt-0.5"></div>
<div className="flex-1">
<div className="text-xs font-semibold text-slate-800 mb-1">
Consulting
</div>
<div className="text-xs text-gray-600">
Expert guidance and support
</div>
</div>
</div>
</div>
</div>
</div>
{/* Footer */}
<div className="absolute bottom-0 left-0 right-0 bg-slate-700 px-4 py-2">
<div className="text-center">
<div className="text-xs text-gray-300">© 2025 Platform</div>
</div>
</div>
</div>
);
};
export default ClassicDemo;
@@ -0,0 +1,259 @@
"use client";
import React, { useState } from "react";
import { useTranslation } from "@/shared/lib/useTranslation";
import { Tabs, Tab, Chip, Card, CardBody } from "@nextui-org/react";
import { ServiceData } from "@/shared/types/marketplace";
import { ProductOverview } from "@/shared/components/marketplace/ProductOverview";
import { ProductNotFound } from "@/shared/components/marketplace/ProductNotFound";
import { FileText, Wrench, Cog } from "lucide-react";
import { Navigation } from "./Navigation";
import { Footer } from "./Footer";
import Link from "next/link";
import { Price } from "@/shared/components/marketplace/Price";
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
import { NavigationItem } from "@/shared/components/Navigation";
interface DetailProps {
product: ServiceData;
breadcrumbs?: {
link: string;
name: string;
}[];
url?: string;
// navigation items
navItems?: NavigationItem[];
}
export const Detail: React.FC<DetailProps> = ({
product,
breadcrumbs,
url,
navItems = [],
}) => {
const { t } = useTranslation();
const [activeTab, setActiveTab] = useState("overview");
const { platformConfig } = usePlatformConfig();
if (!product) {
return <ProductNotFound />;
}
return (
<div className="min-h-screen bg-gray-50 top-0 left-0 right-0 bottom-0 flex flex-col justify-between">
<Navigation items={navItems} />
<div>
{/* Classic Product Header */}
<div className="bg-white border-b border-gray-200 shadow-sm pt-28 pb-6">
<div className="mx-auto p-6 max-w-7xl">
<div className="bg-gray-50 rounded-sm p-6 border border-gray-200">
<Card shadow="none" className="bg-gray-50">
<CardBody>
{/* Breadcrumb */}
<nav className="text-sm text-default-500 flex items-center gap-1 mb-10">
<Link href="/" className="hover:underline">
{t("Home")}
</Link>
<span>/</span>
<b className="text-default-700">{t(product.name)}</b>
</nav>
{/* 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>
{/* Tags */}
{product.tags && product.tags.length > 0 && (
<div className="flex flex-wrap gap-2 my-3">
{product.tags.map((tag, index) => (
<Chip
key={index}
size="sm"
variant="flat"
color="primary"
radius="sm"
className="text-xs h-5"
>
{tag}
</Chip>
))}
</div>
)}
<p className="text-lg mb-4">
{product.short_description ||
t("No description available")}
</p>
</div>
</div>
{/* Price section */}
{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>
</div>
</div>
</div>
{/* Main Content */}
<div className="mx-auto p-6 max-w-7xl">
<div className="flex gap-6 mt-6">
{/* Left side - Main content */}
<div className="flex-1">
<Card className="bg-white border border-gray-200 shadow-sm rounded-sm">
<CardBody className="p-0">
<Tabs
selectedKey={activeTab}
onSelectionChange={(key) => setActiveTab(key as string)}
variant="underlined"
color="primary"
className="px-6 pt-6"
classNames={{
tabList:
"gap-6 w-full relative rounded-none p-0 border-b border-gray-200",
cursor: "w-full bg-red-600",
tab: "max-w-fit px-0 h-12",
tabContent:
"group-data-[selected=true]:text-red-600 font-semibold text-gray-700",
}}
>
<Tab
key="overview"
title={
<div className="flex items-center gap-2">
<FileText className="w-4 h-4" />
<span>{t("Overview")}</span>
</div>
}
>
<div className="p-6 pt-4">
<ProductOverview product={product} />
</div>
</Tab>
<Tab
key="tools"
title={
<div className="flex gap-2 items-center">
<Wrench className="w-4 h-4" />
<span>{t("Tools")}</span>
<Chip
size="sm"
className="h-4 text-xs bg-red-600 text-white rounded-sm"
>
{product.tools.length}
</Chip>
</div>
}
>
<div className="p-6 pt-4">
<div className="space-y-4 px-3">
{product.tools.length > 0 ? (
product.tools.map((tool, index) => (
<Card
radius="sm"
key={`${product.service_id}-tool-${index}`}
shadow="none"
className="border-1"
>
<CardBody>
<h4 className="font-semibold text-sm mb-2 text-red-600">
{tool.name}
</h4>
<p className="text-sm mb-3">
{tool.description ||
t("No description available")}
</p>
</CardBody>
</Card>
))
) : (
<Card>
<CardBody>
<p className="text-center">
{t("No tools available in this service.")}
</p>
</CardBody>
</Card>
)}
</div>
</div>
</Tab>
</Tabs>
</CardBody>
</Card>
</div>
{/* Right side - Server Config */}
<div className="min-w-[400px] w-[40%] max-w-100 flex-shrink-0">
<Card className="bg-white border border-gray-200 shadow-sm rounded-sm">
<CardBody>
<div className="flex items-center gap-3 mb-4">
<div className="w-8 h-8 bg-red-600 rounded-sm flex items-center justify-center">
<Cog className="w-5 h-5 text-white" />
</div>
<h3 className="font-semibold text-lg text-gray-900">
{t("Configuration")}
</h3>
</div>
{/* Code Snippet */}
<Card className="w-full max-w-2xl bg-black text-white p-2 sm:p-4 rounded-lg relative z-10">
<div className="text-left font-mono">
<Chip
className="mb-2 text-white"
size="sm"
variant="flat"
>
{platformConfig?.name} MCP
</Chip>
<pre className="p-2 sm:p-4 rounded-md text-xs overflow-x-auto">
<code className="text-gray-300 whitespace-pre-wrap">
{`{
"mcpServers": {
"xpack-mcp-market": {
"type": "sse",
"autoApprove"":"all",
"url": "${url}?apikey=`}
<span className="text-success">{`{Your-${platformConfig?.name}-API-Key}`}</span>
{`"
}
}
}`}
</code>
</pre>
</div>
</Card>
</CardBody>
</Card>
</div>
</div>
{/* SEO-friendly: Simple text content for search engines */}
<div className="hidden" aria-hidden="true">
<h2>Tools ({product.tools.length})</h2>
{product.tools.length > 0 &&
product.tools.map((tool, index) => (
<div key={`seo-${product.service_id}-tool-${index}`}>
<h4>{tool.name}</h4>
<p>{tool.description || ""}</p>
</div>
))}
</div>
</div>
</div>
<div>
<Footer />
</div>
</div>
);
};
@@ -0,0 +1,32 @@
"use client";
import React from "react";
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
import Link from "next/link";
interface FooterProps {}
export const Footer: React.FC<FooterProps> = ({}) => {
const { platformConfig } = usePlatformConfig();
return (
<>
{/* Classic Footer */}
<footer className="bg-slate-700 text-white py-1">
<div className="mx-auto px-6 max-w-7xl">
<div className="text-center">
<span className="text-gray-300 text-xs mr-2">
© 2025 {platformConfig?.name}
</span>
<Link
className="text-xs text-primary-500 hover:text-primary-600 transition-colors"
href="https://xpack.ai"
>
Powered By XPack.AI
</Link>
</div>
</div>
</footer>
</>
);
};
@@ -0,0 +1,254 @@
"use client";
import React from "react";
import { Spinner } from "@nextui-org/react";
import { Search, Star, Grid, ArrowRight } from "lucide-react";
import {
Input,
Button,
Pagination,
Card,
CardBody,
CardFooter,
} from "@nextui-org/react";
import { useTranslation } from "react-i18next";
import Link from "next/link";
import { ServiceData } from "@/shared/types/marketplace";
import { Price } from "@/shared/components/marketplace/Price";
import {
_DefaultPlatformConfig,
usePlatformConfig,
} from "@/shared/contexts/PlatformConfigContext";
import { Footer } from "./Footer";
import { Navigation } from "./Navigation";
import { NavigationItem } from "@/shared/components/Navigation";
interface HomeProps {
// 状态
searchQuery: string;
services: ServiceData[];
currentPage: number;
total: number;
pageSize: number;
loading: boolean;
error: string | null;
// 事件处理函数
onSearchChange: (value: string) => void;
onSearch: () => void;
onPageChange: (page: number) => void;
// 可选配置
searchSuggestions?: string[];
// navigation items
navItems?: NavigationItem[];
}
export const Home: React.FC<HomeProps> = ({
searchQuery,
services,
currentPage,
total,
pageSize,
loading,
error,
onSearchChange,
onSearch,
onPageChange,
searchSuggestions = [],
navItems = [],
}) => {
const { platformConfig } = usePlatformConfig();
const { t } = useTranslation();
const totalPages = Math.ceil(total / pageSize);
// 如果有错误,显示错误信息
if (error) {
return (
<div className="min-h-screen bg-gray-50">
<div className="mx-auto h-[100px] flex items-center justify-center">
<div className="text-red-600 bg-white px-6 py-4 rounded-lg shadow-md border border-red-200">
Error: {error}
</div>
</div>
</div>
);
}
return (
<div className="min-h-screen bg-gray-50 top-0 left-0 right-0 bottom-0 flex flex-col justify-between">
<Navigation items={navItems} />
<div>
{/* Classic Hero Section */}
<div className="bg-white border-b border-gray-200 pt-20">
<div className="mx-auto px-6 py-16 max-w-6xl">
<div className="text-center mb-12">
{/* Classic Icon */}
<div className="flex justify-center mb-6">
<div className="w-12 h-12 bg-red-600 rounded-sm flex items-center justify-center">
<Grid className="w-6 h-6 text-white" />
</div>
</div>
{/* Classic Title */}
<h1 className="text-4xl lg:text-5xl font-bold mb-6 text-slate-800">
{t(
platformConfig.headline ||
_DefaultPlatformConfig.headline ||
""
)}
</h1>
{/* Classic Subtitle */}
<p className="text-xl text-gray-600 max-w-3xl mx-auto leading-relaxed">
{t(
platformConfig.subheadline ||
_DefaultPlatformConfig.subheadline ||
""
)}
</p>
</div>
{/* Classic Search Bar */}
<div className="max-w-2xl mx-auto">
<div className="bg-white border border-gray-300 rounded-sm shadow-md overflow-hidden">
<div className="flex">
<div className="flex-1">
<Input
size="lg"
placeholder={
searchSuggestions.length > 0
? t(searchSuggestions[0])
: t("Search services...")
}
value={searchQuery}
onChange={(e) => onSearchChange(e.target.value)}
onKeyDown={(e) => e.key === "Enter" && onSearch()}
startContent={
<Search className="w-5 h-5 text-gray-400" />
}
className="w-full"
classNames={{
input:
"text-lg text-gray-900 placeholder:text-gray-500",
inputWrapper: "h-14 shadow-none px-4 bg-white border-0",
}}
variant="flat"
radius="none"
/>
</div>
<Button
onPress={onSearch}
className="bg-red-600 text-white hover:bg-red-700 transition-colors duration-200 h-14 px-8 rounded-sm font-medium"
size="lg"
>
{t("Search")}
</Button>
</div>
</div>
</div>
</div>
</div>
{/* Service List Section */}
{loading ? (
<div className="mx-auto h-[200px] flex items-center justify-center">
<div className="bg-white p-8 rounded-lg shadow-md">
<Spinner size="lg" color="primary" />
</div>
</div>
) : (
<div className="bg-gray-50 py-16">
<div className="mx-auto px-6 max-w-7xl">
{/* Services Grid */}
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6 mb-12">
{services.map((service) => (
<Link
key={service.service_id}
href={`/marketplace/${service.service_id}`}
>
<Card className="group h-[200px] hover:shadow-lg transition-shadow duration-200 cursor-pointer border border-gray-200 bg-white rounded-sm shadow-sm">
<CardBody className="p-4">
{/* Header */}
<div className="flex items-start justify-between mb-3">
<div className="flex items-center gap-2">
<div className="w-8 h-8 bg-slate-600 rounded-sm flex items-center justify-center">
<Star className="w-4 h-4 text-white" />
</div>
<div className="flex-1 min-w-0">
<h3 className="font-semibold text-gray-900 text-base mb-1 truncate group-hover:text-slate-700 transition-colors">
{service.name}
</h3>
</div>
</div>
<ArrowRight className="w-4 h-4 text-gray-400 group-hover:text-slate-600 transition-colors" />
</div>
{/* Description */}
<p className="text-gray-600 text-sm line-clamp-3 leading-relaxed mb-4">
{service.short_description ||
t("No description available")}
</p>
</CardBody>
{/* Footer */}
<CardFooter className="pt-0 px-4 pb-4">
<div className="flex items-center justify-between w-full">
{/* Tools count */}
<div className="flex items-center gap-2">
<div className="w-2 h-2 bg-slate-600 rounded-full"></div>
<span className="text-sm font-medium text-gray-700">
{t("{{count}} Tools", {
count: service.tools.length,
})}
</span>
</div>
{/* Price */}
<div className="flex flex-col items-end">
<Price
price={service.price}
charge_type={service.charge_type}
/>
</div>
</div>
</CardFooter>
</Card>
</Link>
))}
</div>
{/* Classic Pagination */}
{totalPages > 1 && (
<div className="flex justify-center mt-8">
<Pagination
total={totalPages}
page={currentPage}
onChange={onPageChange}
showControls
classNames={{
wrapper:
"gap-0 overflow-visible h-8 border border-gray-300 bg-white shadow-sm rounded-none overflow-hidden",
item: "w-8 h-8 text-small rounded-none bg-transparent text-gray-700 hover:bg-gray-50 rounded-none",
cursor:
"bg-red-600 border-red-600 text-white font-medium rounded-none",
next: "rounded-none",
prev: "rounded-none",
}}
size="sm"
variant="light"
/>
</div>
)}
</div>
</div>
)}
</div>
<div>
<Footer />
</div>
</div>
);
};
@@ -0,0 +1,55 @@
"use client";
import React from "react";
import { Button } from "@nextui-org/react";
import { useTranslation } from "react-i18next";
import { DynamicLogo } from "@/shared/components/DynamicLogo";
import { useAuth } from "@/shared/lib/useAuth";
import Link from "next/link";
import { NavigationItem } from "@/shared/components/Navigation";
interface NavigationProps {
items?: NavigationItem[];
}
export const Navigation: React.FC<NavigationProps> = ({ items }) => {
const { t } = useTranslation();
const { handleLogin } = useAuth();
return (
<div className="fixed top-0 left-0 right-0 z-50">
{/* Classic Header */}
<div className="bg-slate-800 text-white px-4 py-2 ">
<div className="flex items-center justify-between max-w-7xl mx-auto">
<div className="flex items-center space-x-2">
<DynamicLogo alt="Platform Logo" className="h-[20px] text-white" />
</div>
<div className="flex space-x-2">
<Button
color="primary"
className="bg-red-600 hover:bg-red-700 text-white text-sm px-4 py-1 rounded-sm font-medium"
size="sm"
onPress={handleLogin}
>
{t("Get Started")}
</Button>
</div>
</div>
</div>
{/* Classic Navigation */}
<div className="bg-gray-100 border-b border-gray-300 px-4 py-2">
<div className="flex items-center justify-between max-w-7xl mx-auto">
<div className="flex space-x-6">
{items?.map((item) => (
<Link href={item.href} className="text-sm text-gray-500">
{t(item.label)}
</Link>
))}
</div>
</div>
</div>
</div>
);
};
@@ -0,0 +1,41 @@
"use client";
import React from "react";
import { Card, CardBody } from "@nextui-org/react";
import { AboutContent } from "@/components/about/AboutContent";
import { Navigation } from "./Navigation";
import { Footer } from "./Footer";
import { NavigationItem } from "@/shared/components/Navigation";
interface AboutProps {
navItems?: NavigationItem[];
}
export const About: React.FC<AboutProps> = ({ navItems = [] }) => {
return (
<div className="min-h-screen flex flex-col justify-between bg-gradient-to-br from-pink-50 via-white to-blue-50">
<Navigation items={navItems} />
<main className="flex-1 relative mt-20">
{/* Creative background elements */}
<div className="absolute inset-0 overflow-hidden pointer-events-none">
<div className="absolute -top-24 -right-24 w-96 h-96 bg-pink-200 rounded-full opacity-20 blur-3xl"></div>
<div className="absolute top-1/3 -left-24 w-80 h-80 bg-blue-200 rounded-full opacity-20 blur-3xl"></div>
<div className="absolute bottom-1/4 right-1/4 w-64 h-64 bg-purple-200 rounded-full opacity-20 blur-3xl"></div>
</div>
<div className="max-w-7xl mx-auto px-6 py-12 relative z-10">
<Card className="border-none shadow-xl rounded-3xl overflow-hidden bg-white/80 backdrop-blur-sm">
<CardBody className="p-8">
<AboutContent />
</CardBody>
</Card>
</div>
</main>
<div>
<Footer />
</div>
</div>
);
};
@@ -0,0 +1,69 @@
import React from 'react';
const CreativeDemo: React.FC = () => {
return (
<div className="w-full h-full bg-gradient-to-br from-pink-50 via-orange-50 to-yellow-50 relative overflow-hidden">
{/* Header */}
<div className="bg-white/80 backdrop-blur-sm border-b border-pink-200 px-4 py-2">
<div className="flex items-center justify-between">
<div className="flex items-center space-x-2">
<div className="w-6 h-6 bg-gradient-to-r from-pink-500 via-red-500 to-orange-500 rounded-2xl transform rotate-12"></div>
<span className="text-sm font-bold bg-gradient-to-r from-pink-600 to-orange-600 bg-clip-text text-transparent">Creative</span>
</div>
<div className="flex space-x-1">
<div className="w-2 h-2 bg-pink-400 rounded-full"></div>
<div className="w-2 h-2 bg-orange-400 rounded-full"></div>
<div className="w-2 h-2 bg-yellow-400 rounded-full"></div>
</div>
</div>
</div>
{/* Hero Section */}
<div className="px-4 py-6 text-center relative">
<div className="mb-3">
<h1 className="text-lg font-bold bg-gradient-to-r from-pink-600 via-red-500 to-orange-600 bg-clip-text text-transparent mb-1">
Creative Platform
</h1>
<p className="text-xs text-gray-700">Bold & Artistic Design Experience</p>
</div>
{/* CTA Button */}
<div className="mb-4">
<div className="inline-block bg-gradient-to-r from-pink-500 via-red-500 to-orange-500 text-white text-xs px-4 py-2 rounded-2xl shadow-lg transform hover:scale-105 transition-transform">
Explore Now
</div>
</div>
</div>
{/* Feature Cards */}
<div className="px-4 pb-4">
<div className="grid grid-cols-2 gap-3">
<div className="bg-white/70 backdrop-blur-sm rounded-2xl p-3 shadow-lg border border-pink-200/50 transform rotate-1">
<div className="w-4 h-4 bg-gradient-to-r from-pink-400 to-red-400 rounded-xl mb-2 transform rotate-12"></div>
<div className="text-xs font-bold text-gray-800 mb-1">Creative Tools</div>
<div className="text-xs text-gray-600">Artistic Design</div>
</div>
<div className="bg-white/70 backdrop-blur-sm rounded-2xl p-3 shadow-lg border border-orange-200/50 transform -rotate-1">
<div className="w-4 h-4 bg-gradient-to-r from-orange-400 to-yellow-400 rounded-xl mb-2 transform -rotate-12"></div>
<div className="text-xs font-bold text-gray-800 mb-1">Innovation</div>
<div className="text-xs text-gray-600">Bold Ideas</div>
</div>
</div>
</div>
{/* Floating Elements */}
<div className="absolute top-4 right-2 w-8 h-8 bg-gradient-to-r from-pink-400/30 to-red-400/30 rounded-full transform rotate-45"></div>
<div className="absolute top-12 right-8 w-4 h-4 bg-gradient-to-r from-orange-400/40 to-yellow-400/40 rounded-full"></div>
<div className="absolute bottom-8 left-2 w-6 h-6 bg-gradient-to-r from-red-400/30 to-pink-400/30 rounded-full transform -rotate-12"></div>
<div className="absolute bottom-4 left-8 w-3 h-3 bg-gradient-to-r from-yellow-400/40 to-orange-400/40 rounded-full"></div>
{/* Decorative Shapes */}
<div className="absolute top-0 left-1/2 w-16 h-16 bg-gradient-to-br from-pink-300/20 to-orange-300/20 rounded-full transform -translate-x-1/2 -translate-y-8 rotate-45"></div>
<div className="absolute bottom-0 right-0 w-12 h-12 bg-gradient-to-tl from-orange-300/20 to-yellow-300/20 transform translate-x-6 translate-y-6 rotate-12">
<div className="w-full h-full rounded-2xl"></div>
</div>
</div>
);
};
export default CreativeDemo;
@@ -0,0 +1,191 @@
"use client";
import React, { useState } from "react";
import { useTranslation } from "@/shared/lib/useTranslation";
import { Tabs, Tab, Chip, Card, CardBody } from "@nextui-org/react";
import { ServiceData } from "@/shared/types/marketplace";
import { ProductHeader } from "@/shared/components/marketplace/ProductHeader";
import { ProductOverview } from "@/shared/components/marketplace/ProductOverview";
import { ProductTools } from "@/shared/components/marketplace/ProductTools";
import { ProductNotFound } from "@/shared/components/marketplace/ProductNotFound";
import { Sparkles, Zap, Settings2 } from "lucide-react";
import { Navigation } from "./Navigation";
import { Footer } from "./Footer";
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
import { NavigationItem } from "@/shared/components/Navigation";
interface DetailProps {
product: ServiceData;
breadcrumbs?: {
link: string;
name: string;
}[];
url?: string;
// navigation items
navItems?: NavigationItem[];
}
export const Detail: React.FC<DetailProps> = ({
product,
breadcrumbs,
url,
navItems = [],
}) => {
const { t } = useTranslation();
const [activeTab, setActiveTab] = useState("overview");
const { platformConfig } = usePlatformConfig();
if (!product) {
return <ProductNotFound />;
}
return (
<div className="min-h-screen bg-gradient-to-br from-pink-50 via-orange-50 to-yellow-50 relative overflow-hidden">
<Navigation items={navItems} />
{/* Creative Background */}
<div className="absolute inset-0">
{/* Artistic decorative elements */}
<div className="absolute top-20 left-20 w-32 h-32 bg-gradient-to-br from-pink-200/30 to-orange-200/30 rounded-full blur-2xl" />
<div className="absolute top-40 right-32 w-24 h-24 bg-gradient-to-br from-orange-200/40 to-yellow-200/40 rounded-2xl rotate-45 blur-xl" />
<div className="absolute bottom-32 left-1/4 w-40 h-40 bg-gradient-to-br from-yellow-200/25 to-pink-200/25 rounded-full blur-3xl" />
<div className="absolute bottom-20 right-20 w-28 h-28 bg-gradient-to-br from-pink-200/35 to-red-200/35 rounded-2xl rotate-12 blur-xl" />
{/* Additional artistic elements */}
<div className="absolute top-1/3 left-1/3 w-20 h-20 bg-gradient-to-br from-orange-300/20 to-yellow-300/20 rounded-full blur-xl" />
<div className="absolute top-2/3 right-1/3 w-16 h-16 bg-gradient-to-br from-pink-300/25 to-orange-300/25 rounded-lg rotate-45 blur-lg" />
</div>
<div className="relative z-10">
{/* Creative Product Header */}
<div className="pt-24">
<div className="mx-auto p-6 max-w-7xl">
<div className="bg-white/90 backdrop-blur-sm rounded-2xl p-6 shadow-lg border border-pink-200/50">
<ProductHeader product={product} breadcrumbs={breadcrumbs} />
</div>
</div>
</div>
{/* Main Content */}
<div className="mx-auto p-6 max-w-7xl">
<div className="flex gap-6 mt-6">
{/* Left side - Main content */}
<div className="flex-1">
<Card className="bg-white/95 backdrop-blur-sm border border-pink-200/50 shadow-lg overflow-hidden rounded-2xl">
<div className="absolute inset-0 bg-gradient-to-r from-pink-500/5 via-transparent to-orange-500/5" />
<CardBody className="p-0 relative">
<Tabs
selectedKey={activeTab}
onSelectionChange={(key) => setActiveTab(key as string)}
variant="underlined"
color="secondary"
className="px-6 pt-6"
classNames={{
tabList:
"gap-6 w-full relative rounded-none p-0 border-b border-pink-200/50",
cursor:
"w-full bg-gradient-to-r from-pink-500 via-red-500 to-orange-500",
tab: "max-w-fit px-0 h-12",
tabContent:
"group-data-[selected=true]:text-pink-600 font-semibold",
}}
>
<Tab
key="overview"
title={
<div className="flex items-center gap-2">
<Sparkles className="w-4 h-4" />
<span>{t("Overview")}</span>
</div>
}
>
<div className="p-6 pt-4">
<ProductOverview product={product} />
</div>
</Tab>
<Tab
key="tools"
title={
<div className="flex gap-2 items-center">
<Zap className="w-4 h-4" />
<span>{t("Tools")}</span>
<Chip
size="sm"
className="h-4 text-xs bg-gradient-to-r from-pink-500 via-red-500 to-orange-500 text-white shadow-lg"
>
{product.tools.length}
</Chip>
</div>
}
>
<div className="p-6 pt-4">
<ProductTools product={product} />
</div>
</Tab>
</Tabs>
</CardBody>
</Card>
</div>
{/* Right side - Server Config */}
<div className="min-w-[400px] w-[40%] max-w-100 flex-shrink-0">
<Card className="bg-white/95 backdrop-blur-sm border border-pink-200/50 shadow-lg overflow-hidden rounded-2xl">
<div className="absolute inset-0 bg-gradient-to-br from-orange-500/5 via-transparent to-pink-500/5" />
<CardBody className="relative">
<div className="flex items-center gap-3 mb-4">
<div className="p-2 bg-gradient-to-r from-pink-500 via-red-500 to-orange-500 rounded-lg">
<Settings2 className="w-5 h-5 text-white" />
</div>
<h3 className="font-semibold text-lg bg-gradient-to-r from-pink-600 to-orange-600 bg-clip-text text-transparent">
{t("Configuration")}
</h3>
</div>
{/* Code Snippet */}
<Card className="w-full max-w-2xl bg-black text-white p-2 sm:p-4 rounded-lg relative z-10">
<div className="text-left font-mono">
<Chip
className="mb-2 text-white"
size="sm"
variant="flat"
>
{platformConfig?.name} MCP
</Chip>
<pre className="p-2 sm:p-4 rounded-md text-xs overflow-x-auto">
<code className="text-gray-300 whitespace-pre-wrap">
{`{
"mcpServers": {
"xpack-mcp-market": {
"type": "sse",
"autoApprove"":"all",
"url": "${url}?apikey=`}
<span className="text-success">{`{Your-${platformConfig?.name}-API-Key}`}</span>
{`"
}
}
}`}
</code>
</pre>
</div>
</Card>
</CardBody>
</Card>
</div>
</div>
{/* SEO-friendly: Simple text content for search engines */}
<div className="hidden" aria-hidden="true">
<h2>Tools ({product.tools.length})</h2>
{product.tools.length > 0 &&
product.tools.map((tool, index) => (
<div key={`seo-${product.service_id}-tool-${index}`}>
<h4>{tool.name}</h4>
<p>{tool.description || ""}</p>
</div>
))}
</div>
</div>
</div>
<Footer />
</div>
);
};
@@ -0,0 +1,23 @@
"use client";
import React from "react";
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
interface FooterProps {}
export const Footer: React.FC<FooterProps> = ({}) => {
const { platformConfig } = usePlatformConfig();
return (
<>
{/* Creative Footer */}
<footer className="py-4 px-4 sm:px-6 text-center sm:text-end mx-auto text-xs max-w-7xl mx-auto">
<span className="mr-1">
© 2025 {platformConfig?.name}. All rights reserved.
</span>
<a className="text-xs text-primary-500 hover:text-primary-600 transition-colors" href="https://xpack.ai">
Powered By XPack.AI
</a>
</footer>
</>
);
};
@@ -0,0 +1,323 @@
"use client";
import React from "react";
import { Spinner } from "@nextui-org/react";
import { Sparkles, Palette, SearchIcon } from "lucide-react";
import {
Input,
Button,
Pagination,
Card,
CardBody,
CardFooter,
} from "@nextui-org/react";
import { useTranslation } from "react-i18next";
import Link from "next/link";
import { ServiceData } from "@/shared/types/marketplace";
import { Price } from "@/shared/components/marketplace/Price";
import {
_DefaultPlatformConfig,
usePlatformConfig,
} from "@/shared/contexts/PlatformConfigContext";
import { Footer } from "./Footer";
import { Navigation } from "./Navigation";
import { NavigationItem } from "@/shared/components/Navigation";
interface HomeProps {
// 状态
searchQuery: string;
services: ServiceData[];
currentPage: number;
total: number;
pageSize: number;
loading: boolean;
error: string | null;
// 事件处理函数
onSearchChange: (value: string) => void;
onSearch: () => void;
onPageChange: (page: number) => void;
// 可选配置
searchSuggestions?: string[];
// navigation items
navItems?: NavigationItem[];
}
export const Home: React.FC<HomeProps> = ({
searchQuery,
services,
currentPage,
total,
pageSize,
loading,
onSearchChange,
onSearch,
onPageChange,
searchSuggestions = [],
navItems = [],
}) => {
const { platformConfig } = usePlatformConfig();
const { t } = useTranslation();
const totalPages = Math.ceil(total / pageSize);
return (
<div className="min-h-screen relative overflow-hidden bg-gradient-to-br from-pink-50 via-orange-50 to-yellow-50">
<Navigation items={navItems} />
{/* Creative Background decorative elements */}
<div className="absolute inset-0 overflow-hidden pointer-events-none z-50">
{/* 主要装饰圆圈 */}
<div className="absolute top-1/4 left-1/4 w-64 h-64 bg-gradient-to-r from-pink-400/15 to-orange-400/15 rounded-full blur-3xl animate-pulse"></div>
<div className="absolute bottom-1/4 right-1/4 w-96 h-96 bg-gradient-to-r from-orange-400/10 to-yellow-400/10 rounded-full blur-3xl"></div>
{/* 小装饰圆圈 */}
<div className="absolute top-10 right-20 w-16 h-16 bg-gradient-to-br from-pink-400/20 to-red-500/20 rounded-full transform rotate-12"></div>
<div className="absolute top-32 left-16 w-12 h-12 bg-gradient-to-br from-orange-400/25 to-yellow-400/25 rounded-full transform -rotate-12"></div>
<div className="absolute bottom-20 left-1/3 w-20 h-20 bg-gradient-to-br from-yellow-400/15 to-pink-400/15 rounded-full transform rotate-6"></div>
<div className="absolute bottom-32 right-16 w-14 h-14 bg-gradient-to-br from-purple-400/20 to-pink-400/20 rounded-full transform -rotate-6"></div>
{/* 微小装饰点 */}
<div className="absolute top-1/3 right-1/3 w-4 h-4 bg-pink-400/30 rounded-full"></div>
<div className="absolute top-2/3 left-1/5 w-3 h-3 bg-orange-400/40 rounded-full"></div>
<div className="absolute bottom-1/3 right-1/5 w-5 h-5 bg-yellow-400/25 rounded-full"></div>
</div>
{/* Creative Hero Section */}
<div className="relative z-10 pt-32">
<div className="mx-auto px-6 py-12 max-w-6xl">
<div className="text-center mb-12">
{/* Creative Icon */}
<div className="flex justify-center mb-6">
<div className="bg-gradient-to-r from-pink-500 via-red-500 to-orange-500 p-4 rounded-2xl shadow-lg transform rotate-12">
<Palette className="w-8 h-8 text-white" />
</div>
</div>
{/* Creative Title */}
<h1 className="text-4xl lg:text-6xl font-black mb-6 leading-tight">
<span className="bg-clip-text text-transparent bg-gradient-to-r from-pink-600 via-red-500 to-orange-600">
{t(
platformConfig.headline ||
_DefaultPlatformConfig.headline ||
""
)}
</span>
</h1>
{/* Creative Subtitle */}
<p className="text-lg font-medium max-w-3xl mx-auto leading-relaxed text-gray-700">
{t(
platformConfig.subheadline ||
_DefaultPlatformConfig.subheadline ||
""
)}
</p>
</div>
{/* Creative Search Bar */}
<div className="max-w-3xl mx-auto relative">
<div className="relative">
{/* Search container */}
<div className="relative bg-white/70 backdrop-blur-sm p-2 rounded-2xl border border-pink-200/50 shadow-lg">
<div className="flex gap-2">
<div className="flex-1">
<Input
size="lg"
placeholder={
searchSuggestions.length > 0
? t(searchSuggestions[0])
: t("✨ 发现神奇的服务...")
}
value={searchQuery}
onChange={(e) => onSearchChange(e.target.value)}
onKeyDown={(e) => e.key === "Enter" && onSearch()}
startContent={
<div className="flex items-center gap-2 ml-2">
<Sparkles className="w-5 h-5 text-pink-500" />
</div>
}
className="w-full"
classNames={{
input:
"text-lg text-gray-800 placeholder:text-gray-500 font-medium",
inputWrapper:
"h-16 shadow-none px-4 bg-transparent border-0",
}}
variant="flat"
/>
</div>
<Button
onPress={onSearch}
className="bg-gradient-to-r from-pink-500 via-red-500 to-orange-500 text-white shadow-lg hover:shadow-xl transition-all duration-300 hover:scale-105 h-16 w-16 rounded-2xl"
size="lg"
isIconOnly
>
<SearchIcon size={32} />
</Button>
</div>
</div>
</div>
</div>
</div>
</div>
{/* Creative Service List Section */}
{loading ? (
<div className="relative z-10 mx-auto h-[200px] flex items-center justify-center">
<div className="bg-white/90 backdrop-blur-xl p-8 rounded-2xl shadow-lg border border-pink-200/50">
<div className="flex items-center gap-4">
<Spinner size="lg" color="secondary" />
<span className="text-gray-700 text-lg font-bold">
✨ 加载魔法中...
</span>
</div>
</div>
</div>
) : (
<div className="relative z-10">
<div className="relative mx-auto px-6 py-16 max-w-8xl">
{/* Creative Services Grid */}
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 max-w-6xl mx-auto">
{services.map((service, index) => {
const gradientBorders = [
"border-pink-200/50",
"border-orange-200/50",
"border-yellow-200/50",
"border-red-200/50",
"border-purple-200/50",
"border-blue-200/50",
];
const iconGradients = [
"bg-gradient-to-r from-pink-500 via-red-500 to-orange-500",
"bg-gradient-to-r from-orange-400 to-yellow-400",
"bg-gradient-to-r from-yellow-400 to-pink-400",
"bg-gradient-to-r from-red-400 to-pink-500",
"bg-gradient-to-r from-purple-400 to-pink-400",
"bg-gradient-to-r from-blue-400 to-purple-400",
];
const iconRotations = [
"transform rotate-12",
"transform -rotate-12",
"transform rotate-6",
"transform -rotate-6",
"transform rotate-12",
"transform -rotate-12",
];
return (
<Link
key={service.service_id}
href={`/marketplace/${service.service_id}`}
className="block group"
>
<Card
className={`
bg-white/80 backdrop-blur-sm shadow-lg
border ${gradientBorders[index % 6]}
hover:scale-105 hover:shadow-xl
transition-all duration-300 ease-out
group-hover:bg-white/90 relative
h-[200px]
`}
>
<CardBody className="p-6">
{/* 创意图标 */}
<div
className={` absolute -top-2 -left-2
w-8 h-8 ${iconGradients[index % 6]}
rounded-2xl mb-4 ${iconRotations[index % 6]}
group-hover:scale-110 transition-transform duration-300
`}
></div>
{/* 服务标题 */}
<div className="text-lg font-bold text-gray-800 mb-2 group-hover:text-gray-900 transition-colors">
{service.name}
</div>
{/* 服务描述 */}
<div className="text-sm text-gray-600 group-hover:text-gray-700 transition-colors flex-1">
{service.short_description || "探索精彩服务"}
</div>
{/* 装饰性元素 */}
<div className="absolute top-2 right-2 w-3 h-3 bg-gradient-to-r from-pink-400/30 to-orange-400/30 rounded-full opacity-0 group-hover:opacity-100 transition-opacity duration-300"></div>
</CardBody>
{/* Footer */}
<CardFooter className="pt-0 px-4 pb-4">
<div className="flex items-center justify-between w-full">
{/* Tools count */}
<div className="flex items-center gap-2">
<div className="w-2 h-2 bg-blue-600 rounded-full"></div>
<span className="text-sm font-medium text-gray-700">
{t("{{count}} Tools", {
count: service.tools.length,
})}
</span>
</div>
{/* Price */}
<div className="flex flex-col items-end">
<Price
price={service.price}
charge_type={service.charge_type}
/>
</div>
</div>
</CardFooter>
</Card>
</Link>
);
})}
</div>
{/* Creative Pagination */}
{totalPages > 1 && (
<div className="flex justify-center mt-12">
<div className="bg-white/90 backdrop-blur-xl p-4 rounded-2xl shadow-lg border border-pink-200/50">
<Pagination
total={totalPages}
page={currentPage}
onChange={onPageChange}
showControls
color="secondary"
variant="light"
size="lg"
classNames={{
wrapper: "gap-2",
item: "w-10 h-10 text-sm font-bold text-gray-700 hover:bg-pink-100/50 transition-all duration-300",
cursor:
"bg-gradient-to-r from-pink-500 via-red-500 to-orange-500 shadow-lg text-white font-bold",
}}
/>
</div>
</div>
)}
</div>
<style jsx>{`
@keyframes fade-in-up {
from {
opacity: 0;
transform: translateY(50px) scale(0.9);
}
to {
opacity: 1;
transform: translateY(0) scale(1);
}
}
.animate-fade-in-up {
animation: fade-in-up 0.8s ease-out;
}
`}</style>
</div>
)}
<Footer />
</div>
);
};
@@ -0,0 +1,119 @@
"use client";
import React from "react";
import { Button } from "@nextui-org/react";
import { useTranslation } from "react-i18next";
import Link from "next/link";
import { useState } from "react";
import {
Navbar,
NavbarContent,
NavbarMenuToggle,
NavbarMenu,
NavbarMenuItem,
} from "@nextui-org/react";
import { ArrowRightIcon } from "lucide-react";
import { DynamicLogo } from "@/shared/components/DynamicLogo";
import { useAuth } from "@/shared/lib/useAuth";
import { NavigationItem } from "@/shared/components/Navigation";
interface NavigationProps {
items?: NavigationItem[];
}
export const Navigation: React.FC<NavigationProps> = ({ items }) => {
const { t } = useTranslation();
const { handleLogin } = useAuth();
const [isMenuOpen, setIsMenuOpen] = useState(false);
return (
<>
{/* Creative Navigation */}
<Navbar
onMenuOpenChange={setIsMenuOpen}
maxWidth="full"
className="bg-white/95 backdrop-blur-[15px] border-b border-pink-200/50 shadow-sm fixed top-0 left-0 right-0 z-50 "
height="66px"
isBordered={false}
position="static"
classNames={{
wrapper: "max-w-7xl mx-auto",
}}
>
<NavbarContent>
<NavbarMenuToggle
aria-label={isMenuOpen ? "Close menu" : "Open menu"}
className="sm:hidden text-gray-700"
/>
<div className="flex justify-start bg-transparent w-max">
<Link href="/">
<DynamicLogo alt="Platform Logo" className="h-[20px]" />
</Link>
</div>
<div className="hidden lg:flex gap-6 justify-center">
{items?.map((item) => (
<Link href={item.href} className="text-sm text-gray-500">
{t(item.label)}
</Link>
))}
</div>
</NavbarContent>
<NavbarContent justify="end" className="items-center gap-2 sm:gap-4">
<div className="hidden sm:block">
<Button
color="primary"
className="bg-gradient-to-r from-pink-500 via-red-500 to-orange-500 hover:from-pink-600 hover:via-red-600 hover:to-orange-600 text-white shadow-lg hover:shadow-xl transition-all duration-300 hover:scale-105 flex items-center justify-center gap-4 pr-1 h-[45px]"
radius="full"
onPress={handleLogin}
>
<b className="text-md">{t("Get Started")}</b>
<div className="w-8 h-8 bg-white/20 flex items-center justify-center rounded-full">
<ArrowRightIcon
size={16}
className="transition-transform duration-200 ease-in-out group-hover:translate-x-[3px] text-white"
/>
</div>
</Button>
</div>
<div className="sm:hidden">
<Button
className="bg-gradient-to-r from-pink-500 via-red-500 to-orange-500 text-white"
onPress={handleLogin}
size="sm"
>
<b className="text-md">{t("Get Started")}</b>
</Button>
</div>
</NavbarContent>
<NavbarMenu className="pt-6 pb-6 bg-white/95 backdrop-blur-sm border-l border-pink-200/50">
<NavbarMenuItem className="mt-4">
<Button
color="primary"
className="w-full bg-gradient-to-r from-pink-500 via-red-500 to-orange-500 text-white flex items-center justify-between gap-4 pr-1 h-[45px]"
radius="full"
onPress={handleLogin}
>
<b className="text-md">{t("Get Started")}</b>
<div className="w-8 h-8 bg-white/20 flex items-center justify-center rounded-full">
<ArrowRightIcon
size={16}
className="transition-transform duration-200 ease-in-out group-hover:translate-x-[3px]"
/>
</div>
</Button>
</NavbarMenuItem>
</NavbarMenu>
{/* Floating Elements - Demo Style */}
<div className="absolute top-4 -right-12 w-8 h-8 bg-gradient-to-r from-pink-400/30 to-red-400/30 rounded-full transform rotate-45 z-50"></div>
<div className="absolute top-12 -right-8 w-4 h-4 bg-gradient-to-r from-orange-400/40 to-yellow-400/40 rounded-full z-50"></div>
<div className="absolute bottom-8 left-2 w-6 h-6 bg-gradient-to-r from-red-400/30 to-pink-400/30 rounded-full transform -rotate-12 z-50"></div>
<div className="absolute bottom-4 left-8 w-3 h-3 bg-gradient-to-r from-yellow-400/40 to-orange-400/40 rounded-full z-50"></div>
{/* Decorative Shapes - Demo Style */}
<div className="absolute top-0 left-1/2 w-16 h-16 bg-gradient-to-br from-pink-300/20 to-orange-300/20 rounded-full transform -translate-x-1/2 -translate-y-8 rotate-45 z-50"></div>
<div className="absolute bottom-0 -right-10 w-12 h-12 bg-gradient-to-tl from-orange-300/20 to-yellow-300/20 transform translate-x-6 translate-y-6 rotate-12 z-50">
<div className="w-full h-full rounded-2xl"></div>
</div>
</Navbar>
</>
);
};
@@ -0,0 +1,118 @@
"use client";
import React from "react";
import { Search } from "lucide-react";
const DefaultDemo: React.FC = () => {
return (
<div className="w-full h-full bg-white relative overflow-hidden">
{/* Header */}
<div className="absolute top-0 left-0 right-0 bg-white px-4 py-2 border-b border-gray-100">
<div className="flex items-center justify-between">
<div className="flex items-center gap-2">
<div className="w-6 h-6 bg-blue-600 rounded flex items-center justify-center">
<span className="text-white text-xs font-bold">M</span>
</div>
<span className="text-gray-900 font-semibold text-sm">
MCP Store
</span>
</div>
<div className="bg-gray-900 text-white px-4 py-1 rounded-full text-sm">
Get Started
</div>
</div>
</div>
{/* Main Content */}
<div className="absolute top-10 left-0 right-0 bottom-0 px-6 py-8">
{/* Hero Section */}
<div className="text-center mb-4">
<h1 className="text-lg font-bold text-blue-600 mb-2">
Default Platform
</h1>
<p className="text-gray-700 mb-2 text-xs">Clean & Simple Design</p>
{/* Search Bar */}
<div className="max-w-md mx-auto mb-8">
<div className="relative">
<input
type="text"
placeholder="Search services..."
className="w-full px-4 py-3 border border-gray-300 rounded-full text-sm focus:outline-none focus:border-blue-500"
/>
<Search className="absolute right-4 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400" />
</div>
</div>
</div>
{/* Services Grid */}
<div className="grid grid-cols-4 gap-4 max-w-4xl mx-auto">
{/* Service Card 1 */}
<div className="bg-white border border-gray-200 rounded-lg p-4 hover:shadow-md transition-shadow">
<h3 className="font-medium text-gray-900 mb-1 text-sm">测试1</h3>
<p className="text-xs text-gray-600 mb-2">xpack-opensource-1</p>
<div className="flex items-center justify-between">
<span className="bg-blue-100 text-blue-800 px-2 py-1 rounded text-xs">
Beta
</span>
<span className="text-xs text-gray-500">Free</span>
</div>
</div>
{/* Service Card 2 */}
<div className="bg-white border border-gray-200 rounded-lg p-4 hover:shadow-md transition-shadow">
<h3 className="font-medium text-gray-900 mb-1 text-sm">
xpack-opensource
</h3>
<p className="text-xs text-gray-600 mb-2">xpack-opensource-1</p>
<div className="flex items-center justify-between">
<span className="bg-blue-100 text-blue-800 px-2 py-1 rounded text-xs">
Beta
</span>
<span className="text-xs text-gray-500">$0.02 /Per Call</span>
</div>
</div>
{/* Service Card 3 */}
<div className="bg-white border border-gray-200 rounded-lg p-4 hover:shadow-md transition-shadow">
<h3 className="font-medium text-gray-900 mb-1 text-sm">
xpack-opensource
</h3>
<p className="text-xs text-gray-600 mb-2">xpack-opensource</p>
<div className="flex items-center justify-between">
<span className="bg-blue-100 text-blue-800 px-2 py-1 rounded text-xs">
Beta
</span>
<span className="text-xs text-gray-500">$0.02 /Per Call</span>
</div>
</div>
{/* Service Card 4 */}
<div className="bg-white border border-gray-200 rounded-lg p-4 hover:shadow-md transition-shadow">
<h3 className="font-medium text-gray-900 mb-1 text-sm">
Pet Store API
</h3>
<p className="text-xs text-gray-600 mb-2">
A comprehensive API for managing pet store...
</p>
<div className="flex items-center justify-between">
<span className="bg-blue-100 text-blue-800 px-2 py-1 rounded text-xs">
Beta
</span>
<span className="text-xs text-gray-500">Free</span>
</div>
</div>
</div>
</div>
{/* Footer */}
<div className="absolute bottom-0 left-0 right-0 bg-white px-6 py-2 border-t border-gray-100">
<div className="flex items-center justify-end text-xs text-gray-500">
<span>© 2025 Platform</span>
</div>
</div>
</div>
);
};
export default DefaultDemo;
@@ -0,0 +1,43 @@
"use client";
import React from "react";
import { Card, CardBody } from "@nextui-org/react";
import { AboutContent } from "@/components/about/AboutContent";
import { Navigation } from "./Navigation";
import { Footer } from "./Footer";
import { NavigationItem } from "@/shared/components/Navigation";
interface AboutProps {
navItems?: NavigationItem[];
}
export const About: React.FC<AboutProps> = ({ navItems = [] }) => {
return (
<div className="min-h-screen bg-gradient-to-br from-slate-50 to-blue-50 flex flex-col justify-between">
<Navigation items={navItems} />
<div className="relative z-10 mt-20">
{/* Clean Background Pattern */}
<div className="absolute inset-0 opacity-30">
<div
className="w-full h-full"
style={{
backgroundImage: `url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23000000' fill-opacity='0.05'%3E%3Ccircle cx='20' cy='20' r='1'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E")`,
}}
></div>
</div>
{/* Main Content */}
<main className="flex-1 relative z-10">
<div className="max-w-7xl mx-auto px-6 py-12">
<Card className="bg-white/90 backdrop-blur-sm border border-white/20 shadow-lg rounded-2xl">
<CardBody className="p-8">
<AboutContent />
</CardBody>
</Card>
</div>
</main>
</div>
<Footer />
</div>
);
};
@@ -0,0 +1,59 @@
import React from 'react';
const ModernDemo: React.FC = () => {
return (
<div className="w-full h-full bg-gradient-to-br from-blue-50 to-indigo-100 relative overflow-hidden">
{/* Header */}
<div className="bg-white shadow-sm border-b border-gray-100 px-4 py-2">
<div className="flex items-center justify-between">
<div className="flex items-center space-x-2">
<div className="w-6 h-6 bg-gradient-to-r from-blue-500 to-indigo-600 rounded-lg"></div>
<span className="text-sm font-semibold text-gray-800">Platform</span>
</div>
<div className="flex space-x-1">
<div className="w-2 h-2 bg-blue-500 rounded-full"></div>
<div className="w-2 h-2 bg-gray-300 rounded-full"></div>
<div className="w-2 h-2 bg-gray-300 rounded-full"></div>
</div>
</div>
</div>
{/* Hero Section */}
<div className="px-4 py-6 text-center">
<div className="mb-3">
<h1 className="text-lg font-bold text-gray-900 mb-1">Modern Platform</h1>
<p className="text-xs text-gray-600">Clean & Minimalist Design</p>
</div>
{/* CTA Button */}
<div className="mb-4">
<div className="inline-block bg-gradient-to-r from-blue-500 to-indigo-600 text-white text-xs px-4 py-2 rounded-full shadow-lg">
Get Started
</div>
</div>
</div>
{/* Feature Cards */}
<div className="px-4 pb-4">
<div className="grid grid-cols-2 gap-2">
<div className="bg-white rounded-xl p-3 shadow-sm border border-gray-100">
<div className="w-4 h-4 bg-blue-100 rounded-lg mb-2"></div>
<div className="text-xs font-medium text-gray-800 mb-1">Feature 1</div>
<div className="text-xs text-gray-500">Modern UI</div>
</div>
<div className="bg-white rounded-xl p-3 shadow-sm border border-gray-100">
<div className="w-4 h-4 bg-indigo-100 rounded-lg mb-2"></div>
<div className="text-xs font-medium text-gray-800 mb-1">Feature 2</div>
<div className="text-xs text-gray-500">Clean Design</div>
</div>
</div>
</div>
{/* Decorative Elements */}
<div className="absolute top-0 right-0 w-16 h-16 bg-gradient-to-br from-blue-400/20 to-indigo-500/20 rounded-full -translate-y-8 translate-x-8"></div>
<div className="absolute bottom-0 left-0 w-12 h-12 bg-gradient-to-tr from-indigo-400/20 to-blue-500/20 rounded-full translate-y-6 -translate-x-6"></div>
</div>
);
};
export default ModernDemo;
@@ -0,0 +1,188 @@
"use client";
import React, { useState } from "react";
import { useTranslation } from "@/shared/lib/useTranslation";
import { Tabs, Tab, Chip, Card, CardBody } from "@nextui-org/react";
import { ServiceData } from "@/shared/types/marketplace";
import { ProductHeader } from "@/shared/components/marketplace/ProductHeader";
import { ProductOverview } from "@/shared/components/marketplace/ProductOverview";
import { ProductTools } from "@/shared/components/marketplace/ProductTools";
import { ProductNotFound } from "@/shared/components/marketplace/ProductNotFound";
import { Monitor, Code, Settings } from "lucide-react";
import { Navigation } from "./Navigation";
import { Footer } from "./Footer";
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
import { NavigationItem } from "@/shared/components/Navigation";
interface DetailProps {
product: ServiceData;
breadcrumbs?: {
link: string;
name: string;
}[];
url?: string;
// navigation items
navItems?: NavigationItem[];
}
export const Detail: React.FC<DetailProps> = ({
product,
breadcrumbs,
url,
navItems = [],
}) => {
const { t } = useTranslation();
const [activeTab, setActiveTab] = useState("overview");
const { platformConfig } = usePlatformConfig();
if (!product) {
return <ProductNotFound />;
}
return (
<div className="min-h-screen bg-gradient-to-br from-slate-50 to-blue-50 flex flex-col justify-between">
<Navigation items={navItems} />
<div>
{/* Clean Background */}
<div className="absolute inset-0 opacity-30">
<div
className="w-full h-full"
style={{
backgroundImage: `url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23000000' fill-opacity='0.05'%3E%3Ccircle cx='20' cy='20' r='1'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E")`,
}}
></div>
</div>
<div className="relative z-10">
{/* Modern Product Header */}
<div className="pt-20">
<div className="mx-auto pt-6 px-6 max-w-7xl">
<div className="bg-white/80 backdrop-blur-sm rounded-2xl p-6 shadow-lg border border-white/20">
<ProductHeader product={product} breadcrumbs={breadcrumbs} />
</div>
</div>
</div>
{/* Main Content */}
<div className="mx-auto pb-6 px-6 max-w-7xl">
<div className="flex gap-6 mt-6">
{/* Left side - Main content */}
<div className="flex-1">
<Card className="bg-white/90 backdrop-blur-sm border border-gray-200/50 shadow-lg rounded-2xl">
<CardBody className="p-0">
<Tabs
selectedKey={activeTab}
onSelectionChange={(key) => setActiveTab(key as string)}
variant="underlined"
color="primary"
className="px-6 pt-6"
classNames={{
tabList:
"gap-6 w-full relative rounded-none p-0 border-b border-gray-200",
cursor: "w-full bg-blue-600",
tab: "max-w-fit px-0 h-12",
tabContent:
"group-data-[selected=true]:text-blue-600 font-semibold text-gray-600",
}}
>
<Tab
key="overview"
title={
<div className="flex items-center gap-2">
<Monitor className="w-4 h-4" />
<span>{t("Overview")}</span>
</div>
}
>
<div className="p-6 pt-4">
<ProductOverview product={product} />
</div>
</Tab>
<Tab
key="tools"
title={
<div className="flex gap-2 items-center">
<Code className="w-4 h-4" />
<span>{t("Tools")}</span>
<Chip
size="sm"
className="h-4 text-xs bg-blue-600 text-white"
>
{product.tools.length}
</Chip>
</div>
}
>
<div className="p-6 pt-4">
<ProductTools product={product} />
</div>
</Tab>
</Tabs>
</CardBody>
</Card>
</div>
{/* Right side - Server Config */}
<div className="min-w-[400px] w-[40%] max-w-100 flex-shrink-0">
<Card className="bg-white/90 backdrop-blur-sm border border-gray-200/50 shadow-lg rounded-2xl">
<CardBody>
<div className="flex items-center gap-3 mb-4">
<div className="p-2 bg-blue-600 rounded-lg">
<Settings className="w-5 h-5 text-white" />
</div>
<h3 className="font-semibold text-lg text-gray-900">
{t("Configuration")}
</h3>
</div>
{/* Code Snippet */}
<Card className="w-full max-w-2xl bg-black text-white p-2 sm:p-4 rounded-lg relative z-10">
<div className="text-left font-mono">
<Chip
className="mb-2 text-white"
size="sm"
variant="flat"
>
{platformConfig?.name} MCP
</Chip>
<pre className="p-2 sm:p-4 rounded-md text-xs overflow-x-auto">
<code className="text-gray-300 whitespace-pre-wrap">
{`{
"mcpServers": {
"xpack-mcp-market": {
"type": "sse",
"autoApprove"":"all",
"url": "${url}?apikey=`}
<span className="text-success">{`{Your-${platformConfig?.name}-API-Key}`}</span>
{`"
}
}
}`}
</code>
</pre>
</div>
</Card>
</CardBody>
</Card>
</div>
</div>
{/* SEO-friendly: Simple text content for search engines */}
<div className="hidden" aria-hidden="true">
<h2>Tools ({product.tools.length})</h2>
{product.tools.length > 0 &&
product.tools.map((tool, index) => (
<div key={`seo-${product.service_id}-tool-${index}`}>
<h4>{tool.name}</h4>
<p>{tool.description || ""}</p>
</div>
))}
</div>
</div>
</div>
</div>
<div>
<Footer />
</div>
</div>
);
};
@@ -0,0 +1,36 @@
"use client";
import { Sparkles } from "lucide-react";
import React from "react";
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
interface FooterProps {}
export const Footer: React.FC<FooterProps> = ({}) => {
const { platformConfig } = usePlatformConfig();
return (
<>
{/* Modern Footer */}
<footer className="relative z-10">
<div className="bg-gradient-to-r from-slate-800 via-gray-800 to-slate-900">
<div className="mx-auto px-6 py-2 max-w-7xl">
<div className=" flex justify-between items-center gap-2">
<span className="text-gray-300 text-sm">
© 2025 {platformConfig?.name}. All rights reserved.
</span>
<a
href="https://xpack.ai"
target="_blank"
rel="noopener noreferrer"
className="inline-flex items-center gap-2 text-primary-400 text-xs"
>
<span>Powered By XPack.AI</span>
</a>
</div>
</div>
</div>
</footer>
</>
);
};
@@ -0,0 +1,239 @@
"use client";
import React from "react";
import { Spinner } from "@nextui-org/react";
import { Search, Sparkles, Zap } from "lucide-react";
import {
Input,
Button,
Pagination,
Card,
CardBody,
CardFooter,
Chip,
} from "@nextui-org/react";
import { useTranslation } from "react-i18next";
import Link from "next/link";
import { ServiceData } from "@/shared/types/marketplace";
import { Price } from "@/shared/components/marketplace/Price";
import { ArrowRight } from "lucide-react";
import {
_DefaultPlatformConfig,
usePlatformConfig,
} from "@/shared/contexts/PlatformConfigContext";
import { Navigation } from "./Navigation";
import { Footer } from "./Footer";
import { NavigationItem } from "@/shared/components/Navigation";
interface HomeProps {
// 状态
searchQuery: string;
services: ServiceData[];
currentPage: number;
total: number;
pageSize: number;
loading: boolean;
error: string | null;
// 事件处理函数
onSearchChange: (value: string) => void;
onSearch: () => void;
onPageChange: (page: number) => void;
// 可选配置
searchSuggestions?: string[];
// navigation items
navItems?: NavigationItem[];
}
export const Home: React.FC<HomeProps> = ({
searchQuery,
services,
currentPage,
total,
pageSize,
loading,
onSearchChange,
onSearch,
onPageChange,
searchSuggestions = [],
navItems = [],
}) => {
const { platformConfig } = usePlatformConfig();
const { t } = useTranslation();
const totalPages = Math.ceil(total / pageSize);
return (
<div className="min-h-screen bg-gradient-to-br from-blue-50 to-indigo-100 relative overflow-hidden">
{/* Decorative Elements */}
<div className="absolute top-20 right-10 w-16 h-16 bg-gradient-to-br from-blue-400/20 to-indigo-500/20 rounded-full animate-pulse"></div>
<div className="absolute top-40 left-10 w-12 h-12 bg-gradient-to-tr from-indigo-400/20 to-blue-500/20 rounded-full animate-bounce"></div>
<div className="absolute bottom-40 right-20 w-8 h-8 bg-gradient-to-bl from-blue-300/30 to-indigo-400/30 rounded-full animate-pulse"></div>
<div className="absolute bottom-20 left-1/4 w-6 h-6 bg-gradient-to-tl from-indigo-300/30 to-blue-400/30 rounded-full animate-bounce"></div>
{/* Modern Navigation */}
<Navigation items={navItems} />
{/* Modern Hero Section */}
<div className="pt-32">
<div className="mx-auto px-6 py-20 max-w-6xl">
<div className="text-center mb-16">
{/* Modern Icon */}
<div className="flex justify-center mb-8">
<div className="w-12 h-12 bg-gradient-to-r from-blue-500 to-indigo-600 rounded-lg flex items-center justify-center">
<Sparkles className="w-6 h-6 text-white" />
</div>
</div>
{/* Modern Title */}
<h1 className="text-4xl lg:text-6xl font-bold mb-6 text-gray-900 leading-tight">
{t(
platformConfig.headline || _DefaultPlatformConfig.headline || ""
)}
</h1>
{/* Modern Subtitle */}
<p className="text-lg text-gray-600 max-w-2xl mx-auto leading-relaxed">
{t(
platformConfig.subheadline ||
_DefaultPlatformConfig.subheadline ||
""
)}
</p>
</div>
{/* Modern Search Bar */}
<div className="max-w-2xl mx-auto">
<div className="bg-white p-1 rounded-xl shadow-sm border border-gray-100">
<div className="flex">
<div className="flex-1">
<Input
size="lg"
placeholder={
searchSuggestions.length > 0
? t(searchSuggestions[0])
: t("Search services...")
}
value={searchQuery}
onChange={(e) => onSearchChange(e.target.value)}
onKeyDown={(e) => e.key === "Enter" && onSearch()}
startContent={<Search className="w-5 h-5 text-gray-400" />}
className="w-full"
classNames={{
input:
"text-base text-gray-900 placeholder:text-gray-500",
inputWrapper: "h-12 shadow-none px-4 bg-white border-0",
}}
variant="flat"
/>
</div>
<Button
onPress={onSearch}
className="bg-gradient-to-r from-blue-500 to-indigo-600 text-white h-12 px-6 rounded-lg shadow-sm"
size="lg"
>
{t("Search")}
</Button>
</div>
</div>
</div>
</div>
</div>
{/* Service List Section */}
{loading ? (
<div className="mx-auto h-[200px] flex items-center justify-center">
<div className="bg-white p-8 rounded-lg shadow-md">
<Spinner size="lg" color="primary" />
</div>
</div>
) : (
<div className="py-16">
<div className="mx-auto px-6 max-w-7xl">
{/* Services Grid */}
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6 mb-12">
{services.map((service) => (
<Link
key={service.service_id}
href={`/marketplace/${service.service_id}`}
>
<Card className="group h-[200px] hover:shadow-lg transition-all duration-200 cursor-pointer bg-white border border-gray-100 rounded-xl shadow-sm">
<CardBody className="p-4">
{/* Header */}
<div className="flex items-start justify-between mb-3">
<div className="flex items-center gap-2">
<div className="w-8 h-8 bg-blue-100 rounded-lg flex items-center justify-center">
<Zap className="w-4 h-4 text-blue-600" />
</div>
<div className="flex-1 min-w-0">
<h3 className="font-semibold text-gray-900 text-base mb-1 truncate group-hover:text-blue-600 transition-colors">
{service.name}
</h3>
</div>
</div>
<ArrowRight className="w-4 h-4 text-gray-400 group-hover:text-blue-600 transition-colors" />
</div>
{/* Description */}
<p className="text-gray-600 text-sm line-clamp-3 leading-relaxed mb-4">
{service.short_description ||
t("No description available")}
</p>
</CardBody>
{/* Footer */}
<CardFooter className="pt-0 px-4 pb-4">
<div className="flex items-center justify-between w-full">
{/* Tools count */}
<div className="flex items-center gap-2">
<div className="w-2 h-2 bg-blue-600 rounded-full"></div>
<span className="text-sm font-medium text-gray-700">
{t("{{count}} Tools", {
count: service.tools.length,
})}
</span>
</div>
{/* Price */}
<div className="flex flex-col items-end">
<Price
price={service.price}
charge_type={service.charge_type}
/>
</div>
</div>
</CardFooter>
</Card>
</Link>
))}
</div>
{/* Pagination */}
{totalPages > 1 && (
<div className="flex justify-center">
<Pagination
total={totalPages}
page={currentPage}
onChange={onPageChange}
showControls
color="primary"
variant="light"
size="lg"
classNames={{
wrapper: "gap-2",
item: "w-10 h-10 text-sm font-medium",
cursor:
"bg-gradient-to-r from-blue-500 to-indigo-600 shadow-sm",
}}
/>
</div>
)}
</div>
</div>
)}
<Footer />
</div>
);
};
@@ -0,0 +1,105 @@
"use client";
import React from "react";
import { Button } from "@nextui-org/react";
import { useTranslation } from "react-i18next";
import Link from "next/link";
import { useState } from "react";
import {
Navbar,
NavbarContent,
NavbarMenuToggle,
NavbarMenu,
NavbarMenuItem,
} from "@nextui-org/react";
import { ArrowRightIcon } from "lucide-react";
import { DynamicLogo } from "@/shared/components/DynamicLogo";
import { useAuth } from "@/shared/lib/useAuth";
import { NavigationItem } from "@/shared/components/Navigation";
interface NavigationProps {
items?: NavigationItem[];
}
export const Navigation: React.FC<NavigationProps> = ({ items }) => {
const { t } = useTranslation();
const { handleLogin } = useAuth();
const [isMenuOpen, setIsMenuOpen] = useState(false);
return (
<>
{/* Modern Navigation */}
<Navbar
onMenuOpenChange={setIsMenuOpen}
maxWidth="full"
className="mt-0 rounded-full bg-white/95 backdrop-blur-[10px] border-1 border-white/20 fixed top-2 sm:top-5 max-w-7xl mx-auto"
height="66px"
isBordered={false}
>
<NavbarContent>
<NavbarMenuToggle
aria-label={isMenuOpen ? "Close menu" : "Open menu"}
className="sm:hidden text-gray-700"
/>
<div className="flex justify-start bg-transparent w-max">
<Link href="/">
<DynamicLogo alt="Platform Logo" className="h-[20px]" />
</Link>
</div>
<div className="hidden lg:flex gap-6 justify-center">
{items?.map((item) => (
<Link href={item.href} className="text-sm text-gray-500">
{t(item.label)}
</Link>
))}
</div>
</NavbarContent>
<NavbarContent justify="end" className="items-center gap-2 sm:gap-4">
<div className="hidden sm:block">
<Button
color="primary"
className="bg-gradient-to-r from-blue-500 to-purple-600 text-white hover:from-blue-600 hover:to-purple-700 flex items-center justify-center gap-4 pr-1 h-[45px] shadow-lg"
radius="full"
onPress={handleLogin}
>
<b className="text-md">{t("Get Started")}</b>
<div className="w-8 h-8 bg-white/20 flex items-center justify-center rounded-full">
<ArrowRightIcon
size={16}
className="transition-transform duration-200 ease-in-out group-hover:translate-x-[3px] text-white"
/>
</div>
</Button>
</div>
<div className="sm:hidden">
<Button
className="bg-gradient-to-r from-blue-500 to-purple-600 text-white hover:from-blue-600 hover:to-purple-700"
onPress={handleLogin}
size="sm"
>
<b className="text-md">{t("Get Started")}</b>
</Button>
</div>
</NavbarContent>
<NavbarMenu className="pt-6 pb-6 bg-white/95 backdrop-blur-sm">
<NavbarMenuItem className="mt-4">
<Button
color="primary"
className="w-full bg-gradient-to-r from-blue-500 to-purple-600 text-white flex items-center justify-between gap-4 pr-1 h-[45px]"
radius="full"
onPress={handleLogin}
>
<b className="text-md">{t("Get Started")}</b>
<div className="w-8 h-8 bg-white/20 flex items-center justify-center rounded-full">
<ArrowRightIcon
size={16}
className="transition-transform duration-200 ease-in-out group-hover:translate-x-[3px]"
/>
</div>
</Button>
</NavbarMenuItem>
</NavbarMenu>
</Navbar>
</>
);
};
@@ -0,0 +1,27 @@
"use client";
import React from "react";
import { AboutContent } from "@/components/about/AboutContent";
import { Navigation } from "./Navigation";
import { Footer } from "./Footer";
import { NavigationItem } from "@/shared/components/Navigation";
interface AboutProps {
navItems?: NavigationItem[];
}
export const About: React.FC<AboutProps> = ({ navItems = [] }) => {
return (
<div className="min-h-screen bg-gray-50 absolute top-0 left-0 right-0 bottom-0 flex flex-col justify-between bg-white">
<Navigation items={navItems} />
<main className="flex-1 pt-32">
<div className="max-w-7xl mx-auto px-6 pb-12">
<AboutContent />
</div>
</main>
<Footer />
</div>
);
};
+103
View File
@@ -0,0 +1,103 @@
"use client";
import React from "react";
import { ShoppingBag, Search, Tag, Star } from "lucide-react";
const TemuDemo: React.FC = () => {
return (
<div className="w-full h-full bg-gradient-to-r from-orange-400 via-orange-500 to-red-500 relative overflow-hidden">
{/* Header */}
<div className="absolute top-0 left-0 right-0 bg-white/10 backdrop-blur-sm px-3 py-2">
<div className="flex items-center justify-between">
<div className="flex items-center gap-2">
<ShoppingBag className="w-4 h-4 text-white" />
<span className="text-white font-bold text-sm">MCP Store</span>
</div>
<div className="flex items-center gap-1">
<div className="w-2 h-2 bg-white/60 rounded-full"></div>
<div className="w-2 h-2 bg-white/60 rounded-full"></div>
<div className="w-2 h-2 bg-white/60 rounded-full"></div>
</div>
</div>
</div>
{/* Hero Section */}
<div className="absolute top-8 left-0 right-0 px-3 py-4">
<div className="text-center">
{/* Title */}
<h1 className="text-lg font-bold text-white mb-1">
Discover Amazing Services
</h1>
{/* Subtitle */}
<p className="text-xs text-white/90 mb-3">
Find the perfect MCP service for your needs
</p>
{/* Search Bar */}
<div className="flex gap-1 mb-3">
<div className="flex-1 bg-white rounded-md px-2 py-1 flex items-center gap-1">
<Search className="w-3 h-3 text-gray-400" />
<span className="text-xs text-gray-500">Search...</span>
</div>
<div className="bg-white px-3 py-1 rounded-md">
<span className="text-xs text-orange-500 font-medium">Go</span>
</div>
</div>
</div>
</div>
{/* Products Section */}
<div className="absolute top-[150px] left-0 right-0 bg-white rounded-t-lg px-3 py-3">
{/* Section Header */}
<div className="flex items-center gap-1 mb-2">
<Tag className="w-3 h-3 text-orange-500" />
<span className="text-sm font-bold text-gray-900">Featured</span>
</div>
{/* Products Grid */}
<div className="grid grid-cols-2 gap-2">
{/* Product 1 */}
<div className="bg-gray-50 rounded-lg p-2 border border-gray-100">
<div className="mb-1">
<h3 className="text-xs font-semibold text-gray-900 line-clamp-1">
AI Assistant
</h3>
<p className="text-xs text-gray-600 line-clamp-1">
Smart AI helper
</p>
</div>
<div className="flex items-center justify-between">
<span className="text-xs font-bold text-orange-600">$9.99</span>
<div className="flex items-center gap-1">
<Star className="w-2 h-2 text-yellow-400 fill-current" />
<span className="text-xs text-gray-500">4.8</span>
</div>
</div>
</div>
{/* Product 2 */}
<div className="bg-gray-50 rounded-lg p-2 border border-gray-100">
<div className="mb-1">
<h3 className="text-xs font-semibold text-gray-900 line-clamp-1">
Data Analyzer
</h3>
<p className="text-xs text-gray-600 line-clamp-1">
Powerful analytics
</p>
</div>
<div className="flex items-center justify-between">
<span className="text-xs font-bold text-orange-600">$14.99</span>
<div className="flex items-center gap-1">
<Star className="w-2 h-2 text-yellow-400 fill-current" />
<span className="text-xs text-gray-500">4.9</span>
</div>
</div>
</div>
</div>
</div>
</div>
);
};
export default TemuDemo;
@@ -0,0 +1,195 @@
"use client";
import React, { useState } from "react";
import { useTranslation } from "@/shared/lib/useTranslation";
import { Tabs, Tab, Chip, Card, CardBody } from "@nextui-org/react";
import { ServiceData } from "@/shared/types/marketplace";
import { ProductHeader } from "@/shared/components/marketplace/ProductHeader";
import { ProductOverview } from "@/shared/components/marketplace/ProductOverview";
import { ProductTools } from "@/shared/components/marketplace/ProductTools";
import { ProductNotFound } from "@/shared/components/marketplace/ProductNotFound";
import { FileText, Wrench, Cog } from "lucide-react";
import { Navigation } from "./Navigation";
import { Footer } from "./Footer";
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
import { NavigationItem } from "@/shared/components/Navigation";
interface DetailProps {
product: ServiceData;
breadcrumbs?: {
link: string;
name: string;
}[];
url?: string;
// navigation items
navItems?: NavigationItem[];
}
export const Detail: React.FC<DetailProps> = ({
product,
breadcrumbs,
url,
navItems = [],
}) => {
const { t } = useTranslation();
const [activeTab, setActiveTab] = useState("overview");
const { platformConfig } = usePlatformConfig();
if (!product) {
return <ProductNotFound />;
}
return (
<div className="min-h-screen bg-gray-50 flex flex-col justify-between">
<Navigation items={navItems} />
<div>
{/* Temu Style Product Header */}
<div className="bg-white border-b border-gray-200 shadow-sm pt-20">
<div className="mx-auto p-6 max-w-7xl">
{/* Breadcrumbs */}
{breadcrumbs && breadcrumbs.length > 0 && (
<nav className="mb-4">
<ol className="flex items-center space-x-2 text-sm text-gray-600">
{breadcrumbs.map((crumb, index) => (
<li key={index} className="flex items-center">
{index > 0 && (
<span className="mx-2 text-gray-400">/</span>
)}
<a
href={crumb.link}
className="hover:text-orange-500 transition-colors"
>
{crumb.name}
</a>
</li>
))}
</ol>
</nav>
)}
<ProductHeader product={product} breadcrumbs={breadcrumbs} />
</div>
</div>
{/* Main Content */}
<div className="mx-auto p-6 max-w-7xl mt-6">
<Card className="bg-white border border-gray-200 shadow-sm">
<CardBody className="p-0">
<Tabs
selectedKey={activeTab}
onSelectionChange={(key) => setActiveTab(key as string)}
variant="underlined"
color="warning"
className="px-6 pt-6"
classNames={{
tabList:
"gap-6 w-full relative rounded-none p-0 border-b border-gray-200",
cursor: "w-full bg-orange-500",
tab: "max-w-fit px-0 h-12",
tabContent:
"group-data-[selected=true]:text-orange-600 font-medium text-gray-700",
}}
>
<Tab
key="overview"
title={
<div className="flex items-center gap-2">
<FileText className="w-4 h-4" />
<span>{t("Overview")}</span>
</div>
}
>
<div className="p-6">
<ProductOverview product={product} />
</div>
</Tab>
<Tab
key="tools"
title={
<div className="flex items-center gap-2">
<Wrench className="w-4 h-4" />
<span>{t("Tools")}</span>
</div>
}
>
<div className="p-2">
<div className="space-y-4 px-3">
{product.tools.length > 0 ? (
product.tools.map((tool, index) => (
<Card
radius="sm"
key={`${product.service_id}-tool-${index}`}
shadow="none"
className="border-1"
>
<CardBody>
<h4 className="font-semibold text-sm mb-2 text-orange-600">
{tool.name}
</h4>
<p className="text-sm mb-3">
{tool.description ||
t("No description available")}
</p>
</CardBody>
</Card>
))
) : (
<Card>
<CardBody>
<p className="text-center">
{t("No tools available in this service.")}
</p>
</CardBody>
</Card>
)}
</div>
</div>
</Tab>
<Tab
key="config"
title={
<div className="flex items-center gap-2">
<Cog className="w-4 h-4" />
<span>{t("Configuration")}</span>
</div>
}
>
<div className="p-6">
{/* Code Snippet */}
<Card className="w-full bg-black text-white p-2 sm:p-4 rounded-lg relative z-10">
<div className="text-left font-mono">
<Chip
className="mb-2 text-white"
size="sm"
variant="flat"
>
{platformConfig?.name} MCP
</Chip>
<pre className="p-2 sm:p-4 rounded-md text-xs overflow-x-auto">
<code className="text-gray-300 whitespace-pre-wrap">
{`{
"mcpServers": {
"xpack-mcp-market": {
"type": "sse",
"autoApprove"":"all",
"url": "${url}?apikey=`}
<span className="text-success">{`{Your-${platformConfig?.name}-API-Key}`}</span>
{`"
}
}
}`}
</code>
</pre>
</div>
</Card>
</div>
</Tab>
</Tabs>
</CardBody>
</Card>
</div>
</div>
<Footer />
</div>
);
};
@@ -0,0 +1,68 @@
"use client";
import React from "react";
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
import { ShoppingBag, Star, Heart } from "lucide-react";
import { useTranslation } from "react-i18next";
interface FooterProps {}
export const Footer: React.FC<FooterProps> = ({}) => {
const { platformConfig } = usePlatformConfig();
const { t } = useTranslation();
return (
<>
{/* Temu Style Footer */}
<footer className="bg-gray-50 border-t border-gray-200">
<div className="mx-auto px-6 pt-12 pb-6 max-w-7xl">
<div className="grid grid-cols-1 md:grid-cols-2 gap-8 mb-8">
{/* Company Info */}
<div>
<h3 className="text-lg font-bold text-gray-900 mb-4">
{platformConfig?.name}
</h3>
<p className="text-gray-600 text-sm mb-4">
{t(
"A marketplace for AI tools and services. Discover and integrate powerful AI solutions for your projects."
)}
</p>
<div className="flex items-center gap-2 text-orange-500">
<ShoppingBag className="w-5 h-5" />
<span className="text-sm font-medium">
{t("AI Tools Marketplace")}
</span>
</div>
</div>
</div>
{/* Bottom Section */}
<div className="border-t border-gray-200 pt-8">
<div className="flex flex-col md:flex-row justify-between items-center gap-4">
{/* Copyright */}
<div className="flex items-center gap-2 text-gray-600 text-sm">
<span>
© 2025 {platformConfig?.name}. All rights reserved.
</span>
</div>
{/* Powered By */}
<div className="flex items-center gap-4">
<a
href="https://xpack.ai"
target="_blank"
rel="noopener noreferrer"
className="inline-flex items-center gap-2 text-gray-600 hover:text-orange-500 transition-colors text-sm font-medium"
>
<div className="flex items-center gap-2 bg-white px-3 py-1 rounded-full border border-gray-200 hover:border-orange-200 transition-all duration-200">
<Star className="w-4 h-4 text-orange-500" />
<span>Powered By XPack.AI</span>
</div>
</a>
</div>
</div>
</div>
</div>
</footer>
</>
);
};
+220
View File
@@ -0,0 +1,220 @@
"use client";
import React from "react";
import { CardFooter, Spinner } from "@nextui-org/react";
import { Search, ShoppingBag, Tag, TrendingUp } from "lucide-react";
import {
Input,
Button,
Pagination,
Card,
CardBody,
Chip,
} from "@nextui-org/react";
import { useTranslation } from "react-i18next";
import Link from "next/link";
import { ServiceData } from "@/shared/types/marketplace";
import { Price } from "@/shared/components/marketplace/Price";
import {
_DefaultPlatformConfig,
usePlatformConfig,
} from "@/shared/contexts/PlatformConfigContext";
import { Footer } from "./Footer";
import { Navigation } from "./Navigation";
import { NavigationItem } from "@/shared/components/Navigation";
interface HomeProps {
// 状态
searchQuery: string;
services: ServiceData[];
currentPage: number;
total: number;
pageSize: number;
loading: boolean;
error: string | null;
// 事件处理函数
onSearchChange: (value: string) => void;
onSearch: () => void;
onPageChange: (page: number) => void;
// 可选配置
searchSuggestions?: string[];
// navigation items
navItems?: NavigationItem[];
}
export const Home: React.FC<HomeProps> = ({
searchQuery,
services,
currentPage,
total,
pageSize,
loading,
error,
onSearchChange,
onSearch,
onPageChange,
navItems = [],
}) => {
const { platformConfig } = usePlatformConfig();
const { t } = useTranslation();
const totalPages = Math.ceil(total / pageSize);
// 如果有错误,显示错误信息
if (error) {
return (
<div className="min-h-screen bg-gray-50">
<div className="mx-auto h-[100px] flex items-center justify-center">
<div className="text-red-600 bg-white px-6 py-4 rounded-lg shadow-md border border-red-200">
Error: {error}
</div>
</div>
</div>
);
}
return (
<div className="min-h-screen absolute top-0 left-0 right-0 bottom-0">
<Navigation items={navItems} />
{/* Temu Style Hero Section */}
<div className="bg-gradient-to-r from-orange-400 via-orange-500 to-red-500 pt-20">
<div className="mx-auto px-6 py-16 max-w-7xl">
<div className="text-center mb-12">
{/* Icon */}
<div className="flex justify-center mb-6">
<div className="bg-white/20 p-4 rounded-2xl backdrop-blur-sm">
<ShoppingBag className="w-10 h-10 text-white" />
</div>
</div>
{/* Title */}
<h1 className="text-4xl lg:text-6xl font-bold mb-6 text-white">
{t(
platformConfig.headline || _DefaultPlatformConfig.headline || ""
)}
</h1>
{/* Subtitle */}
<p className="text-xl text-white/90 mb-8 max-w-2xl mx-auto">
{t(
platformConfig.subheadline ||
_DefaultPlatformConfig.subheadline ||
""
)}
</p>
{/* Search Bar */}
<div className="max-w-2xl mx-auto mb-8">
<div className="flex gap-3">
<Input
placeholder={t("Search services...")}
value={searchQuery}
onChange={(e) => onSearchChange(e.target.value)}
onKeyDown={(e) => e.key === "Enter" && onSearch()}
startContent={<Search className="w-5 h-5 text-gray-400" />}
className="flex-1"
classNames={{
input: "text-lg",
inputWrapper: "h-14 bg-white shadow-lg border-0",
}}
radius="lg"
/>
<Button
onPress={onSearch}
className="bg-white text-orange-500 hover:bg-gray-50 font-semibold px-8 h-14 shadow-lg"
radius="lg"
>
{t("Search")}
</Button>
</div>
</div>
</div>
</div>
</div>
{/* Products Section */}
<div className="mx-auto px-6 py-12 max-w-7xl">
{/* Section Header */}
<div className="flex items-center justify-between mb-8">
<div className="flex items-center gap-3">
<Tag className="w-6 h-6 text-orange-500" />
<h2 className="text-2xl font-bold text-gray-900">
{searchQuery ? t("Search Results") : t("Featured Products")}
</h2>
{searchQuery && (
<Chip color="warning" variant="flat">
{total} {t("results")}
</Chip>
)}
</div>
</div>
{/* Loading State */}
{loading && (
<div className="flex justify-center items-center py-20">
<Spinner size="lg" color="warning" />
</div>
)}
{/* Products Grid */}
{!loading && (
<>
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6 mb-12">
{services.map((service) => (
<Link
key={service.service_id}
href={`/marketplace/${service.service_id}`}
>
<Card className="group hover:shadow-xl transition-all duration-300 hover:-translate-y-1 border border-gray-200 hover:border-orange-200 h-[200px]">
<CardBody className="p-0">
{/* Product Info */}
<div className="p-4">
<h3 className="font-semibold text-gray-900 mb-2 line-clamp-2 group-hover:text-orange-600 transition-colors">
{service.name}
</h3>
<p className="text-gray-600 text-sm mb-3 line-clamp-2">
{service.short_description ||
service.long_description ||
"No description available"}
</p>
</div>
</CardBody>
<CardFooter>
{/* Price */}
<div className="flex items-center gap-2">
<Price
price={service.price}
charge_type={service.charge_type}
/>
</div>
</CardFooter>
</Card>
</Link>
))}
</div>
{/* Pagination */}
{totalPages > 1 && (
<div className="flex justify-center">
<Pagination
total={totalPages}
page={currentPage}
onChange={onPageChange}
color="warning"
size="lg"
showControls
className="gap-2"
/>
</div>
)}
</>
)}
</div>
<Footer />
</div>
);
};
@@ -0,0 +1,113 @@
"use client";
import React from "react";
import { Button } from "@nextui-org/react";
import { useTranslation } from "react-i18next";
import Link from "next/link";
import { useState } from "react";
import {
Navbar,
NavbarContent,
NavbarMenuToggle,
NavbarMenu,
NavbarMenuItem,
} from "@nextui-org/react";
import { ArrowRightIcon, ShoppingCart } from "lucide-react";
import { DynamicLogo } from "@/shared/components/DynamicLogo";
import { useAuth } from "@/shared/lib/useAuth";
import { NavigationItem } from "@/shared/components/Navigation";
interface NavigationProps {
items?: NavigationItem[];
}
export const Navigation: React.FC<NavigationProps> = ({ items }) => {
const { t } = useTranslation();
const { handleLogin } = useAuth();
const [isMenuOpen, setIsMenuOpen] = useState(false);
return (
<>
{/* Temu Style Navigation */}
<Navbar
onMenuOpenChange={setIsMenuOpen}
maxWidth="full"
className="mt-0 bg-white border-b border-gray-200 shadow-sm fixed top-0 z-50"
height="70px"
isBordered={false}
classNames={{
wrapper: "max-w-7xl mx-auto",
}}
>
<NavbarContent>
<NavbarMenuToggle
aria-label={isMenuOpen ? "Close menu" : "Open menu"}
className="sm:hidden text-gray-700"
/>
<div className="flex justify-start bg-transparent w-max">
<Link href="/">
<DynamicLogo alt="Platform Logo" className="h-[24px]" />
</Link>
</div>
<div className="hidden lg:flex gap-8 justify-center ml-8">
{items?.map((item) => (
<Link
href={item.href}
className="text-gray-700 hover:text-orange-500 font-medium transition-colors"
>
{t(item.label)}
</Link>
))}
</div>
</NavbarContent>
<NavbarContent justify="end" className="items-center gap-2 sm:gap-4">
<div className="hidden sm:flex items-center gap-3">
<Button
className="bg-orange-500 hover:bg-orange-600 text-white font-semibold px-6 h-[40px] transition-all duration-200"
radius="md"
onPress={handleLogin}
>
{t("Sign In")}
</Button>
</div>
<div className="sm:hidden">
<Button
className="bg-orange-500 hover:bg-orange-600 text-white font-semibold"
onPress={handleLogin}
size="sm"
>
{t("Sign In")}
</Button>
</div>
</NavbarContent>
<NavbarMenu className="pt-6 pb-6 bg-white border-r border-gray-200">
<NavbarMenuItem className="mb-4">
<Link
href="/"
className="text-gray-700 hover:text-orange-500 font-medium text-lg"
>
Home
</Link>
</NavbarMenuItem>
<NavbarMenuItem className="mb-4">
<Link
href="/marketplace"
className="text-gray-700 hover:text-orange-500 font-medium text-lg"
>
Marketplace
</Link>
</NavbarMenuItem>
<NavbarMenuItem className="mt-6">
<Button
className="w-full bg-orange-500 hover:bg-orange-600 text-white font-semibold h-[45px]"
radius="md"
onPress={handleLogin}
>
{t("Sign In")}
</Button>
</NavbarMenuItem>
</NavbarMenu>
</Navbar>
</>
);
};
@@ -12,15 +12,8 @@ const UserManagement: React.FC = () => {
const { t } = useTranslation();
// use custom hook to manage user data
const {
users,
loading,
searchQuery,
pagination,
handleDeleteUser,
setSearch,
setPage,
} = useUserManagement();
const { users, loading, pagination, handleDeleteUser, setPage } =
useUserManagement();
// Modal states
const [deleteModal, setDeleteModal] = useState({
@@ -57,15 +50,11 @@ const UserManagement: React.FC = () => {
return (
<DashboardDemoContent
title={t("User Management")}
description={t("Manage registered users, view user information, and handle user operations")}
description={t(
"Manage registered users, view user information, and handle user operations"
)}
>
<div className="space-y-6 w-full">
{/* comming soon:Filters */}
{/* <UserFiltersBar
searchQuery={searchQuery}
onSearchChange={setSearch}
/> */}
<UserTable
users={users}
loading={loading}
@@ -80,9 +69,7 @@ const UserManagement: React.FC = () => {
onClose={handleCloseDeleteModal}
onConfirm={handleConfirmDelete}
title={t("Delete User")}
description={t(
"Are you sure you want to delete this user? "
)}
description={t("Are you sure you want to delete this user? ")}
/>
</DashboardDemoContent>
);