Skip to content

Commit

Permalink
fix(snapshot-upload): fix report error if snapshot upload+recovery fa…
Browse files Browse the repository at this point in the history
…ils (#254)
  • Loading branch information
kartik-gupta-ij authored Dec 9, 2024
1 parent d84abf7 commit d1714fb
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions src/components/Snapshots/SnapshotUploadForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { StyledStatusBar } from '../Uploader/StyledStatusBar';
import '@uppy/core/dist/style.min.css';
import '@uppy/drag-drop/dist/style.min.css';
import '@uppy/status-bar/dist/style.min.css';
import { bigIntJSON } from '../../common/bigIntJSON';

export const SnapshotUploadForm = ({ onSubmit, onComplete, sx }) => {
const { client: qdrantClient } = useClient();
Expand Down Expand Up @@ -58,27 +57,29 @@ export const SnapshotUploadForm = ({ onSubmit, onComplete, sx }) => {
headers: getHeaders(),
formData: true,
fieldName: 'snapshot',
getResponseError: (responseText) => {
enqueueSnackbar(bigIntJSON.parse(responseText)?.status?.error, {
variant: 'error',
autoHideDuration: null,
action: (key) => (
<Button
variant="outlined"
color="inherit"
onClick={() => {
closeSnackbar(key);
}}
>
Dismiss
</Button>
),
anchorOrigin: {
vertical: 'bottom',
horizontal: 'center',
},
});
},
});

uppy.on('upload-error', (_, error, response) => {
const errorMessage = response?.body?.status?.error || error.message || 'Unknown error';
enqueueSnackbar(`Upload failed: ${errorMessage}`, {
variant: 'error',
autoHideDuration: null,
action: (key) => (
<Button
variant="outlined"
color="inherit"
onClick={() => {
closeSnackbar(key);
}}
>
Dismiss
</Button>
),
anchorOrigin: {
vertical: 'bottom',
horizontal: 'center',
},
});
});

uppy.on('upload-success', () => {
Expand Down

0 comments on commit d1714fb

Please sign in to comment.