Skip to content

Commit c20fbf9

Browse files
committed
fix: correct webhook response structure access in MediaLibrary import
1 parent 53ed845 commit c20fbf9

File tree

2 files changed

+6
-17
lines changed

2 files changed

+6
-17
lines changed

admin/src/pages/MediaLibrary/MediaLibrary.tsx

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,10 @@ const MediaLibraryPage = () => {
6060
data: assetData,
6161
};
6262

63-
interface AxiosResponse<T> {
64-
data: T;
65-
status: number;
66-
statusText: string;
67-
headers: Record<string, string>;
68-
}
69-
70-
const response = (await http.post('/webhook', payload)) as AxiosResponse<WebhookResponse>;
71-
const data = response.data;
63+
const response = await http.post<WebhookPayload, WebhookResponse>('/webhook', payload);
7264

73-
if (data?.status === 'success') {
74-
const stats = data.stats || { successful: 0, total: 0, failed: 0 };
65+
if (response?.status === 'success') {
66+
const stats = response.stats || { successful: 0, total: 0, failed: 0 };
7567

7668
toggleNotification({
7769
type: 'success',
@@ -83,18 +75,15 @@ const MediaLibraryPage = () => {
8375
{ successful: stats.successful, total: stats.total }
8476
),
8577
});
86-
87-
if (stats.successful > 0) {
88-
}
89-
} else if (data?.status === 'warning') {
78+
} else if (response?.status === 'warning') {
9079
toggleNotification({
9180
type: 'warning',
9281
message: formatMessage(
9382
{
9483
id: `${camelCase(PLUGIN_ID)}.page.mediaLibrary.notification.import.warning`,
9584
defaultMessage: 'Import completed with warnings: {message}',
9685
},
97-
{ message: data.message || 'Some files may not have been imported' }
86+
{ message: response.message || 'Some files may not have been imported' }
9887
),
9988
});
10089
} else {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.0.0",
2+
"version": "1.0.1",
33
"keywords": [],
44
"type": "commonjs",
55
"exports": {

0 commit comments

Comments
 (0)