Update package-lock.json with latest dependency versions
Upgraded multiple dependencies across Babel, Emotion, ESLint, and DevExpress packages in `package-lock.json` to their latest versions. These updates ensure compatibility, fix minor issues, and improve overall performance and security.
This commit is contained in:
@ -118,8 +118,8 @@ const SampleSpreadsheet: React.FC<SampleSpreadsheetProps> = ({ dewarId }) => {
|
||||
{ field: "spacegroupnumber", headerName: "Space Group Number", width: 200, editable: true },
|
||||
{ field: "cellparameters", headerName: "Cell Parameters", width: 300, editable: true },
|
||||
{ field: "rescutkey", headerName: "ResCut Key", width: 150, editable: true },
|
||||
{ field: "rescutvalue", headerName: "ResCut Value", width: 150, editable: true, editable: true },
|
||||
{ field: "userresolution", headerName: "User Resolution", width: 150, editable: true, editable: true },
|
||||
{ field: "rescutvalue", headerName: "ResCut Value", width: 150, editable: true },
|
||||
{ field: "userresolution", headerName: "User Resolution", width: 150, editable: true },
|
||||
{ field: "pdbid", headerName: "PDB ID", width: 150, editable: true },
|
||||
{ field: "autoprocfull", headerName: "AutoProc Full", width: 200, editable: true },
|
||||
{ field: "procfull", headerName: "Proc Full", width: 200, editable: true },
|
||||
|
@ -40,6 +40,8 @@ const SpreadsheetTable = ({
|
||||
const [dewarsToReplace, setDewarsToReplace] = useState([]);
|
||||
const [dewarsToCreate, setDewarsToCreate] = useState(new Map());
|
||||
const [correctionMetadata, setCorrectionMetadata] = useState(addinfo || []); // Store addinfo
|
||||
const [errorDialogOpen, setErrorDialogOpen] = useState(false); // Controls dialog visibility
|
||||
const [errorMessages, setErrorMessages] = useState<string[]>([]); // Error messages from the server
|
||||
|
||||
const enhancedRawData = raw_data.map((row) => {
|
||||
const metadata = correctionMetadata.find((info) => info.row_num === row.row_num) || {};
|
||||
@ -407,11 +409,20 @@ const SpreadsheetTable = ({
|
||||
|
||||
try {
|
||||
const dewarsArray = Array.from(dewarsToCreate.values());
|
||||
await handleDewarCreation(dewarsArray); // Updated logic handles replacement
|
||||
console.log('Dewars replaced successfully');
|
||||
} catch (error) {
|
||||
console.error('Error replacing dewars:', error);
|
||||
|
||||
// Perform the creation/update operation
|
||||
await handleDewarCreation(dewarsArray);
|
||||
|
||||
console.log("Dewars replaced successfully");
|
||||
} catch (error: any) {
|
||||
console.error("Error replacing dewars:", error);
|
||||
|
||||
let errorMessage = error?.message || "Unexpected error occurred while replacing dewars.";
|
||||
setErrorMessages((prevMessages) => [...prevMessages, errorMessage]);
|
||||
setErrorDialogOpen(true);
|
||||
}
|
||||
|
||||
// Reset controls after either success or failure
|
||||
setShowUpdateDialog(false);
|
||||
setDewarsToReplace([]);
|
||||
setDewarsToCreate(new Map());
|
||||
@ -424,19 +435,54 @@ const SpreadsheetTable = ({
|
||||
};
|
||||
|
||||
const handleDewarCreation = async (dewarsArray: any[]) => {
|
||||
const errorMessages: string[] = []; // Collect error messages for display
|
||||
|
||||
for (const dewar of dewarsArray) {
|
||||
try {
|
||||
// Prepare payload and exclude number_of_pucks before sending
|
||||
const { number_of_pucks, number_of_samples, ...payload } = dewar;
|
||||
|
||||
// Call the backend to create or update dewars
|
||||
// Attempt to create or update a dewar
|
||||
await DewarsService.createOrUpdateDewarDewarsPost(selectedShipment.id, payload);
|
||||
|
||||
console.log(`Dewar "${dewar.dewar_name}" processed successfully.`);
|
||||
} catch (error) {
|
||||
console.error("Error creating/updating dewar:", error);
|
||||
console.log(`Dewar "${dewar.dewar_name}" created/updated successfully.`);
|
||||
} catch (error: any) {
|
||||
// Log the full error object for debugging purposes
|
||||
console.error("Full error object:", error);
|
||||
|
||||
let backendReason = "Unexpected error occurred."; // Default fallback message
|
||||
|
||||
if (error instanceof ApiError && error.body) {
|
||||
// API error response (similar to delete route)
|
||||
console.error("API error body:", error.body);
|
||||
backendReason = error.body.detail || backendReason;
|
||||
} else if (error?.response?.data?.detail) {
|
||||
// Fallback for Axios-like errors
|
||||
backendReason = error.response.data.detail;
|
||||
} else if (error?.response) {
|
||||
// Unexpected HTTP response (no error detail)
|
||||
backendReason = `Unknown error occurred (Status: ${error.response.status}).`;
|
||||
console.error("Error Response Data:", error.response.data);
|
||||
} else if (error?.message) {
|
||||
// Client-side error (e.g., network issues)
|
||||
backendReason = error.message;
|
||||
}
|
||||
|
||||
// Append the detailed error message to the list
|
||||
errorMessages.push(`Dewar "${dewar.dewar_name}": ${backendReason}`);
|
||||
}
|
||||
}
|
||||
|
||||
// Notify the user if there are error messages
|
||||
if (errorMessages.length > 0) {
|
||||
setErrorMessages(errorMessages); // Set state to render an error dialog
|
||||
setErrorDialogOpen(true); // Open the error dialog
|
||||
|
||||
// Re-throw the error to let the parent function (e.g., handleConfirmUpdate) know something went wrong
|
||||
throw new Error("Error(s) occurred while creating/updating dewars.");
|
||||
} else {
|
||||
console.log("All dewars processed successfully.");
|
||||
alert("All dewars created successfully!"); // Show success message
|
||||
}
|
||||
};
|
||||
|
||||
const handleSubmit = async () => {
|
||||
@ -607,7 +653,33 @@ const SpreadsheetTable = ({
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
|
||||
<Dialog
|
||||
open={errorDialogOpen}
|
||||
onClose={() => setErrorDialogOpen(false)}
|
||||
aria-labelledby="error-dialog-title"
|
||||
aria-describedby="error-dialog-description"
|
||||
>
|
||||
<DialogTitle>Error Creating/Updating Dewars</DialogTitle>
|
||||
<DialogContent>
|
||||
<DialogContentText>
|
||||
The following errors occurred while processing dewars:
|
||||
<ul>
|
||||
{errorMessages.map((message, index) => (
|
||||
<li key={index}>{message}</li>
|
||||
))}
|
||||
</ul>
|
||||
</DialogContentText>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={() => setErrorDialogOpen(false)} color="primary">
|
||||
Close
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
|
||||
</TableContainer>
|
||||
|
||||
);
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user