import { usePinAuth } from '@camarauth/sdk/react';
function LoginComponent() {
const auth = usePinAuth({
// Requeridas
apiUrl: 'http://localhost:3001',
whatsappNumber: '+1234567890',
// Opcionales
pinLength: 6,
expiresIn: 180,
maxAutoRegenerations: 3,
autoGenerate: false,
messagePrefix: 'PIN:',
// Callbacks
onPinGenerated: (pin, emojis) => {
console.log('PIN:', pin);
},
onSuccess: (user) => {
console.log('Éxito:', user);
},
onError: (error) => {
console.error('Error:', error);
},
onExpire: () => {
console.log('Expirado');
},
onMaxRegenerationsReached: () => {
console.log('Máximo alcanzado');
}
});
return (
<button onClick={auth.generate}>
Generar PIN
</button>
);
}