First Commit

This commit is contained in:
cesnimda
2026-03-21 11:55:27 +01:00
commit 2e8a29b4d0
1757 changed files with 166084 additions and 0 deletions
@@ -0,0 +1,85 @@
import React, { useMemo, useState } from "react";
import { Box, Button, Paper, TextField, Typography } from "@mui/material";
import { useLocation, useNavigate } from "react-router-dom";
import { api } from "../api";
import { useToast } from "../toast";
function useQuery() {
const { search } = useLocation();
return useMemo(() => new URLSearchParams(search), [search]);
}
export default function ResetPasswordPage() {
const { toast } = useToast();
const navigate = useNavigate();
const q = useQuery();
const email = q.get("email") || "";
const token = q.get("token") || "";
const [newPassword, setNewPassword] = useState("");
const [loading, setLoading] = useState(false);
return (
<Box
sx={{
minHeight: "100vh",
display: "flex",
alignItems: "center",
justifyContent: "center",
p: 2,
background:
"radial-gradient(1200px 700px at 20% 0%, rgba(79,140,255,0.14), transparent 55%), radial-gradient(900px 600px at 80% 20%, rgba(245,158,11,0.10), transparent 55%)",
}}
>
<Paper sx={{ width: "min(520px, 100%)", p: 3 }}>
<Typography variant="h5" sx={{ fontWeight: 900, mb: 0.5 }}>
Reset password
</Typography>
<Typography sx={{ color: "text.secondary", mb: 2 }}>
Set a new password for your account.
</Typography>
<Box
component="form"
onSubmit={(e) => {
e.preventDefault();
if (!email || !token) {
toast("Missing email/token in link.", "error");
return;
}
setLoading(true);
api
.post("/auth/reset-password", { email, token, newPassword })
.then(() => {
toast("Password reset. Please sign in.", "success");
navigate("/login", { replace: true });
})
.catch((e2: any) => {
const msg = e2?.response?.data || e2?.message || "Reset failed.";
toast(String(msg), "error");
})
.finally(() => setLoading(false));
}}
sx={{ display: "flex", flexDirection: "column", gap: 1.5 }}
>
<TextField label="Email" value={email} disabled fullWidth />
<TextField label="New password" type="password" value={newPassword} onChange={(e) => setNewPassword(e.target.value)} fullWidth />
<Box sx={{ display: "flex", justifyContent: "flex-end", gap: 1, mt: 1 }}>
<Button type="button" variant="outlined" onClick={() => navigate("/login")} disabled={loading}>
Back to login
</Button>
<Button type="submit" variant="contained" disabled={loading}>
Update password
</Button>
</Box>
</Box>
</Paper>
</Box>
);
}