"use client"; import { useState } from "react"; // Icons const TruckIcon = ({ className }: { className?: string }) => ( ); const ShieldIcon = ({ className }: { className?: string }) => ( ); const CheckIcon = ({ className }: { className?: string }) => ( ); const AlertIcon = ({ className }: { className?: string }) => ( ); const EyeIcon = ({ className }: { className?: string }) => ( ); const EyeOffIcon = ({ className }: { className?: string }) => ( ); export default function AdvancedShipping({ brandId }: { brandId: string }) { const [carrier, setCarrier] = useState("fedex"); const [accountNumber, setAccountNumber] = useState(""); const [apiKey, setApiKey] = useState(""); const [showApiKey, setShowApiKey] = useState(false); const [saving, setSaving] = useState(false); const [testResult, setTestResult] = useState<{ ok: boolean; message: string } | null>(null); async function handleTest() { setTestResult(null); if (!accountNumber.trim()) { setTestResult({ ok: false, message: "Account number is required" }); return; } await new Promise(r => setTimeout(r, 1000)); setTestResult({ ok: true, message: `${carrier.toUpperCase()} connection successful` }); } async function handleSave() { setSaving(true); await new Promise(r => setTimeout(r, 500)); setSaving(false); setTestResult({ ok: true, message: "Shipping settings saved" }); } return (
{/* Security Warning */}

API Key Security

  • Shipping fraud is real — Stolen carrier credentials enable fake label purchases on your account.
  • Carrier API costs — FedEx/UPS APIs charge per rate quote ($0.01-$0.05) and per label ($3-$10).
  • Set account limits — Most carriers let you set monthly spending caps. Use them!
  • Test in sandbox — Use test credentials before connecting production shipping accounts.
  • Audit regularly — Check carrier invoices monthly for unauthorized activity.
{/* Shipping Carriers Card */}

Shipping Carriers

Configure shipping provider credentials

{/* Carrier Selection */}
{/* Account Number */}
setAccountNumber(e.target.value)} placeholder="Enter account number" 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" />
{/* API Key / Password */}
setApiKey(e.target.value)} placeholder="Enter API key or password" className="w-full rounded-lg border border-[var(--admin-border)] bg-white px-3 py-2.5 pr-10 text-sm text-[var(--admin-text-primary)] placeholder:text-stone-400 outline-none focus:border-emerald-500 focus:ring-1 focus:ring-emerald-500" />
{/* Test Result */} {testResult && (
{testResult.ok ? : } {testResult.message}
)} {/* Actions */}
{/* Shipping Options Card */}

Shipping Options

{[ { id: "live_rates", label: "Live Rate Quotes", desc: "Show real-time shipping rates at checkout" }, { id: "label_printing", label: "Label Printing", desc: "Generate shipping labels automatically" }, { id: "tracking", label: "Tracking Updates", desc: "Send tracking notifications to customers" }, { id: "insurance", label: "Shipping Insurance", desc: "Protect high-value shipments" }, ].map((option) => (

{option.label}

{option.desc}

))}
); }