mirror of
https://github.com/danbulant/Portfolio
synced 2026-05-24 12:35:31 +00:00
Merge pull request #80 from EETagent/file_upload_error
(frontend) upload errors
This commit is contained in:
commit
79e570248d
4 changed files with 39 additions and 6 deletions
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Reference in a new issue