feat:1.1 UI/UX
This commit is contained in:
1 parent
3c9b037ba7
commit
521c1b7a07
163 files changed
+8325
-2918
No files matched your search
@@ -0,0 +1,138 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState } from "react";
|
||||
import { Input, Button } from "@nextui-org/react";
|
||||
import { Eye, EyeOff } from "lucide-react";
|
||||
import { AdminConfig } from "@/types/system";
|
||||
import { z } from "zod";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
|
||||
const formSchema = z.object({
|
||||
password: z
|
||||
.string()
|
||||
.min(1, "Password is required")
|
||||
.max(100, "Password is too long")
|
||||
.min(8, "Password must be at least 8 characters"),
|
||||
confirmPassword: z
|
||||
.string()
|
||||
.min(1, "Confirm password is required")
|
||||
.max(100, "Confirm password is too long")
|
||||
.min(8, "Confirm password must be at least 8 characters"),
|
||||
});
|
||||
type FormData = z.infer<typeof formSchema>;
|
||||
|
||||
interface AdminConfigFormProps {
|
||||
onSave: (config: AdminConfig) => Promise<boolean>;
|
||||
}
|
||||
|
||||
export const AdminConfigForm: React.FC<AdminConfigFormProps> = ({ onSave }) => {
|
||||
const { t } = useTranslation();
|
||||
const {
|
||||
handleSubmit,
|
||||
control,
|
||||
watch,
|
||||
formState: { errors, isSubmitting, isValid },
|
||||
} = useForm<FormData>({
|
||||
resolver: zodResolver(formSchema),
|
||||
mode: "onBlur",
|
||||
});
|
||||
const [showPassword, setShowPassword] = useState(false);
|
||||
const [showConfirmPassword, setShowConfirmPassword] = useState(false);
|
||||
|
||||
const onSubmit = async (data: FormData) => {
|
||||
await onSave({
|
||||
password: data.password,
|
||||
} as AdminConfig);
|
||||
};
|
||||
const passwordsMatch = watch("password") === watch("confirmPassword");
|
||||
|
||||
return (
|
||||
<form
|
||||
onSubmit={handleSubmit(onSubmit)}
|
||||
className="flex flex-col gap-4 pb-4"
|
||||
>
|
||||
<Controller
|
||||
name="password"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<Input
|
||||
{...field}
|
||||
label={t("Administrator Password")}
|
||||
placeholder={t("Enter administrator password")}
|
||||
description={t("Password must be at least 8 characters long")}
|
||||
isInvalid={!!errors.password}
|
||||
errorMessage={errors.password?.message}
|
||||
type={showPassword ? "text" : "password"}
|
||||
endContent={
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setShowPassword(!showPassword)}
|
||||
className="focus:outline-none"
|
||||
>
|
||||
{showPassword ? (
|
||||
<EyeOff className="w-4 h-4 text-gray-400" />
|
||||
) : (
|
||||
<Eye className="w-4 h-4 text-gray-400" />
|
||||
)}
|
||||
</button>
|
||||
}
|
||||
isRequired
|
||||
autoComplete="new-password"
|
||||
labelPlacement="outside"
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
<Controller
|
||||
name="confirmPassword"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<Input
|
||||
{...field}
|
||||
label={t("Confirm Password")}
|
||||
placeholder={t("Confirm administrator password")}
|
||||
description={t("Re-enter the password to confirm")}
|
||||
isInvalid={
|
||||
!!errors.confirmPassword ||
|
||||
(!passwordsMatch && (field.value?.length || 0) > 0)
|
||||
}
|
||||
errorMessage={
|
||||
errors.confirmPassword?.message || t("Passwords do not match")
|
||||
}
|
||||
type={showConfirmPassword ? "text" : "password"}
|
||||
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>
|
||||
}
|
||||
autoComplete="new-password"
|
||||
isRequired
|
||||
labelPlacement="outside"
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
|
||||
<div className="flex mt-2">
|
||||
<Button
|
||||
type="submit"
|
||||
color="primary"
|
||||
isLoading={isSubmitting}
|
||||
isDisabled={!isValid}
|
||||
className="w-fit"
|
||||
size="sm"
|
||||
>
|
||||
{t("Save")}
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
);
|
||||
};
|
||||
@@ -1,5 +0,0 @@
|
||||
.xpack-console-stats-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
|
||||
max-width: 100%;
|
||||
}
|
||||
@@ -1,105 +1,318 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { overviewService } from "@/services/overviewService";
|
||||
import { PlatformOverviewData } from "@/types/dashboard";
|
||||
import "./ConsoleStats.css"
|
||||
import { Alert, Card, CardBody, CardFooter } from "@nextui-org/react";
|
||||
import React, { useMemo, useState, useEffect } from "react";
|
||||
import {
|
||||
Card,
|
||||
CardBody,
|
||||
CardHeader,
|
||||
Tabs,
|
||||
Tab,
|
||||
Listbox,
|
||||
ListboxItem,
|
||||
Skeleton,
|
||||
} from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { ChartBarIcon, DollarSignIcon, ServerIcon, UserIcon } from "lucide-react";
|
||||
import {
|
||||
LineChart,
|
||||
Line,
|
||||
XAxis,
|
||||
YAxis,
|
||||
CartesianGrid,
|
||||
Tooltip,
|
||||
ResponsiveContainer,
|
||||
} from "recharts";
|
||||
import {
|
||||
getAdminAnalytics,
|
||||
AdminAnalyticsData,
|
||||
TopServiceItem,
|
||||
} from "@/api/adminAnalytics.api";
|
||||
import toast from "react-hot-toast";
|
||||
|
||||
interface StatCardProps {
|
||||
title: string;
|
||||
value: string | number;
|
||||
icon: React.ReactNode;
|
||||
description?: string;
|
||||
// Chart data interface to match existing chart component
|
||||
interface ChartDataItem {
|
||||
date: string;
|
||||
users: number;
|
||||
revenue: number;
|
||||
calls: number;
|
||||
}
|
||||
|
||||
const StatCard: React.FC<StatCardProps> = ({ title, value, icon, description }) => {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Card shadow="none" className="border-1">
|
||||
<CardBody>
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex-1">
|
||||
<p className="text-sm font-medium text-gray-600 mb-1">{t(title)}</p>
|
||||
<p className="text-2xl font-bold text-gray-900">{value}</p>
|
||||
</div>
|
||||
<div className="ml-4 text-blue-500">
|
||||
{icon}
|
||||
</div>
|
||||
</div>
|
||||
</CardBody>
|
||||
<CardFooter>
|
||||
{description && (
|
||||
<p className="text-xs text-gray-500 mt-1">{t(description)}</p>
|
||||
)}
|
||||
</CardFooter>
|
||||
</Card>
|
||||
// Transform API data to chart format
|
||||
const transformToChartData = (
|
||||
analytics: AdminAnalyticsData
|
||||
): ChartDataItem[] => {
|
||||
// Get the maximum length of days arrays to handle potential mismatches
|
||||
const maxLength = Math.max(
|
||||
analytics.user_register.days.length,
|
||||
analytics.user_pay.days.length,
|
||||
analytics.mcp_call.days.length
|
||||
);
|
||||
|
||||
const chartData: ChartDataItem[] = [];
|
||||
|
||||
for (let i = 0; i < maxLength; i++) {
|
||||
// Format date for display (converting from YYYY-MM-DD to MMM DD)
|
||||
const userRegDay = analytics.user_register.days[i];
|
||||
const payDay = analytics.user_pay.days[i];
|
||||
const callDay = analytics.mcp_call.days[i];
|
||||
|
||||
// Use the first available date, format it nicely
|
||||
const rawDate =
|
||||
userRegDay?.stats_day || payDay?.stats_day || callDay?.stats_day;
|
||||
const formattedDate = rawDate
|
||||
? new Date(rawDate).toLocaleDateString("en-US", {
|
||||
month: "short",
|
||||
day: "numeric",
|
||||
})
|
||||
: `Day ${i + 1}`;
|
||||
|
||||
chartData.push({
|
||||
date: formattedDate,
|
||||
users: userRegDay ? parseInt(userRegDay.count as string) || 0 : 0,
|
||||
revenue: payDay ? payDay.count : 0,
|
||||
calls: callDay ? callDay.count : 0,
|
||||
});
|
||||
}
|
||||
|
||||
return chartData;
|
||||
};
|
||||
|
||||
// Render label + total value in tab header
|
||||
const TabTitle: React.FC<{
|
||||
label: string;
|
||||
total: number | string;
|
||||
}> = ({ label, total }) => (
|
||||
<div className="flex flex-col items-start gap-2">
|
||||
<div className="text-sm text-default-500">{label}</div>
|
||||
<div className="text-2xl font-semibold text-default-900">
|
||||
{typeof total === "number" ? total.toLocaleString() : total}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
const ConsoleStats: React.FC = () => {
|
||||
const { t } = useTranslation();
|
||||
const [overviewData, setOverviewData] = useState<PlatformOverviewData | null>(null);
|
||||
const fetchOverviewData = async () => {
|
||||
try {
|
||||
const data = await overviewService.getPlatformOverview();
|
||||
setOverviewData(data);
|
||||
} catch (err) {
|
||||
console.error('Failed to fetch overview data:', err);
|
||||
} finally {
|
||||
}
|
||||
};
|
||||
// get platform overview data
|
||||
const [activeTab, setActiveTab] = useState<string>("users");
|
||||
|
||||
// State for API data
|
||||
const [analyticsData, setAnalyticsData] = useState<AdminAnalyticsData | null>(
|
||||
null
|
||||
);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
// Fetch analytics data on component mount
|
||||
useEffect(() => {
|
||||
fetchOverviewData();
|
||||
const fetchData = async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const response = await getAdminAnalytics();
|
||||
|
||||
if (response.success) {
|
||||
setAnalyticsData(response.data);
|
||||
} else {
|
||||
toast.error(
|
||||
response.error_message || "Failed to load analytics data"
|
||||
);
|
||||
}
|
||||
} catch (err) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
fetchData();
|
||||
}, []);
|
||||
|
||||
// Transform API data to chart format
|
||||
const chartData = useMemo<ChartDataItem[]>(() => {
|
||||
if (!analyticsData) return [];
|
||||
return transformToChartData(analyticsData);
|
||||
}, [analyticsData]);
|
||||
|
||||
// Format revenue as currency (USD by default)
|
||||
const formatCurrency = (value: number, currency: string = "USD") =>
|
||||
new Intl.NumberFormat("en-US", { style: "currency", currency }).format(
|
||||
value
|
||||
);
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="w-full flex flex-col gap-4 h-full">
|
||||
<Skeleton className="rounded-lg" isLoaded={!loading}>
|
||||
<div className="h-24 rounded-lg bg-secondary" />
|
||||
</Skeleton>
|
||||
<div className="flex flex-col gap-3">
|
||||
<Skeleton className="w-3/5 rounded-lg" isLoaded={!loading}>
|
||||
<div className="h-3 w-full rounded-lg bg-secondary" />
|
||||
</Skeleton>
|
||||
<Skeleton className="w-4/5 rounded-lg" isLoaded={!loading}>
|
||||
<div className="h-3 w-full rounded-lg bg-secondary-300" />
|
||||
</Skeleton>
|
||||
<Skeleton className="w-2/5 rounded-lg" isLoaded={!loading}>
|
||||
<div className="h-3 w-full rounded-lg bg-secondary-200" />
|
||||
</Skeleton>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
{/* stat card grid */}
|
||||
<div className="xpack-console-stats-grid gap-4">
|
||||
<StatCard
|
||||
title="Total Users"
|
||||
value={overviewData?.total_user.toLocaleString() || 0}
|
||||
icon={
|
||||
<UserIcon size={32} />
|
||||
}
|
||||
description="Platform registered users"
|
||||
/>
|
||||
<StatCard
|
||||
title="Total Revenue"
|
||||
value={overviewData?.total_balance.toLocaleString() || 0}
|
||||
icon={
|
||||
<DollarSignIcon size={32} />
|
||||
}
|
||||
description="Platform total fund pool"
|
||||
/>
|
||||
<StatCard
|
||||
title="Today's API Calls"
|
||||
value={overviewData?.invoke_count.today.toLocaleString() || 0}
|
||||
icon={
|
||||
<ChartBarIcon size={32} />
|
||||
}
|
||||
description="API call count"
|
||||
/>
|
||||
{/* Charts with Tabs */}
|
||||
<Card shadow="none" className="border-1">
|
||||
<CardHeader className="p-0 flex items-center justify-between">
|
||||
<Tabs
|
||||
selectedKey={activeTab}
|
||||
onSelectionChange={(key) => setActiveTab(key as string)}
|
||||
variant="underlined"
|
||||
color="primary"
|
||||
classNames={{
|
||||
base: "w-full",
|
||||
tab: "h-fit justify-start border-b-1 p-4",
|
||||
cursor: "w-[90%]",
|
||||
tabList: "w-full gap-0 p-0",
|
||||
}}
|
||||
>
|
||||
<Tab
|
||||
key="users"
|
||||
title={
|
||||
<TabTitle
|
||||
label={t("Daily Registered Users")}
|
||||
total={analyticsData?.user_register.today || 0}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
<Tab
|
||||
key="revenue"
|
||||
title={
|
||||
<TabTitle
|
||||
label={t("Daily Revenue")}
|
||||
total={formatCurrency(analyticsData?.user_pay.today || 0)}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
<Tab
|
||||
key="calls"
|
||||
title={
|
||||
<TabTitle
|
||||
label={t("Daily API Calls")}
|
||||
total={analyticsData?.mcp_call.today || 0}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</Tabs>
|
||||
</CardHeader>
|
||||
<CardBody>
|
||||
<div className="w-full h-[300px]">
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
<LineChart data={chartData}>
|
||||
<CartesianGrid strokeDasharray="3 3" vertical={false} />
|
||||
<XAxis dataKey="date" />
|
||||
<YAxis />
|
||||
<Tooltip
|
||||
labelStyle={{ color: "#374151" }}
|
||||
contentStyle={{
|
||||
backgroundColor: "#f9fafb",
|
||||
border: "1px solid #e5e7eb",
|
||||
borderRadius: "8px",
|
||||
padding: "12px",
|
||||
}}
|
||||
/>
|
||||
{activeTab === "users" && (
|
||||
<Line
|
||||
type="monotone"
|
||||
dataKey="users"
|
||||
stroke="#3b82f6"
|
||||
strokeWidth={2}
|
||||
dot={false}
|
||||
activeDot={{ fill: "#3b82f6", strokeWidth: 2, r: 4 }}
|
||||
/>
|
||||
)}
|
||||
{activeTab === "revenue" && (
|
||||
<Line
|
||||
type="monotone"
|
||||
dataKey="revenue"
|
||||
stroke="#10b981"
|
||||
strokeWidth={2}
|
||||
dot={false}
|
||||
activeDot={{ fill: "#10b981", strokeWidth: 2, r: 4 }}
|
||||
/>
|
||||
)}
|
||||
{activeTab === "calls" && (
|
||||
<Line
|
||||
type="monotone"
|
||||
dataKey="calls"
|
||||
stroke="#f59e0b"
|
||||
strokeWidth={2}
|
||||
dot={false}
|
||||
activeDot={{ fill: "#f59e0b", strokeWidth: 2, r: 4 }}
|
||||
/>
|
||||
)}
|
||||
</LineChart>
|
||||
</ResponsiveContainer>
|
||||
</div>
|
||||
</CardBody>
|
||||
</Card>
|
||||
|
||||
<StatCard
|
||||
title="Total MCP Services"
|
||||
value={overviewData?.total_service.toLocaleString() || 0}
|
||||
icon={
|
||||
<ServerIcon size={32} />
|
||||
}
|
||||
description="Deployed services"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* welcome guide */}
|
||||
<Alert color="primary" title={t("Welcome to XPack.AI Open Source")} description={t("This is your AI service management center. You can quickly view platform core data on the left and manage and configure your MCP services, users, payment channels, etc.")}></Alert>
|
||||
{/* Top Servers List */}
|
||||
<Card shadow="none" className="border-1">
|
||||
<CardHeader className="pb-0 flex items-center justify-between">
|
||||
<h4 className="text-lg font-semibold text-gray-900">
|
||||
{t("Top Servers by Calls")}
|
||||
</h4>
|
||||
</CardHeader>
|
||||
<CardBody>
|
||||
<div>
|
||||
{analyticsData?.top_services?.length ? (
|
||||
<Listbox
|
||||
aria-label="top servers"
|
||||
selectionMode="none"
|
||||
className="overflow-visible p-0"
|
||||
classNames={{ list: "overflow-visible space-y-3" }}
|
||||
>
|
||||
{(analyticsData.top_services || []).map(
|
||||
(service: TopServiceItem, index: number) => (
|
||||
<ListboxItem
|
||||
key={service.id}
|
||||
className="p-3 bg-gray-50 data-[hover=true]:bg-gray-100 cursor-default"
|
||||
classNames={{
|
||||
title: "w-full",
|
||||
}}
|
||||
>
|
||||
<div className="flex items-center justify-between w-full gap-3">
|
||||
<div className="flex items-center justify-center min-w-8 w-8 h-8 bg-blue-100 text-blue-600 rounded-full text-sm font-semibold">
|
||||
{index + 1}
|
||||
</div>
|
||||
<div className="flex flex-col items-start flex-1 overflow-hidden">
|
||||
<span className="truncate w-full">
|
||||
{" "}
|
||||
{service.name}
|
||||
</span>
|
||||
<span className="text-xs text-gray-500 truncate w-full">
|
||||
{service.short_description}
|
||||
</span>
|
||||
</div>
|
||||
<div className="text-right">
|
||||
<div className="text-lg font-semibold text-gray-900">
|
||||
{service.call_count.toLocaleString()}
|
||||
</div>
|
||||
<div className="text-xs text-gray-500">
|
||||
{t("Calls")}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ListboxItem>
|
||||
)
|
||||
)}
|
||||
</Listbox>
|
||||
) : (
|
||||
<div className="text-center py-8 text-gray-500">
|
||||
{t("No servers available")}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</CardBody>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ConsoleStats;
|
||||
export default ConsoleStats;
|
||||
@@ -15,6 +15,7 @@ interface LoginSettingsContentProps {
|
||||
loginConfig: LoginConfig;
|
||||
saveLoginConfig: (config: LoginConfig) => Promise<boolean>;
|
||||
emailConfig: EmailConfig;
|
||||
type?: "email" | "google";
|
||||
}
|
||||
|
||||
export const LoginSettingsContent: React.FC<LoginSettingsContentProps> = ({
|
||||
@@ -22,6 +23,7 @@ export const LoginSettingsContent: React.FC<LoginSettingsContentProps> = ({
|
||||
loginConfig,
|
||||
saveLoginConfig,
|
||||
emailConfig,
|
||||
type = "email",
|
||||
}) => {
|
||||
const [googleSubmitLoading, setGoogleSubmitLoading] = useState(false);
|
||||
const [emailSubmitLoading, setEmailSubmitLoading] = useState(false);
|
||||
@@ -83,20 +85,24 @@ export const LoginSettingsContent: React.FC<LoginSettingsContentProps> = ({
|
||||
return (
|
||||
<div className="space-y-4 w-full">
|
||||
{/* email config */}
|
||||
<EmailConfigForm
|
||||
config={loginConfig}
|
||||
emailConfig={emailConfig}
|
||||
onSave={handleSaveLoginConfig}
|
||||
isLoading={emailSubmitLoading}
|
||||
onTabNavigate={onTabNavigate}
|
||||
/>
|
||||
{type === "email" && (
|
||||
<EmailConfigForm
|
||||
config={loginConfig}
|
||||
emailConfig={emailConfig}
|
||||
onSave={handleSaveLoginConfig}
|
||||
isLoading={emailSubmitLoading}
|
||||
onTabNavigate={onTabNavigate}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* google auth config */}
|
||||
<GoogleAuthConfigForm
|
||||
config={loginConfig.google}
|
||||
onSave={handleSaveGoogleAuthConfig}
|
||||
isLoading={googleSubmitLoading}
|
||||
/>
|
||||
{type === "google" && (
|
||||
<GoogleAuthConfigForm
|
||||
config={loginConfig.google}
|
||||
onSave={handleSaveGoogleAuthConfig}
|
||||
isLoading={googleSubmitLoading}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -1,156 +1,108 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect, useState, Suspense } from "react";
|
||||
import { useRouter, useSearchParams } from "next/navigation";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useSearchParams } from "next/navigation";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { useAdminStore } from "@/store/admin";
|
||||
import DashboardDemoContent from "@/shared/components/DashboardDemoContent";
|
||||
import ConsoleStats from "@/components/console/ConsoleStats";
|
||||
import PaymentChannelsContent from "@/components/console/PaymentChannelsContent";
|
||||
import SystemSettingsContent from "@/components/console/SystemSettingsContent";
|
||||
import { SidebarItem, TabKey } from "@/shared/types/dashboard";
|
||||
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 {
|
||||
CreditCard,
|
||||
DollarSign,
|
||||
Home,
|
||||
Settings,
|
||||
Users,
|
||||
ServerIcon,
|
||||
} from "lucide-react";
|
||||
import ConsoleSidebar from "./Sidebar";
|
||||
import { withComponentInjection } from "@/shared/hooks/useComponentInjection";
|
||||
import { DollarSign, Home, ServerIcon, Users } from "lucide-react";
|
||||
import OnboardingWelcome, { REQUIRED_TASK_KEYS } from "./OnboardingWelcome";
|
||||
import ConsoleStats from "./ConsoleStats";
|
||||
import SystemSettingsModal from "./SystemSettingsModal";
|
||||
import SharePlatformModal from "./SharePlatformModal";
|
||||
import {
|
||||
OnboardingTaskKey,
|
||||
TaskItem,
|
||||
TaskStatusEnum,
|
||||
updateAdminOnboardingTasks,
|
||||
} from "@/api/onboard.api";
|
||||
|
||||
const ConsoleContent: React.FC = () => {
|
||||
const { t } = useTranslation();
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
const [admin_token] = useAdminStore((state) => [state.admin_token]);
|
||||
|
||||
const _DefaultSubTab = "general";
|
||||
const [admin_token, getAdminUser] = useAdminStore((state) => [
|
||||
state.admin_token,
|
||||
state.getAdminUser,
|
||||
]);
|
||||
|
||||
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)
|
||||
["mcp-services", "user-management", "revenue-management"].includes(
|
||||
tabFromUrl
|
||||
)
|
||||
) {
|
||||
return tabFromUrl;
|
||||
}
|
||||
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 isSkipOnboarding =
|
||||
typeof window !== "undefined" &&
|
||||
localStorage.getItem("admin_onboarding_skip") === "1";
|
||||
const [showOnboarding, setShowOnboarding] = useState<boolean>(false);
|
||||
const [completedTasks, setCompletedTasks] = useState<string[]>([]);
|
||||
const [isSettingsModalOpen, setIsSettingsModalOpen] =
|
||||
useState<boolean>(false);
|
||||
const [isShareModalOpen, setIsShareModalOpen] = useState<boolean>(false);
|
||||
const [settingModalKeyword, setSettingModalKeyword] = useState<string>("");
|
||||
const sidebarItems: SidebarItem[] = [
|
||||
{
|
||||
key: TabKey.CONSOLE,
|
||||
icon: <Home size={18} />,
|
||||
label: t("Dashboard"),
|
||||
description: t("Overview and analytics"),
|
||||
label: t("Analytics"),
|
||||
description: t("Analyze platform usage and revenue"),
|
||||
},
|
||||
{
|
||||
key: TabKey.MCP_SERVICES,
|
||||
icon: <ServerIcon size={18} />,
|
||||
label: t("MCP Services"),
|
||||
description: t("Manage MCP services and API tools"),
|
||||
label: t("MCP"),
|
||||
description: t("Manage MCP servers and API tools"),
|
||||
},
|
||||
{
|
||||
key: TabKey.USER_MANAGEMENT,
|
||||
icon: <Users size={18} />,
|
||||
label: t("User Management"),
|
||||
label: t("User"),
|
||||
description: t("Manage registered users"),
|
||||
},
|
||||
{
|
||||
key: TabKey.REVENUE_MANAGEMENT,
|
||||
icon: <DollarSign size={18} />,
|
||||
label: t("Revenue Management"),
|
||||
label: t("Revenue"),
|
||||
description: t("View user recharge history"),
|
||||
},
|
||||
{
|
||||
key: TabKey.PAYMENT_CHANNELS,
|
||||
icon: <CreditCard size={18} />,
|
||||
label: t("Payment Channels"),
|
||||
description: t("Configure payment channels"),
|
||||
},
|
||||
{
|
||||
key: TabKey.SYSTEM_SETTINGS,
|
||||
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",
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
// If admin is not logged in, redirect to admin login page
|
||||
useEffect(() => {
|
||||
if (!admin_token) {
|
||||
router.push("/admin");
|
||||
window.location.href =
|
||||
process.env.NEXT_PUBLIC_ADMIN_LOGIN_URL || "/admin";
|
||||
}
|
||||
}, [admin_token, router]);
|
||||
}, [admin_token]);
|
||||
|
||||
const handleTabNavigate = (tab: TabKey, subTab?: string) => {
|
||||
setActiveTab(tab);
|
||||
setActiveSubTab(subTab || _DefaultSubTab);
|
||||
const handleTabNavigate = (tab: TabKey | string, _subTab?: string) => {
|
||||
setActiveTab(tab as TabKey);
|
||||
|
||||
// update url params
|
||||
if (tab === TabKey.CONSOLE) {
|
||||
// when switch to dashboard, clear all query params, only keep base path
|
||||
router.push("/console", { scroll: false });
|
||||
window.history.pushState({}, "", "/admin/console");
|
||||
} else {
|
||||
// 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 });
|
||||
window.history.pushState({}, "", `/admin/console?${params.toString()}`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -161,6 +113,94 @@ const ConsoleContent: React.FC = () => {
|
||||
adminLogout();
|
||||
};
|
||||
|
||||
const handleSettingsClick = () => {
|
||||
setIsSettingsModalOpen(true);
|
||||
};
|
||||
|
||||
const handleSettingsModalClose = () => {
|
||||
setIsSettingsModalOpen(false);
|
||||
setSettingModalKeyword("");
|
||||
};
|
||||
const initOnboarding = async () => {
|
||||
const res = await getAdminUser();
|
||||
if (!res.success) {
|
||||
adminLogout();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const completedTasks: string[] = (res.data.onboarding_tasks || [])
|
||||
.filter(
|
||||
(task: TaskItem) => task.task_status === TaskStatusEnum.COMPLETED
|
||||
)
|
||||
.map((task: TaskItem) => task.task_id);
|
||||
setCompletedTasks(completedTasks);
|
||||
setShowOnboarding(completedTasks.length !== REQUIRED_TASK_KEYS.length);
|
||||
} catch (e) {
|
||||
// Fallback to show onboarding if localStorage not available
|
||||
setShowOnboarding(false);
|
||||
}
|
||||
};
|
||||
//todo: onboarding
|
||||
// Initialize onboarding state from localStorage
|
||||
useEffect(() => {
|
||||
if (isSkipOnboarding) {
|
||||
setShowOnboarding(false);
|
||||
return;
|
||||
}
|
||||
initOnboarding();
|
||||
}, []);
|
||||
|
||||
const handleSkipOnboarding = () => {
|
||||
localStorage.setItem("admin_onboarding_skip", "1");
|
||||
setShowOnboarding(false);
|
||||
};
|
||||
|
||||
const markTaskAsCompleted = async (taskKey: OnboardingTaskKey) => {
|
||||
// Mark task as completed
|
||||
const next = Array.from(new Set([...completedTasks, taskKey]));
|
||||
setCompletedTasks(next);
|
||||
const result = await updateAdminOnboardingTasks({
|
||||
task_id: taskKey,
|
||||
task_status: TaskStatusEnum.COMPLETED,
|
||||
});
|
||||
if (!result) return;
|
||||
|
||||
if (next.length === REQUIRED_TASK_KEYS.length) {
|
||||
localStorage.setItem("admin_onboarding_skip", "1");
|
||||
setShowOnboarding(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleTaskClick = async (taskKey: OnboardingTaskKey) => {
|
||||
switch (taskKey) {
|
||||
case OnboardingTaskKey.PLATFORM_SETUP:
|
||||
setIsSettingsModalOpen(true);
|
||||
await markTaskAsCompleted(taskKey);
|
||||
break;
|
||||
case OnboardingTaskKey.MCP_SERVICES:
|
||||
handleTabNavigate(TabKey.MCP_SERVICES);
|
||||
await markTaskAsCompleted(taskKey);
|
||||
break;
|
||||
case OnboardingTaskKey.REVENUE_MANAGEMENT:
|
||||
setSettingModalKeyword("Payment");
|
||||
setIsSettingsModalOpen(true);
|
||||
await markTaskAsCompleted(taskKey);
|
||||
break;
|
||||
case OnboardingTaskKey.SHARE_PLATFORM:
|
||||
setIsShareModalOpen(true);
|
||||
// 不在这里标记完成,等待实际分享后再标记
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
const handleShareComplete = async () => {
|
||||
await markTaskAsCompleted(OnboardingTaskKey.SHARE_PLATFORM);
|
||||
};
|
||||
|
||||
const handleShareModalClose = () => {
|
||||
setIsShareModalOpen(false);
|
||||
};
|
||||
|
||||
// render different content based on activeTab
|
||||
const renderContent = () => {
|
||||
switch (activeTab) {
|
||||
@@ -178,30 +218,24 @@ const ConsoleContent: React.FC = () => {
|
||||
<RevenueManagement />
|
||||
</div>
|
||||
);
|
||||
case TabKey.PAYMENT_CHANNELS:
|
||||
return (
|
||||
<DashboardDemoContent
|
||||
title={t("Payment Channels")}
|
||||
description={t("Configure payment channels")}
|
||||
>
|
||||
<PaymentChannelsContent />
|
||||
</DashboardDemoContent>
|
||||
);
|
||||
case "system-settings":
|
||||
return (
|
||||
<SystemSettingsContent
|
||||
activeSubTab={activeSubTab}
|
||||
subTab={sidebarItems
|
||||
.find((item) => item.key === activeTab)
|
||||
?.subItems?.find((item) => item.key === activeSubTab)}
|
||||
onTabNavigate={handleTabNavigate}
|
||||
/>
|
||||
);
|
||||
default:
|
||||
return (
|
||||
return showOnboarding ? (
|
||||
<OnboardingWelcome
|
||||
onSkipOnboarding={handleSkipOnboarding}
|
||||
onTaskClick={handleTaskClick}
|
||||
completedTasks={completedTasks}
|
||||
/>
|
||||
) : (
|
||||
<DashboardDemoContent
|
||||
title={t("Admin Dashboard")}
|
||||
description={t("Platform management and analytics")}
|
||||
title={
|
||||
<div className="flex items-center gap-2">
|
||||
<span>{t("Analytics")}</span>
|
||||
<span className="text-primary text-lg font-medium">
|
||||
{t("(30 days)")}
|
||||
</span>
|
||||
</div>
|
||||
}
|
||||
description={t("Analyze platform usage and revenue")}
|
||||
>
|
||||
<ConsoleStats />
|
||||
</DashboardDemoContent>
|
||||
@@ -215,15 +249,33 @@ const ConsoleContent: React.FC = () => {
|
||||
{/* Sidebar */}
|
||||
<ConsoleSidebar
|
||||
activeTab={activeTab}
|
||||
activeSubTab={activeSubTab}
|
||||
onTabNavigate={handleTabNavigate}
|
||||
onLogout={handleLogout}
|
||||
sidebarItems={sidebarItems}
|
||||
onSettingsClick={handleSettingsClick}
|
||||
/>
|
||||
|
||||
{/* Main Content */}
|
||||
<div className="flex-1 h-screen overflow-y-auto">{renderContent()}</div>
|
||||
</div>
|
||||
|
||||
{/* Settings Modal */}
|
||||
{isSettingsModalOpen && (
|
||||
<SystemSettingsModal
|
||||
isOpen={true}
|
||||
onClose={handleSettingsModalClose}
|
||||
keyword={settingModalKeyword}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Share Platform Modal */}
|
||||
{isShareModalOpen && (
|
||||
<SharePlatformModal
|
||||
isOpen={true}
|
||||
onClose={handleShareModalClose}
|
||||
onShareComplete={handleShareComplete}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -244,4 +296,8 @@ const ConsoleMain: React.FC = () => {
|
||||
);
|
||||
};
|
||||
|
||||
export default ConsoleMain;
|
||||
// Export the base component for direct use
|
||||
export { ConsoleMain as ConsoleMainBase };
|
||||
|
||||
// Export with component injection support
|
||||
export default withComponentInjection("console/Main", ConsoleMain);
|
||||
@@ -0,0 +1,180 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect, useState } from "react";
|
||||
import {
|
||||
CheckCircle2,
|
||||
Share2,
|
||||
ArrowRight,
|
||||
Settings,
|
||||
ServerIcon,
|
||||
DollarSign,
|
||||
} from "lucide-react";
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
CardBody,
|
||||
Listbox,
|
||||
ListboxItem,
|
||||
Link,
|
||||
} from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
|
||||
import { OnboardingTaskKey } from "@/api/onboard.api";
|
||||
|
||||
export const REQUIRED_TASK_KEYS = [
|
||||
OnboardingTaskKey.PLATFORM_SETUP,
|
||||
OnboardingTaskKey.MCP_SERVICES,
|
||||
OnboardingTaskKey.REVENUE_MANAGEMENT,
|
||||
OnboardingTaskKey.SHARE_PLATFORM,
|
||||
];
|
||||
interface OnboardingWelcomeProps {
|
||||
onSkipOnboarding: () => void;
|
||||
completedTasks: string[];
|
||||
onTaskClick: (taskKey: OnboardingTaskKey) => void;
|
||||
}
|
||||
const OnboardingWelcome: React.FC<OnboardingWelcomeProps> = ({
|
||||
onSkipOnboarding,
|
||||
completedTasks,
|
||||
onTaskClick,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { platformConfig } = usePlatformConfig();
|
||||
const [activeTab, setActiveTab] = useState<OnboardingTaskKey | undefined>(
|
||||
REQUIRED_TASK_KEYS.find((task) => !completedTasks.includes(task))
|
||||
);
|
||||
useEffect(() => {
|
||||
setActiveTab(
|
||||
REQUIRED_TASK_KEYS.find((task) => !completedTasks.includes(task))
|
||||
);
|
||||
}, [completedTasks]);
|
||||
|
||||
const tasks = [
|
||||
{
|
||||
key: OnboardingTaskKey.PLATFORM_SETUP,
|
||||
title: t("Configure Platform Settings"),
|
||||
subtitle: t("Set up your platform name, domain, and branding."),
|
||||
icon: <Settings size={18} />,
|
||||
},
|
||||
{
|
||||
key: OnboardingTaskKey.MCP_SERVICES,
|
||||
title: t("Add MCP Services"),
|
||||
subtitle: t("Configure and deploy your first MCP server tools."),
|
||||
icon: <ServerIcon size={18} />,
|
||||
},
|
||||
{
|
||||
key: OnboardingTaskKey.REVENUE_MANAGEMENT,
|
||||
title: t("Configure Payment & Billing"),
|
||||
subtitle: t("Set up payment channels and token pricing."),
|
||||
icon: <DollarSign size={18} />,
|
||||
},
|
||||
{
|
||||
key: OnboardingTaskKey.SHARE_PLATFORM,
|
||||
title: t("Share Your Platform"),
|
||||
subtitle: t("Invite users and promote your MCP platform."),
|
||||
icon: <Share2 size={18} />,
|
||||
},
|
||||
];
|
||||
|
||||
const isTaskCompleted = (taskKey: string) => completedTasks.includes(taskKey);
|
||||
|
||||
return (
|
||||
<div className="min-h-screen flex flex-col items-center justify-center p-6">
|
||||
{/* Header */}
|
||||
<div className="text-center mb-8">
|
||||
<h1 className="text-2xl font-bold text-gray-900 mb-2">
|
||||
{t("Welcome to {{name}}!", {
|
||||
name: platformConfig.name || "your platform",
|
||||
})}
|
||||
</h1>
|
||||
<p className="text-gray-600 text-sm">
|
||||
{t("Let's set up {{name}} to get you started.", {
|
||||
name: platformConfig.name || "your platform",
|
||||
})}
|
||||
</p>
|
||||
</div>
|
||||
<Card className="w-full max-w-lg border-1 overflow-visible" shadow="none">
|
||||
<CardBody className="py-0 overflow-y-visible">
|
||||
<Listbox
|
||||
aria-label="Onboarding tasks"
|
||||
className="overflow-visible"
|
||||
classNames={{
|
||||
list: "overflow-visible",
|
||||
}}
|
||||
>
|
||||
{tasks.map((task, index) => (
|
||||
<ListboxItem
|
||||
key={task.key}
|
||||
startContent={
|
||||
<div
|
||||
className={`flex-shrink-0 ${
|
||||
!isTaskCompleted(task.key)
|
||||
? "text-primary"
|
||||
: "text-default-400"
|
||||
}`}
|
||||
>
|
||||
{task.icon}
|
||||
</div>
|
||||
}
|
||||
endContent={
|
||||
isTaskCompleted(task.key) ? (
|
||||
<CheckCircle2
|
||||
size={18}
|
||||
className="text-green-500 flex-shrink-0"
|
||||
/>
|
||||
) : (
|
||||
<ArrowRight
|
||||
size={18}
|
||||
className="text-primary flex-shrink-0 group-data-[hover=true]:translate-x-1 duration-300 ease-in-out"
|
||||
/>
|
||||
)
|
||||
}
|
||||
description={activeTab === task.key ? task.subtitle : undefined}
|
||||
onPress={() => {
|
||||
onTaskClick(task.key);
|
||||
}}
|
||||
className={`py-6 gap-3 ${
|
||||
!isTaskCompleted(task.key)
|
||||
? "data-[hover=true]:opacity-50"
|
||||
: "text-default-500 data-[hover=true]:text-default-500"
|
||||
} ${activeTab === task.key ? "scale-[1.15] border-2 border-primary bg-white px-6 data-[hover=true]:opacity-100 data-[hover=true]:bg-white" : "data-[hover=true]:bg-transparent"}`}
|
||||
classNames={{
|
||||
title: "font-bold text-md",
|
||||
}}
|
||||
showDivider={
|
||||
index !== tasks.length - 1 && activeTab !== task.key
|
||||
}
|
||||
>
|
||||
{task.title}
|
||||
</ListboxItem>
|
||||
))}
|
||||
</Listbox>
|
||||
</CardBody>
|
||||
</Card>
|
||||
|
||||
{/* Help Section */}
|
||||
<div className="text-center my-6">
|
||||
<p className="text-xs text-gray-500">
|
||||
{t("Need help getting started? Check out our")}{" "}
|
||||
<Link
|
||||
href="https://discord.gg/cyZfcdCXkW"
|
||||
size="sm"
|
||||
className="font-medium"
|
||||
target="_blank"
|
||||
>
|
||||
{t("Discord Community")}
|
||||
</Link>
|
||||
.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Skip Button */}
|
||||
<div className="text-center">
|
||||
<Button onPress={onSkipOnboarding} size="sm" variant="bordered">
|
||||
{t("Skip setup guide")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default OnboardingWelcome;
|
||||
@@ -6,7 +6,13 @@ import { AlipayConfigForm } from "../payment/AlipayConfigForm";
|
||||
import { WechatConfigForm } from "../payment/WechatConfigForm";
|
||||
import { usePaymentChannelManagement } from "@/hooks/usePaymentChannelManagement";
|
||||
|
||||
export const PaymentChannelsContent: React.FC = () => {
|
||||
interface PaymentChannelsContentProps {
|
||||
labelPlacement?: "outside" | "inside";
|
||||
}
|
||||
|
||||
export const PaymentChannelsContent: React.FC<PaymentChannelsContentProps> = ({
|
||||
labelPlacement = "inside",
|
||||
}) => {
|
||||
const {
|
||||
stripeConfig,
|
||||
alipayConfig,
|
||||
@@ -30,6 +36,7 @@ export const PaymentChannelsContent: React.FC = () => {
|
||||
onEnable={enableChannel}
|
||||
onDisable={disableChannel}
|
||||
isLoading={isStripeSaving}
|
||||
labelPlacement={labelPlacement}
|
||||
/>
|
||||
{/* coming soon */}
|
||||
{/* alipay configuration */}
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { Link as LinkIcon } from "lucide-react";
|
||||
import {
|
||||
Modal,
|
||||
ModalContent,
|
||||
ModalBody,
|
||||
Button,
|
||||
Image,
|
||||
} from "@nextui-org/react";
|
||||
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
|
||||
import { FaFacebook } from "react-icons/fa";
|
||||
import { FaLinkedin } from "react-icons/fa6";
|
||||
import { FaXTwitter } from "react-icons/fa6";
|
||||
import { copyToClipboard } from "@/shared/utils/clipboard";
|
||||
import toast from "react-hot-toast";
|
||||
|
||||
interface SharePlatformModalProps {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
onShareComplete: () => void;
|
||||
}
|
||||
|
||||
const SharePlatformModal: React.FC<SharePlatformModalProps> = ({
|
||||
isOpen,
|
||||
onClose,
|
||||
onShareComplete,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { platformConfig } = usePlatformConfig();
|
||||
|
||||
const handleCopyLink = async () => {
|
||||
try {
|
||||
const res = await copyToClipboard(window.location.origin);
|
||||
onShareComplete();
|
||||
if (res.success) {
|
||||
toast.success(t("Copied to clipboard"));
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Failed to copy link:", err);
|
||||
}
|
||||
};
|
||||
|
||||
const handleSocialShare = (platform: "x" | "facebook" | "linkedin") => {
|
||||
const text = t(
|
||||
`Just launched my first MCP Platform:{{name}} with xpack.ai 🚀
|
||||
Built in minutes, no coding, ready for AI Agents 🤖
|
||||
|
||||
👉Go and try my MCP: {{link}}
|
||||
#MCP #AI #APIs #XPack #AIagents #DevTools`,
|
||||
{
|
||||
name: platformConfig.name,
|
||||
link: window.location.origin,
|
||||
}
|
||||
);
|
||||
let url = "";
|
||||
const shareUrl = encodeURIComponent(window.location.origin);
|
||||
|
||||
switch (platform) {
|
||||
case "x":
|
||||
url = `https://twitter.com/intent/tweet?text=${encodeURIComponent(text)}&url=${shareUrl}`;
|
||||
break;
|
||||
case "facebook":
|
||||
url = `https://www.facebook.com/sharer/sharer.php?u=${shareUrl}`;
|
||||
break;
|
||||
case "linkedin":
|
||||
url = `https://www.linkedin.com/sharing/share-offsite/?url=${shareUrl}`;
|
||||
break;
|
||||
}
|
||||
if (url) {
|
||||
window.open(url, "_blank", "width=600,height=400");
|
||||
onShareComplete();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal isOpen={isOpen} onClose={onClose} size="xl">
|
||||
<ModalContent>
|
||||
<ModalBody>
|
||||
{/* Header */}
|
||||
<div className="my-6 flex flex-col gap-2 ">
|
||||
<h2 className="text-2xl font-extrabold text-primary md:text-4xl">
|
||||
{t("Your MCP Market is ready.")}
|
||||
</h2>
|
||||
<p className="text-2xl font-bold text-gray-900">
|
||||
{t("Share your MCP to the world")}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Preview Card */}
|
||||
<div className="mb-6 rounded-xl border border-gray-200 bg-white p-6">
|
||||
<div className="space-y-2">
|
||||
<h3 className="text-xl font-semibold text-gray-900">
|
||||
{platformConfig.website_title || platformConfig.name}
|
||||
</h3>
|
||||
<p className="text-gray-700">{platformConfig.meta_description}</p>
|
||||
</div>
|
||||
<div className="mt-4 flex items-center gap-2 text-sm text-gray-800">
|
||||
{platformConfig.logo && (
|
||||
<Image
|
||||
src={platformConfig.logo}
|
||||
alt={platformConfig.name}
|
||||
width={20}
|
||||
height={20}
|
||||
/>
|
||||
)}
|
||||
<span className="font-semibold">{platformConfig.name}</span>
|
||||
<span>•</span>
|
||||
<span className="text-gray-600">{window.location.hostname}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Actions */}
|
||||
<div className="flex flex-col items-stretch gap-4 sm:flex-row sm:items-center sm:justify-between mb-4">
|
||||
{/* Social buttons */}
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
onPress={() => handleSocialShare("x")}
|
||||
title={t("Share on X")}
|
||||
isIconOnly
|
||||
size="lg"
|
||||
variant="flat"
|
||||
>
|
||||
<FaXTwitter size={20} />
|
||||
</Button>
|
||||
<Button
|
||||
onPress={() => handleSocialShare("facebook")}
|
||||
title={t("Share on Facebook")}
|
||||
isIconOnly
|
||||
size="lg"
|
||||
variant="flat"
|
||||
>
|
||||
<FaFacebook size={20} className="text-primary" />
|
||||
</Button>
|
||||
<Button
|
||||
onPress={() => handleSocialShare("linkedin")}
|
||||
title={t("Share on LinkedIn")}
|
||||
isIconOnly
|
||||
size="lg"
|
||||
variant="flat"
|
||||
>
|
||||
<FaLinkedin size={20} className="text-blue-500" />
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{/* Copy link button */}
|
||||
<Button
|
||||
onPress={handleCopyLink}
|
||||
size="lg"
|
||||
color="primary"
|
||||
className="gap-1 w-full bg-default-900"
|
||||
>
|
||||
<LinkIcon size={20} />
|
||||
<span className="text-base font-semibold">{t("Copy link")}</span>
|
||||
</Button>
|
||||
</div>
|
||||
</ModalBody>
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default SharePlatformModal;
|
||||
@@ -2,159 +2,112 @@
|
||||
|
||||
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 { Button, Divider, Tooltip } from "@nextui-org/react";
|
||||
import { ExternalLinkIcon, LogOut, Settings } from "lucide-react";
|
||||
import { DashboardSidebarProps } from "@/shared/types/dashboard";
|
||||
import { DynamicLogo } from "@/shared/components/DynamicLogo";
|
||||
import { FaDiscord } from "react-icons/fa";
|
||||
import Link from "next/link";
|
||||
|
||||
const ConsoleSidebar: React.FC<DashboardSidebarProps> = ({
|
||||
interface ConsoleSidebarProps extends DashboardSidebarProps {
|
||||
onSettingsClick?: () => void;
|
||||
}
|
||||
|
||||
const ConsoleSidebar: React.FC<ConsoleSidebarProps> = ({
|
||||
activeTab,
|
||||
activeSubTab,
|
||||
onTabNavigate,
|
||||
onLogout,
|
||||
sidebarItems,
|
||||
onSettingsClick,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const handleSubItemClick = (parentKey: string, subKey: string) => {
|
||||
onTabNavigate?.(parentKey as any, subKey);
|
||||
};
|
||||
// Filter out system settings from sidebar items
|
||||
const filteredSidebarItems = sidebarItems.filter(
|
||||
(item) => item.key !== "system-settings"
|
||||
);
|
||||
|
||||
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"
|
||||
<>
|
||||
<div className="flex h-screen">
|
||||
{/* Main Sidebar */}
|
||||
<div className="py-2 px-4 w-[300px] overflow-hidden border-r border-divider flex flex-col justify-between bg-default-50">
|
||||
{/* Header */}
|
||||
<div className="mb-6 mt-4 flex gap-2 justify-between items-center">
|
||||
<Link href="/" prefetch target="_blank">
|
||||
<DynamicLogo
|
||||
alt="Platform Logo"
|
||||
className="max-w-full h-[32px] object-contain"
|
||||
/>
|
||||
</Link>
|
||||
<Tooltip content={t("Open in new tab")} closeDelay={0} disableAnimation>
|
||||
<Link
|
||||
href="/"
|
||||
prefetch
|
||||
target="_blank"
|
||||
className="hover:text-primary"
|
||||
>
|
||||
<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>
|
||||
<ExternalLinkIcon size={18} />
|
||||
</Link>
|
||||
</Tooltip>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<Divider className="my-2" />
|
||||
{/* Navigation */}
|
||||
<div className="flex flex-col gap-2 flex-1">
|
||||
{filteredSidebarItems.map((item) => (
|
||||
<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 justify-start"
|
||||
onPress={() => onTabNavigate?.(item.key)}
|
||||
>
|
||||
{t(item.label)}
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Tooltip
|
||||
content={t("Discord")}
|
||||
closeDelay={0}
|
||||
disableAnimation
|
||||
placement="right"
|
||||
>
|
||||
<div>
|
||||
<Divider className="my-2" />
|
||||
|
||||
<div className="space-y-2">
|
||||
<Button
|
||||
variant="light"
|
||||
startContent={<FaDiscord size={18} />}
|
||||
className="w-full h-auto p-4"
|
||||
className="w-full h-auto p-4 justify-start"
|
||||
onPress={() => {
|
||||
window.open("https://discord.gg/cyZfcdCXkW", "_blank");
|
||||
}}
|
||||
isIconOnly
|
||||
></Button>
|
||||
</Tooltip>
|
||||
>
|
||||
{t("Discord")}
|
||||
</Button>
|
||||
|
||||
{/* Logout */}
|
||||
<Tooltip
|
||||
content={t("Log Out")}
|
||||
closeDelay={0}
|
||||
disableAnimation
|
||||
placement="right"
|
||||
>
|
||||
{/* Settings */}
|
||||
<Button
|
||||
variant="light"
|
||||
startContent={<Settings size={18} />}
|
||||
className="w-full h-auto p-4 justify-start"
|
||||
onPress={onSettingsClick}
|
||||
>
|
||||
{t("Settings")}
|
||||
</Button>
|
||||
|
||||
{/* Logout */}
|
||||
<Button
|
||||
variant="light"
|
||||
color="danger"
|
||||
startContent={<LogOut size={18} />}
|
||||
className="w-full h-auto p-4"
|
||||
className="w-full h-auto p-4 justify-start"
|
||||
onPress={onLogout}
|
||||
isIconOnly
|
||||
></Button>
|
||||
</Tooltip>
|
||||
>
|
||||
{t("Log Out")}
|
||||
</Button>
|
||||
</div>
|
||||
</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>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,156 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState } from "react";
|
||||
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";
|
||||
|
||||
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,
|
||||
platformLoading,
|
||||
savePlatformConfig,
|
||||
|
||||
// admin config
|
||||
adminConfig,
|
||||
adminLoading,
|
||||
saveAdminConfig,
|
||||
|
||||
// email config
|
||||
emailConfig,
|
||||
emailLoading,
|
||||
saveEmailConfig,
|
||||
|
||||
// image upload
|
||||
uploadImage,
|
||||
|
||||
// login config
|
||||
loginConfig,
|
||||
saveLoginConfig,
|
||||
} = useSystemConfigManagement();
|
||||
|
||||
// save admin config
|
||||
const handleSaveAdminConfig = async (config: typeof adminConfig) => {
|
||||
await saveAdminConfig(config);
|
||||
};
|
||||
|
||||
// save email config
|
||||
const handleSaveEmailConfig = async (config: typeof emailConfig) => {
|
||||
await saveEmailConfig(config);
|
||||
};
|
||||
|
||||
// save platform config
|
||||
const handleSavePlatformConfig = async (config: typeof platformConfig) => {
|
||||
const result = await savePlatformConfig(config);
|
||||
if (!result) return;
|
||||
updateClientConfig({
|
||||
platform: config,
|
||||
});
|
||||
if (config.language !== i18n.language) {
|
||||
i18n.changeLanguage(config.language);
|
||||
}
|
||||
};
|
||||
|
||||
// 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,
|
||||
});
|
||||
};
|
||||
|
||||
// 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 (
|
||||
<DashboardDemoContent
|
||||
title={t(subTab?.label || "System Settings")}
|
||||
description={t(subTab?.description || "Platform basic configuration")}
|
||||
>
|
||||
{renderSubTabContent()}
|
||||
</DashboardDemoContent>
|
||||
);
|
||||
};
|
||||
|
||||
export default SystemSettingsContent;
|
||||
@@ -0,0 +1,465 @@
|
||||
"use client";
|
||||
|
||||
import React, {
|
||||
useCallback,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from "react";
|
||||
import {
|
||||
Modal,
|
||||
ModalContent,
|
||||
ModalBody,
|
||||
ModalHeader,
|
||||
Button,
|
||||
} from "@nextui-org/react";
|
||||
import { useSystemConfigManagement } from "@/hooks/useSystemConfigManagement";
|
||||
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
|
||||
import { Theme } from "@/shared/types/system";
|
||||
import SystemSettingsSidebar, {
|
||||
SettingsGroup,
|
||||
SettingsMenuItem,
|
||||
} from "./SystemSettingsSidebar";
|
||||
import {
|
||||
AppWindow,
|
||||
Captions,
|
||||
Code,
|
||||
CreditCard,
|
||||
GhostIcon,
|
||||
GlobeIcon,
|
||||
LockIcon,
|
||||
Mail,
|
||||
Package,
|
||||
Palette,
|
||||
SquareMenu,
|
||||
TableOfContents,
|
||||
Trello,
|
||||
XIcon,
|
||||
} from "lucide-react";
|
||||
import SystemSettingsRightContent from "./SystemSettingsRightContent";
|
||||
import { SettingModalTab } from "./console.type";
|
||||
import { useHomepageConfigManagement } from "@/hooks/useHomepageConfigManagement";
|
||||
import { FcGoogle } from "react-icons/fc";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
|
||||
interface SystemSettingsModalProps {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
keyword?: string;
|
||||
}
|
||||
|
||||
const SystemSettingsModal: React.FC<SystemSettingsModalProps> = ({
|
||||
isOpen,
|
||||
onClose,
|
||||
keyword,
|
||||
}) => {
|
||||
// Left menu active state
|
||||
const [activeSubTab, setActiveSubTab] = useState<SettingModalTab>(
|
||||
SettingModalTab.BRANDING
|
||||
);
|
||||
const { t } = useTranslation();
|
||||
|
||||
// Search state (pure frontend)
|
||||
const [searchQuery, setSearchQuery] = useState<string>(keyword || "");
|
||||
|
||||
// Scroll container and section refs
|
||||
const rightContentRef = useRef<HTMLDivElement | null>(null);
|
||||
const sectionRefs = useRef<Record<string, HTMLElement | null>>({});
|
||||
const titleRefs = useRef<Record<string, HTMLElement | null>>({});
|
||||
const scrollingByClickRef = useRef(false);
|
||||
const activeKeyRef = useRef<SettingModalTab>(SettingModalTab.BRANDING);
|
||||
|
||||
useEffect(() => {
|
||||
activeKeyRef.current = activeSubTab;
|
||||
}, [activeSubTab]);
|
||||
|
||||
// Load and manage config once here to avoid duplicate network calls
|
||||
const { updateClientConfig } = usePlatformConfig();
|
||||
const {
|
||||
// platform config
|
||||
platformConfig,
|
||||
savePlatformConfig,
|
||||
|
||||
// image upload
|
||||
uploadImage,
|
||||
|
||||
// login config
|
||||
loginConfig,
|
||||
saveLoginConfig,
|
||||
|
||||
// email config
|
||||
emailConfig,
|
||||
saveEmailConfig,
|
||||
emailLoading,
|
||||
} = useSystemConfigManagement();
|
||||
const {
|
||||
homepageConfig,
|
||||
saveNavigationConfig,
|
||||
saveEmbeddedHtmlConfig,
|
||||
saveFaqConfig,
|
||||
} = useHomepageConfigManagement();
|
||||
|
||||
const handleSavePlatformConfig = async (config: { [key: string]: any }) => {
|
||||
const newConfig = { ...platformConfig, ...config };
|
||||
const result = await savePlatformConfig(newConfig);
|
||||
if (!result) return false;
|
||||
updateClientConfig({ platform: newConfig });
|
||||
return result;
|
||||
};
|
||||
|
||||
const handleThemeChange = async (theme: Theme) => {
|
||||
const updatedConfig = { ...platformConfig, theme };
|
||||
const result = await savePlatformConfig(updatedConfig, "theme");
|
||||
if (!result) return;
|
||||
updateClientConfig({ platform: updatedConfig });
|
||||
};
|
||||
|
||||
const settingsMenuItems: SettingsMenuItem[] = [
|
||||
// General settings
|
||||
|
||||
{
|
||||
key: SettingModalTab.BRANDING,
|
||||
label: "Branding",
|
||||
icon: <Trello size={16} />,
|
||||
description: "Logo, colors, and brand identity",
|
||||
},
|
||||
{
|
||||
key: SettingModalTab.TITLE_DESCRIPTION,
|
||||
label: "Title & description",
|
||||
icon: <Captions size={16} />,
|
||||
description: "Configure your site title and description",
|
||||
},
|
||||
{
|
||||
key: SettingModalTab.META_DATA,
|
||||
label: "Meta data",
|
||||
icon: <AppWindow size={16} />,
|
||||
description: "Extra content for search engines and social accounts",
|
||||
},
|
||||
{
|
||||
key: SettingModalTab.CUSTOM_DOMAIN,
|
||||
label: "Domain",
|
||||
icon: <GhostIcon size={16} />,
|
||||
description: "Configure your custom domain settings",
|
||||
},
|
||||
{
|
||||
key: SettingModalTab.PLATFORM_LANGUAGE,
|
||||
label: "Platform Language",
|
||||
icon: <GlobeIcon size={16} />,
|
||||
description: "Configure platform language",
|
||||
},
|
||||
// Site
|
||||
{
|
||||
key: SettingModalTab.THEME,
|
||||
label: "Theme",
|
||||
icon: <Palette size={16} />,
|
||||
description: "Visual theme and appearance settings",
|
||||
},
|
||||
{
|
||||
key: SettingModalTab.NAVIGATION,
|
||||
label: "Navigation",
|
||||
icon: <SquareMenu size={16} />,
|
||||
description: "Configure site navigation and menus",
|
||||
},
|
||||
{
|
||||
key: SettingModalTab.FAQ,
|
||||
label: "FAQ",
|
||||
icon: <TableOfContents size={16} />,
|
||||
description: "Configure FAQ",
|
||||
},
|
||||
// Business
|
||||
{
|
||||
key: SettingModalTab.PAYMENT,
|
||||
label: "Payment",
|
||||
icon: <CreditCard size={16} />,
|
||||
description: "Configure payment channels",
|
||||
},
|
||||
{
|
||||
key: SettingModalTab.XPACK_EXPLORE,
|
||||
label: "XPack Explore",
|
||||
icon: <Package size={16} />,
|
||||
description: "Explore XPack features and integrations",
|
||||
},
|
||||
// Advanced
|
||||
{
|
||||
key: SettingModalTab.SMTP_SETTINGS,
|
||||
label: "Email Configuration",
|
||||
icon: <Mail size={16} />,
|
||||
description: "Configure SMTP settings for email notifications",
|
||||
},
|
||||
|
||||
{
|
||||
key: SettingModalTab.EMAIL_LOGIN_SETTINGS,
|
||||
label: "Email Login Settings",
|
||||
icon: <LockIcon size={16} />,
|
||||
description: "Configure email-based authentication",
|
||||
},
|
||||
{
|
||||
key: SettingModalTab.GOOGLE_LOGIN_SETTINGS,
|
||||
label: "Google Login Settings",
|
||||
icon: <FcGoogle size={16} />,
|
||||
description: "Configure Google OAuth integration",
|
||||
},
|
||||
{
|
||||
key: SettingModalTab.CODE_INJECTION,
|
||||
label: "Code injection",
|
||||
icon: <Code size={16} />,
|
||||
description: "Custom code injection and scripts",
|
||||
},
|
||||
// Account
|
||||
{
|
||||
key: SettingModalTab.CHANGE_PASSWORD,
|
||||
label: "Password",
|
||||
icon: <LockIcon size={16} />,
|
||||
description: "Change your password",
|
||||
},
|
||||
];
|
||||
|
||||
// Hierarchical groups for the sidebar
|
||||
const settingsGroups: SettingsGroup[] = useMemo(() => {
|
||||
const mapByKey = Object.fromEntries(
|
||||
settingsMenuItems.map((it) => [it.key, it])
|
||||
);
|
||||
const groupItems = (keys: SettingModalTab[]) =>
|
||||
keys.map((k) => mapByKey[k]).filter(Boolean) as SettingsMenuItem[];
|
||||
return [
|
||||
{
|
||||
key: "general-settings",
|
||||
title: "General settings",
|
||||
items: groupItems([
|
||||
SettingModalTab.BRANDING,
|
||||
SettingModalTab.TITLE_DESCRIPTION,
|
||||
SettingModalTab.META_DATA,
|
||||
SettingModalTab.CUSTOM_DOMAIN,
|
||||
SettingModalTab.PLATFORM_LANGUAGE,
|
||||
]),
|
||||
},
|
||||
{
|
||||
key: "site",
|
||||
title: "Site",
|
||||
items: groupItems([
|
||||
SettingModalTab.THEME,
|
||||
SettingModalTab.NAVIGATION,
|
||||
SettingModalTab.FAQ,
|
||||
]),
|
||||
},
|
||||
{
|
||||
key: "business",
|
||||
title: "Business",
|
||||
items: groupItems([
|
||||
SettingModalTab.PAYMENT,
|
||||
SettingModalTab.XPACK_EXPLORE,
|
||||
]),
|
||||
},
|
||||
{
|
||||
key: "advanced",
|
||||
title: "Advanced",
|
||||
items: groupItems([
|
||||
SettingModalTab.SMTP_SETTINGS,
|
||||
SettingModalTab.EMAIL_LOGIN_SETTINGS,
|
||||
SettingModalTab.GOOGLE_LOGIN_SETTINGS,
|
||||
SettingModalTab.CODE_INJECTION,
|
||||
]),
|
||||
},
|
||||
{
|
||||
key: "account",
|
||||
title: "Account",
|
||||
items: groupItems([SettingModalTab.CHANGE_PASSWORD]),
|
||||
},
|
||||
];
|
||||
}, []);
|
||||
|
||||
// Filter keys by search (pure frontend)
|
||||
const filteredKeys = useMemo(() => {
|
||||
const q = searchQuery.trim().toLowerCase();
|
||||
if (!q) return settingsMenuItems.map((it) => it.key);
|
||||
return settingsMenuItems
|
||||
.filter(
|
||||
(it) =>
|
||||
t(it.label).toLowerCase().includes(q) ||
|
||||
t(it.description || "")
|
||||
?.toLowerCase()
|
||||
.includes(q)
|
||||
)
|
||||
.map((it) => it.key);
|
||||
}, [searchQuery]);
|
||||
|
||||
// Optimized scroll to section function
|
||||
const scrollToSection = useCallback((key: SettingModalTab) => {
|
||||
const container = rightContentRef.current;
|
||||
const el = titleRefs.current[key];
|
||||
if (!container || !el) return;
|
||||
|
||||
// Prevent multiple rapid calls
|
||||
if (scrollingByClickRef.current) return;
|
||||
|
||||
const containerRect = container.getBoundingClientRect();
|
||||
const elRect = el.getBoundingClientRect();
|
||||
// scroll so that the title is aligned near the top of the container viewport
|
||||
const TOP_OFFSET = 16; // small padding
|
||||
const offset =
|
||||
elRect.top - containerRect.top + container.scrollTop - TOP_OFFSET;
|
||||
|
||||
scrollingByClickRef.current = true;
|
||||
setActiveSubTab(key);
|
||||
|
||||
// Use CSS-based scroll with better performance
|
||||
const prevBehavior = container.style.scrollBehavior;
|
||||
container.style.scrollBehavior = "smooth";
|
||||
container.scrollTo({ top: Math.max(0, offset) });
|
||||
|
||||
// Reset scroll behavior and stop suppressing after animation completes
|
||||
window.setTimeout(() => {
|
||||
if (container) {
|
||||
container.style.scrollBehavior = prevBehavior || "auto";
|
||||
}
|
||||
scrollingByClickRef.current = false;
|
||||
}, 400);
|
||||
}, []);
|
||||
|
||||
// Scroll-based scrollspy using rAF to avoid IO jitter
|
||||
useEffect(() => {
|
||||
const container = rightContentRef.current;
|
||||
if (!container || !isOpen) return;
|
||||
|
||||
let ticking = false;
|
||||
|
||||
const computeActive = () => {
|
||||
if (!container) return;
|
||||
const keys = filteredKeys;
|
||||
const rect = container.getBoundingClientRect();
|
||||
const containerTop = rect.top;
|
||||
const TOP_OFFSET = 16;
|
||||
|
||||
const scrollTop = container.scrollTop;
|
||||
const scrollHeight = container.scrollHeight;
|
||||
const containerHeight = container.clientHeight;
|
||||
|
||||
// Bottom stickiness
|
||||
if (scrollTop + containerHeight >= scrollHeight - 2) {
|
||||
const lastKey = keys[keys.length - 1];
|
||||
if (lastKey && activeKeyRef.current !== lastKey) {
|
||||
setActiveSubTab(lastKey);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Determine the last section whose title top is above the top + offset
|
||||
let currentKey: SettingModalTab | null = null;
|
||||
for (const k of keys) {
|
||||
const el = titleRefs.current[k];
|
||||
if (!el) continue;
|
||||
const r = el.getBoundingClientRect();
|
||||
if (r.top - containerTop <= TOP_OFFSET + 1) {
|
||||
currentKey = k;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!currentKey) {
|
||||
const firstKey = keys[0];
|
||||
if (firstKey && activeKeyRef.current !== firstKey) {
|
||||
setActiveSubTab(firstKey);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentKey && activeKeyRef.current !== currentKey) {
|
||||
setActiveSubTab(currentKey);
|
||||
}
|
||||
};
|
||||
|
||||
const onScroll = () => {
|
||||
if (scrollingByClickRef.current) return;
|
||||
if (!ticking) {
|
||||
ticking = true;
|
||||
requestAnimationFrame(() => {
|
||||
computeActive();
|
||||
ticking = false;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// Initial compute and bind listeners
|
||||
computeActive();
|
||||
container.addEventListener("scroll", onScroll, { passive: true });
|
||||
|
||||
return () => {
|
||||
container.removeEventListener("scroll", onScroll);
|
||||
};
|
||||
}, [isOpen, filteredKeys]);
|
||||
|
||||
// When searching, auto-jump to first matched section
|
||||
useEffect(() => {
|
||||
if (!searchQuery.trim()) return;
|
||||
if (filteredKeys.length > 0) {
|
||||
const firstKey = filteredKeys[0];
|
||||
if (firstKey !== activeSubTab) {
|
||||
scrollToSection(firstKey);
|
||||
}
|
||||
}
|
||||
}, [searchQuery]); // Only depend on searchQuery, not filteredKeys
|
||||
|
||||
return (
|
||||
<Modal
|
||||
isOpen={isOpen}
|
||||
onClose={onClose}
|
||||
size="full"
|
||||
classNames={{
|
||||
base: "h-screen !max-w-none !w-screen p-0",
|
||||
body: "flex-1 overflow-hidden",
|
||||
}}
|
||||
isDismissable={false}
|
||||
hideCloseButton={true}
|
||||
>
|
||||
<ModalContent>
|
||||
<ModalHeader className="flex justify-between border-b border-default">
|
||||
<h2 className="text-2xl font-bold">{t("System Settings")}</h2>
|
||||
<Button onPress={onClose} isIconOnly size="sm" variant="light">
|
||||
<XIcon size={24} className="text-gray-500" />
|
||||
</Button>
|
||||
</ModalHeader>
|
||||
<ModalBody className="p-0">
|
||||
<div className="flex h-full">
|
||||
{/* Left Navigation */}
|
||||
<SystemSettingsSidebar
|
||||
activeKey={activeSubTab}
|
||||
onSelect={scrollToSection}
|
||||
searchQuery={searchQuery}
|
||||
onSearchChange={setSearchQuery}
|
||||
groups={settingsGroups}
|
||||
filteredKeys={filteredKeys}
|
||||
/>
|
||||
|
||||
{/* Right Content: stacked sections with anchors */}
|
||||
<div className="flex-1">
|
||||
<SystemSettingsRightContent
|
||||
filteredKeys={filteredKeys}
|
||||
settingsMenuItems={settingsMenuItems}
|
||||
platformConfig={platformConfig}
|
||||
homepageConfig={homepageConfig}
|
||||
onSaveEmbeddedHtml={saveEmbeddedHtmlConfig}
|
||||
sectionRefs={sectionRefs}
|
||||
titleRefs={titleRefs}
|
||||
onSavePlatformConfig={handleSavePlatformConfig}
|
||||
handleThemeChange={handleThemeChange}
|
||||
uploadImage={uploadImage}
|
||||
scrollContainerRef={rightContentRef}
|
||||
saveNavigationConfig={saveNavigationConfig}
|
||||
saveFaqConfig={saveFaqConfig}
|
||||
saveLoginConfig={saveLoginConfig}
|
||||
emailConfig={emailConfig}
|
||||
loginConfig={loginConfig}
|
||||
onSaveEmailConfig={saveEmailConfig}
|
||||
emailSubmitLoading={emailLoading}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</ModalBody>
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default SystemSettingsModal;
|
||||
@@ -0,0 +1,243 @@
|
||||
"use client";
|
||||
|
||||
import React, { useMemo } from "react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import {
|
||||
EmbeddedHtmlConfig,
|
||||
FaqItem,
|
||||
LoginConfig,
|
||||
PlatformConfig,
|
||||
Theme,
|
||||
TopNavigationItem,
|
||||
} from "@/shared/types/system";
|
||||
import { SettingsMenuItem } from "./SystemSettingsSidebar";
|
||||
import TitleAndDescPanel, {
|
||||
TitleAndDescPanelConfig,
|
||||
} from "./system-setting/TitleAndDescPanel";
|
||||
import MetaDataPanel from "./system-setting/MetaDataPanel";
|
||||
import BrandPanel, { BrandPanelConfig } from "./system-setting/BrandPanel";
|
||||
import { ThemeSelector } from "@/components/system-setting/ThemeSelector";
|
||||
import { TopNavigationSettings } from "@/components/system-setting/TopNavigationSettings";
|
||||
import { EmbeddedHtmlSettings } from "@/components/system-setting/EmbeddedHtmlSettings";
|
||||
import { ExplorePanel } from "./system-setting/ExplorePanel";
|
||||
import DomainPanel from "./system-setting/DomainPanel";
|
||||
import PaymentChannelsContent from "@/components/console/PaymentChannelsContent";
|
||||
import { HomepageConfig } from "@/services/homepageConfigService";
|
||||
import { FaqSettings } from "@/components/system-setting/FaqSettings";
|
||||
import { AdminConfigForm } from "./AdminConfigForm";
|
||||
import { systemConfigService } from "@/services/systemConfigService";
|
||||
import { md5Encrypt } from "@/shared/utils/crypto";
|
||||
import { AdminConfig, EmailConfig } from "@/types/system";
|
||||
import { LoginSettingsContent } from "./LoginSettingsContent";
|
||||
import { EmailConfigForm } from "@/components/system-setting/EmailConfigForm";
|
||||
import { LanguageSetting } from "@/components/system-setting/LanguageSetting";
|
||||
|
||||
interface SystemSettingsRightContentProps {
|
||||
filteredKeys: string[];
|
||||
settingsMenuItems: SettingsMenuItem[];
|
||||
platformConfig: PlatformConfig;
|
||||
homepageConfig: HomepageConfig;
|
||||
sectionRefs: React.MutableRefObject<Record<string, HTMLElement | null>>;
|
||||
titleRefs: React.MutableRefObject<Record<string, HTMLElement | null>>; // New: refs for section titles
|
||||
onSavePlatformConfig: (config: { [key: string]: any }) => Promise<boolean>;
|
||||
onSaveEmbeddedHtml: (config: EmbeddedHtmlConfig) => Promise<boolean>;
|
||||
handleThemeChange: (theme: Theme) => Promise<void>;
|
||||
uploadImage: any;
|
||||
scrollContainerRef?: React.RefObject<HTMLDivElement>;
|
||||
saveNavigationConfig: (config: TopNavigationItem[]) => Promise<boolean>;
|
||||
saveFaqConfig: (config: FaqItem[]) => Promise<boolean>;
|
||||
saveLoginConfig: (config: LoginConfig) => Promise<boolean>;
|
||||
emailConfig: EmailConfig;
|
||||
loginConfig: LoginConfig;
|
||||
onSaveEmailConfig: (config: EmailConfig) => Promise<boolean>;
|
||||
emailSubmitLoading: boolean;
|
||||
}
|
||||
|
||||
const SystemSettingsRightContent: React.FC<SystemSettingsRightContentProps> = ({
|
||||
filteredKeys,
|
||||
settingsMenuItems,
|
||||
platformConfig,
|
||||
homepageConfig,
|
||||
onSaveEmbeddedHtml,
|
||||
sectionRefs,
|
||||
titleRefs, // New prop
|
||||
onSavePlatformConfig,
|
||||
handleThemeChange,
|
||||
uploadImage,
|
||||
scrollContainerRef,
|
||||
saveNavigationConfig,
|
||||
saveFaqConfig,
|
||||
saveLoginConfig,
|
||||
emailConfig,
|
||||
loginConfig,
|
||||
onSaveEmailConfig,
|
||||
emailSubmitLoading,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const menuItems = useMemo(() => {
|
||||
return settingsMenuItems.filter((it) => filteredKeys.includes(it.key));
|
||||
}, [settingsMenuItems, filteredKeys]);
|
||||
const handleChangePassword = async (config: AdminConfig) => {
|
||||
const result = await systemConfigService.updateSystemConfig(
|
||||
{
|
||||
account: {
|
||||
...config,
|
||||
password: md5Encrypt(config.password),
|
||||
},
|
||||
},
|
||||
"password"
|
||||
);
|
||||
return result;
|
||||
};
|
||||
return (
|
||||
<div
|
||||
ref={scrollContainerRef}
|
||||
className="flex-1 overflow-y-auto h-full pb-40 space-y-6"
|
||||
style={{ scrollBehavior: "auto" }}
|
||||
>
|
||||
<div className="h-0" aria-hidden="true"></div>
|
||||
{menuItems.map((section) => (
|
||||
<>
|
||||
<section
|
||||
key={section.key}
|
||||
ref={(el) => {
|
||||
if (el) sectionRefs.current[section.key] = el;
|
||||
}}
|
||||
id={`section-${section.key}`}
|
||||
className="px-6 py-6 scroll-mt-16 border-1 rounded-lg shadow-md max-w-2xl mx-auto"
|
||||
>
|
||||
<div className="mb-4">
|
||||
<h2
|
||||
className="text-xl font-semibold"
|
||||
ref={(el) => {
|
||||
if (el) titleRefs.current[section.key] = el;
|
||||
}}
|
||||
id={`title-${section.key}`}
|
||||
>
|
||||
{t(section.label)}
|
||||
</h2>
|
||||
<p className="text-sm text-default-500">
|
||||
{t(section.description || "")}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Content sections */}
|
||||
{section.key === "title-description" && (
|
||||
<TitleAndDescPanel
|
||||
config={platformConfig as TitleAndDescPanelConfig}
|
||||
onSave={onSavePlatformConfig}
|
||||
/>
|
||||
)}
|
||||
|
||||
{section.key === "meta-data" && (
|
||||
<MetaDataPanel
|
||||
metaData={platformConfig}
|
||||
onSave={onSavePlatformConfig}
|
||||
uploadImage={uploadImage}
|
||||
platformConfig={platformConfig}
|
||||
/>
|
||||
)}
|
||||
|
||||
{section.key === "custom-domain" && (
|
||||
<div className="space-y-4">
|
||||
<DomainPanel
|
||||
config={platformConfig}
|
||||
onSave={onSavePlatformConfig}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{section.key === "platform-language" && (
|
||||
<LanguageSetting
|
||||
config={platformConfig}
|
||||
onSave={onSavePlatformConfig}
|
||||
/>
|
||||
)}
|
||||
|
||||
{section.key === "branding" && (
|
||||
<BrandPanel
|
||||
config={platformConfig as BrandPanelConfig}
|
||||
onSave={onSavePlatformConfig}
|
||||
onUploadImage={uploadImage}
|
||||
/>
|
||||
)}
|
||||
|
||||
{section.key === "theme" && (
|
||||
<ThemeSelector
|
||||
value={platformConfig.theme || Theme.DEFAULT}
|
||||
onChange={handleThemeChange}
|
||||
/>
|
||||
)}
|
||||
{section.key === "smtp-settings" && (
|
||||
<EmailConfigForm
|
||||
config={emailConfig}
|
||||
onSave={onSaveEmailConfig}
|
||||
isLoading={emailSubmitLoading}
|
||||
/>
|
||||
)}
|
||||
|
||||
{section.key === "email-login-settings" && (
|
||||
<LoginSettingsContent
|
||||
loginConfig={loginConfig}
|
||||
saveLoginConfig={saveLoginConfig}
|
||||
emailConfig={emailConfig}
|
||||
type="email"
|
||||
/>
|
||||
)}
|
||||
|
||||
{section.key === "google-login-settings" && (
|
||||
<LoginSettingsContent
|
||||
loginConfig={loginConfig}
|
||||
saveLoginConfig={saveLoginConfig}
|
||||
emailConfig={emailConfig}
|
||||
type="google"
|
||||
/>
|
||||
)}
|
||||
|
||||
{section.key === "navigation" && (
|
||||
<TopNavigationSettings
|
||||
onSave={saveNavigationConfig}
|
||||
config={homepageConfig.top_navigation}
|
||||
labelPlacement="outside"
|
||||
/>
|
||||
)}
|
||||
|
||||
{section.key === "faq" && (
|
||||
<FaqSettings
|
||||
onSave={saveFaqConfig}
|
||||
config={homepageConfig.faq}
|
||||
labelPlacement="outside"
|
||||
/>
|
||||
)}
|
||||
|
||||
{section.key === "payment" && (
|
||||
<PaymentChannelsContent labelPlacement="outside" />
|
||||
)}
|
||||
|
||||
{section.key === "xpack-explore" && (
|
||||
<ExplorePanel
|
||||
isEnabled={!!platformConfig.is_showcased}
|
||||
onSave={onSavePlatformConfig}
|
||||
/>
|
||||
)}
|
||||
|
||||
{section.key === "code-injection" && (
|
||||
<EmbeddedHtmlSettings
|
||||
onSave={onSaveEmbeddedHtml}
|
||||
config={homepageConfig.embeded_html}
|
||||
labelPlacement="outside"
|
||||
/>
|
||||
)}
|
||||
|
||||
{section.key === "change-password" && (
|
||||
<AdminConfigForm onSave={handleChangePassword} />
|
||||
)}
|
||||
</section>
|
||||
</>
|
||||
))}
|
||||
{/* Bottom spacer to allow last sections to scroll higher into view for better selection */}
|
||||
<div className="h-40" aria-hidden="true" />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default SystemSettingsRightContent;
|
||||
@@ -0,0 +1,157 @@
|
||||
"use client";
|
||||
|
||||
import React, { useMemo, useRef, useEffect } from "react";
|
||||
import { Input, Button, ScrollShadow } from "@nextui-org/react";
|
||||
import { Search } from "lucide-react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { SettingModalTab } from "./console.type";
|
||||
|
||||
export interface SettingsMenuItem {
|
||||
key: SettingModalTab;
|
||||
label: string;
|
||||
description?: string;
|
||||
icon?: React.ReactNode;
|
||||
}
|
||||
|
||||
export interface SettingsGroup {
|
||||
key: string;
|
||||
title: string;
|
||||
items: SettingsMenuItem[];
|
||||
}
|
||||
|
||||
interface Props {
|
||||
activeKey: SettingModalTab;
|
||||
onSelect: (key: SettingModalTab) => void;
|
||||
searchQuery: string;
|
||||
onSearchChange: (val: string) => void;
|
||||
groups: SettingsGroup[];
|
||||
filteredKeys: SettingModalTab[]; // which item keys match the current search
|
||||
}
|
||||
|
||||
const SystemSettingsSidebar: React.FC<Props> = ({
|
||||
activeKey,
|
||||
onSelect,
|
||||
searchQuery,
|
||||
onSearchChange,
|
||||
groups,
|
||||
filteredKeys,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const sidebarScrollRef = useRef<HTMLDivElement | null>(null);
|
||||
const activeItemRefs = useRef<Record<string, HTMLButtonElement | null>>({});
|
||||
|
||||
// filter groups based on filteredKeys
|
||||
const visibleGroups = useMemo(() => {
|
||||
const keySet = new Set(filteredKeys);
|
||||
return groups
|
||||
.map((g) => ({
|
||||
...g,
|
||||
items: g.items.filter((it) => keySet.has(it.key)),
|
||||
}))
|
||||
.filter((g) => g.items.length > 0);
|
||||
}, [groups, filteredKeys]);
|
||||
|
||||
const hasResults = visibleGroups.length > 0;
|
||||
|
||||
// Auto-scroll to active item when activeKey changes
|
||||
useEffect(() => {
|
||||
const activeElement = activeItemRefs.current[activeKey];
|
||||
const scrollContainer = sidebarScrollRef.current;
|
||||
|
||||
if (activeElement && scrollContainer) {
|
||||
// Get the scroll container element (ScrollShadow wraps content)
|
||||
const scrollElement =
|
||||
(scrollContainer.querySelector(
|
||||
'[data-scrollable="true"]'
|
||||
) as HTMLElement) || scrollContainer;
|
||||
|
||||
const containerRect = scrollElement.getBoundingClientRect();
|
||||
const elementRect = activeElement.getBoundingClientRect();
|
||||
|
||||
// Check if element is visible in container
|
||||
const isElementVisible =
|
||||
elementRect.top >= containerRect.top &&
|
||||
elementRect.bottom <= containerRect.bottom;
|
||||
|
||||
if (!isElementVisible) {
|
||||
// Calculate scroll position to center the active item
|
||||
const containerHeight = containerRect.height;
|
||||
const elementTop = activeElement.offsetTop;
|
||||
const elementHeight = activeElement.offsetHeight;
|
||||
const scrollTop = elementTop - containerHeight / 2 + elementHeight / 2;
|
||||
|
||||
scrollElement.scrollTo({
|
||||
top: Math.max(0, scrollTop),
|
||||
behavior: "smooth",
|
||||
});
|
||||
}
|
||||
}
|
||||
}, [activeKey]);
|
||||
|
||||
return (
|
||||
<ScrollShadow
|
||||
ref={sidebarScrollRef}
|
||||
className="w-[300px] border-r border-divider bg-content1/50 scrollbar-thin"
|
||||
>
|
||||
<div className="p-4 space-y-4">
|
||||
<Input
|
||||
size="sm"
|
||||
aria-label={t("Search settings")}
|
||||
placeholder={t("Search settings")}
|
||||
value={searchQuery}
|
||||
onValueChange={onSearchChange}
|
||||
startContent={<Search size={16} className="text-default-400" />}
|
||||
isClearable
|
||||
onClear={() => onSearchChange("")}
|
||||
/>
|
||||
|
||||
{!hasResults ? (
|
||||
<div className="text-xs text-default-400 px-1 py-2">
|
||||
{t("No results")}
|
||||
</div>
|
||||
) : (
|
||||
<nav className="space-y-6">
|
||||
{visibleGroups.map((group) => (
|
||||
<div key={group.key} className="space-y-1">
|
||||
<div className="px-2 text-[11px] tracking-wide text-default-400">
|
||||
{t(group.title)}
|
||||
</div>
|
||||
<div className="flex flex-col gap-2">
|
||||
{group.items.map((item) => {
|
||||
const isActive = activeKey === item.key;
|
||||
return (
|
||||
<Button
|
||||
key={item.key}
|
||||
ref={(el) => {
|
||||
if (el) activeItemRefs.current[item.key] = el;
|
||||
}}
|
||||
variant={isActive ? "flat" : "light"}
|
||||
color={isActive ? "primary" : "default"}
|
||||
size="sm"
|
||||
className={`w-full border-1 justify-start h-auto py-3 px-3 text-left rounded-md ${
|
||||
isActive
|
||||
? "bg-primary/10 border-primary/20"
|
||||
: "hover:bg-default-100 border-transparent"
|
||||
}`}
|
||||
onPress={() => onSelect(item.key)}
|
||||
startContent={item.icon}
|
||||
>
|
||||
<div className="flex flex-col items-start w-full">
|
||||
<div className="font-medium text-sm">
|
||||
{t(item.label)}
|
||||
</div>
|
||||
</div>
|
||||
</Button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</nav>
|
||||
)}
|
||||
</div>
|
||||
</ScrollShadow>
|
||||
);
|
||||
};
|
||||
|
||||
export default SystemSettingsSidebar;
|
||||
@@ -0,0 +1,17 @@
|
||||
export enum SettingModalTab {
|
||||
TITLE_DESCRIPTION = "title-description",
|
||||
META_DATA = "meta-data",
|
||||
CUSTOM_DOMAIN = "custom-domain",
|
||||
BRANDING = "branding",
|
||||
THEME = "theme",
|
||||
PAYMENT = "payment",
|
||||
CODE_INJECTION = "code-injection",
|
||||
XPACK_EXPLORE = "xpack-explore",
|
||||
NAVIGATION = "navigation",
|
||||
FAQ = "faq",
|
||||
CHANGE_PASSWORD = "change-password",
|
||||
EMAIL_LOGIN_SETTINGS = "email-login-settings",
|
||||
GOOGLE_LOGIN_SETTINGS = "google-login-settings",
|
||||
SMTP_SETTINGS = "smtp-settings",
|
||||
PLATFORM_LANGUAGE = "platform-language",
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState } from "react";
|
||||
import { Input, Card, CardBody } from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
|
||||
interface CustomDomainPanelProps {
|
||||
domain: string;
|
||||
setDomain: (domain: string) => void;
|
||||
}
|
||||
|
||||
const CustomDomainPanel: React.FC<CustomDomainPanelProps> = ({
|
||||
domain,
|
||||
setDomain,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const [validationError, setValidationError] = useState<string | undefined>();
|
||||
|
||||
// Validate domain URL
|
||||
const validateDomain = (value: string): string | undefined => {
|
||||
if (!value.trim()) {
|
||||
return undefined; // Domain is optional
|
||||
}
|
||||
|
||||
// Basic domain format validation ,like www.example.com
|
||||
const domainRegex =
|
||||
/(?=.{1,255}$)(?:(?!-)[a-zA-Z0-9-]{1,63}(?<!-)\.)+[a-zA-Z]{2,}/;
|
||||
if (!domainRegex.test(value)) {
|
||||
return t("Please enter a valid domain");
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
const handleBlur = () => {
|
||||
const error = validateDomain(domain);
|
||||
setValidationError(error);
|
||||
};
|
||||
|
||||
return (
|
||||
<Card shadow="none">
|
||||
<CardBody className="flex flex-col p-0">
|
||||
<h3 className="font-semibold mb-2">
|
||||
{"1. "}
|
||||
{t("Enter the domain you want to use")}
|
||||
</h3>
|
||||
|
||||
<Input
|
||||
label={t("Domain")}
|
||||
placeholder={t("Enter your full domain name (e.g., www.example.com)")}
|
||||
value={domain}
|
||||
onChange={(e) => setDomain(e.target.value)}
|
||||
onBlur={handleBlur}
|
||||
isInvalid={!!validationError}
|
||||
errorMessage={validationError}
|
||||
/>
|
||||
</CardBody>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
|
||||
export default CustomDomainPanel;
|
||||
@@ -0,0 +1,66 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import {
|
||||
Card,
|
||||
CardBody,
|
||||
Table,
|
||||
TableHeader,
|
||||
TableColumn,
|
||||
TableBody,
|
||||
TableRow,
|
||||
TableCell,
|
||||
} from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
|
||||
interface DNSRecordsPanelProps {
|
||||
cnameTarget: string; // e.g., subdomain.domainhost.com
|
||||
apexATarget?: string; // optional A record IP for apex
|
||||
}
|
||||
|
||||
type DnsRow = { key: string; type: string; host: string; value: string };
|
||||
|
||||
const DNSRecordsPanel: React.FC<DNSRecordsPanelProps> = ({
|
||||
cnameTarget,
|
||||
apexATarget,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const rows: DnsRow[] = [
|
||||
...(cnameTarget
|
||||
? [{ key: "cname", type: "CNAME", host: "www", value: cnameTarget }]
|
||||
: []),
|
||||
...(apexATarget
|
||||
? [{ key: "a-record", type: "A", host: "@", value: apexATarget }]
|
||||
: []),
|
||||
];
|
||||
|
||||
return (
|
||||
<Card shadow="none">
|
||||
<CardBody className="p-0 flex flex-col gap-2">
|
||||
<h3 className="font-semibold mb-2">
|
||||
{"2. "}
|
||||
{t("Create your DNS records")}
|
||||
</h3>
|
||||
<Table aria-label={t("DNS Records Table")} shadow="none" removeWrapper>
|
||||
<TableHeader>
|
||||
<TableColumn>{t("Type")}</TableColumn>
|
||||
<TableColumn>{t("Host")}</TableColumn>
|
||||
<TableColumn>{t("Value")}</TableColumn>
|
||||
</TableHeader>
|
||||
<TableBody items={rows}>
|
||||
{(item) => (
|
||||
<TableRow key={item.key}>
|
||||
<TableCell>{item.type}</TableCell>
|
||||
<TableCell>{item.host}</TableCell>
|
||||
<TableCell>{item.value}</TableCell>
|
||||
</TableRow>
|
||||
)}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</CardBody>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
|
||||
export default DNSRecordsPanel;
|
||||
@@ -0,0 +1,86 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState } from "react";
|
||||
import {
|
||||
Button,
|
||||
Modal,
|
||||
ModalContent,
|
||||
ModalBody,
|
||||
ModalHeader,
|
||||
Card,
|
||||
CardBody,
|
||||
} from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import CustomDomainPanel from "./CustomDomainPanel";
|
||||
import DNSRecordsPanel from "./DNSRecordsPanel";
|
||||
|
||||
export type DomainActivationPanelConfig = {
|
||||
domain?: string;
|
||||
subdomain?: string;
|
||||
cname_a_ip?: string;
|
||||
};
|
||||
|
||||
interface DomainActivationPanelProps {
|
||||
config: DomainActivationPanelConfig;
|
||||
onSave: (config: DomainActivationPanelConfig) => void;
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
const DomainActivationPanel: React.FC<DomainActivationPanelProps> = ({
|
||||
config,
|
||||
onSave,
|
||||
isOpen,
|
||||
onClose,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [domain, setDomain] = useState(config.domain || "");
|
||||
const handleActivate = async () => {
|
||||
setIsLoading(true);
|
||||
try {
|
||||
await onSave({
|
||||
domain,
|
||||
});
|
||||
onClose();
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Modal isOpen={isOpen} onClose={onClose} size="xl">
|
||||
<ModalContent>
|
||||
<ModalHeader>{t("Set Custom Domain")}</ModalHeader>
|
||||
<ModalBody className="flex flex-col gap-4">
|
||||
<CustomDomainPanel domain={domain} setDomain={setDomain} />
|
||||
<DNSRecordsPanel
|
||||
cnameTarget={`${config.subdomain || ""}${process.env.NEXT_PUBLIC_DOMAIN_HOST || ""}`}
|
||||
apexATarget={config.cname_a_ip}
|
||||
/>
|
||||
<Card shadow="none">
|
||||
<CardBody className="p-0 flex flex-col gap-2 pb-4">
|
||||
<h3 className="font-semibold mb-2">
|
||||
{"3. "}
|
||||
{t("Activate your domain")}
|
||||
</h3>
|
||||
<Button
|
||||
color="primary"
|
||||
isDisabled={!domain}
|
||||
isLoading={isLoading}
|
||||
onPress={handleActivate}
|
||||
size="sm"
|
||||
>
|
||||
{t("Activate")}
|
||||
</Button>
|
||||
</CardBody>
|
||||
</Card>
|
||||
</ModalBody>
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default DomainActivationPanel;
|
||||
@@ -0,0 +1,108 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect } from "react";
|
||||
import { Input, Button } from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { z } from "zod";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import UploadImage from "@/components/common/UploadImage";
|
||||
|
||||
export type BrandPanelConfig = {
|
||||
logo: string;
|
||||
name: string;
|
||||
};
|
||||
|
||||
const brandPanelSchema = z.object({
|
||||
logo: z.string(),
|
||||
name: z.string().min(1, "Name is required"),
|
||||
});
|
||||
|
||||
interface BrandPanelProps {
|
||||
config: BrandPanelConfig;
|
||||
onSave: (config: BrandPanelConfig) => Promise<boolean>;
|
||||
onUploadImage: (file: File, sha256?: string) => Promise<string>;
|
||||
}
|
||||
|
||||
const BrandPanel: React.FC<BrandPanelProps> = ({
|
||||
config,
|
||||
onSave,
|
||||
onUploadImage,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const {
|
||||
handleSubmit,
|
||||
control,
|
||||
setValue,
|
||||
formState: { errors, isSubmitting, isValid },
|
||||
} = useForm<BrandPanelConfig>({
|
||||
resolver: zodResolver(brandPanelSchema),
|
||||
mode: "onBlur",
|
||||
defaultValues: config,
|
||||
});
|
||||
useEffect(() => {
|
||||
setValue("name", config.name);
|
||||
setValue("logo", config.logo);
|
||||
}, [config]);
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<div className="flex flex-col gap-4">
|
||||
<form onSubmit={handleSubmit(onSave)} className="flex flex-col gap-4">
|
||||
<Controller
|
||||
name="name"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<>
|
||||
<Input
|
||||
{...field}
|
||||
label={t("Your brand")}
|
||||
placeholder={t("Enter your brand name")}
|
||||
isInvalid={!!errors.name}
|
||||
errorMessage={errors.name?.message}
|
||||
labelPlacement="outside"
|
||||
isRequired
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
/>
|
||||
<Controller
|
||||
name="logo"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<div className="flex flex-col gap-2">
|
||||
<div>
|
||||
<label className="text-sm font-medium text-foreground">
|
||||
{t("Logo")}
|
||||
</label>
|
||||
<p className="text-xs text-gray-500">
|
||||
{t("Support JPG, PNG, GIF, SVG. Max size 5MB")}
|
||||
</p>
|
||||
</div>
|
||||
<UploadImage
|
||||
onSave={onUploadImage}
|
||||
setImageUrl={(imageUrl) => field.onChange(imageUrl)}
|
||||
imageUrl={field.value}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
<Button
|
||||
color="primary"
|
||||
variant="solid"
|
||||
type="submit"
|
||||
isLoading={isSubmitting}
|
||||
size="sm"
|
||||
isDisabled={!isValid}
|
||||
className="mt-2 w-fit"
|
||||
>
|
||||
{t("Save")}
|
||||
</Button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default BrandPanel;
|
||||
@@ -0,0 +1,70 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { Button } from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { EditIcon } from "lucide-react";
|
||||
import DomainActivationPanel from "../custom-domain/DomainActivationPanel";
|
||||
|
||||
export type DomainPanelConfig = {
|
||||
subdomain?: string;
|
||||
domain?: string;
|
||||
cname_a_ip?: string;
|
||||
};
|
||||
|
||||
interface DomainPanelProps {
|
||||
config: DomainPanelConfig;
|
||||
onSave: (config: DomainPanelConfig) => Promise<boolean>;
|
||||
}
|
||||
|
||||
const DomainPanel: React.FC<DomainPanelProps> = ({ config, onSave }) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const [formData, setFormData] = useState<DomainPanelConfig>(config);
|
||||
const [showCustomDomainModal, setShowCustomDomainModal] = useState(false);
|
||||
// when context config updated, sync to form
|
||||
useEffect(() => {
|
||||
setFormData(config);
|
||||
}, [config]);
|
||||
|
||||
const handleCustomDomainSave = async (config: DomainPanelConfig) => {
|
||||
const result = await onSave(config);
|
||||
if (!result) return;
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="flex flex-col gap-4">
|
||||
<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("Custom Domain")}</span>
|
||||
<span className="text-xs text-gray-500">
|
||||
{formData.domain || t("Set your custom domain for the platform")}
|
||||
</span>
|
||||
</div>
|
||||
<Button
|
||||
size="sm"
|
||||
onPress={() => setShowCustomDomainModal(true)}
|
||||
isIconOnly
|
||||
startContent={<EditIcon size={16} />}
|
||||
variant="flat"
|
||||
></Button>
|
||||
</div>
|
||||
</div>
|
||||
{showCustomDomainModal && (
|
||||
<DomainActivationPanel
|
||||
config={{
|
||||
subdomain: formData.subdomain,
|
||||
domain: formData.domain,
|
||||
cname_a_ip: config.cname_a_ip,
|
||||
}}
|
||||
onSave={handleCustomDomainSave}
|
||||
isOpen={showCustomDomainModal}
|
||||
onClose={() => setShowCustomDomainModal(false)}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default DomainPanel;
|
||||
@@ -0,0 +1,51 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import { Switch } from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
|
||||
export type ExplorePanelConfig = {
|
||||
is_showcased: boolean;
|
||||
};
|
||||
|
||||
interface ExplorePanelProps {
|
||||
isEnabled: boolean;
|
||||
onSave: (config: ExplorePanelConfig) => void;
|
||||
}
|
||||
|
||||
export const ExplorePanel: React.FC<ExplorePanelProps> = ({
|
||||
isEnabled,
|
||||
onSave,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<div className="flex flex-col gap-4">
|
||||
{/* showcase in xpack */}
|
||||
<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("Featured in the XPack showcase")}
|
||||
</span>
|
||||
<span className="text-xs text-gray-500">
|
||||
{t(
|
||||
"Enable this option to feature your site in the XPack global showcase and reach users worldwide."
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
<Switch
|
||||
isSelected={isEnabled}
|
||||
onValueChange={(value) => {
|
||||
onSave({
|
||||
is_showcased: value,
|
||||
});
|
||||
}}
|
||||
color="primary"
|
||||
size="sm"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,159 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect } from "react";
|
||||
import { Button, Card, CardBody, Input } from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import UploadImage from "@/components/common/UploadImage";
|
||||
import { z } from "zod";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { PlatformConfig } from "@/shared/types/system";
|
||||
import { FaFacebook } from "react-icons/fa6";
|
||||
|
||||
export interface FacebookMetaData {
|
||||
facebook_title: string;
|
||||
facebook_description: string;
|
||||
facebook_image_url?: string;
|
||||
}
|
||||
|
||||
const formSchema = z.object({
|
||||
facebook_title: z
|
||||
.string()
|
||||
.max(200, "Title is too long")
|
||||
.optional()
|
||||
.default(""),
|
||||
facebook_description: z
|
||||
.string()
|
||||
.max(1000, "Description is too long")
|
||||
.optional()
|
||||
.default(""),
|
||||
facebook_image_url: z.string().optional().or(z.literal("")).default(""),
|
||||
});
|
||||
|
||||
type FormData = z.infer<typeof formSchema>;
|
||||
|
||||
interface MetaDataFacebookFormProps {
|
||||
metaData: FacebookMetaData;
|
||||
onSave: (metaData: FacebookMetaData) => Promise<boolean>;
|
||||
onUploadImage: (file: File, sha256?: string) => Promise<string>;
|
||||
platformConfig: PlatformConfig;
|
||||
}
|
||||
|
||||
const MetaDataFacebookForm: React.FC<MetaDataFacebookFormProps> = ({
|
||||
metaData,
|
||||
onSave,
|
||||
onUploadImage,
|
||||
platformConfig,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
setValue,
|
||||
formState: { errors, isSubmitting, isValid },
|
||||
} = useForm<FormData>({
|
||||
resolver: zodResolver(formSchema),
|
||||
mode: "onBlur",
|
||||
defaultValues: metaData,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (!metaData) return;
|
||||
setValue("facebook_title", metaData.facebook_title || "");
|
||||
setValue("facebook_description", metaData.facebook_description || "");
|
||||
setValue("facebook_image_url", metaData.facebook_image_url || "");
|
||||
}, [metaData, setValue]);
|
||||
const onSubmit = async (data: FormData) => {
|
||||
await onSave(data);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="max-w-2xl">
|
||||
<div className="mb-2">
|
||||
<div className="flex items-center gap-2">
|
||||
<FaFacebook className="text-primary" size={40} />
|
||||
<div className="flex flex-col">
|
||||
<span className="font-semibold text-default-900">
|
||||
{platformConfig.name}
|
||||
</span>
|
||||
<span className="text-default-400 text-xs">2h</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mb-2 h-3 w-full rounded-large bg-default-100"></div>
|
||||
<div className="mb-4 h-3 w-3/5 rounded-large bg-default-100"></div>
|
||||
</div>
|
||||
<Card shadow="none" className="border-1 max-w-2xl">
|
||||
<CardBody className="px-0 py-4">
|
||||
<form
|
||||
onSubmit={handleSubmit(onSubmit)}
|
||||
className="flex flex-col gap-4 px-4"
|
||||
>
|
||||
<Controller
|
||||
name="facebook_image_url"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<UploadImage
|
||||
onSave={onUploadImage}
|
||||
imageUrl={field.value}
|
||||
setImageUrl={(imageUrl) => {
|
||||
field.onChange(imageUrl);
|
||||
}}
|
||||
className="h-[280px] w-full bg-default-100"
|
||||
description={t("Upload Facebook Image")}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
name="facebook_title"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<Input
|
||||
{...field}
|
||||
label={t("Facebook Title")}
|
||||
placeholder={platformConfig.headline || " "}
|
||||
isInvalid={!!errors.facebook_title}
|
||||
errorMessage={errors.facebook_title?.message}
|
||||
labelPlacement="outside"
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
name="facebook_description"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<Input
|
||||
{...field}
|
||||
label={t("Facebook Description")}
|
||||
placeholder={platformConfig.subheadline || " "}
|
||||
isInvalid={!!errors.facebook_description}
|
||||
errorMessage={errors.facebook_description?.message}
|
||||
labelPlacement="outside"
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
|
||||
<div className="flex justify-start mt-2">
|
||||
<Button
|
||||
type="submit"
|
||||
color="primary"
|
||||
size="sm"
|
||||
className="w-fit"
|
||||
isLoading={isSubmitting}
|
||||
isDisabled={!isValid}
|
||||
>
|
||||
{t("Save")}
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
</CardBody>
|
||||
</Card>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default MetaDataFacebookForm;
|
||||
@@ -0,0 +1,82 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect } from "react";
|
||||
import { Tabs, Tab } from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import MetaDataFacebookForm from "./MetaDataFacebookForm";
|
||||
import MetaDataXForm from "./MetaDataXForm";
|
||||
import MetaDataSearchForm from "./MetaDataSearchForm";
|
||||
import { FacebookMetaData } from "./MetaDataFacebookForm";
|
||||
import { SearchMetaData } from "./MetaDataSearchForm";
|
||||
import { XMetaData } from "./MetaDataXForm";
|
||||
import { PlatformConfig } from "@/shared/types/system";
|
||||
|
||||
interface MetaData {
|
||||
website_title?: string;
|
||||
meta_description?: string;
|
||||
x_title?: string;
|
||||
x_description?: string;
|
||||
x_image_url?: string;
|
||||
facebook_title?: string;
|
||||
facebook_description?: string;
|
||||
facebook_image_url?: string;
|
||||
}
|
||||
|
||||
interface MetaDataPanelProps {
|
||||
metaData: MetaData;
|
||||
onSave: (metaData: MetaData) => Promise<boolean>;
|
||||
uploadImage: (file: File, sha256?: string) => Promise<string>;
|
||||
platformConfig: PlatformConfig;
|
||||
}
|
||||
|
||||
const MetaDataPanel: React.FC<MetaDataPanelProps> = ({
|
||||
metaData,
|
||||
onSave,
|
||||
uploadImage,
|
||||
platformConfig,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const handleSave = async (data: MetaData) => {
|
||||
return await onSave({
|
||||
...metaData,
|
||||
...data,
|
||||
});
|
||||
};
|
||||
return (
|
||||
<Tabs
|
||||
aria-label="Meta data options"
|
||||
variant="solid"
|
||||
className="w-full"
|
||||
destroyInactiveTabPanel={false}
|
||||
>
|
||||
<Tab key="search" title={t("Search")} className="pb-0">
|
||||
<MetaDataSearchForm
|
||||
metaData={metaData as SearchMetaData}
|
||||
onSave={handleSave}
|
||||
platformConfig={platformConfig}
|
||||
/>
|
||||
</Tab>
|
||||
|
||||
<Tab key="x" title={t("X Card")} className="pb-0">
|
||||
<MetaDataXForm
|
||||
metaData={metaData as XMetaData}
|
||||
onSave={handleSave}
|
||||
onUploadImage={uploadImage}
|
||||
platformConfig={platformConfig}
|
||||
/>
|
||||
</Tab>
|
||||
|
||||
<Tab key="facebook" title={t("Facebook Card")} className="pb-0">
|
||||
<MetaDataFacebookForm
|
||||
metaData={metaData as FacebookMetaData}
|
||||
onSave={handleSave}
|
||||
onUploadImage={uploadImage}
|
||||
platformConfig={platformConfig}
|
||||
/>
|
||||
</Tab>
|
||||
</Tabs>
|
||||
);
|
||||
};
|
||||
|
||||
export default MetaDataPanel;
|
||||
@@ -0,0 +1,215 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect } from "react";
|
||||
import { Button, Card, CardBody, CardFooter, Input } from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { z } from "zod";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { PlatformConfig } from "@/shared/types/system";
|
||||
|
||||
export interface SearchMetaData {
|
||||
website_title: string;
|
||||
meta_description: string;
|
||||
}
|
||||
|
||||
const formSchema = z.object({
|
||||
website_title: z.string().max(75, "Title is too long").optional().default(""),
|
||||
meta_description: z
|
||||
.string()
|
||||
.max(156, "Description is too long")
|
||||
.optional()
|
||||
.or(z.literal(""))
|
||||
.default(""),
|
||||
});
|
||||
|
||||
type FormData = z.infer<typeof formSchema>;
|
||||
|
||||
interface MetaDataSearchFormProps {
|
||||
metaData: SearchMetaData;
|
||||
platformConfig: PlatformConfig;
|
||||
onSave: (metaData: SearchMetaData) => Promise<boolean>;
|
||||
}
|
||||
|
||||
const MetaDataSearchForm: React.FC<MetaDataSearchFormProps> = ({
|
||||
metaData,
|
||||
platformConfig,
|
||||
onSave,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
setValue,
|
||||
watch,
|
||||
formState: { errors, isSubmitting, isValid },
|
||||
} = useForm<FormData>({
|
||||
resolver: zodResolver(formSchema),
|
||||
mode: "onBlur",
|
||||
defaultValues: metaData,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (!metaData) return;
|
||||
setValue("meta_description", metaData.meta_description || "");
|
||||
setValue("website_title", metaData.website_title || "");
|
||||
}, [metaData, setValue]);
|
||||
|
||||
const onSubmit = async (data: FormData) => {
|
||||
await onSave(data);
|
||||
};
|
||||
|
||||
const metaDescription = watch("meta_description");
|
||||
const websiteTitle = watch("website_title");
|
||||
|
||||
return (
|
||||
<Card shadow="none" className="border-1 max-w-2xl">
|
||||
<CardBody className="px-0 py-4">
|
||||
<form
|
||||
onSubmit={handleSubmit(onSubmit)}
|
||||
className="flex flex-col gap-4 px-4"
|
||||
>
|
||||
<Controller
|
||||
name="website_title"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<Input
|
||||
{...field}
|
||||
label={t("Meta Title")}
|
||||
placeholder={platformConfig.headline || " "}
|
||||
isInvalid={!!errors.website_title}
|
||||
errorMessage={errors.website_title?.message}
|
||||
labelPlacement="outside"
|
||||
defaultValue={t("Recommended: 70 characters")}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
name="meta_description"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<Input
|
||||
{...field}
|
||||
label={t("Meta Description")}
|
||||
placeholder={platformConfig.subheadline || " "}
|
||||
isInvalid={!!errors.meta_description}
|
||||
errorMessage={errors.meta_description?.message}
|
||||
labelPlacement="outside"
|
||||
defaultValue={t("Recommended: 156 characters")}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
|
||||
<div className="flex justify-start mt-2">
|
||||
<Button
|
||||
type="submit"
|
||||
color="primary"
|
||||
size="sm"
|
||||
className="w-fit"
|
||||
isLoading={isSubmitting}
|
||||
isDisabled={!isValid}
|
||||
>
|
||||
{t("Save")}
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
</CardBody>
|
||||
<CardFooter className="p-0">
|
||||
<div className="w-full bg-default-100">
|
||||
<div className="mt-4 mb-2 text-grey-500 px-5 uppercase text-xs">
|
||||
{t("Preview")}
|
||||
</div>
|
||||
<div className="mx-5 -mb-5 overflow-hidden rounded-b-xl bg-grey-50 pt-2 ">
|
||||
<div className="rounded-t-lg bg-white px-5 py-3 shadow-lg mb-5">
|
||||
<div className="mt-3 flex items-center">
|
||||
<div>
|
||||
<svg fill="none" viewBox="0 0 92 31" className="mr-7 h-7">
|
||||
<title>google</title>
|
||||
<path
|
||||
d="M39.15 15.898c0 4.303-3.378 7.473-7.525 7.473s-7.526-3.17-7.526-7.473c0-4.334 3.38-7.474 7.526-7.474 4.147 0 7.526 3.14 7.526 7.474zm-3.294 0c0-2.69-1.958-4.529-4.231-4.529-2.273 0-4.231 1.84-4.231 4.529 0 2.662 1.958 4.528 4.231 4.528 2.273 0 4.231-1.87 4.231-4.528z"
|
||||
fill="#EA4335"
|
||||
></path>
|
||||
<path
|
||||
d="M55.386 15.898c0 4.303-3.379 7.473-7.526 7.473-4.146 0-7.526-3.17-7.526-7.473 0-4.33 3.38-7.474 7.526-7.474 4.147 0 7.526 3.14 7.526 7.474zm-3.294 0c0-2.69-1.959-4.529-4.232-4.529s-4.231 1.84-4.231 4.529c0 2.662 1.958 4.528 4.231 4.528 2.273 0 4.232-1.87 4.232-4.528z"
|
||||
fill="#FBBC05"
|
||||
></path>
|
||||
<path
|
||||
d="M70.945 8.875v13.418c0 5.52-3.267 7.774-7.13 7.774-3.636 0-5.825-2.423-6.65-4.404l2.868-1.19c.511 1.217 1.763 2.652 3.779 2.652 2.472 0 4.004-1.52 4.004-4.38V21.67h-.115c-.737.906-2.158 1.698-3.95 1.698-3.751 0-7.188-3.255-7.188-7.443 0-4.22 3.437-7.501 7.188-7.501 1.789 0 3.21.792 3.95 1.671h.115V8.88h3.129v-.004zm-2.895 7.05c0-2.632-1.763-4.556-4.005-4.556-2.273 0-4.177 1.924-4.177 4.556 0 2.604 1.904 4.501 4.177 4.501 2.242 0 4.005-1.897 4.005-4.501z"
|
||||
fill="#4285F4"
|
||||
></path>
|
||||
<path
|
||||
d="M76.103 1.01v21.903H72.89V1.011h3.213z"
|
||||
fill="#34A853"
|
||||
></path>
|
||||
<path
|
||||
d="M88.624 18.357l2.558 1.699c-.826 1.216-2.815 3.312-6.251 3.312-4.262 0-7.445-3.282-7.445-7.474 0-4.444 3.21-7.473 7.076-7.473 3.893 0 5.798 3.086 6.42 4.754l.341.85-10.028 4.137c.768 1.5 1.962 2.264 3.636 2.264 1.678 0 2.841-.822 3.693-2.069zm-7.87-2.688l6.703-2.774c-.368-.933-1.478-1.583-2.783-1.583-1.674 0-4.005 1.472-3.92 4.357z"
|
||||
fill="#EA4335"
|
||||
></path>
|
||||
<path
|
||||
d="M11.936 13.953v-3.17h10.726c.105.552.159 1.206.159 1.914 0 2.378-.653 5.32-2.757 7.416-2.046 2.123-4.66 3.255-8.124 3.255-6.42 0-11.818-5.21-11.818-11.605C.122 5.368 5.52.158 11.94.158c3.551 0 6.081 1.389 7.982 3.198l-2.246 2.237c-1.363-1.273-3.21-2.264-5.74-2.264-4.688 0-8.354 3.764-8.354 8.434s3.666 8.434 8.354 8.434c3.041 0 4.773-1.216 5.882-2.322.9-.896 1.492-2.176 1.725-3.925l-7.607.003z"
|
||||
fill="#4285F4"
|
||||
></path>
|
||||
</svg>
|
||||
</div>
|
||||
<div className="grow">
|
||||
<div className="flex w-full items-center justify-end rounded-full bg-white p-3 px-4 shadow dark:bg-grey-900">
|
||||
<svg
|
||||
viewBox="0 0 24 24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
stroke-width="1.5"
|
||||
className="pointer-events-none size-4 stroke-[2px] text-blue-600"
|
||||
>
|
||||
<path
|
||||
d="M0.750 9.812 A9.063 9.063 0 1 0 18.876 9.812 A9.063 9.063 0 1 0 0.750 9.812 Z"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
transform="translate(-3.056 4.62) rotate(-23.025)"
|
||||
></path>
|
||||
<path
|
||||
d="M16.221 16.22L23.25 23.25"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
></path>
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-4 flex items-center gap-2 border-t border-grey-200 pt-4 dark:border-grey-900">
|
||||
<div
|
||||
className="flex size-7 items-center justify-center rounded-full bg-grey-200 dark:bg-grey-700"
|
||||
style={{
|
||||
backgroundImage: `url("${platformConfig.logo}")`,
|
||||
backgroundSize: "contain",
|
||||
}}
|
||||
></div>
|
||||
<div className="flex flex-col text-sm">
|
||||
<span>{platformConfig.domain || window.location.host}</span>
|
||||
<span className="-mt-0.5 inline-block text-xs text-grey-600">
|
||||
https://
|
||||
{platformConfig.domain || window.location.host}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-1 flex flex-col">
|
||||
<span className="text-lg text-[#1a0dab] dark:text-blue">
|
||||
{websiteTitle || platformConfig.headline}
|
||||
</span>
|
||||
<span className="text-sm text-grey-900 dark:text-grey-700">
|
||||
{metaDescription || platformConfig.subheadline}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
|
||||
export default MetaDataSearchForm;
|
||||
@@ -0,0 +1,160 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect } from "react";
|
||||
import { Button, Card, CardBody, Input } from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import UploadImage from "@/components/common/UploadImage";
|
||||
import { z } from "zod";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { PlatformConfig } from "@/shared/types/system";
|
||||
import { FaXTwitter } from "react-icons/fa6";
|
||||
|
||||
export interface XMetaData {
|
||||
x_title: string;
|
||||
x_description: string;
|
||||
x_image_url?: string;
|
||||
}
|
||||
|
||||
const formSchema = z.object({
|
||||
x_title: z.string().max(200, "Title is too long").optional().default(""),
|
||||
x_description: z
|
||||
.string()
|
||||
.max(1000, "Description is too long")
|
||||
.optional()
|
||||
.or(z.literal(""))
|
||||
.default(""),
|
||||
x_image_url: z.string().optional().or(z.literal("")).default(""),
|
||||
});
|
||||
|
||||
type FormData = z.infer<typeof formSchema>;
|
||||
|
||||
interface MetaDataXFormProps {
|
||||
metaData: XMetaData;
|
||||
onSave: (metaData: XMetaData) => Promise<boolean>;
|
||||
onUploadImage: (file: File, sha256?: string) => Promise<string>;
|
||||
platformConfig: PlatformConfig;
|
||||
}
|
||||
|
||||
const MetaDataXForm: React.FC<MetaDataXFormProps> = ({
|
||||
metaData,
|
||||
onSave,
|
||||
onUploadImage,
|
||||
platformConfig,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
setValue,
|
||||
formState: { errors, isSubmitting, isValid },
|
||||
} = useForm<FormData>({
|
||||
resolver: zodResolver(formSchema),
|
||||
mode: "onBlur",
|
||||
defaultValues: metaData,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (!metaData) return;
|
||||
setValue("x_title", metaData.x_title || "");
|
||||
setValue("x_description", metaData.x_description || "");
|
||||
setValue("x_image_url", metaData.x_image_url || "");
|
||||
}, [metaData, setValue]);
|
||||
|
||||
const onSubmit = async (data: FormData) => {
|
||||
await onSave(data);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="flex items-start gap-2 w-full">
|
||||
<FaXTwitter size={40} />
|
||||
<div className="w-full">
|
||||
<div className="max-w-2xl">
|
||||
<div className="mb-2">
|
||||
<div className="flex">
|
||||
<span className="mr-1 font-semibold text-default-900">
|
||||
{platformConfig.name}
|
||||
</span>
|
||||
<span className="text-default-400">· 2h</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mb-2 h-3 w-full rounded-large bg-default-100"></div>
|
||||
<div className="mb-4 h-3 w-3/5 rounded-large bg-default-100"></div>
|
||||
</div>
|
||||
|
||||
<Card shadow="none" className="border-1 max-w-2xl">
|
||||
<CardBody className="px-0 py-4">
|
||||
<form
|
||||
onSubmit={handleSubmit(onSubmit)}
|
||||
className="flex flex-col gap-4 px-4"
|
||||
>
|
||||
<Controller
|
||||
name="x_image_url"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<UploadImage
|
||||
onSave={onUploadImage}
|
||||
imageUrl={field.value}
|
||||
setImageUrl={(imageUrl) => {
|
||||
field.onChange(imageUrl);
|
||||
}}
|
||||
className="h-[280px] w-full bg-default-100"
|
||||
description={t("Upload X Image")}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
name="x_title"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<Input
|
||||
{...field}
|
||||
label={t("X Title")}
|
||||
placeholder={platformConfig.headline || " "}
|
||||
isInvalid={!!errors.x_title}
|
||||
errorMessage={errors.x_title?.message}
|
||||
labelPlacement="outside"
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
name="x_description"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<Input
|
||||
{...field}
|
||||
label={t("X Description")}
|
||||
placeholder={platformConfig.subheadline || " "}
|
||||
isInvalid={!!errors.x_description}
|
||||
errorMessage={errors.x_description?.message}
|
||||
labelPlacement="outside"
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
|
||||
<div className="flex justify-start mt-2">
|
||||
<Button
|
||||
type="submit"
|
||||
color="primary"
|
||||
size="sm"
|
||||
className="w-fit"
|
||||
isLoading={isSubmitting}
|
||||
isDisabled={!isValid}
|
||||
>
|
||||
{t("Save")}
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
</CardBody>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default MetaDataXForm;
|
||||
@@ -0,0 +1,106 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect } from "react";
|
||||
import { Input, Button } from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { z } from "zod";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
|
||||
export type TitleAndDescPanelConfig = {
|
||||
headline: string;
|
||||
subheadline: string;
|
||||
};
|
||||
|
||||
const titleAndDescPanelSchema = z.object({
|
||||
headline: z.string().min(1, "Title is required"),
|
||||
subheadline: z.string(),
|
||||
});
|
||||
|
||||
interface TitleAndDescPanelProps {
|
||||
config: TitleAndDescPanelConfig;
|
||||
onSave: (config: TitleAndDescPanelConfig) => Promise<boolean>;
|
||||
}
|
||||
|
||||
const TitleAndDescPanel: React.FC<TitleAndDescPanelProps> = ({
|
||||
config,
|
||||
onSave,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const {
|
||||
handleSubmit,
|
||||
control,
|
||||
setValue,
|
||||
formState: { errors, isSubmitting, isValid },
|
||||
} = useForm<TitleAndDescPanelConfig>({
|
||||
resolver: zodResolver(titleAndDescPanelSchema),
|
||||
mode: "onBlur",
|
||||
defaultValues: config,
|
||||
});
|
||||
useEffect(() => {
|
||||
setValue("headline", config.headline);
|
||||
setValue("subheadline", config.subheadline);
|
||||
}, [config]);
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<div className="flex flex-col gap-4">
|
||||
<form onSubmit={handleSubmit(onSave)} className="flex flex-col gap-4">
|
||||
<Controller
|
||||
name="headline"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<>
|
||||
{/* homepage headline */}
|
||||
<Input
|
||||
{...field}
|
||||
label={t("Site title")}
|
||||
placeholder={t("Enter site title")}
|
||||
description={t("Main title displayed on the home page")}
|
||||
isInvalid={!!errors.headline}
|
||||
errorMessage={errors.headline?.message}
|
||||
labelPlacement="outside"
|
||||
isRequired
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
/>
|
||||
<Controller
|
||||
name="subheadline"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<>
|
||||
{/* homepage subheadline */}
|
||||
<Input
|
||||
{...field}
|
||||
label={t("Site description")}
|
||||
placeholder={t("Enter site description")}
|
||||
description={t(
|
||||
"Secondary description displayed below the main title"
|
||||
)}
|
||||
isInvalid={!!errors.subheadline}
|
||||
errorMessage={errors.subheadline?.message}
|
||||
labelPlacement="outside"
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
/>
|
||||
<Button
|
||||
color="primary"
|
||||
variant="solid"
|
||||
type="submit"
|
||||
isLoading={isSubmitting}
|
||||
size="sm"
|
||||
isDisabled={!isValid}
|
||||
className="mt-2 w-fit"
|
||||
>
|
||||
{t("Save")}
|
||||
</Button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default TitleAndDescPanel;
|
||||
Reference in new issue
Block a user