/* import { useEffect, useState, useCallback } from "react"; import { useFetcher } from "@remix-run/react"; import { Page, Layout, Card, Tabs, Button, BlockStack, InlineStack, Text, Badge, Link, } from "@shopify/polaris"; import { TitleBar, useAppBridge } from "@shopify/app-bridge-react"; import { authenticate } from "../shopify.server"; export const loader = async ({ request }) => { await authenticate.admin(request); return null; }; export const action = async ({ request }) => { const { admin } = await authenticate.admin(request); return null; }; export default function Index() { const fetcher = useFetcher(); const shopify = useAppBridge(); const isLoading = ["loading", "submitting"].includes(fetcher.state) && fetcher.formMethod === "POST"; const productId = fetcher.data?.product?.id.replace( "gid://shopify/Product/", "", ); function TabsInsideOfACardExample() { const [selected, setSelected] = useState(0); const handleTabChange = useCallback( (selectedTabIndex) => setSelected(selectedTabIndex), [], ); const tabs = [ { id: "settings", content: "⚙️ Settings" }, { id: "brands", content: "🏷️ Brands" }, { id: "manage", content: "📦 Manage Brands" }, { id: "help", content: "🆘 Help" }, { id: "login", content: "🔐 Login" }, ]; return ( Tab {selected} selected ); } useEffect(() => { if (productId) { shopify.toast.show("Product created"); } }, [productId, shopify]); const generateProduct = () => fetcher.submit({}, { method: "POST" }); return ( Go to Settings Page Go to Brands Page Go to Brands Manage Page ); } */ /* //woking code import { useEffect, useState, useCallback } from "react"; import { useFetcher } from "@remix-run/react"; import { Page, Layout, Card, Tabs, Button, BlockStack, InlineStack, Text, Badge, Link, LegacyCard, } from "@shopify/polaris"; import { TitleBar, useAppBridge } from "@shopify/app-bridge-react"; import { authenticate } from "../shopify.server"; export const loader = async ({ request }) => { await authenticate.admin(request); return null; }; export const action = async ({ request }) => { const { admin } = await authenticate.admin(request); return null; }; export default function Index() { const fetcher = useFetcher(); const shopify = useAppBridge(); const isLoading = ["loading", "submitting"].includes(fetcher.state) && fetcher.formMethod === "POST"; const productId = fetcher.data?.product?.id?.replace( "gid://shopify/Product/", "" ); useEffect(() => { // Temporarily disabling toast to avoid crash // You can safely add App Bridge toast later }, [productId, shopify]); const generateProduct = () => fetcher.submit({}, { method: "POST" }); // Tabs logic const [selectedTab, setSelectedTab] = useState(0); const handleTabChange = useCallback( (selectedTabIndex) => setSelectedTab(selectedTabIndex), [] ); const tabs = [ { id: "settings-tab", content: "⚙️ Settings", panelID: "settings-content", }, { id: "brands-tab", content: "🏷️ Brands", panelID: "brands-content", }, { id: "manage-tab", content: "📦 Manage Brands", panelID: "manage-content", }, { id: "help-tab", content: "🆘 Help", panelID: "help-content", }, { id: "login-tab", content: "🔐 Login", panelID: "login-content", }, ]; return ( {selectedTab === 0 && ( Configure Turn14 integration settings. Go to Settings Page )} {selectedTab === 1 && ( View available brands from Turn14. Go to Brands Page )} {selectedTab === 2 && ( Manage your synced brand collections. Go to Manage Brands )} {selectedTab === 3 && ( Help and documentation links. Open Help Docs Contact Support )} {selectedTab === 4 && ( Login to manage Turn14 credentials. Go to Login )} ); } */ /* import { Page, Layout, Card, Text, BlockStack } from "@shopify/polaris"; import { TitleBar } from "@shopify/app-bridge-react"; import { authenticate } from "../shopify.server"; export const loader = async ({ request }) => { await authenticate.admin(request); return null; }; export default function Index() { return ( Welcome to your Turn14 integration dashboard! Use the navigation in the left sidebar to manage settings, view brands, sync collections, and more. ); } */ import { Page, Layout, Card, BlockStack, Text, Badge, InlineStack, Image, Divider, } from "@shopify/polaris"; import { TitleBar } from "@shopify/app-bridge-react"; import data4autosLogo from "../assets/data4autos_logo.png"; // make sure this exists export default function Index() { return ( Welcome to your Turn14 Dashboard 🚀 Data4Autos Turn14 Integration gives you the power to sync product brands, manage collections, and automate catalog setup directly from Turn14 to your Shopify store. 🔧 Use the left sidebar to: ⚙️ Manage API settings 🏷️ Browse and import available brands 📦 Sync brand collections to Shopify 🔐 Handle secure Turn14 login credentials Status: Connected Shopify x Turn14 Need help? Contact us at{" "} support@data4autos.com ); } /* import { useEffect, useState, useCallback } from "react"; import { useFetcher, useNavigate } from "@remix-run/react"; import { Page, Layout, Card, Tabs, LegacyCard, } from "@shopify/polaris"; import { TitleBar, useAppBridge } from "@shopify/app-bridge-react"; import { authenticate } from "../shopify.server"; export const loader = async ({ request }) => { await authenticate.admin(request); return null; }; export const action = async ({ request }) => { const { admin } = await authenticate.admin(request); return null; }; export default function Index() { const fetcher = useFetcher(); const shopify = useAppBridge(); const navigate = useNavigate(); const productId = fetcher.data?.product?.id?.replace( "gid://shopify/Product/", "" ); useEffect(() => { // You can add toast messages here if needed }, [productId, shopify]); const tabs = [ { id: "settings-tab", content: "⚙️ Settings", panelID: "settings-content", to: "/app/settings", }, { id: "brands-tab", content: "🏷️ Brands", panelID: "brands-content", to: "/app/brands", }, { id: "manage-tab", content: "📦 Manage Brands", panelID: "manage-content", to: "/app/managebrand", }, { id: "help-tab", content: "🆘 Help", panelID: "help-content", to: "/app/help", }, { id: "login-tab", content: "🔐 Login", panelID: "login-content", to: "/app/login", }, ]; const [selectedTab, setSelectedTab] = useState(0); const handleTabChange = useCallback( (selectedTabIndex) => { setSelectedTab(selectedTabIndex); navigate(tabs[selectedTabIndex].to); }, [navigate] ); return ( Redirecting to {tabs[selectedTab].content}... ); } */ /* import { useEffect, useState, useCallback } from "react"; import { useFetcher } from "@remix-run/react"; import { Page, Layout, Card, Tabs, Button, BlockStack, InlineStack, Text, Badge, Link, LegacyCard, } from "@shopify/polaris"; import { TitleBar, useAppBridge } from "@shopify/app-bridge-react"; import { authenticate } from "../shopify.server"; import SettingsPage from "./app.settings"; // Adjust the path if needed export const loader = async ({ request }) => { await authenticate.admin(request); return null; }; export const action = async ({ request }) => { const { admin } = await authenticate.admin(request); return null; }; export default function Index() { const fetcher = useFetcher(); const shopify = useAppBridge(); const isLoading = ["loading", "submitting"].includes(fetcher.state) && fetcher.formMethod === "POST"; const productId = fetcher.data?.product?.id?.replace( "gid://shopify/Product/", "" ); useEffect(() => { // Toast placeholder (disabled) }, [productId, shopify]); const generateProduct = () => fetcher.submit({}, { method: "POST" }); const [selectedTab, setSelectedTab] = useState(0); const handleTabChange = useCallback( (selectedTabIndex) => setSelectedTab(selectedTabIndex), [] ); const tabs = [ { id: "settings-tab", content: "⚙️ Settings", panelID: "settings-content", }, { id: "brands-tab", content: "🏷️ Brands", panelID: "brands-content", }, { id: "manage-tab", content: "📦 Manage Brands", panelID: "manage-content", }, { id: "help-tab", content: "🆘 Help", panelID: "help-content", }, { id: "login-tab", content: "🔐 Login", panelID: "login-content", }, ]; return ( {selectedTab === 0 && ( )} {selectedTab === 1 && ( View available brands from Turn14. Go to Brands Page )} {selectedTab === 2 && ( Manage your synced brand collections. Go to Manage Brands )} {selectedTab === 3 && ( Help and documentation links. Open Help Docs Contact Support )} {selectedTab === 4 && ( Login to manage Turn14 credentials. Go to Login )} ); } */
Tab {selected} selected
Redirecting to {tabs[selectedTab].content}...