ensure pre-rendering does not fail
This commit is contained in:
		| @@ -7,7 +7,7 @@ import ReCAPTCHA from "react-google-recaptcha"; | |||||||
| export default function ContactComponent({ | export default function ContactComponent({ | ||||||
|   recaptchaSiteKey, |   recaptchaSiteKey, | ||||||
| }: { | }: { | ||||||
|   recaptchaSiteKey: string; |   recaptchaSiteKey: string | undefined; | ||||||
| }) { | }) { | ||||||
|   const inputStyle = { |   const inputStyle = { | ||||||
|     backgroundColor: "#111", |     backgroundColor: "#111", | ||||||
| @@ -57,7 +57,7 @@ export default function ContactComponent({ | |||||||
|             {"success" in state && "Submitted successfully!"} |             {"success" in state && "Submitted successfully!"} | ||||||
|           </span> |           </span> | ||||||
|         )} |         )} | ||||||
|         <ReCAPTCHA sitekey={recaptchaSiteKey} theme="dark" /> |         <ReCAPTCHA sitekey={recaptchaSiteKey ?? ""} theme="dark" /> | ||||||
|         <button |         <button | ||||||
|           type="submit" |           type="submit" | ||||||
|           style={{ |           style={{ | ||||||
| @@ -71,7 +71,7 @@ export default function ContactComponent({ | |||||||
|           onMouseLeave={(e) => { |           onMouseLeave={(e) => { | ||||||
|             if (!pending) e.currentTarget.style.backgroundColor = "#111"; |             if (!pending) e.currentTarget.style.backgroundColor = "#111"; | ||||||
|           }} |           }} | ||||||
|           disabled={pending} |           disabled={pending || recaptchaSiteKey == null} | ||||||
|         > |         > | ||||||
|           {pending ? "Sending..." : "Submit"} |           {pending ? "Sending..." : "Submit"} | ||||||
|         </button> |         </button> | ||||||
|   | |||||||
| @@ -4,9 +4,5 @@ import ContactComponent from "./ContactComponent"; | |||||||
|  |  | ||||||
| export default async function ContactPage() { | export default async function ContactPage() { | ||||||
|   const recaptchaSiteKey = process.env.RECAPTCHA_SITE_KEY; |   const recaptchaSiteKey = process.env.RECAPTCHA_SITE_KEY; | ||||||
|   if (!recaptchaSiteKey) { |  | ||||||
|     console.error("ReCAPTCHA site key is not set"); |  | ||||||
|     throw new Error("ReCAPTCHA not correctly configured"); |  | ||||||
|   } |  | ||||||
|   return <ContactComponent recaptchaSiteKey={recaptchaSiteKey} />; |   return <ContactComponent recaptchaSiteKey={recaptchaSiteKey} />; | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user