Merge pull request #80 from EETagent/file_upload_error

(frontend) upload errors
This commit is contained in:
Vojtěch Jungmann 2022-12-06 00:20:34 +01:00 committed by GitHub
commit 79e570248d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 6 deletions

View file

@ -2,11 +2,19 @@
import { fetchSubmProgress } from '$lib/stores/portfolio';
import { apiDeleteCoverLetter, apiUploadCoverLetter } from '$lib/@api/candidate';
import DashboardUploadCard from './DashboardUploadCard.svelte';
import type { ApiError } from '$lib/@api';
let error: string | null = null;
const onFileDrop = async (detail: any) => {
const file = detail.file;
const callback = detail.callback;
await apiUploadCoverLetter(file, callback);
try {
await apiUploadCoverLetter(file, callback);
error = null;
} catch (e) {
error = (e as ApiError).msg;
}
await fetchSubmProgress();
};
@ -17,6 +25,7 @@
</script>
<DashboardUploadCard
{error}
on:filedrop={(e) => onFileDrop(e.detail)}
on:delete={onDelete}
title="Motivační dopis"

View file

@ -13,6 +13,8 @@
const dispatch = createEventDispatcher();
export let error: string | null = null;
export let title: string;
export let filetype: 'PDF' | 'ZIP';
export let filesize: number;
@ -112,7 +114,7 @@
<StatusNotificationDot {status} />
</div>
</div>
{#if fileDropped}
{#if fileDropped && error === null}
<div class="body uploaded flex content-around items-center justify-between">
<div class="w-24">
<img
@ -168,8 +170,12 @@
on:mouseleave={dashAnimationStop}
style={`background-image: url("data:image/svg+xml,%3csvg width='100%25' height='100%25' xmlns='http://www.w3.org/2000/svg'%3e%3crect width='100%25' height='100%25' fill='none' rx='9' ry='9' stroke-opacity='50%' stroke='%23406280' stroke-width='4' stroke-dasharray='10' stroke-dashoffset='${dashAnimationProgress}' stroke-linecap='square'/%3e%3c/svg%3e");`}
>
<span class="text-[#406280]">Sem přetáhněte,</span>
<span class="text-sspsGray">nebo nahrajte {placeholder}</span>
{#if error}
<span class="font-semibold text-red-600">{error}</span>
{:else}
<span class="text-[#406280]">Sem přetáhněte,</span>
<span class="text-sspsGray">nebo nahrajte {placeholder}</span>
{/if}
</div>
</div>
{/if}

View file

@ -1,12 +1,20 @@
<script lang="ts">
import type { ApiError } from '$lib/@api';
import { fetchSubmProgress } from '$lib/stores/portfolio';
import { apiDeletePortfolioLetter, apiUploadPortfolioLetter } from '../../@api/candidate';
import DashboardUploadCard from './DashboardUploadCard.svelte';
let error: string | null = null;
const onFileDrop = async (detail: any) => {
const file = detail.file;
const callback = detail.callback;
await apiUploadPortfolioLetter(file, callback);
try {
await apiUploadPortfolioLetter(file, callback);
error = null;
} catch (e) {
error = (e as ApiError).msg;
}
await fetchSubmProgress();
};
@ -17,6 +25,7 @@
</script>
<DashboardUploadCard
{error}
on:filedrop={(e) => onFileDrop(e.detail)}
on:delete={onDelete}
title="Portfolio"

View file

@ -2,11 +2,19 @@
import { fetchSubmProgress } from '$lib/stores/portfolio';
import { apiDeletePortfolioZip, apiUploadPortfolioZip } from '$lib/@api/candidate';
import DashboardUploadCard from './DashboardUploadCard.svelte';
import type { ApiError } from '$lib/@api';
let error: string | null = null;
const onFileDrop = async (detail: any) => {
const file = detail.file;
const callback = detail.callback;
await apiUploadPortfolioZip(file, callback);
try {
await apiUploadPortfolioZip(file, callback);
error = null;
} catch (e) {
error = (e as ApiError).msg;
}
await fetchSubmProgress();
};
@ -17,6 +25,7 @@
</script>
<DashboardUploadCard
{error}
on:filedrop={(e) => onFileDrop(e.detail)}
on:delete={onDelete}
title="Další data"