feat(ui): dynamic logo customization, centralized contact links, hero slider, banner placements, reorganized admin sidebar & ui-texts save fix
Deploy Canina / deploy (push) Has been cancelled
Deploy Canina / deploy (push) Has been cancelled
This commit is contained in:
1 parent
2fca778930
commit
2d594c5d69
34 files changed
+126746
-9764
No files matched your search
@@ -1,63 +1,50 @@
|
||||
import { useState, useEffect, useRef } from 'react';
|
||||
import { Link, useLocation } from 'react-router-dom';
|
||||
import { Users, ShoppingCart, Tag, Settings, TrendingUp, FolderTree, FileText, BookOpen, Heart, Package, LayoutDashboard, Languages, Image, Video, PhoneCall, Sparkles, MessageSquareQuote, FlaskConical, Building2, Globe, DollarSign, Sliders, MessageSquare, Receipt, CreditCard } from 'lucide-react';
|
||||
import {
|
||||
LayoutDashboard,
|
||||
TrendingUp,
|
||||
ShoppingCart,
|
||||
Receipt,
|
||||
Package,
|
||||
FolderTree,
|
||||
Tag,
|
||||
Sparkles,
|
||||
FileText,
|
||||
Users,
|
||||
Heart,
|
||||
MessageSquare,
|
||||
Building2,
|
||||
PhoneCall,
|
||||
Image,
|
||||
FlaskConical,
|
||||
MessageSquareQuote,
|
||||
BookOpen,
|
||||
Video,
|
||||
Settings,
|
||||
ShieldCheck,
|
||||
Languages,
|
||||
DollarSign,
|
||||
Sliders,
|
||||
Globe,
|
||||
ChevronDown,
|
||||
Star,
|
||||
Layers,
|
||||
} from 'lucide-react';
|
||||
import api from '../services/api';
|
||||
|
||||
const menuGroups = [
|
||||
{
|
||||
title: 'اصلی',
|
||||
items: [
|
||||
{ icon: LayoutDashboard, label: 'داشبورد', path: '/' },
|
||||
{ icon: TrendingUp, label: 'گزارشات', path: '/reports' },
|
||||
]
|
||||
},
|
||||
{
|
||||
title: 'فروشگاه و تخصصی',
|
||||
items: [
|
||||
{ icon: ShoppingCart, label: 'سفارشات', path: '/orders' },
|
||||
{ icon: Receipt, label: 'تراکنشها و لاگ پرداخت', path: '/transactions' },
|
||||
{ icon: Package, label: 'محصولات', path: '/products' },
|
||||
{ icon: MessageSquare, label: 'نظرات محصولات', path: '/reviews' },
|
||||
{ icon: FolderTree, label: 'دستهبندیها', path: '/categories' },
|
||||
{ icon: Tag, label: 'کدهای تخفیف', path: '/coupons' },
|
||||
{ icon: Sparkles, label: 'مشاور هوشمند', path: '/smart-advisor' },
|
||||
{ icon: FileText, label: 'نسخههای پزشکی', path: '/prescriptions' },
|
||||
]
|
||||
},
|
||||
{
|
||||
title: 'مدیریت و همکاران B2B',
|
||||
items: [
|
||||
{ icon: Users, label: 'کاربران', path: '/users' },
|
||||
{ icon: Heart, label: 'حیوانات (Pets)', path: '/pets' },
|
||||
{ icon: MessageSquare, label: 'تیکتها & مشاوره دامپزشک', path: '/tickets' },
|
||||
{ icon: Building2, label: 'مدیریت B2B & عمده', path: '/b2b' },
|
||||
{ icon: PhoneCall, label: 'تماس با ما & اطلاعات', path: '/contact' },
|
||||
]
|
||||
},
|
||||
{
|
||||
title: 'محتوا و دانشنامه',
|
||||
items: [
|
||||
{ icon: Image, label: 'بنرها و اسلایدرها', path: '/banners' },
|
||||
{ icon: FlaskConical, label: 'دانشنامه ترکیبات', path: '/ingredients' },
|
||||
{ icon: MessageSquareQuote, label: 'نظرات و گواهیها', path: '/testimonials' },
|
||||
{ icon: FileText, label: 'وبلاگ', path: '/blogs' },
|
||||
{ icon: BookOpen, label: 'دانشنامه عمومی', path: '/wiki' },
|
||||
{ icon: Video, label: 'مدیریت ویدئوها', path: '/videos' },
|
||||
]
|
||||
},
|
||||
{
|
||||
title: 'سیستم و تنظیمات',
|
||||
items: [
|
||||
{ icon: Settings, label: 'تنظیمات کلی', path: '/settings' },
|
||||
{ icon: MessageSquare, label: 'تنظیمات پیامک', path: '/settings/sms' },
|
||||
{ icon: Globe, label: 'تنظیمات سئو', path: '/settings/seo' },
|
||||
{ icon: DollarSign, label: 'تنظیمات مالی & ارسال', path: '/settings/financial' },
|
||||
{ icon: Sliders, label: 'تنظیمات سیستمی', path: '/settings/system' },
|
||||
{ icon: Languages, label: 'متون رابط کاربری', path: '/ui-texts' },
|
||||
{ icon: Image, label: 'مدیریت رسانه', path: '/media' },
|
||||
]
|
||||
}
|
||||
];
|
||||
interface SubMenuItem {
|
||||
icon: React.ComponentType<{ className?: string }>;
|
||||
label: string;
|
||||
path: string;
|
||||
badge?: string | number;
|
||||
}
|
||||
|
||||
interface MenuGroup {
|
||||
id: string;
|
||||
title: string;
|
||||
icon: React.ComponentType<{ className?: string }>;
|
||||
items: SubMenuItem[];
|
||||
}
|
||||
|
||||
interface SidebarProps {
|
||||
isOpen: boolean;
|
||||
@@ -69,12 +56,17 @@ export default function Sidebar({ isOpen, setIsOpen }: SidebarProps) {
|
||||
const [newOrdersCount, setNewOrdersCount] = useState(0);
|
||||
const intervalRef = useRef<ReturnType<typeof setInterval> | null>(null);
|
||||
|
||||
// Auto-close sidebar on mobile navigation
|
||||
useEffect(() => {
|
||||
setIsOpen(false);
|
||||
}, [location.pathname, setIsOpen]);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchOrdersCount = async () => {
|
||||
try {
|
||||
const response = await api.get('/admin/dashboard/stats');
|
||||
if (response.data?.success) {
|
||||
setNewOrdersCount(response.data.data.newOrders);
|
||||
setNewOrdersCount(response.data.data.newOrders || 0);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to fetch stats in sidebar', err);
|
||||
@@ -87,6 +79,106 @@ export default function Sidebar({ isOpen, setIsOpen }: SidebarProps) {
|
||||
};
|
||||
}, []);
|
||||
|
||||
const menuGroups: MenuGroup[] = [
|
||||
{
|
||||
id: 'main',
|
||||
title: 'داشبورد و تحلیل داده',
|
||||
icon: LayoutDashboard,
|
||||
items: [
|
||||
{ icon: LayoutDashboard, label: 'نمای کلی داشبورد', path: '/' },
|
||||
{ icon: TrendingUp, label: 'گزارشات و تحلیل فروش', path: '/reports' },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'orders',
|
||||
title: 'سفارشات و مالی',
|
||||
icon: ShoppingCart,
|
||||
items: [
|
||||
{
|
||||
icon: ShoppingCart,
|
||||
label: 'مدیریت سفارشات',
|
||||
path: '/orders',
|
||||
badge: newOrdersCount > 0 ? newOrdersCount : undefined,
|
||||
},
|
||||
{ icon: Receipt, label: 'تراکنشها و لاگ پرداخت', path: '/transactions' },
|
||||
{ icon: DollarSign, label: 'تنظیمات مالی و ارسال', path: '/settings/financial' },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'products',
|
||||
title: 'محصولات و کاتالوگ',
|
||||
icon: Package,
|
||||
items: [
|
||||
{ icon: Package, label: 'لیست محصولات', path: '/products' },
|
||||
{ icon: Star, label: 'نظرات و امتیازات', path: '/reviews' },
|
||||
{ icon: FolderTree, label: 'دستهبندیهای تخصصی', path: '/categories' },
|
||||
{ icon: Tag, label: 'کدهای تخفیف', path: '/coupons' },
|
||||
{ icon: Sparkles, label: 'مشاور هوشمند بالینی', path: '/smart-advisor' },
|
||||
{ icon: FileText, label: 'نسخههای دریافتی', path: '/prescriptions' },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'crm',
|
||||
title: 'کاربران و همکاران',
|
||||
icon: Users,
|
||||
items: [
|
||||
{ icon: Users, label: 'مدیریت کاربران', path: '/users' },
|
||||
{ icon: Heart, label: 'پرونده پتها (همدمها)', path: '/pets' },
|
||||
{ icon: MessageSquare, label: 'تیکتها و مشاوره تخصصی', path: '/tickets' },
|
||||
{ icon: Building2, label: 'پرتال B2B و همکاران', path: '/b2b' },
|
||||
{ icon: PhoneCall, label: 'اطلاعات تماس و پیامها', path: '/contact' },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'content',
|
||||
title: 'محتوا و دانشنامه',
|
||||
icon: Layers,
|
||||
items: [
|
||||
{ icon: Image, label: 'بنرها و اسلایدرها', path: '/banners' },
|
||||
{ icon: FileText, label: 'وبلاگ و مقالات', path: '/blogs' },
|
||||
{ icon: FlaskConical, label: 'دانشنامه ترکیبات', path: '/ingredients' },
|
||||
{ icon: BookOpen, label: 'دانشنامه عمومی و علمی', path: '/wiki' },
|
||||
{ icon: MessageSquareQuote, label: 'نظرات و گواهی متخصصان', path: '/testimonials' },
|
||||
{ icon: Video, label: 'ویدئوها و آموزشها', path: '/videos' },
|
||||
{ icon: Image, label: 'کتابخانه رسانه', path: '/media' },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'settings',
|
||||
title: 'سیستم و تنظیمات',
|
||||
icon: Settings,
|
||||
items: [
|
||||
{ icon: Settings, label: 'تنظیمات اصلی فروشگاه', path: '/settings' },
|
||||
{ icon: Languages, label: 'متون رابط کاربری', path: '/ui-texts' },
|
||||
{ icon: MessageSquare, label: 'درگاه پیامک (MeliPayamak)', path: '/settings/sms' },
|
||||
{ icon: ShieldCheck, label: 'گواهی SSL و امنیت', path: '/settings/ssl' },
|
||||
{ icon: Globe, label: 'تنظیمات سئو (SEO)', path: '/settings/seo' },
|
||||
{ icon: Sliders, label: 'تنظیمات سیستمی پیشرفته', path: '/settings/system' },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
// Auto expand active group
|
||||
const [expandedGroups, setExpandedGroups] = useState<Record<string, boolean>>(() => {
|
||||
const initial: Record<string, boolean> = {};
|
||||
menuGroups.forEach((g) => {
|
||||
const hasActive = g.items.some(
|
||||
(item) =>
|
||||
location.pathname === item.path ||
|
||||
(item.path !== '/' && location.pathname.startsWith(item.path))
|
||||
);
|
||||
initial[g.id] = hasActive || g.id === 'main' || g.id === 'orders';
|
||||
});
|
||||
return initial;
|
||||
});
|
||||
|
||||
const toggleGroup = (groupId: string) => {
|
||||
setExpandedGroups((prev) => ({
|
||||
...prev,
|
||||
[groupId]: !prev[groupId],
|
||||
}));
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* Mobile Backdrop */}
|
||||
@@ -97,43 +189,100 @@ export default function Sidebar({ isOpen, setIsOpen }: SidebarProps) {
|
||||
/>
|
||||
)}
|
||||
|
||||
<aside className={`w-64 bg-white border-l border-gray-200 h-screen fixed lg:fixed lg:right-0 lg:top-0 lg:bottom-0 flex flex-col font-vazir shadow-sm z-50 transform transition-transform duration-300 ease-in-out ${isOpen ? 'translate-x-0' : 'translate-x-full lg:translate-x-0'
|
||||
}`}>
|
||||
<div className="h-16 flex items-center justify-center border-b border-gray-200 shrink-0">
|
||||
<h1 className="text-xl font-black text-purple-600">کنینا | ادمینپنل</h1>
|
||||
<aside
|
||||
className={`w-64 bg-white border-l border-gray-200 h-screen fixed lg:fixed lg:right-0 lg:top-0 lg:bottom-0 flex flex-col font-vazir shadow-sm z-50 transform transition-transform duration-300 ease-in-out ${
|
||||
isOpen ? 'translate-x-0' : 'translate-x-full lg:translate-x-0'
|
||||
}`}
|
||||
>
|
||||
{/* Header */}
|
||||
<div className="h-16 flex items-center justify-between px-5 border-b border-gray-200 shrink-0 bg-white">
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="w-8 h-8 rounded-xl bg-purple-600 flex items-center justify-center text-white font-black text-sm italic shadow-md">
|
||||
C
|
||||
</div>
|
||||
<span className="text-base font-black text-gray-900">کنینا | ادمینپنل</span>
|
||||
</div>
|
||||
<span className="text-[10px] bg-purple-50 text-purple-700 font-bold px-2 py-0.5 rounded-md border border-purple-200">
|
||||
v2.4
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<nav className="flex-1 overflow-y-auto py-4 px-3 space-y-6">
|
||||
{menuGroups.map((group, idx) => (
|
||||
<div key={idx}>
|
||||
<h3 className="px-3 mb-2 text-xs font-black text-gray-400 uppercase tracking-wider">{group.title}</h3>
|
||||
<div className="space-y-1">
|
||||
{group.items.map((item) => {
|
||||
const isActive = location.pathname === item.path || (item.path !== '/' && location.pathname.startsWith(item.path));
|
||||
const Icon = item.icon;
|
||||
{/* Menu Navigation */}
|
||||
<nav className="flex-1 overflow-y-auto py-3 px-3 space-y-2">
|
||||
{menuGroups.map((group) => {
|
||||
const GroupIcon = group.icon;
|
||||
const isExpanded = !!expandedGroups[group.id];
|
||||
const hasActiveChild = group.items.some(
|
||||
(item) =>
|
||||
location.pathname === item.path ||
|
||||
(item.path !== '/' && location.pathname.startsWith(item.path))
|
||||
);
|
||||
|
||||
return (
|
||||
<Link
|
||||
key={item.path}
|
||||
to={item.path}
|
||||
className={`flex items-center gap-3 px-3 py-2.5 rounded-xl transition-all font-bold ${isActive
|
||||
? 'bg-purple-50 text-purple-600'
|
||||
: 'text-gray-500 hover:bg-gray-50 hover:text-gray-900'
|
||||
}`}
|
||||
>
|
||||
<Icon className="w-5 h-5" />
|
||||
<span>{item.label}</span>
|
||||
{item.label === 'سفارشات' && newOrdersCount > 0 && (
|
||||
<span className="mr-auto bg-purple-600 text-white text-[11px] font-black px-2 py-0.5 rounded-full min-w-[20px] text-center">
|
||||
{newOrdersCount}
|
||||
</span>
|
||||
)}
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
return (
|
||||
<div key={group.id} className="rounded-2xl overflow-hidden bg-gray-50/50 border border-gray-100">
|
||||
{/* Group Accordion Header */}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => toggleGroup(group.id)}
|
||||
className={`w-full flex items-center justify-between px-3 py-2.5 text-xs font-black transition-all ${
|
||||
hasActiveChild ? 'text-purple-700 bg-purple-50/70' : 'text-gray-600 hover:bg-gray-100/60'
|
||||
}`}
|
||||
>
|
||||
<div className="flex items-center gap-2">
|
||||
<GroupIcon className={`w-4 h-4 ${hasActiveChild ? 'text-purple-600' : 'text-gray-400'}`} />
|
||||
<span>{group.title}</span>
|
||||
</div>
|
||||
<ChevronDown
|
||||
className={`w-4 h-4 transition-transform duration-200 text-gray-400 ${
|
||||
isExpanded ? 'rotate-180' : ''
|
||||
}`}
|
||||
/>
|
||||
</button>
|
||||
|
||||
{/* Submenu Items */}
|
||||
{isExpanded && (
|
||||
<div className="p-1 space-y-0.5 bg-white border-t border-gray-100">
|
||||
{group.items.map((item) => {
|
||||
const isActive =
|
||||
location.pathname === item.path ||
|
||||
(item.path !== '/' && location.pathname.startsWith(item.path));
|
||||
const Icon = item.icon;
|
||||
|
||||
return (
|
||||
<Link
|
||||
key={item.path}
|
||||
to={item.path}
|
||||
onClick={() => setIsOpen(false)}
|
||||
className={`flex items-center justify-between px-3 py-2 rounded-xl text-xs font-bold transition-all ${
|
||||
isActive
|
||||
? 'bg-purple-600 text-white shadow-sm shadow-purple-600/30'
|
||||
: 'text-gray-600 hover:bg-purple-50/50 hover:text-purple-700'
|
||||
}`}
|
||||
>
|
||||
<div className="flex items-center gap-2.5">
|
||||
<Icon className={`w-4 h-4 ${isActive ? 'text-white' : 'text-gray-400'}`} />
|
||||
<span>{item.label}</span>
|
||||
</div>
|
||||
|
||||
{item.badge !== undefined && (
|
||||
<span
|
||||
className={`text-[10px] font-black px-1.5 py-0.5 rounded-full min-w-[18px] text-center ${
|
||||
isActive
|
||||
? 'bg-white text-purple-700'
|
||||
: 'bg-purple-600 text-white'
|
||||
}`}
|
||||
>
|
||||
{item.badge}
|
||||
</span>
|
||||
)}
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
);
|
||||
})}
|
||||
</nav>
|
||||
</aside>
|
||||
</>
|
||||
|
||||
@@ -239,7 +239,17 @@ export default function BannersManager() {
|
||||
</td>
|
||||
<td className="py-4 px-6">
|
||||
<span className="inline-block px-3 py-1 bg-purple-50 text-purple-700 text-xs font-bold rounded-lg border border-purple-100">
|
||||
{banner.position === 'home_hero' ? 'اسلایدر هیرو اصلی' : banner.position === 'category_top' ? 'بالای دستهبندی' : 'سایدبار'}
|
||||
{banner.position === 'home_hero'
|
||||
? 'اسلایدر هیرو اصلی'
|
||||
: banner.position === 'home_middle'
|
||||
? 'بنر میانی صفحه نخست'
|
||||
: banner.position === 'home_bottom'
|
||||
? 'بنر عریض پایین خانه'
|
||||
: banner.position === 'shop_top'
|
||||
? 'بالای فروشگاه و کاتالوگ'
|
||||
: banner.position === 'category_top'
|
||||
? 'بالای دستهبندی'
|
||||
: 'سایدبار'}
|
||||
</span>
|
||||
</td>
|
||||
<td className="py-4 px-6 text-gray-500 font-mono text-xs dir-ltr text-right">
|
||||
@@ -354,8 +364,11 @@ export default function BannersManager() {
|
||||
className="w-full px-4 py-2.5 rounded-xl border border-gray-200 focus:border-purple-500 outline-none text-sm font-bold bg-white"
|
||||
>
|
||||
<option value="home_hero">اسلایدر هیرو اصلی (home_hero)</option>
|
||||
<option value="home_middle">بنر میانی صفحه نخست (home_middle)</option>
|
||||
<option value="home_bottom">بنر عریض پایین خانه (home_bottom)</option>
|
||||
<option value="shop_top">بالای فروشگاه و کاتالوگ (shop_top)</option>
|
||||
<option value="category_top">بالای دستهبندی (category_top)</option>
|
||||
<option value="sidebar">سایدبار (sidebar)</option>
|
||||
<option value="product_sidebar">سایدبار صفحات محصول و مقالات (product_sidebar)</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -25,12 +25,16 @@ export default function Settings() {
|
||||
ZIBAL_SANDBOX: 'true',
|
||||
FRONTEND_URL: 'https://canina.ir',
|
||||
CONTACT_PHONE: '۰۲۱-۸۸۸۸ ۴۴۴۴',
|
||||
CONTACT_PHONE_LINK: 'tel:02188884444',
|
||||
CONTACT_EMAIL: 'info@canina-iran.com',
|
||||
SOCIAL_WHATSAPP: '09120000000',
|
||||
SOCIAL_INSTAGRAM: 'https://instagram.com/canina_iran',
|
||||
SOCIAL_TELEGRAM: 'https://t.me/canina_iran',
|
||||
CONTACT_ADDRESS: 'تهران، جردن، خیابان سعیدی، ساختمان کنینا، طبقه ۵، واحد ۱۹',
|
||||
BRAND_LOGO_URL: '/logo.png',
|
||||
BRAND_LOGO_URL: '',
|
||||
BRAND_LOGO_TEXT_EN: 'Canina',
|
||||
BRAND_LOGO_TEXT_FA: 'ایران',
|
||||
BRAND_LOGO_SUBTITLE: 'نماینده رسمی CANINA PHARMA GMBH GERMANY',
|
||||
ENAMAD_CODE: '',
|
||||
THEME_PRIMARY_COLOR: '#7c3aed',
|
||||
BRAND_TYPOGRAPHY: 'vazirmatn',
|
||||
@@ -62,13 +66,17 @@ export default function Settings() {
|
||||
ZIBAL_MERCHANT: response.data.data.ZIBAL_MERCHANT || 'zibal',
|
||||
ZIBAL_SANDBOX: response.data.data.ZIBAL_SANDBOX || 'true',
|
||||
FRONTEND_URL: response.data.data.FRONTEND_URL || 'https://canina.ir',
|
||||
CONTACT_PHONE: response.data.data.CONTACT_PHONE || '۰۲۱-۸۸۸۸ ۴۴۴۴',
|
||||
CONTACT_EMAIL: response.data.data.CONTACT_EMAIL || 'info@canina-iran.com',
|
||||
SOCIAL_WHATSAPP: response.data.data.SOCIAL_WHATSAPP || '09120000000',
|
||||
SOCIAL_INSTAGRAM: response.data.data.SOCIAL_INSTAGRAM || 'https://instagram.com/canina_iran',
|
||||
SOCIAL_TELEGRAM: response.data.data.SOCIAL_TELEGRAM || 'https://t.me/canina_iran',
|
||||
CONTACT_ADDRESS: response.data.data.CONTACT_ADDRESS || 'تهران، جردن، خیابان سعیدی، ساختمان کنینا، طبقه ۵، واحد ۱۹',
|
||||
BRAND_LOGO_URL: response.data.data.BRAND_LOGO_URL || '/logo.png',
|
||||
CONTACT_PHONE: response.data.data.CONTACT_PHONE || response.data.data.contact_phone || '۰۲۱-۸۸۸۸ ۴۴۴۴',
|
||||
CONTACT_PHONE_LINK: response.data.data.CONTACT_PHONE_LINK || response.data.data.contact_phone_link || 'tel:02188884444',
|
||||
CONTACT_EMAIL: response.data.data.CONTACT_EMAIL || response.data.data.contact_email || 'info@canina-iran.com',
|
||||
SOCIAL_WHATSAPP: response.data.data.SOCIAL_WHATSAPP || response.data.data.contact_whatsapp || '09120000000',
|
||||
SOCIAL_INSTAGRAM: response.data.data.SOCIAL_INSTAGRAM || response.data.data.contact_instagram || 'https://instagram.com/canina_iran',
|
||||
SOCIAL_TELEGRAM: response.data.data.SOCIAL_TELEGRAM || response.data.data.contact_telegram || 'https://t.me/canina_iran',
|
||||
CONTACT_ADDRESS: response.data.data.CONTACT_ADDRESS || response.data.data.contact_address || 'تهران، جردن، خیابان سعیدی، ساختمان کنینا، طبقه ۵، واحد ۱۹',
|
||||
BRAND_LOGO_URL: response.data.data.BRAND_LOGO_URL || response.data.data.site_logo || '',
|
||||
BRAND_LOGO_TEXT_EN: response.data.data.BRAND_LOGO_TEXT_EN || response.data.data.site_logo_text_en || 'Canina',
|
||||
BRAND_LOGO_TEXT_FA: response.data.data.BRAND_LOGO_TEXT_FA || response.data.data.site_logo_text_fa || 'ایران',
|
||||
BRAND_LOGO_SUBTITLE: response.data.data.BRAND_LOGO_SUBTITLE || response.data.data.site_logo_subtitle || 'نماینده رسمی CANINA PHARMA GMBH GERMANY',
|
||||
ENAMAD_CODE: response.data.data.ENAMAD_CODE || '',
|
||||
THEME_PRIMARY_COLOR: response.data.data.THEME_PRIMARY_COLOR || '#7c3aed',
|
||||
BRAND_TYPOGRAPHY: response.data.data.BRAND_TYPOGRAPHY || 'vazirmatn',
|
||||
@@ -334,16 +342,30 @@ export default function Settings() {
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label className="block text-xs font-bold text-gray-700 mb-1">تلفن پشتیبانی و فروش</label>
|
||||
<label className="block text-xs font-bold text-gray-700 mb-1">متن نمایشی تلفن پشتیبانی و فروش</label>
|
||||
<input
|
||||
type="text"
|
||||
value={settings.CONTACT_PHONE}
|
||||
onChange={(e) => setSettings({ ...settings, CONTACT_PHONE: e.target.value })}
|
||||
placeholder="مثال: ۰۲۱-۸۸۸۸۴۴۴۴ یا ۰۹۲۱۲۳۴۵۶۷۸"
|
||||
className="w-full border border-gray-200 rounded-xl p-2.5 outline-none focus:ring-2 focus:ring-purple-500 text-xs font-bold"
|
||||
dir="ltr"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="block text-xs font-bold text-gray-700 mb-1">لینک مستقیم تماس (Phone Link)</label>
|
||||
<input
|
||||
type="text"
|
||||
value={settings.CONTACT_PHONE_LINK}
|
||||
onChange={(e) => setSettings({ ...settings, CONTACT_PHONE_LINK: e.target.value })}
|
||||
placeholder="مثال: tel:+982188884444 یا tel:09212345678"
|
||||
className="w-full border border-gray-200 rounded-xl p-2.5 outline-none focus:ring-2 focus:ring-purple-500 text-xs font-mono"
|
||||
dir="ltr"
|
||||
/>
|
||||
<p className="text-[10px] text-gray-400 mt-1">لینکی که با کلیک روی شماره تلفن در سایت باز میشود (مثلاً شماره بینالمللی یا لینک تماس).</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="block text-xs font-bold text-gray-700 mb-1">ایمیل رسمی پشتیبانی</label>
|
||||
<input
|
||||
@@ -410,14 +432,14 @@ export default function Settings() {
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label className="block text-xs font-bold text-gray-700 mb-1">لینک لوگوی برند (Brand Logo URL)</label>
|
||||
<label className="block text-xs font-bold text-gray-700 mb-1">لینک لوگوی تصویری (Brand Logo Image URL)</label>
|
||||
<div className="flex gap-2">
|
||||
<input
|
||||
type="text"
|
||||
value={settings.BRAND_LOGO_URL}
|
||||
onChange={(e) => setSettings({ ...settings, BRAND_LOGO_URL: e.target.value })}
|
||||
className="flex-1 border border-gray-200 rounded-xl p-2.5 outline-none focus:ring-2 focus:ring-purple-500 text-xs font-mono"
|
||||
placeholder="https://... یا /logo.png"
|
||||
placeholder="https://... یا /logo.png (اختیاری)"
|
||||
dir="ltr"
|
||||
/>
|
||||
{settings.BRAND_LOGO_URL && (
|
||||
@@ -426,7 +448,41 @@ export default function Settings() {
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<p className="text-[10px] text-gray-400 mt-1">این لوگو در صورت پر بودن، جایگزین تایپوگرافی هدر سایت در اپلیکیشن خواهد شد.</p>
|
||||
<p className="text-[10px] text-gray-400 mt-1">در صورت خالی بودن، لوگوی متنی زیر در هدر، فوتر و صفحه تعمیرات استفاده خواهد شد.</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="block text-xs font-bold text-gray-700 mb-1">متن انگلیسی لوگو (Text Logo EN)</label>
|
||||
<input
|
||||
type="text"
|
||||
value={settings.BRAND_LOGO_TEXT_EN}
|
||||
onChange={(e) => setSettings({ ...settings, BRAND_LOGO_TEXT_EN: e.target.value })}
|
||||
placeholder="Canina"
|
||||
className="w-full border border-gray-200 rounded-xl p-2.5 outline-none focus:ring-2 focus:ring-purple-500 text-xs font-bold"
|
||||
dir="ltr"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="block text-xs font-bold text-gray-700 mb-1">متن فارسی لوگو (Text Logo FA)</label>
|
||||
<input
|
||||
type="text"
|
||||
value={settings.BRAND_LOGO_TEXT_FA}
|
||||
onChange={(e) => setSettings({ ...settings, BRAND_LOGO_TEXT_FA: e.target.value })}
|
||||
placeholder="ایران"
|
||||
className="w-full border border-gray-200 rounded-xl p-2.5 outline-none focus:ring-2 focus:ring-purple-500 text-xs font-bold"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="block text-xs font-bold text-gray-700 mb-1">زیرعنوان رسمی لوگو (Logo Subtitle)</label>
|
||||
<input
|
||||
type="text"
|
||||
value={settings.BRAND_LOGO_SUBTITLE}
|
||||
onChange={(e) => setSettings({ ...settings, BRAND_LOGO_SUBTITLE: e.target.value })}
|
||||
placeholder="نماینده رسمی CANINA PHARMA GMBH GERMANY"
|
||||
className="w-full border border-gray-200 rounded-xl p-2.5 outline-none focus:ring-2 focus:ring-purple-500 text-xs font-bold"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="md:col-span-2">
|
||||
|
||||
@@ -159,14 +159,24 @@ export default function UITexts() {
|
||||
const value = edits[key] ?? texts[key] ?? '';
|
||||
setSaving(key);
|
||||
try {
|
||||
await api.put(`/settings/ui-texts/${key}`, { value });
|
||||
await api.put(`/settings/ui-texts/${encodeURIComponent(key)}`, { value });
|
||||
setTexts(prev => ({ ...prev, [key]: value }));
|
||||
setSavedKey(key);
|
||||
toast.success('ذخیرهسازی با موفقیت انجام شد');
|
||||
setTimeout(() => setSavedKey(null), 2000);
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
console.error('Failed to save UI text:', e);
|
||||
toast.error('خطا در ذخیرهسازی');
|
||||
try {
|
||||
// Fallback to PATCH if PUT fails
|
||||
await api.patch(`/settings/ui-texts/${encodeURIComponent(key)}`, { value });
|
||||
setTexts(prev => ({ ...prev, [key]: value }));
|
||||
setSavedKey(key);
|
||||
toast.success('ذخیرهسازی با موفقیت انجام شد');
|
||||
setTimeout(() => setSavedKey(null), 2000);
|
||||
} catch (err: any) {
|
||||
const errorMsg = err?.response?.data?.message || e?.response?.data?.message || 'خطا در ذخیرهسازی';
|
||||
toast.error(typeof errorMsg === 'string' ? errorMsg : 'خطا در ذخیرهسازی');
|
||||
}
|
||||
} finally {
|
||||
setSaving(null);
|
||||
}
|
||||
@@ -182,7 +192,7 @@ export default function UITexts() {
|
||||
});
|
||||
const fileUrl = res.data.url || res.data.fileUrl;
|
||||
setEdits(prev => ({ ...prev, [key]: fileUrl }));
|
||||
await api.put(`/settings/ui-texts/${key}`, { value: fileUrl });
|
||||
await api.put(`/settings/ui-texts/${encodeURIComponent(key)}`, { value: fileUrl });
|
||||
setTexts(prev => ({ ...prev, [key]: fileUrl }));
|
||||
setSavedKey(key);
|
||||
toast.success('تصویر با موفقیت آپلود شد');
|
||||
|
||||
Reference in new issue
Block a user