feature/IO-3103-Ant5-Notifications
This commit is contained in:
@@ -9,6 +9,7 @@ import { handleUpload } from "./documents-local-upload.utility";
|
||||
import { HasFeatureAccess } from "../feature-wrapper/feature-wrapper.component";
|
||||
import LockWrapperComponent from "../lock-wrapper/lock-wrapper.component";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useNotification } from "../../contexts/Notifications/notificationContext.jsx";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
currentUser: selectCurrentUser,
|
||||
@@ -27,6 +28,8 @@ export function DocumentsLocalUploadComponent({
|
||||
}) {
|
||||
const [fileList, setFileList] = useState([]);
|
||||
const { t } = useTranslation();
|
||||
const notification = useNotification();
|
||||
|
||||
const handleDone = (uid) => {
|
||||
setTimeout(() => {
|
||||
setFileList((fileList) => fileList.filter((x) => x.uid !== uid));
|
||||
@@ -53,7 +56,8 @@ export function DocumentsLocalUploadComponent({
|
||||
vendorid,
|
||||
invoice_number,
|
||||
callback: callbackAfterUpload
|
||||
}
|
||||
},
|
||||
notification
|
||||
})
|
||||
}
|
||||
{...(!allowAllTypes && {
|
||||
|
||||
@@ -2,10 +2,9 @@ import cleanAxios from "../../utils/CleanAxios";
|
||||
import { store } from "../../redux/store";
|
||||
import { addMediaForJob } from "../../redux/media/media.actions";
|
||||
import normalizeUrl from "normalize-url";
|
||||
import { notification } from "antd";
|
||||
import i18n from "i18next";
|
||||
|
||||
export const handleUpload = async ({ ev, context }) => {
|
||||
export const handleUpload = async ({ ev, context, notification }) => {
|
||||
const { onError, onSuccess, onProgress, file } = ev;
|
||||
const { jobid, invoice_number, vendorid, callbackAfterUpload } = context;
|
||||
|
||||
@@ -43,11 +42,15 @@ export const handleUpload = async ({ ev, context }) => {
|
||||
}
|
||||
} else {
|
||||
onSuccess && onSuccess(file);
|
||||
notification.open({
|
||||
type: "success",
|
||||
key: "docuploadsuccess",
|
||||
message: i18n.t("documents.successes.insert")
|
||||
});
|
||||
if (notification) {
|
||||
notification.open({
|
||||
type: "success",
|
||||
key: "docuploadsuccess",
|
||||
message: i18n.t("documents.successes.insert")
|
||||
});
|
||||
} else {
|
||||
console.error("No notification context found in document local upload utility.");
|
||||
}
|
||||
store.dispatch(
|
||||
addMediaForJob({
|
||||
jobid,
|
||||
|
||||
Reference in New Issue
Block a user