add random candidato
All checks were successful
Frontend Build and Deploy / build (push) Successful in 1m2s

This commit is contained in:
2025-06-10 20:39:19 -03:00
parent 1e4f288ec4
commit 2764dbdc4e
6 changed files with 76 additions and 12 deletions

View File

@@ -31,12 +31,9 @@ const Button: React.FC<ButtonProps> = ({
rounded-full
backdrop-blur-xs
shadow-xl
ring-1
transition-all
duration-200
hover:ring-indigo-400/20
hover:bg-gray-700/40
ring-gray-900
text-white
transition-colors
${animationClasses} ${cursorClasses} ${className}`;

View File

@@ -0,0 +1,40 @@
import React from 'react';
import { useNavigate } from 'react-router-dom';
import { ArrowPathIcon } from '@heroicons/react/24/outline';
import Button from './Button';
import { openCandApi } from '../api/openCandApi';
interface RandomCandButtonProps {
className?: string;
hasAnimation?: boolean;
}
const RandomCandButton: React.FC<RandomCandButtonProps> = ({
className = '',
hasAnimation = false
}) => {
const navigate = useNavigate();
const handleRandomCandidate = async () => {
try {
const randomCandidate = await openCandApi.getRandomCandidate();
navigate(`/candidato/${randomCandidate.idCandidato}`);
} catch (error) {
console.error('Erro ao buscar candidato aleatório:', error);
// You might want to show a toast notification or error message to the user
}
};
return (
<Button
onClick={handleRandomCandidate}
className={`flex items-center ${className}`}
hasAnimation={hasAnimation}
>
<ArrowPathIcon className="h-4 w-4 mr-2" />
Candidato aleatório
</Button>
);
};
export default RandomCandButton;