mirror of
https://github.com/danbulant/Portfolio
synced 2026-05-27 14:02:14 +00:00
feat: file upload error
This commit is contained in:
parent
0b36b96802
commit
42c297d9d5
4 changed files with 39 additions and 6 deletions
|
|
@ -2,16 +2,25 @@
|
||||||
import { fetchSubmProgress } from '$lib/stores/portfolio';
|
import { fetchSubmProgress } from '$lib/stores/portfolio';
|
||||||
import { apiUploadCoverLetter } from '$lib/@api/candidate';
|
import { apiUploadCoverLetter } from '$lib/@api/candidate';
|
||||||
import DashboardUploadCard from './DashboardUploadCard.svelte';
|
import DashboardUploadCard from './DashboardUploadCard.svelte';
|
||||||
|
import type { ApiError } from '$lib/@api';
|
||||||
|
|
||||||
|
let error: string | null = null;
|
||||||
|
|
||||||
const onFileDrop = async (detail: any) => {
|
const onFileDrop = async (detail: any) => {
|
||||||
const file = detail.file;
|
const file = detail.file;
|
||||||
const callback = detail.callback;
|
const callback = detail.callback;
|
||||||
await apiUploadCoverLetter(file, callback);
|
try {
|
||||||
|
await apiUploadCoverLetter(file, callback);
|
||||||
|
error = null;
|
||||||
|
} catch (e) {
|
||||||
|
error = (e as ApiError).msg;
|
||||||
|
}
|
||||||
await fetchSubmProgress();
|
await fetchSubmProgress();
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<DashboardUploadCard
|
<DashboardUploadCard
|
||||||
|
{error}
|
||||||
on:filedrop={(e) => onFileDrop(e.detail)}
|
on:filedrop={(e) => onFileDrop(e.detail)}
|
||||||
title="Motivační dopis"
|
title="Motivační dopis"
|
||||||
filetype="PDF"
|
filetype="PDF"
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,8 @@
|
||||||
|
|
||||||
const dispatch = createEventDispatcher();
|
const dispatch = createEventDispatcher();
|
||||||
|
|
||||||
|
export let error: string | null = null;
|
||||||
|
|
||||||
export let title: string;
|
export let title: string;
|
||||||
export let filetype: 'PDF' | 'ZIP';
|
export let filetype: 'PDF' | 'ZIP';
|
||||||
export let filesize: number;
|
export let filesize: number;
|
||||||
|
|
@ -105,7 +107,7 @@
|
||||||
<StatusNotificationDot {status} />
|
<StatusNotificationDot {status} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{#if fileDropped}
|
{#if fileDropped && error === null}
|
||||||
<div class="body uploaded flex content-around items-center justify-between">
|
<div class="body uploaded flex content-around items-center justify-between">
|
||||||
<div class="w-24">
|
<div class="w-24">
|
||||||
<img
|
<img
|
||||||
|
|
@ -161,8 +163,12 @@
|
||||||
on:mouseleave={dashAnimationStop}
|
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");`}
|
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>
|
{#if error}
|
||||||
<span class="text-sspsGray">nebo nahrajte {placeholder}</span>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,26 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import type { ApiError } from '$lib/@api';
|
||||||
import { fetchSubmProgress } from '$lib/stores/portfolio';
|
import { fetchSubmProgress } from '$lib/stores/portfolio';
|
||||||
import { apiUploadPortfolioLetter } from '../../@api/candidate';
|
import { apiUploadPortfolioLetter } from '../../@api/candidate';
|
||||||
import DashboardUploadCard from './DashboardUploadCard.svelte';
|
import DashboardUploadCard from './DashboardUploadCard.svelte';
|
||||||
|
|
||||||
|
let error: string | null = null;
|
||||||
|
|
||||||
const onFileDrop = async (detail: any) => {
|
const onFileDrop = async (detail: any) => {
|
||||||
const file = detail.file;
|
const file = detail.file;
|
||||||
const callback = detail.callback;
|
const callback = detail.callback;
|
||||||
await apiUploadPortfolioLetter(file, callback);
|
try {
|
||||||
|
await apiUploadPortfolioLetter(file, callback);
|
||||||
|
error = null;
|
||||||
|
} catch (e) {
|
||||||
|
error = (e as ApiError).msg;
|
||||||
|
}
|
||||||
await fetchSubmProgress();
|
await fetchSubmProgress();
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<DashboardUploadCard
|
<DashboardUploadCard
|
||||||
|
{error}
|
||||||
on:filedrop={(e) => onFileDrop(e.detail)}
|
on:filedrop={(e) => onFileDrop(e.detail)}
|
||||||
title="Portfolio"
|
title="Portfolio"
|
||||||
filetype="PDF"
|
filetype="PDF"
|
||||||
|
|
|
||||||
|
|
@ -2,16 +2,25 @@
|
||||||
import { fetchSubmProgress } from '$lib/stores/portfolio';
|
import { fetchSubmProgress } from '$lib/stores/portfolio';
|
||||||
import { apiUploadPortfolioZip } from '$lib/@api/candidate';
|
import { apiUploadPortfolioZip } from '$lib/@api/candidate';
|
||||||
import DashboardUploadCard from './DashboardUploadCard.svelte';
|
import DashboardUploadCard from './DashboardUploadCard.svelte';
|
||||||
|
import type { ApiError } from '$lib/@api';
|
||||||
|
|
||||||
|
let error: string | null = null;
|
||||||
|
|
||||||
const onFileDrop = async (detail: any) => {
|
const onFileDrop = async (detail: any) => {
|
||||||
const file = detail.file;
|
const file = detail.file;
|
||||||
const callback = detail.callback;
|
const callback = detail.callback;
|
||||||
await apiUploadPortfolioZip(file, callback);
|
try {
|
||||||
|
await apiUploadPortfolioZip(file, callback);
|
||||||
|
error = null;
|
||||||
|
} catch (e) {
|
||||||
|
error = (e as ApiError).msg;
|
||||||
|
}
|
||||||
await fetchSubmProgress();
|
await fetchSubmProgress();
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<DashboardUploadCard
|
<DashboardUploadCard
|
||||||
|
{error}
|
||||||
on:filedrop={(e) => onFileDrop(e.detail)}
|
on:filedrop={(e) => onFileDrop(e.detail)}
|
||||||
title="Další data"
|
title="Další data"
|
||||||
filetype="ZIP"
|
filetype="ZIP"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue