/**
* Example Usage of IdentityUnlockPrompt Component
*
* This file demonstrates how to use the IdentityUnlockPrompt modal component
* in your application.
*/
'use client';
import { useState } from 'react';
import { useAuth } from '@/lib/contexts/AuthContext';
import { IdentityUnlockPrompt } from './IdentityUnlockPrompt';
export function ExampleUsage() {
const { isIdentityUnlocked } = useAuth();
const [showUnlockPrompt, setShowUnlockPrompt] = useState(false);
// Example 1: Show unlock prompt when user tries to perform an action
const handleLikePost = async () => {
if (!isIdentityUnlocked) {
setShowUnlockPrompt(true);
return;
}
// Proceed with the action (e.g., like the post)
console.log('Liking post...');
};
// Example 2: Handle successful unlock
const handleUnlock = () => {
console.log('Identity unlocked successfully!');
setShowUnlockPrompt(false);
// Optionally retry the action that triggered the prompt
// For example, if user tried to like a post, like it now
};
// Example 3: Handle cancel
const handleCancel = () => {
console.log('User cancelled unlock');
setShowUnlockPrompt(false);
};
return (
{/* Your UI components */}
{/* Show unlock prompt when needed */}
{showUnlockPrompt && (
)}
);
}
/**
* Example 2: Using the component without callbacks
*
* The component can be used without callbacks if you just want
* to unlock the identity without any additional actions.
*/
export function SimpleExample() {
const [showUnlockPrompt, setShowUnlockPrompt] = useState(false);
return (