bigblocks
Version:
Complete Bitcoin UI component library - authentication, social, wallet, market, inscriptions, and blockchain interactions for React
15 lines • 6.61 kB
JSON
{
"name": "bap-identity-components-bapprofilesync",
"type": "registry:component",
"dependencies": [],
"devDependencies": [],
"registryDependencies": [],
"files": [
{
"path": "components/bap-identity/components/BapProfileSync.tsx",
"type": "registry:component",
"content": "import {\n\tMagnifyingGlassIcon,\n\tReloadIcon,\n\tUpdateIcon,\n} from \"@radix-ui/react-icons\";\nimport { cn } from \"../../../lib/utils.js\";\nimport { Badge } from \"../../ui/badge.js\";\nimport { Button } from \"../../ui/button.js\";\nimport { Card, CardContent } from \"../../ui/card.js\";\nimport { Progress } from \"../../ui/progress.js\";\nimport { useBapProfileSync } from \"../hooks/useBapProfileSync.js\";\n\nexport interface BapProfileSyncProps {\n\tautoSync?: boolean;\n\tmaxDiscoveryAttempts?: number;\n\tsigmaApiUrl?: string;\n\tonSyncComplete?: (result: {\n\t\tdiscoveredProfiles: unknown[];\n\t\ttotalFound: number;\n\t}) => void;\n\tsize?: \"1\" | \"2\" | \"3\" | \"4\";\n\tvariant?: \"surface\" | \"classic\" | \"ghost\";\n\tclassName?: string;\n}\n\n/**\n * BapProfileSync component for discovering additional BAP identities\n */\nexport function BapProfileSync({\n\tautoSync = false,\n\tmaxDiscoveryAttempts = 50,\n\tsigmaApiUrl,\n\tonSyncComplete,\n\tsize = \"3\",\n\tvariant = \"surface\",\n\tclassName,\n}: BapProfileSyncProps) {\n\tconst profileSync = useBapProfileSync({\n\t\tautoSync,\n\t\tmaxDiscoveryAttempts,\n\t\tsigmaApiUrl,\n\t});\n\n\t// Handle sync completion\n\tconst handleSyncComplete = () => {\n\t\tif (!profileSync.result) return;\n\n\t\tonSyncComplete?.({\n\t\t\tdiscoveredProfiles: profileSync.result.discoveredProfiles || [],\n\t\t\ttotalFound: profileSync.result.totalFound,\n\t\t});\n\t};\n\n\t// Trigger completion callback when sync succeeds\n\tif (profileSync.isSuccess && profileSync.result && onSyncComplete) {\n\t\thandleSyncComplete();\n\t}\n\n\treturn (\n\t\t<Card className={cn(\"p-6\", className)}>\n\t\t\t<CardContent className=\"space-y-4\">\n\t\t\t\t{/* Header */}\n\t\t\t\t<div>\n\t\t\t\t\t<div className=\"flex justify-between items-center mb-3\">\n\t\t\t\t\t\t<h3 className=\"text-lg font-bold\">\n\t\t\t\t\t\t\t<div className=\"flex items-center gap-2\">\n\t\t\t\t\t\t\t\t<MagnifyingGlassIcon width=\"20\" height=\"20\" />\n\t\t\t\t\t\t\t\tProfile Synchronization\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</h3>\n\t\t\t\t\t\t{profileSync.foundCount > 0 && (\n\t\t\t\t\t\t\t<Badge variant=\"default\" className=\"bg-green-100 text-green-800\">\n\t\t\t\t\t\t\t\t{profileSync.foundCount} found\n\t\t\t\t\t\t\t</Badge>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</div>\n\n\t\t\t\t\t<p className=\"text-sm text-muted-foreground\">\n\t\t\t\t\t\tDiscover additional BAP identities associated with your master\n\t\t\t\t\t\tbackup by scanning the blockchain.\n\t\t\t\t\t</p>\n\t\t\t\t</div>\n\n\t\t\t\t{/* Sync Progress */}\n\t\t\t\t{profileSync.isScanning && (\n\t\t\t\t\t<div>\n\t\t\t\t\t\t<div className=\"flex justify-between items-center mb-2\">\n\t\t\t\t\t\t\t<span className=\"text-sm font-medium\">\n\t\t\t\t\t\t\t\tScanning for profiles...\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t<span className=\"text-xs text-muted-foreground\">\n\t\t\t\t\t\t\t\t{profileSync.progress}%\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<Progress value={profileSync.progress} className=\"mb-2\" />\n\t\t\t\t\t\t<div className=\"flex justify-between\">\n\t\t\t\t\t\t\t<span className=\"text-xs text-muted-foreground\">\n\t\t\t\t\t\t\t\tCurrent ID: {profileSync.currentId}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t<span className=\"text-xs text-muted-foreground\">\n\t\t\t\t\t\t\t\tFound: {profileSync.foundCount}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\n\t\t\t\t{/* Results */}\n\t\t\t\t{profileSync.isSuccess && profileSync.result && (\n\t\t\t\t\t<div className=\"p-4 bg-green-50 border border-green-200 rounded-lg\">\n\t\t\t\t\t\t<div className=\"flex items-center gap-2 mb-2\">\n\t\t\t\t\t\t\t<span className=\"text-sm font-medium text-green-800\">\n\t\t\t\t\t\t\t\tSync Complete!\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<p className=\"text-sm text-green-700\">\n\t\t\t\t\t\t\tFound {profileSync.result.totalFound} profiles total.\n\t\t\t\t\t\t\t{profileSync.result.discoveredProfiles &&\n\t\t\t\t\t\t\tprofileSync.result.discoveredProfiles.length > 0\n\t\t\t\t\t\t\t\t? ` Discovered ${profileSync.result.discoveredProfiles.length} new identities.`\n\t\t\t\t\t\t\t\t: \" No new identities discovered.\"}\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t{profileSync.result.updatedBackup && (\n\t\t\t\t\t\t\t<p className=\"text-sm text-green-700 mt-1\">\n\t\t\t\t\t\t\t\tYour backup has been updated with new identities.\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\n\t\t\t\t{/* Error Display */}\n\t\t\t\t{profileSync.error && (\n\t\t\t\t\t<Card className=\"p-3 bg-red-50 border border-red-200\">\n\t\t\t\t\t\t<div className=\"flex items-center gap-2\">\n\t\t\t\t\t\t\t<span className=\"text-sm font-medium text-red-800\">\n\t\t\t\t\t\t\t\tSync Error: {profileSync.error.message}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</Card>\n\t\t\t\t)}\n\n\t\t\t\t{/* Action Buttons */}\n\t\t\t\t<div className=\"flex gap-3 justify-end\">\n\t\t\t\t\t{profileSync.isScanning && (\n\t\t\t\t\t\t<Button variant=\"outline\" onClick={profileSync.resetSync}>\n\t\t\t\t\t\t\t<ReloadIcon width=\"16\" height=\"16\" className=\"mr-2\" />\n\t\t\t\t\t\t\tCancel\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t)}\n\n\t\t\t\t\t{!profileSync.isScanning && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{(profileSync.error || profileSync.isSuccess) && (\n\t\t\t\t\t\t\t\t<Button variant=\"outline\" onClick={profileSync.resetSync}>\n\t\t\t\t\t\t\t\t\tReset\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tonClick={profileSync.syncProfiles}\n\t\t\t\t\t\t\t\tdisabled={profileSync.isScanning}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<UpdateIcon width=\"16\" height=\"16\" className=\"mr-2\" />\n\t\t\t\t\t\t\t\t{profileSync.isSuccess ? \"Sync Again\" : \"Start Sync\"}\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t</>\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\n\t\t\t\t{/* Configuration Info */}\n\t\t\t\t{!profileSync.isScanning && (\n\t\t\t\t\t<div className=\"mt-2\">\n\t\t\t\t\t\t<span className=\"text-xs text-muted-foreground\">\n\t\t\t\t\t\t\tMax attempts: {maxDiscoveryAttempts} • Auto-sync:{\" \"}\n\t\t\t\t\t\t\t{autoSync ? \"Enabled\" : \"Disabled\"}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t</CardContent>\n\t\t</Card>\n\t);\n}\n",
"target": "<%- config.aliases.components %>/bapprofilesync.tsx"
}
]
}