Profile image works, editing profile works, now uses first/last name
This commit is contained in:
@@ -79,15 +79,21 @@ export function AuthProvider({ children }) {
|
||||
return userInfo;
|
||||
}, [refreshUser]);
|
||||
|
||||
const register = useCallback(async ({ username, password, email, fullName, phone }) => {
|
||||
const register = useCallback(async ({ username, password, email, firstName, lastName, phone }) => {
|
||||
const res = await fetch("/api/v1/auth/register", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ username, password, email, fullName, phone }),
|
||||
body: JSON.stringify({ username, password, email, firstName, lastName, phone }),
|
||||
});
|
||||
const data = await res.json();
|
||||
|
||||
if (!res.ok) {
|
||||
if (data.errors && typeof data.errors === "object") {
|
||||
const fieldErrors = Object.entries(data.errors)
|
||||
.map(([field, msg]) => `${field}: ${msg}`)
|
||||
.join(", ");
|
||||
throw new Error(fieldErrors || data.message || "Registration failed");
|
||||
}
|
||||
throw new Error(data.message || "Registration failed");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user