feat: create register
ci-front / build (push) Successful in 2m1s

This commit is contained in:
2026-04-04 05:57:34 +03:00
parent ed439656f8
commit 96f82b4162
3 changed files with 59 additions and 17 deletions
+43 -12
View File
@@ -5,7 +5,7 @@ import { useAuthStore } from "@/modules/auth/store/useAuthStore";
export const RegisterPage: React.FC = () => {
const navigate = useNavigate();
const { register, isLoading, error, clearError, token } = useAuthStore();
const { register, isLoading, error, clearError } = useAuthStore();
const [formData, setFormData] = useState({
login: "",
password: "",
@@ -14,12 +14,7 @@ export const RegisterPage: React.FC = () => {
lastName: "",
});
const [passwordError, setPasswordError] = useState<string | null>(null);
useEffect(() => {
if (token) {
navigate("/");
}
}, [token, navigate]);
const [successMessage, setSuccessMessage] = useState<string | null>(null);
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
@@ -38,7 +33,17 @@ export const RegisterPage: React.FC = () => {
firstName: formData.firstName,
lastName: formData.lastName,
});
navigate("/");
setSuccessMessage("Аккаунт успешно создан! Теперь вы можете войти.");
setFormData({
login: "",
password: "",
confirmPassword: "",
firstName: "",
lastName: "",
});
setTimeout(() => {
navigate("/auth");
}, 2000);
} catch (err) {
// Error is handled by store
}
@@ -82,7 +87,10 @@ export const RegisterPage: React.FC = () => {
className="w-16 h-16 mx-auto mb-4 rounded-full flex items-center justify-center"
style={{ backgroundColor: "var(--bg-secondary)" }}
>
<FiUserPlus className="w-8 h-8" style={{ color: "var(--accent)" }} />
<FiUserPlus
className="w-8 h-8"
style={{ color: "var(--accent)" }}
/>
</div>
<h1
className="text-3xl font-bold mb-2"
@@ -109,6 +117,20 @@ export const RegisterPage: React.FC = () => {
</div>
)}
{/* Success Message */}
{successMessage && (
<div
className="mb-6 p-4 rounded-lg border text-sm"
style={{
backgroundColor: "var(--success-bg)",
borderColor: "var(--success-border)",
color: "var(--success-text)",
}}
>
{successMessage}
</div>
)}
{/* Form */}
<form onSubmit={handleSubmit} className="space-y-4">
{/* Name Fields */}
@@ -293,8 +315,16 @@ export const RegisterPage: React.FC = () => {
className="mt-2 text-sm flex items-center gap-1"
style={{ color: "var(--error-text)" }}
>
<svg className="w-4 h-4" fill="currentColor" viewBox="0 0 20 20">
<path fillRule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z" clipRule="evenodd" />
<svg
className="w-4 h-4"
fill="currentColor"
viewBox="0 0 20 20"
>
<path
fillRule="evenodd"
d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z"
clipRule="evenodd"
/>
</svg>
{passwordError}
</p>
@@ -311,7 +341,8 @@ export const RegisterPage: React.FC = () => {
}}
onMouseEnter={(e) => {
if (!isLoading) {
e.currentTarget.style.backgroundColor = "var(--button-primary-hover)";
e.currentTarget.style.backgroundColor =
"var(--button-primary-hover)";
}
}}
onMouseLeave={(e) => {