Fix return type of detail queries (#8038)

This commit is contained in:
Oliver 2024-08-30 10:38:48 +10:00 committed by GitHub
parent 3951b3f56e
commit cc45c23915
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -403,17 +403,17 @@ export default function PartDetail() {
case 200: case 200:
return response.data; return response.data;
default: default:
return null; return {};
} }
}) })
.catch(() => { .catch(() => {
return null; return {};
}); });
} }
}); });
return ( return (
data && data.overall_min &&
`${formatPriceRange(data.overall_min, data.overall_max)}${ `${formatPriceRange(data.overall_min, data.overall_max)}${
part.units && ' / ' + part.units part.units && ' / ' + part.units
}` }`
@ -443,19 +443,19 @@ export default function PartDetail() {
if (response.data.length > 0) { if (response.data.length > 0) {
return response.data[response.data.length - 1]; return response.data[response.data.length - 1];
} else { } else {
return null; return {};
} }
default: default:
return null; return {};
} }
}) })
.catch(() => { .catch(() => {
return null; return {};
}); });
} }
}); });
if (data.quantity) { if (data && data.quantity) {
return `${data.quantity} (${data.date})`; return `${data.quantity} (${data.date})`;
} else { } else {
return '-'; return '-';
@ -482,11 +482,11 @@ export default function PartDetail() {
case 200: case 200:
return response.data[response.data.length - 1]; return response.data[response.data.length - 1];
default: default:
return null; return {};
} }
}) })
.catch(() => { .catch(() => {
return null; return {};
}); });
} }
}); });