diff --git a/src/App.jsx b/src/App.jsx index cd6caadf..b15ae738 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -379,9 +379,18 @@ function App() { } }; - const handleGuestLogin = () => { + const handleGuestLogin = async ({ onSuccess, onFailure }) => { if (userRef.current) { - userRef.current.loginAsGuest(); + try { + await userRef.current.loginAsGuest(); + setIsLoginUserHidden(true); + setIsLoggingIn(false); + if (onSuccess) onSuccess(); + } catch (error) { + setIsLoginUserHidden(false); + setIsLoggingIn(false); + if (onFailure) onFailure(error); + } } } diff --git a/src/modals/CreateUserModal.jsx b/src/modals/CreateUserModal.jsx index c48a18cd..cb65a5aa 100644 --- a/src/modals/CreateUserModal.jsx +++ b/src/modals/CreateUserModal.jsx @@ -10,22 +10,31 @@ const CreateUserModal = ({ isHidden, form, setForm, handleCreateUser, setIsCreat const [confirmPassword, setConfirmPassword] = useState(''); const [showPassword, setShowPassword] = useState(false); const [showConfirmPassword, setShowConfirmPassword] = useState(false); + const [isLoading, setIsLoading] = useState(false); const isFormValid = () => { if (!form.username || !form.password || form.password !== confirmPassword) return false; return true; }; - const handleCreate = () => { - handleCreateUser({ - ...form - }); + const handleCreate = async () => { + setIsLoading(true); + try { + await handleCreateUser({ + ...form, + onSuccess: () => setIsLoading(false), + onFailure: () => setIsLoading(false) + }); + } catch (error) { + setIsLoading(false); + } }; useEffect(() => { if (isHidden) { setForm({ username: '', password: '' }); setConfirmPassword(''); + setIsLoading(false); } }, [isHidden]); @@ -54,18 +63,23 @@ const CreateUserModal = ({ isHidden, form, setForm, handleCreateUser, setIsCreat
{ event.preventDefault(); - if (isFormValid()) handleCreate(); + if (isFormValid() && !isLoading) handleCreate(); }} > Username setForm({ ...form, username: event.target.value })} sx={{ backgroundColor: theme.palette.general.primary, color: theme.palette.text.primary, + '&:disabled': { + opacity: 0.5, + backgroundColor: theme.palette.general.primary, + }, }} /> @@ -73,6 +87,7 @@ const CreateUserModal = ({ isHidden, form, setForm, handleCreateUser, setIsCreat Password
setForm({ ...form, password: event.target.value })} @@ -80,13 +95,21 @@ const CreateUserModal = ({ isHidden, form, setForm, handleCreateUser, setIsCreat backgroundColor: theme.palette.general.primary, color: theme.palette.text.primary, flex: 1, + '&:disabled': { + opacity: 0.5, + backgroundColor: theme.palette.general.primary, + }, }} /> setShowPassword(!showPassword)} sx={{ color: theme.palette.text.primary, marginLeft: 1, + '&:disabled': { + opacity: 0.5, + }, }} > {showPassword ? : } @@ -97,6 +120,7 @@ const CreateUserModal = ({ isHidden, form, setForm, handleCreateUser, setIsCreat Confirm Password
setConfirmPassword(event.target.value)} @@ -104,13 +128,21 @@ const CreateUserModal = ({ isHidden, form, setForm, handleCreateUser, setIsCreat backgroundColor: theme.palette.general.primary, color: theme.palette.text.primary, flex: 1, + '&:disabled': { + opacity: 0.5, + backgroundColor: theme.palette.general.primary, + }, }} /> setShowConfirmPassword(!showConfirmPassword)} sx={{ color: theme.palette.text.primary, marginLeft: 1, + '&:disabled': { + opacity: 0.5, + }, }} > {showConfirmPassword ? : } @@ -119,17 +151,22 @@ const CreateUserModal = ({ isHidden, form, setForm, handleCreateUser, setIsCreat diff --git a/src/modals/ProfileModal.jsx b/src/modals/ProfileModal.jsx index 4b69d391..177a23ad 100644 --- a/src/modals/ProfileModal.jsx +++ b/src/modals/ProfileModal.jsx @@ -71,6 +71,10 @@ export default function ProfileModal({ > Delete Account + +
+ v2.0.1 +