import React, { useState } from "react"; import axios from "axios"; const API_URL = process.env.REACT_APP_API_URL || "http://localhost:5001"; const AlphaGate: React.FC = () => { const [code, setCode] = useState(""); const [loading, setLoading] = useState(false); const [error, setError] = useState(""); const handleCodeChange = (e: React.ChangeEvent) => { const value = e.target.value.toUpperCase(); // Only allow alphanumeric, max 8 characters if (value.length <= 8 && /^[A-Z0-9]*$/.test(value)) { setCode(value); } setError(""); }; const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setError(""); if (code.length < 8) { setError("Please enter a complete alpha access code"); return; } setLoading(true); const fullCode = `ALPHA-${code}`; try { const response = await axios.post( `${API_URL}/alpha/validate-code`, { code: fullCode }, { withCredentials: true } ); if (response.data.success) { // Store alpha verification in localStorage as backup localStorage.setItem("alphaVerified", "true"); // Reload the page to trigger access check window.location.reload(); } } catch (err: any) { if (err.response?.status === 429) { setError("Too many attempts. Please try again in a few minutes."); } else if (err.response?.data?.error) { setError(err.response.data.error); } else { setError("Failed to validate code. Please try again."); } } finally { setLoading(false); } }; return (

Community Rentals

  • Earn extra income with the stuff you already have
  • Find items for special events, weekend projects, family trips and more
  • Discover affordable options
Currently in Alpha Testing!

You're among the first to try Community Rentals! Help us create something special by sharing your thoughts as we build this together.

Have an alpha code? Get started below!

Want to join?{" "} Request access

{/* Static ALPHA- text */} ALPHA- {/* Input for 8 characters */} {/* Error icon outside the input */} {error && ( ⚠️ )}
); }; export default AlphaGate;