()
| 8 | import { getFunctions, httpsCallable } from 'firebase/functions'; |
| 9 | |
| 10 | function UpperCaser() { |
| 11 | const functions = useFunctions(); |
| 12 | const capitalizeTextRemoteFunction = httpsCallable<{ text: string }, string>(functions, 'capitalizeText'); |
| 13 | const [uppercasedText, setText] = useState<string>(''); |
| 14 | const [isUppercasing, setIsUppercasing] = useState<boolean>(false); |
| 15 | |
| 16 | const greetings = ['Hello World', 'yo', `what's up?`]; |
| 17 | const textToUppercase = greetings[Math.floor(Math.random() * greetings.length)]; |
| 18 | |
| 19 | async function handleButtonClick() { |
| 20 | setIsUppercasing(true); |
| 21 | |
| 22 | const { data: capitalizedText } = await capitalizeTextRemoteFunction({ text: textToUppercase }); |
| 23 | setText(capitalizedText); |
| 24 | |
| 25 | setIsUppercasing(false); |
| 26 | } |
| 27 | |
| 28 | return ( |
| 29 | <> |
| 30 | <WideButton label="Uppercase some text" onClick={handleButtonClick} /> |
| 31 | {isUppercasing ? <LoadingSpinner /> : <span>{uppercasedText || `click the button to capitalize "${textToUppercase}"`}</span>} |
| 32 | </> |
| 33 | ); |
| 34 | } |
| 35 | |
| 36 | function UpperCaserOnRender() { |
| 37 | const greetings = ['Hello World', 'yo', `what's up?`]; |
nothing calls this directly
no test coverage detected