add random candidato
All checks were successful
Frontend Build and Deploy / build (push) Successful in 1m2s
All checks were successful
Frontend Build and Deploy / build (push) Successful in 1m2s
This commit is contained in:
@@ -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}`;
|
||||
|
40
src/shared/RandomCandButton.tsx
Normal file
40
src/shared/RandomCandButton.tsx
Normal 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;
|
Reference in New Issue
Block a user