75 lines
1.6 KiB
JavaScript
75 lines
1.6 KiB
JavaScript
import {
|
|
pluginId
|
|
} from "./chunk-ALMC553V.js";
|
|
import {
|
|
useMutation,
|
|
useQuery
|
|
} from "./chunk-QLEKUQKW.js";
|
|
import {
|
|
useFetchClient
|
|
} from "./chunk-FCIM6RNO.js";
|
|
import {
|
|
useTracking
|
|
} from "./chunk-GSN7U3BK.js";
|
|
import {
|
|
useNotification
|
|
} from "./chunk-N55RVBRV.js";
|
|
import {
|
|
useIntl
|
|
} from "./chunk-7XB6XSWQ.js";
|
|
|
|
// node_modules/@strapi/upload/dist/admin/hooks/useConfig.mjs
|
|
var endpoint = `/${pluginId}/configuration`;
|
|
var queryKey = [
|
|
pluginId,
|
|
"configuration"
|
|
];
|
|
var useConfig = () => {
|
|
const { trackUsage } = useTracking();
|
|
const { formatMessage } = useIntl();
|
|
const { toggleNotification } = useNotification();
|
|
const { get, put } = useFetchClient();
|
|
const config = useQuery(queryKey, async () => {
|
|
const res = await get(endpoint);
|
|
return res.data.data;
|
|
}, {
|
|
onError() {
|
|
return toggleNotification({
|
|
type: "danger",
|
|
message: formatMessage({
|
|
id: "notification.error"
|
|
})
|
|
});
|
|
},
|
|
/**
|
|
* We're cementing that we always expect an object to be returned.
|
|
*/
|
|
select: (data) => data || {}
|
|
});
|
|
const putMutation = useMutation(async (body) => {
|
|
await put(endpoint, body);
|
|
}, {
|
|
onSuccess() {
|
|
trackUsage("didEditMediaLibraryConfig");
|
|
config.refetch();
|
|
},
|
|
onError() {
|
|
return toggleNotification({
|
|
type: "danger",
|
|
message: formatMessage({
|
|
id: "notification.error"
|
|
})
|
|
});
|
|
}
|
|
});
|
|
return {
|
|
config,
|
|
mutateConfig: putMutation
|
|
};
|
|
};
|
|
|
|
export {
|
|
useConfig
|
|
};
|
|
//# sourceMappingURL=chunk-JF4AI5LV.js.map
|