import { MetaFunction, useNavigate, useParams } from "@remix-run/react"; import { useSellerData } from "../requestHandler/use-seller-hooks"; import { ChevronLeft, LogOut, LayoutDashboard, ShoppingCart, Truck, PackagePlus, TableProperties, PenLine, Code, Instagram, MessageCircle, } from "lucide-react"; import HeaderWithSupport from "../components/HeaderWithSupport"; import { useStoreOwnership } from "../hooks/useStoreOwnership"; import { useState } from "react"; import { SunMoonToggle } from "~/components/SunMoonToggle"; import { useRootData } from "~/hooks/use-root-data"; import { PushSettingToggle } from "~/components/notifications/PushSettingToggle"; // Import the InstagramSyncDrawer component import { InstagramSyncDrawer } from "./store.$storeId._index"; import CallDialog from "~/components/CallDialog"; interface MenuItemType { title: string; link?: string; pageName: string; hasBorder?: boolean; image: React.ReactNode; } export default function StoreSetting() { const { storeId } = useParams(); const navigate = useNavigate(); const { data } = useSellerData(storeId); const { theme: initialTheme } = useRootData(); // Check store ownership - this will redirect if user doesn't own the store const { isLoading: isOwnershipLoading } = useStoreOwnership(storeId); // State for Instagram sync drawer const [instagramSyncDrawerOpen, setInstagramSyncDrawerOpen] = useState(false); const [isCallModalOpen, setIsCallModalOpen] = useState(false); // Show loading while checking ownership if (isOwnershipLoading) { return (
); } // Menu items for store management const storeMenuItems: MenuItemType[] = [ { title: "وارد کردن پست های اینستاگرام", pageName: "instagram-sync", hasBorder: true, image: , }, { title: "سفارش‌های دریافتی", pageName: "seller-orders", link: `/store/${storeId}/orders`, image: , }, { title: "پیام های دریافتی", pageName: "seller-messages", link: `/store/${storeId}/threads`, image: , }, { title: "داشبورد مالی", pageName: "financial-dashboard", link: `/store/${storeId}/financial-dashboard`, image: , }, { title: "تعیین نحوه ارسال", pageName: "shipping-method", link: `/store/${storeId}/shipping-method`, image: , }, { title: "افزودن محصول جدید", pageName: "add-product", link: `/store/add/manual/${storeId}`, image: , }, { title: "لیست محصولات", pageName: "products-list", link: `/store/${storeId}/products`, image: , }, { title: "ویرایش اطلاعات فروشگاه", pageName: "edit-store", link: `/store/${storeId}/edit`, image: , }, { title: "خروج", pageName: "logout", link: `/store/${storeId}/logout`, hasBorder: true, image: , }, ]; const handleBack = () => { navigate(`/store/${storeId}`); }; const handleItemClick = (item: MenuItemType) => { // Special handling for "instagram-sync" item if (item.pageName === "instagram-sync") { // Open Instagram sync drawer instead of navigating setInstagramSyncDrawerOpen(true); return; } // Special handling for "logout" item if (item.pageName === "logout") { // Handle logout logic navigate("/"); return; } // Default rendering for other items with Link if they have a link if (item.link) { navigate(item.link); return; } }; return (
{/* Header */}

تنظیمات فروشگاه

{/* Status + Theme cards */}
{/* Store Status */}

وضعیت فروشگاه (فعال)

در حالت فعال، فروشگاه برای مخاطبان نمایش داده می‌شود.

{/* Theme Toggle */}

{initialTheme === "dark" ? "حالت تاریک" : "حالت روشن"}

تغییر حالت نمایش به تاریک یا روشن

{/* Push notifications */}
{/* Menu Items */}
{storeMenuItems.map((item, index) => { const isLogout = item.pageName === "logout"; return (
handleItemClick(item)} role="button" tabIndex={0} onKeyDown={(e) => { if (e.key === "Enter" || e.key === " ") { handleItemClick(item); } }} >
{item.image}

{item.title}

); })}
{/* Instagram Sync Drawer */} { window.location.href = `tel:${import.meta.env.VITE_SUPPORT_PHONE}`; }} />
); } export const meta: MetaFunction = () => { return [ { title: "تنظیمات فروشگاه - ویترون" }, { name: "description", content: "مدیریت و مشاهده تمام تنظیمات فروشگاه در فروشگاه شما. فیلتر بر اساس وضعیت و جستجو در تنظیمات فروشگاه.", }, { name: "keywords", content: "تنظیمات فروشگاه، مدیریت تنظیمات فروشگاه، فروشگاه، مشتری، ویترون", }, { name: "robots", content: "noindex, follow" }, { property: "og:title", content: "تنظیمات فروشگاه - ویترون" }, { property: "og:description", content: "مدیریت و مشاهده تمام تنظیمات فروشگاه در فروشگاه شما. فیلتر بر اساس وضعیت و جستجو در تنظیمات فروشگاه.", }, { property: "og:type", content: "website" }, { name: "twitter:card", content: "summary" }, { name: "twitter:title", content: "تنظیمات فروشگاه - ویترون" }, { name: "twitter:description", content: "مدیریت و مشاهده تمام تنظیمات فروشگاه در فروشگاه شما. فیلتر بر اساس وضعیت و جستجو در تنظیمات فروشگاه.", }, ]; };