feat(compete): upload file
This commit is contained in:
parent
e85ea0c475
commit
ded0a634d2
5 changed files with 250 additions and 39 deletions
46
src/stores/uploadProgress.ts
Normal file
46
src/stores/uploadProgress.ts
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
import { defineStore } from 'pinia';
|
||||
import { ref } from 'vue';
|
||||
|
||||
interface PendingUpload {
|
||||
jobId: string;
|
||||
type: 'candidate' | 'score' | 'result' | 'period';
|
||||
periodId: string;
|
||||
}
|
||||
|
||||
export const useUploadProgressStore = defineStore('uploadProgress', () => {
|
||||
const pendingUploads = ref<PendingUpload[]>([]);
|
||||
|
||||
function addUpload(jobId: string, periodId: string, uploadType: 'candidate' | 'score' | 'result' | 'period') {
|
||||
pendingUploads.value.push({
|
||||
jobId,
|
||||
type: uploadType,
|
||||
periodId
|
||||
});
|
||||
}
|
||||
|
||||
function removeUpload(jobId: string) {
|
||||
const index = pendingUploads.value.findIndex(u => u.jobId === jobId);
|
||||
if (index !== -1) {
|
||||
pendingUploads.value.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
function removeByPeriodAndType(periodId: string, uploadType: string) {
|
||||
const index = pendingUploads.value.findIndex(
|
||||
u => u.periodId === periodId && u.type === uploadType
|
||||
);
|
||||
if (index !== -1) {
|
||||
pendingUploads.value.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
function isUploading(periodId: string, uploadType: string): boolean {
|
||||
return pendingUploads.value.some(
|
||||
u => u.periodId === periodId && u.type === uploadType
|
||||
);
|
||||
}
|
||||
|
||||
return { pendingUploads, addUpload, removeUpload, removeByPeriodAndType, isUploading };
|
||||
}, {
|
||||
persist: true
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue