Update vue-toast-notification and use in signature app

This commit is contained in:
nobohan 2024-07-23 10:04:25 +02:00
parent 64e527672d
commit e57d52d00e
2 changed files with 17 additions and 9 deletions

View File

@ -59,7 +59,7 @@
"vue": "^3.2.37",
"vue-i18n": "^9.1.6",
"vue-multiselect": "3.0.0-alpha.2",
"vue-toast-notification": "^2.0",
"vue-toast-notification": "^3.1.2",
"vuex": "^4.0.0"
},
"browserslist": [

View File

@ -113,6 +113,8 @@
<script setup lang="ts">
import { ref, Ref, reactive } from "vue";
import { useToast } from "vue-toast-notification";
import "vue-toast-notification/dist/theme-sugar.css";
import { Signature, SignatureZone, SignedState } from "../../types";
import { makeFetch } from "../../../../../ChillMainBundle/Resources/public/lib/api/apiMethods";
import * as pdfjsLib from "pdfjs-dist";
@ -152,6 +154,8 @@ declare global {
}
}
const $toast = useToast();
const signature = window.signature;
const urlInfo = build_download_info_link(signature.storedObject.filename);
@ -330,8 +334,10 @@ const checkSignature = () => {
})
.catch((error) => {
signedState.value = "error";
console.log('Error while checking the signature', error);
//TODO toast error
console.log("Error while checking the signature", error);
$toast.error(
`Erreur lors de la vérification de la signature: ${error.txt}`
);
});
};
@ -348,17 +354,19 @@ const checkForReady = () => {
signedState.value = "error";
stopTrySigning();
console.log("Reached the maximum number of tentative to try signing");
//TODO toast error
$toast.error(
"Le nombre maximum de tentatives pour essayer de signer est atteint"
);
}
if (signedState.value === "rejected") {
stopTrySigning();
console.log("Signature rejected by the server");
//TODO toast error
$toast.error("Signature rejetée par le serveur");
}
if (signedState.value === "canceled") {
stopTrySigning();
console.log("Signature canceledconsole.log('Error while posting the signature', error);");
//TODO toast error
console.log("Signature canceled");
$toast.error("Signature annulée");
}
if (signedState.value === "pending") {
tryForReady = tryForReady + 1;
@ -383,9 +391,9 @@ const confirmSign = () => {
checkForReady();
})
.catch((error) => {
console.log('Error while posting the signature', error);
console.log("Error while posting the signature", error);
stopTrySigning();
//TODO toast
$toast.error(`Erreur lors de la soumission de la signature: ${error.txt}`);
});
};