Small corrections

This commit is contained in:
augmentedpotato
2026-04-15 06:39:41 -06:00
parent 78a8992f71
commit c37650d942
5 changed files with 21 additions and 16 deletions

View File

@@ -159,11 +159,7 @@ export default function AdoptPage() {
{loading && <p className="adopt-status-msg">Loading pets...</p>} {loading && <p className="adopt-status-msg">Loading pets...</p>}
{error && ( {error && (
<div className="adopt-error-box"> <p className="adopt-status-msg">Unable to load pets, please try again later.</p>
<p className="adopt-error-title">Failed to load pets</p>
<code className="adopt-error-detail">{error}</code>
<p className="adopt-error-hint">Make sure the backend is running and try again.</p>
</div>
)} )}
{!loading && !error && displayedPets.length === 0 && ( {!loading && !error && displayedPets.length === 0 && (

View File

@@ -28,11 +28,11 @@ export default function ContactPage() {
const params = new URLSearchParams({ page: "0", size: "100", sort: "storeName,asc" }); const params = new URLSearchParams({ page: "0", size: "100", sort: "storeName,asc" });
fetch(`/api/v1/stores?${params}`) fetch(`/api/v1/stores?${params}`)
.then((res) => { .then((res) => {
if (!res.ok) throw new Error(`HTTP ${res.status}`); if (!res.ok) throw new Error("Unable to load store, please try again later.");
return res.json(); return res.json();
}) })
.then((data) => setLocations(data.content ?? [])) .then((data) => setLocations(data.content ?? []))
.catch((err) => setError(err.message)) .catch(() => setError("Unable to load store, please try again later."))
.finally(() => setLoading(false)); .finally(() => setLoading(false));
}, []); }, []);

View File

@@ -80,10 +80,7 @@ export default function ProductsPage() {
{loading && <p className="adopt-status-msg">Loading products...</p>} {loading && <p className="adopt-status-msg">Loading products...</p>}
{error && ( {error && (
<div className="adopt-error-box"> <p className="adopt-status-msg">Unable to load products, please try again later.</p>
<p className="adopt-error-title">Failed to load products</p>
<code className="adopt-error-detail">{error}</code>
</div>
)} )}
{!loading && !error && products.length === 0 && ( {!loading && !error && products.length === 0 && (

View File

@@ -64,10 +64,15 @@ export function AuthProvider({ children }) {
body: JSON.stringify({ username, password }), body: JSON.stringify({ username, password }),
}); });
const data = await res.json(); let data;
try {
data = await res.json();
} catch {
throw new Error("Unable to log in, please try again later.");
}
if (!res.ok) { if (!res.ok) {
throw new Error(data.message || "Login failed"); throw new Error(data.message || "Unable to log in, please try again later.");
} }
const jwt = data.token; const jwt = data.token;
@@ -85,16 +90,22 @@ export function AuthProvider({ children }) {
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
body: JSON.stringify({ username, password, email, firstName, lastName, phone }), body: JSON.stringify({ username, password, email, firstName, lastName, phone }),
}); });
const data = await res.json();
let data;
try {
data = await res.json();
} catch {
throw new Error("Unable to register, please try again later.");
}
if (!res.ok) { if (!res.ok) {
if (data.errors && typeof data.errors === "object") { if (data.errors && typeof data.errors === "object") {
const fieldErrors = Object.entries(data.errors) const fieldErrors = Object.entries(data.errors)
.map(([field, msg]) => `${field}: ${msg}`) .map(([field, msg]) => `${field}: ${msg}`)
.join(", "); .join(", ");
throw new Error(fieldErrors || data.message || "Registration failed"); throw new Error(fieldErrors || data.message || "Unable to register, please try again later.");
} }
throw new Error(data.message || "Registration failed"); throw new Error(data.message || "Unable to register, please try again later.");
} }
const jwt = data.token; const jwt = data.token;

View File

@@ -2,6 +2,7 @@
const nextConfig = { const nextConfig = {
output: 'standalone', output: 'standalone',
reactCompiler: true, reactCompiler: true,
devIndicators: false,
}; };
export default nextConfig; export default nextConfig;