import React, { useContext, useEffect, useState } from 'react'; import ErrorOccurrenceContext from '../../contexts/ErrorOccurrenceContext'; import Solution from './Solution'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faLightbulb, faTimes } from '@fortawesome/free-solid-svg-icons'; export default function Solutions() { const { solutions } = useContext(ErrorOccurrenceContext); const [canExecuteSolutions, setCanExecuteSolutions] = useState(false); const [showSolutions, setShowSolutions] = useState(true); useEffect(() => { try { (async () => { if (!solutions[0]?.execute_endpoint) { return; } const healthCheck = await ( await fetch(solutions[0].execute_endpoint.replace('execute-solution', 'health-check')) ).json(); setCanExecuteSolutions(healthCheck.can_execute_commands); // TODO: rename to can_execute_solutions (in laravel-ignition as well) })(); } catch (error) { console.error(error); setCanExecuteSolutions(false); } }, []); return ( <> {showSolutions ? ( ) : ( setShowSolutions(true)} className=" absolute -top-3 -right-3 z-20 w-6 h-6 rounded-full flex items-center justify-center text-xs bg-emerald-500 text-white hover:shadow-lg shadow-md active:shadow-sm active:translate-y-px" > )} > ); }