mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-18 13:12:16 +01:00
add error notifications to importer
This commit is contained in:
@@ -33,7 +33,7 @@ onMounted(async () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const reportResult = ref<ImportReport>();
|
const reportResult = ref<ImportReport | null>();
|
||||||
const files = ref<FileList | null>(null);
|
const files = ref<FileList | null>(null);
|
||||||
|
|
||||||
async function importData() {
|
async function importData() {
|
||||||
@@ -51,18 +51,24 @@ async function importData() {
|
|||||||
const base64String = await toBase64(files.value[0]);
|
const base64String = await toBase64(files.value[0]);
|
||||||
const organizationId = getCurrentOrganizationId();
|
const organizationId = getCurrentOrganizationId();
|
||||||
if (organizationId !== null) {
|
if (organizationId !== null) {
|
||||||
reportResult.value = await api.importData(
|
const { handleApiRequestNotifications } = useNotificationsStore();
|
||||||
{
|
|
||||||
type: importType.value.key,
|
reportResult.value = await handleApiRequestNotifications(
|
||||||
data: base64String.replace('data:text/csv;base64,', ''),
|
api.importData(
|
||||||
},
|
{
|
||||||
{
|
type: importType.value.key,
|
||||||
params: {
|
data: base64String.replace('data:text/csv;base64,', ''),
|
||||||
organization: organizationId,
|
|
||||||
},
|
},
|
||||||
}
|
{
|
||||||
|
params: {
|
||||||
|
organization: organizationId,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
);
|
);
|
||||||
showResultModal.value = true;
|
if (reportResult.value) {
|
||||||
|
showResultModal.value = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
export type NotificationType = 'success' | 'error';
|
export type NotificationType = 'success' | 'error';
|
||||||
|
|
||||||
export const useNotificationsStore = defineStore('notifications', () => {
|
export const useNotificationsStore = defineStore('notifications', () => {
|
||||||
@@ -50,9 +51,7 @@ export const useNotificationsStore = defineStore('notifications', () => {
|
|||||||
if (axios.isAxiosError(error)) {
|
if (axios.isAxiosError(error)) {
|
||||||
if (
|
if (
|
||||||
error?.response?.status === 403 ||
|
error?.response?.status === 403 ||
|
||||||
(error?.response?.status === 400 &&
|
error?.response?.status === 400
|
||||||
error?.response?.data?.error === true &&
|
|
||||||
error?.response?.data?.errorMessage !== undefined)
|
|
||||||
) {
|
) {
|
||||||
addNotification(
|
addNotification(
|
||||||
'error',
|
'error',
|
||||||
|
|||||||
Reference in New Issue
Block a user