feature/ui:1.0 feature,like mcp price method support use token and set more config about home page
This commit is contained in:
1 parent
2262a7f49a
commit
8946be619d
69 files changed
+4189
-1021
No files matched your search
@@ -1,38 +1,33 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import React, { useState } 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";
|
||||
import { EmailConfig } from "@/types/system";
|
||||
|
||||
interface LoginSettingsContentProps {
|
||||
onTabNavigate?: (tab: TabKey) => void;
|
||||
loginConfig: LoginConfig;
|
||||
saveLoginConfig: (config: LoginConfig) => Promise<boolean>;
|
||||
emailConfig: EmailConfig;
|
||||
}
|
||||
|
||||
export const LoginSettingsContent: React.FC<LoginSettingsContentProps> = ({
|
||||
onTabNavigate,
|
||||
loginConfig,
|
||||
saveLoginConfig,
|
||||
emailConfig,
|
||||
}) => {
|
||||
const [googleSubmitLoading, setGoogleSubmitLoading] = useState(false);
|
||||
const [emailSubmitLoading, setEmailSubmitLoading] = useState(false);
|
||||
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 =
|
||||
@@ -57,12 +52,13 @@ export const LoginSettingsContent: React.FC<LoginSettingsContentProps> = ({
|
||||
return;
|
||||
}
|
||||
|
||||
setEmailSubmitLoading(true);
|
||||
const result = await saveLoginConfig(config);
|
||||
if (!result) return;
|
||||
updateClientConfig({
|
||||
platform: platformConfig,
|
||||
login: config,
|
||||
});
|
||||
setEmailSubmitLoading(false);
|
||||
};
|
||||
|
||||
// save google auth config
|
||||
@@ -76,22 +72,23 @@ export const LoginSettingsContent: React.FC<LoginSettingsContentProps> = ({
|
||||
return;
|
||||
}
|
||||
|
||||
setGoogleSubmitLoading(true);
|
||||
const result = await saveLoginConfig(updatedLoginConfig);
|
||||
if (!result) return;
|
||||
updateClientConfig({
|
||||
platform: platformConfig,
|
||||
login: updatedLoginConfig,
|
||||
});
|
||||
setGoogleSubmitLoading(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-6 w-full">
|
||||
<div className="space-y-4 w-full">
|
||||
{/* email config */}
|
||||
<EmailConfigForm
|
||||
config={loginConfig}
|
||||
emailConfig={emailConfig}
|
||||
onSave={handleSaveLoginConfig}
|
||||
isLoading={loginLoading}
|
||||
isLoading={emailSubmitLoading}
|
||||
onTabNavigate={onTabNavigate}
|
||||
/>
|
||||
|
||||
@@ -99,7 +96,7 @@ export const LoginSettingsContent: React.FC<LoginSettingsContentProps> = ({
|
||||
<GoogleAuthConfigForm
|
||||
config={loginConfig.google}
|
||||
onSave={handleSaveGoogleAuthConfig}
|
||||
isLoading={loginLoading}
|
||||
isLoading={googleSubmitLoading}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -4,7 +4,6 @@ import React, { useEffect, useState, Suspense } from "react";
|
||||
import { useRouter, useSearchParams } from "next/navigation";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useAdminStore } from "@/store/admin";
|
||||
import DashboardSidebar from "@/shared/components/DashboardSidebar";
|
||||
import DashboardDemoContent from "@/shared/components/DashboardDemoContent";
|
||||
import ConsoleStats from "@/components/console/ConsoleStats";
|
||||
import PaymentChannelsContent from "@/components/console/PaymentChannelsContent";
|
||||
@@ -15,17 +14,16 @@ import { MCPServicesManagement } from "@/components/mcp-services/MCPServicesMana
|
||||
import UserManagement from "@/components/user-management/UserManagement";
|
||||
import RevenueManagement from "@/components/revenue-management/RevenueManagement";
|
||||
import {
|
||||
Cog,
|
||||
CreditCard,
|
||||
DollarSign,
|
||||
Home,
|
||||
Settings,
|
||||
Users,
|
||||
LogIn,
|
||||
ServerIcon,
|
||||
} from "lucide-react";
|
||||
import { LoginSettingsContent } from "@/components/console/LoginSettingsContent";
|
||||
import { Button } from "@nextui-org/react";
|
||||
import { FaDiscord } from "react-icons/fa";
|
||||
import ConsoleSidebar from "./Sidebar";
|
||||
|
||||
const ConsoleContent: React.FC = () => {
|
||||
const { t } = useTranslation();
|
||||
@@ -33,6 +31,8 @@ const ConsoleContent: React.FC = () => {
|
||||
const searchParams = useSearchParams();
|
||||
const [admin_token] = useAdminStore((state) => [state.admin_token]);
|
||||
|
||||
const _DefaultSubTab = "general";
|
||||
|
||||
const getInitialTab = (): TabKey => {
|
||||
const tabFromUrl = searchParams.get("tab") as TabKey;
|
||||
if (
|
||||
@@ -51,49 +51,79 @@ const ConsoleContent: React.FC = () => {
|
||||
return TabKey.CONSOLE;
|
||||
};
|
||||
|
||||
const getInitialSubTab = (): string | undefined => {
|
||||
const subTabFromUrl = searchParams.get("subtab");
|
||||
return subTabFromUrl || _DefaultSubTab;
|
||||
};
|
||||
|
||||
const [activeTab, setActiveTab] = useState<TabKey>(getInitialTab);
|
||||
const [activeSubTab, setActiveSubTab] = useState<string | undefined>(
|
||||
getInitialSubTab
|
||||
);
|
||||
const sidebarItems: SidebarItem[] = [
|
||||
{
|
||||
key: TabKey.CONSOLE,
|
||||
icon: <Home className="w-5 h-5" />,
|
||||
icon: <Home size={18} />,
|
||||
label: t("Dashboard"),
|
||||
description: t("Overview and analytics"),
|
||||
},
|
||||
{
|
||||
key: TabKey.MCP_SERVICES,
|
||||
icon: <Settings className="w-5 h-5" />,
|
||||
icon: <ServerIcon size={18} />,
|
||||
label: t("MCP Services"),
|
||||
description: t("Manage MCP services and API tools"),
|
||||
},
|
||||
{
|
||||
key: TabKey.USER_MANAGEMENT,
|
||||
icon: <Users className="w-5 h-5" />,
|
||||
icon: <Users size={18} />,
|
||||
label: t("User Management"),
|
||||
description: t("Manage registered users"),
|
||||
},
|
||||
{
|
||||
key: TabKey.REVENUE_MANAGEMENT,
|
||||
icon: <DollarSign className="w-5 h-5" />,
|
||||
icon: <DollarSign size={18} />,
|
||||
label: t("Revenue Management"),
|
||||
description: t("View user recharge history"),
|
||||
},
|
||||
{
|
||||
key: TabKey.PAYMENT_CHANNELS,
|
||||
icon: <CreditCard className="w-5 h-5" />,
|
||||
icon: <CreditCard size={18} />,
|
||||
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" />,
|
||||
icon: <Settings size={18} />,
|
||||
label: t("System Settings"),
|
||||
description: t("Platform basic configuration"),
|
||||
// Sub-menu items for System Settings
|
||||
subItems: [
|
||||
{
|
||||
key: "general",
|
||||
label: "General",
|
||||
description: "Platform basic configuration",
|
||||
},
|
||||
{
|
||||
key: "login-settings",
|
||||
label: "Login Settings",
|
||||
description: "Configure authentication methods",
|
||||
},
|
||||
{
|
||||
key: "homepage",
|
||||
label: "Homepage",
|
||||
description: "Homepage content and theme settings",
|
||||
},
|
||||
{
|
||||
key: "about-page",
|
||||
label: "About Page",
|
||||
description: "About page content configuration",
|
||||
},
|
||||
{
|
||||
key: "email-admin",
|
||||
label: "Email & Admin",
|
||||
description: "Email and administrator settings",
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
@@ -104,8 +134,10 @@ const ConsoleContent: React.FC = () => {
|
||||
}
|
||||
}, [admin_token, router]);
|
||||
|
||||
const handleTabNavigate = (tab: TabKey) => {
|
||||
const handleTabNavigate = (tab: TabKey, subTab?: string) => {
|
||||
setActiveTab(tab);
|
||||
setActiveSubTab(subTab || _DefaultSubTab);
|
||||
|
||||
// update url params
|
||||
if (tab === TabKey.CONSOLE) {
|
||||
// when switch to dashboard, clear all query params, only keep base path
|
||||
@@ -114,6 +146,12 @@ const ConsoleContent: React.FC = () => {
|
||||
// other tabs set corresponding tab params
|
||||
const params = new URLSearchParams();
|
||||
params.set("tab", tab);
|
||||
|
||||
// add subtab parameter if provided
|
||||
if (subTab) {
|
||||
params.set("subtab", subTab);
|
||||
}
|
||||
|
||||
router.push(`/console?${params.toString()}`, { scroll: false });
|
||||
}
|
||||
};
|
||||
@@ -151,23 +189,15 @@ const ConsoleContent: React.FC = () => {
|
||||
<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>
|
||||
<SystemSettingsContent
|
||||
activeSubTab={activeSubTab}
|
||||
subTab={sidebarItems
|
||||
.find((item) => item.key === activeTab)
|
||||
?.subItems?.find((item) => item.key === activeSubTab)}
|
||||
onTabNavigate={handleTabNavigate}
|
||||
/>
|
||||
);
|
||||
default:
|
||||
return (
|
||||
@@ -185,25 +215,12 @@ const ConsoleContent: React.FC = () => {
|
||||
<div className="min-h-screen bg-background">
|
||||
<div className="flex">
|
||||
{/* Sidebar */}
|
||||
<DashboardSidebar
|
||||
<ConsoleSidebar
|
||||
activeTab={activeTab}
|
||||
activeSubTab={activeSubTab}
|
||||
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>
|
||||
}
|
||||
/>
|
||||
|
||||
{/* Main Content */}
|
||||
|
||||
@@ -1,46 +1,56 @@
|
||||
'use client';
|
||||
"use client";
|
||||
|
||||
import React from 'react';
|
||||
import { StripeConfigForm } from './StripeConfigForm';
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import React from "react";
|
||||
import { StripeConfigForm } from "../payment/StripeConfigForm";
|
||||
import { AlipayConfigForm } from "../payment/AlipayConfigForm";
|
||||
import { WechatConfigForm } from "../payment/WechatConfigForm";
|
||||
import { usePaymentChannelManagement } from "@/hooks/usePaymentChannelManagement";
|
||||
import { StripeConfig } from "@/types/payment";
|
||||
import { toast } from "react-hot-toast";
|
||||
|
||||
export const PaymentChannelsContent: React.FC = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const {
|
||||
stripeConfig,
|
||||
isSaving,
|
||||
alipayConfig,
|
||||
wechatConfig,
|
||||
isWechatSaving,
|
||||
isStripeSaving,
|
||||
isAlipaySaving,
|
||||
saveStripeConfig,
|
||||
testStripeConnection,
|
||||
saveAlipayConfig,
|
||||
saveWechatConfig,
|
||||
enableChannel,
|
||||
disableChannel,
|
||||
} = usePaymentChannelManagement();
|
||||
|
||||
|
||||
// test stripe connection
|
||||
const handleTestStripeConnection = async (config: StripeConfig) => {
|
||||
const result = await testStripeConnection(config);
|
||||
|
||||
if (result.success) {
|
||||
toast.success(t("Stripe connection test successful"));
|
||||
} else {
|
||||
toast.error(result.message || t("Stripe connection test failed"));
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-6 w-full">
|
||||
{/* stripe configuration */}
|
||||
<StripeConfigForm
|
||||
config={stripeConfig}
|
||||
onSave={saveStripeConfig}
|
||||
onTest={handleTestStripeConnection}
|
||||
isLoading={isSaving}
|
||||
isTestLoading={false}
|
||||
onEnable={enableChannel}
|
||||
onDisable={disableChannel}
|
||||
isLoading={isStripeSaving}
|
||||
/>
|
||||
{/* coming soon */}
|
||||
{/* alipay configuration */}
|
||||
{/* <AlipayConfigForm
|
||||
config={alipayConfig}
|
||||
onSave={saveAlipayConfig}
|
||||
onEnable={enableChannel}
|
||||
onDisable={disableChannel}
|
||||
isLoading={isAlipaySaving}
|
||||
/> */}
|
||||
{/* coming soon */}
|
||||
{/* wechat configuration */}
|
||||
{/* <WechatConfigForm
|
||||
config={wechatConfig}
|
||||
onSave={saveWechatConfig}
|
||||
onEnable={enableChannel}
|
||||
onDisable={disableChannel}
|
||||
isLoading={isWechatSaving}
|
||||
/> */}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default PaymentChannelsContent;
|
||||
export default PaymentChannelsContent;
|
||||
@@ -0,0 +1,161 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { Button, Divider, Link, Tooltip } from "@nextui-org/react";
|
||||
import { LogOut } from "lucide-react";
|
||||
import { DashboardSidebarProps } from "@/shared/types/dashboard";
|
||||
import { DynamicLogo } from "@/shared/components/DynamicLogo";
|
||||
import { FaDiscord } from "react-icons/fa";
|
||||
|
||||
const ConsoleSidebar: React.FC<DashboardSidebarProps> = ({
|
||||
activeTab,
|
||||
activeSubTab,
|
||||
onTabNavigate,
|
||||
onLogout,
|
||||
sidebarItems,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const handleSubItemClick = (parentKey: string, subKey: string) => {
|
||||
onTabNavigate?.(parentKey as any, subKey);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex h-screen">
|
||||
{/* Main Sidebar */}
|
||||
<div className="py-2 px-2 w-[70px] overflow-hidden border-r border-divider flex flex-col justify-between">
|
||||
{/* Header */}
|
||||
<div className="mb-6 mt-4 flex flex-col items-center gap-2">
|
||||
<Link href={process.env.NEXT_PUBLIC_DOMAIN || "/"}>
|
||||
<DynamicLogo
|
||||
alt="Platform Logo"
|
||||
className="max-w-full h-auto max-h-[30px]"
|
||||
/>
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
{/* Navigation */}
|
||||
<div className="flex flex-col gap-2 flex-1">
|
||||
{sidebarItems.map((item) => (
|
||||
<React.Fragment key={item.key}>
|
||||
<Tooltip
|
||||
content={t(item.label)}
|
||||
closeDelay={0}
|
||||
disableAnimation
|
||||
placement="right"
|
||||
>
|
||||
<Button
|
||||
key={item.key}
|
||||
variant={activeTab === item.key ? "flat" : "light"}
|
||||
color={activeTab === item.key ? "primary" : "default"}
|
||||
startContent={item.icon}
|
||||
className="w-full h-auto p-4"
|
||||
onPress={() => onTabNavigate?.(item.key)}
|
||||
isIconOnly
|
||||
></Button>
|
||||
</Tooltip>
|
||||
</React.Fragment>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<Divider className="my-2" />
|
||||
|
||||
<div className="space-y-2">
|
||||
<Tooltip
|
||||
content={t("Discord")}
|
||||
closeDelay={0}
|
||||
disableAnimation
|
||||
placement="right"
|
||||
>
|
||||
<Button
|
||||
variant="light"
|
||||
startContent={<FaDiscord size={18} />}
|
||||
className="w-full h-auto p-4"
|
||||
onPress={() => {
|
||||
window.open("https://discord.gg/cyZfcdCXkW", "_blank");
|
||||
}}
|
||||
isIconOnly
|
||||
></Button>
|
||||
</Tooltip>
|
||||
|
||||
{/* Logout */}
|
||||
<Tooltip
|
||||
content={t("Log Out")}
|
||||
closeDelay={0}
|
||||
disableAnimation
|
||||
placement="right"
|
||||
>
|
||||
<Button
|
||||
variant="light"
|
||||
color="danger"
|
||||
startContent={<LogOut size={18} />}
|
||||
className="w-full h-auto p-4"
|
||||
onPress={onLogout}
|
||||
isIconOnly
|
||||
></Button>
|
||||
</Tooltip>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Sub Menu Panel */}
|
||||
{(() => {
|
||||
const activeItem = sidebarItems.find((item) => item.key === activeTab);
|
||||
if (!activeItem?.subItems?.length) return null;
|
||||
|
||||
return (
|
||||
<div className="relative bg-content2/50 border-r overflow-hidden w-[240px] p-3">
|
||||
<div className="mb-3 pb-2 border-b">
|
||||
<h4 className="font-medium text-sm text-default-700">
|
||||
{t(activeItem.label)}
|
||||
</h4>
|
||||
<p className="text-xs text-default-500 mt-1">
|
||||
{t(activeItem.description)}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="space-y-1">
|
||||
{activeItem.subItems?.map((subItem) => {
|
||||
const isSubActive = activeSubTab === subItem.key;
|
||||
|
||||
return (
|
||||
<React.Fragment key={subItem.key}>
|
||||
<Button
|
||||
key={subItem.key}
|
||||
variant={isSubActive ? "flat" : "light"}
|
||||
color={isSubActive ? "primary" : "default"}
|
||||
size="sm"
|
||||
className={`w-full justify-start h-auto p-2 text-left ${
|
||||
isSubActive
|
||||
? "bg-primary/10 border border-primary/20"
|
||||
: "hover:bg-default-100"
|
||||
}`}
|
||||
onPress={() =>
|
||||
handleSubItemClick(activeItem.key, subItem.key)
|
||||
}
|
||||
>
|
||||
<div className="flex flex-col items-start w-full">
|
||||
<div className="font-medium text-xs">
|
||||
{t(subItem.label)}
|
||||
</div>
|
||||
{subItem.description && (
|
||||
<div className="text-xs opacity-60 mt-0.5 truncate w-full">
|
||||
{t(subItem.description)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</Button>
|
||||
</React.Fragment>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})()}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ConsoleSidebar;
|
||||
@@ -1,121 +0,0 @@
|
||||
'use client';
|
||||
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Input, Button, AccordionItem, Accordion } from '@nextui-org/react';
|
||||
import { Eye, EyeOff } from 'lucide-react';
|
||||
import { StripeConfig } from '@/types/payment';
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
|
||||
interface StripeConfigFormProps {
|
||||
config: StripeConfig;
|
||||
onSave: (config: StripeConfig) => void;
|
||||
onTest: (config: StripeConfig) => void;
|
||||
isLoading?: boolean;
|
||||
isTestLoading?: boolean;
|
||||
}
|
||||
|
||||
export const StripeConfigForm: React.FC<StripeConfigFormProps> = ({
|
||||
config,
|
||||
onSave,
|
||||
isLoading = false,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const [formData, setFormData] = useState<StripeConfig>(config);
|
||||
const [showSecretKey, setShowSecretKey] = useState(false);
|
||||
const [showWebhookSecret, setShowWebhookSecret] = useState(false);
|
||||
useEffect(() => {
|
||||
console.log("config", config);
|
||||
setFormData(config);
|
||||
}, [config]);
|
||||
|
||||
const handleInputChange = (field: keyof StripeConfig, value: string) => {
|
||||
setFormData(prev => ({
|
||||
...prev,
|
||||
[field]: value
|
||||
}));
|
||||
};
|
||||
|
||||
const handleSave = () => {
|
||||
onSave(formData);
|
||||
};
|
||||
|
||||
|
||||
const isFormValid = formData.secret.trim() !== '' && formData.webhook_secret.trim() !== '';
|
||||
|
||||
return (
|
||||
<Accordion variant='splitted' itemClasses={{
|
||||
base: 'shadow-none border-1',
|
||||
}} defaultExpandedKeys={['stripe-config']} className='px-0'>
|
||||
<AccordionItem key="stripe-config" title={
|
||||
<div className="flex flex-col justify-between">
|
||||
<h3 className="text-lg font-semibold">{t('Stripe Configuration')}</h3>
|
||||
<p className="text-sm text-gray-500">{t('Configure Stripe payment interface')}</p>
|
||||
</div>
|
||||
} >
|
||||
<div className="space-y-4">
|
||||
{/* Secret Key */}
|
||||
<Input
|
||||
label={t('Secret Key')}
|
||||
placeholder="sk_test_... or sk_live_..."
|
||||
description={t('Stripe secret key for server-side API calls')}
|
||||
value={formData.secret}
|
||||
onChange={(e) => handleInputChange('secret', e.target.value)}
|
||||
type={showSecretKey ? "text" : "password"}
|
||||
endContent={
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setShowSecretKey(!showSecretKey)}
|
||||
className="focus:outline-none"
|
||||
>
|
||||
{showSecretKey ? (
|
||||
<EyeOff className="w-4 h-4 text-gray-400" />
|
||||
) : (
|
||||
<Eye className="w-4 h-4 text-gray-400" />
|
||||
)}
|
||||
</button>
|
||||
}
|
||||
isRequired
|
||||
/>
|
||||
|
||||
{/* Webhook Secret (Optional) */}
|
||||
<Input
|
||||
label={t('Webhook Secret')}
|
||||
placeholder="whsec_..."
|
||||
description={t('Webhook signing secret for verifying Stripe events')}
|
||||
value={formData.webhook_secret || ''}
|
||||
onChange={(e) => handleInputChange('webhook_secret', e.target.value)}
|
||||
type={showWebhookSecret ? "text" : "password"}
|
||||
isRequired
|
||||
endContent={
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setShowWebhookSecret(!showWebhookSecret)}
|
||||
className="focus:outline-none"
|
||||
>
|
||||
{showWebhookSecret ? (
|
||||
<EyeOff className="w-4 h-4 text-gray-400" />
|
||||
) : (
|
||||
<Eye className="w-4 h-4 text-gray-400" />
|
||||
)}
|
||||
</button>
|
||||
}
|
||||
/>
|
||||
</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>
|
||||
</div>
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
);
|
||||
};
|
||||
@@ -1,18 +1,33 @@
|
||||
"use client";
|
||||
|
||||
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 { HomepageSettings } from "@/components/system-setting/HomepageSettings";
|
||||
import { AboutPageSettings } from "@/components/system-setting/AboutPageSettings";
|
||||
import { EmailAndAdminSettings } from "@/components/system-setting/EmailAndAdminSettings";
|
||||
import { useSystemConfigManagement } from "@/hooks/useSystemConfigManagement";
|
||||
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
|
||||
import { Theme } from "@/shared/types/system";
|
||||
import i18n from "@/shared/lib/i18n";
|
||||
import { PlatformConfigForm } from "../system-setting/PlatformConfigForm";
|
||||
import DashboardDemoContent from "@/shared/components/DashboardDemoContent";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { SidebarSubItem, TabKey } from "@/shared/types/dashboard";
|
||||
import { LoginSettingsContent } from "./LoginSettingsContent";
|
||||
|
||||
export const SystemSettingsContent: React.FC = () => {
|
||||
interface SystemSettingsContentProps {
|
||||
activeSubTab?: string;
|
||||
subTab?: SidebarSubItem;
|
||||
onTabNavigate: (tab: TabKey, subTab?: string) => void;
|
||||
}
|
||||
|
||||
export const SystemSettingsContent: React.FC<SystemSettingsContentProps> = ({
|
||||
activeSubTab,
|
||||
subTab,
|
||||
onTabNavigate,
|
||||
}) => {
|
||||
const { updateClientConfig } = usePlatformConfig();
|
||||
const [isAboutLoading, setIsAboutLoading] = useState(false);
|
||||
|
||||
const { t } = useTranslation();
|
||||
const {
|
||||
// platform config
|
||||
platformConfig,
|
||||
@@ -31,6 +46,10 @@ export const SystemSettingsContent: React.FC = () => {
|
||||
|
||||
// image upload
|
||||
uploadImage,
|
||||
|
||||
// login config
|
||||
loginConfig,
|
||||
saveLoginConfig,
|
||||
} = useSystemConfigManagement();
|
||||
|
||||
// save admin config
|
||||
@@ -77,33 +96,60 @@ export const SystemSettingsContent: React.FC = () => {
|
||||
});
|
||||
};
|
||||
|
||||
// Render content based on active sub tab
|
||||
const renderSubTabContent = () => {
|
||||
switch (activeSubTab) {
|
||||
case "homepage":
|
||||
return <HomepageSettings />;
|
||||
case "about-page":
|
||||
return (
|
||||
<AboutPageSettings
|
||||
config={platformConfig}
|
||||
onAboutSave={handleAboutSave}
|
||||
onImageUpload={uploadImage}
|
||||
isAboutLoading={isAboutLoading}
|
||||
/>
|
||||
);
|
||||
case "email-admin":
|
||||
return (
|
||||
<EmailAndAdminSettings
|
||||
emailConfig={emailConfig}
|
||||
adminConfig={adminConfig}
|
||||
onSaveEmailConfig={handleSaveEmailConfig}
|
||||
onSaveAdminConfig={handleSaveAdminConfig}
|
||||
isLoading={emailLoading}
|
||||
isAdminLoading={adminLoading}
|
||||
/>
|
||||
);
|
||||
case "login-settings":
|
||||
return (
|
||||
<LoginSettingsContent
|
||||
onTabNavigate={onTabNavigate}
|
||||
loginConfig={loginConfig}
|
||||
saveLoginConfig={saveLoginConfig}
|
||||
emailConfig={emailConfig}
|
||||
/>
|
||||
);
|
||||
case "general":
|
||||
default:
|
||||
return (
|
||||
<PlatformConfigForm
|
||||
config={platformConfig}
|
||||
onSave={handleSavePlatformConfig}
|
||||
onThemeChange={handleThemeChange}
|
||||
isLoading={platformLoading}
|
||||
/>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-6 w-full">
|
||||
{/* platform config */}
|
||||
<PlatformConfigForm
|
||||
config={platformConfig}
|
||||
onSave={handleSavePlatformConfig}
|
||||
onThemeChange={handleThemeChange}
|
||||
onAboutSave={handleAboutSave}
|
||||
isLoading={platformLoading}
|
||||
isAboutLoading={isAboutLoading}
|
||||
onImageUpload={uploadImage}
|
||||
/>
|
||||
|
||||
{/* admin config */}
|
||||
<AdminConfigForm
|
||||
config={adminConfig}
|
||||
onSave={handleSaveAdminConfig}
|
||||
isLoading={adminLoading}
|
||||
/>
|
||||
|
||||
{/* email config */}
|
||||
<EmailConfigForm
|
||||
config={emailConfig}
|
||||
onSave={handleSaveEmailConfig}
|
||||
isLoading={emailLoading}
|
||||
/>
|
||||
</div>
|
||||
<DashboardDemoContent
|
||||
title={t(subTab?.label || "System Settings")}
|
||||
description={t(subTab?.description || "Platform basic configuration")}
|
||||
>
|
||||
{renderSubTabContent()}
|
||||
</DashboardDemoContent>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user