Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions frontend/src/pages/Cliente/clientePerfil.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const initialFormStructure = [
// (Keep this function as it's needed for displaying fetched data)
const transformApiDataToFormData = (apiData) => {
if (!apiData) return initialFormStructure.map(f => ({ ...f, value: '' }));
console.log("Mapping API data to form:", apiData);
return initialFormStructure.map(field => {
let finalValue = '';
if (field.key === 'dataNascCliente' && apiData[field.key]) {
Expand Down Expand Up @@ -76,9 +75,7 @@ const ClientePerfil = () => {
setIsLoading(true);
setError(null);
try {
console.log("Fetching profile data for user login ID:", user.id);
const data = await fetchWithAuth(`/api/clientes/me`);
console.log("API Data received:", data);
if (!data) throw new Error("API não retornou dados do perfil.");
const dataWithEmail = { ...data, email: data.email || user?.email };
setOriginalData(data);
Expand Down Expand Up @@ -162,22 +159,13 @@ const ClientePerfil = () => {
const imageFile = imageInput?.files?.[0];
if (imageFile) {
dataToSend.append('ImagemCliente', imageFile, imageFile.name);
console.log("Appending image file to FormData with key 'ImagemCliente'");
} else {
console.log("No new image file selected.");
}
// --- End Construct FormData Payload ---

console.log("FormData content (keys):");
for (let key of dataToSend.keys()) { console.log(` - ${key}`); }

try {
const url = `/api/clientes/me`; // Endpoint without query params
console.log("Attempting API call to URL:", url);
console.log("Sending FormData object as body.");

await fetchWithAuth(url, { method: 'PUT', body: dataToSend, });
console.log("API call successful.");

const refreshedData = await fetchWithAuth(`/api/clientes/me`);
if (refreshedData) {
Expand Down