mirror of
https://github.com/danbulant/Portfolio
synced 2026-05-24 12:35:31 +00:00
feat: more upload statuses
This commit is contained in:
parent
485bd8613d
commit
d749b05f09
3 changed files with 23 additions and 15 deletions
|
|
@ -1,8 +1,7 @@
|
|||
<script lang="ts">
|
||||
import FileType from './FileType.svelte';
|
||||
import FileDrop from 'filedrop-svelte';
|
||||
import FileMissingNotification from './StatusNotification.svelte';
|
||||
import { submissionProgress, UploadStatus } from '../../../stores/portfolio';
|
||||
import { submissionProgress, UploadStatus, type Status } from '../../../stores/portfolio';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import StatusNotification from './StatusNotification.svelte';
|
||||
|
||||
|
|
@ -13,20 +12,26 @@
|
|||
export let filesize: string;
|
||||
export let fileType: number = 0;
|
||||
|
||||
let missing = false;
|
||||
let status: Status = "missing";
|
||||
|
||||
$: if ($submissionProgress) {
|
||||
missing = isMissing();
|
||||
status = getStatus();
|
||||
}
|
||||
|
||||
const isMissing = (): boolean => {
|
||||
const getStatus = (): Status => {
|
||||
switch ($submissionProgress.status) {
|
||||
case UploadStatus.None:
|
||||
return true;
|
||||
return 'missing';
|
||||
case UploadStatus.Some:
|
||||
return !$submissionProgress.files!.some(code => code === fileType);
|
||||
if (!$submissionProgress.files!.some(code => code === fileType)) {
|
||||
return 'uploaded';
|
||||
}
|
||||
case UploadStatus.All:
|
||||
return 'uploaded';
|
||||
case UploadStatus.Submitted:
|
||||
return 'submitted';
|
||||
default:
|
||||
return false;
|
||||
return 'missing';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -70,9 +75,7 @@
|
|||
<!-- <div class="flex flex-col justify-between">
|
||||
</div> -->
|
||||
<h3>{title}</h3>
|
||||
{#if missing}
|
||||
<StatusNotification type="missing" />
|
||||
{/if}
|
||||
<StatusNotification {status} />
|
||||
<div class="mt-1 sm:mt-0">
|
||||
<FileType {filetype} {filesize} />
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
<script lang="ts">
|
||||
export let type: "submitted" | "uploaded" | "missing";
|
||||
import type { Status } from "../../../stores/portfolio";
|
||||
|
||||
|
||||
export let status: Status;
|
||||
let title: string;
|
||||
switch (type) {
|
||||
|
||||
$: switch (status) {
|
||||
case "submitted":
|
||||
title = "Odeslané";
|
||||
break;
|
||||
|
|
@ -16,7 +20,7 @@
|
|||
|
||||
<!-- make red dot -->
|
||||
<div class="flex flex-col justify-between">
|
||||
<span class="mt-1 w-5 h-5 rounded-full {type}" />
|
||||
<span class="mt-1 w-5 h-5 rounded-full {status}" />
|
||||
<h3 class="ml-8 font-bold text-xl">{title}</h3>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
import { apiFetchSubmissionProgress } from "../@api/candidate";
|
||||
import { writable } from "svelte/store";
|
||||
|
||||
export type Status = 'submitted' | 'uploaded' | 'missing';
|
||||
|
||||
export enum UploadStatus {
|
||||
None = 1,
|
||||
Some = 2,
|
||||
|
|
@ -12,7 +14,6 @@ export interface SubmissionProgress {
|
|||
status?: UploadStatus;
|
||||
files?: [number];
|
||||
}
|
||||
|
||||
export const submissionProgress = writable<SubmissionProgress>({});
|
||||
|
||||
export async function fetchSubmProgress() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue