"use client"; import { useState } from "react"; // Icons const ShieldIcon = ({ className }: { className?: string }) => ( ); const GridIcon = ({ className }: { className?: string }) => ( ); const CheckIcon = ({ className }: { className?: string }) => ( ); const AlertIcon = ({ className }: { className?: string }) => ( ); export default function AdvancedSquareSync({ brandId }: { brandId: string }) { const [connected, setConnected] = useState(false); const [appId, setAppId] = useState(""); const [accessToken, setAccessToken] = useState(""); const [locationId, setLocationId] = useState(""); const [saving, setSaving] = useState(false); const [testResult, setTestResult] = useState<{ ok: boolean; message: string } | null>(null); async function handleTest() { setTestResult(null); if (!appId.trim() || !accessToken.trim()) { setTestResult({ ok: false, message: "App ID and Access Token are required" }); return; } // Simulate test await new Promise(r => setTimeout(r, 1000)); setTestResult({ ok: true, message: "Square connection successful" }); setConnected(true); } async function handleSave() { setSaving(true); await new Promise(r => setTimeout(r, 500)); setSaving(false); setTestResult({ ok: true, message: "Square sync settings saved" }); } return (
{/* Security Warning */}

API Key Security

  • Square access = real money — API can process transactions, refunds, and access customer data.
  • Monitor API calls — Square charges per API call. Heavy integrations can run up fees.
  • Token expiry — Square access tokens expire. Production apps need automatic refresh logic.
  • Use sandbox first — Test with Square sandbox before going live to avoid real charges.
  • Secure storage — Never expose credentials in client code or public repositories.
{/* Square Sync Card */}

Square Sync

Sync inventory with Square POS

{connected && ( Connected )}
setAppId(e.target.value)} placeholder="sq0idp-..." className="w-full rounded-lg border border-[var(--admin-border)] bg-white px-3 py-2.5 text-sm text-[var(--admin-text-primary)] placeholder:text-stone-400 outline-none focus:border-emerald-500 focus:ring-1 focus:ring-emerald-500" />
setAccessToken(e.target.value)} placeholder="EAAAl..." className="w-full rounded-lg border border-[var(--admin-border)] bg-white px-3 py-2.5 text-sm text-[var(--admin-text-primary)] placeholder:text-stone-400 outline-none focus:border-emerald-500 focus:ring-1 focus:ring-emerald-500" />
setLocationId(e.target.value)} placeholder="L..." className="w-full rounded-lg border border-[var(--admin-border)] bg-white px-3 py-2.5 text-sm text-[var(--admin-text-primary)] placeholder:text-stone-400 outline-none focus:border-emerald-500 focus:ring-1 focus:ring-emerald-500" />
{testResult && (
{testResult.ok ? : } {testResult.message}
)}
{/* Sync Options */}

Sync Options

{[ { id: "inventory", label: "Inventory Sync", desc: "Sync product quantities from Square" }, { id: "products", label: "Product Sync", desc: "Import/export products from Square catalog" }, { id: "prices", label: "Price Updates", desc: "Keep prices synchronized" }, ].map((option) => (

{option.label}

{option.desc}

))}
); }