Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
gsteenkamp89 committed Mar 20, 2024
1 parent 81e396b commit cff8986
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions src/plugins/oSnap/components/TransactionBuilder/SafeImport.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,16 @@ const emit = defineEmits<{
updateTransaction: [transaction: SafeImportTransaction];
}>();
type FileInputState =
| 'IDLE'
| 'DROPPING'
| 'INVALID_TYPE'
| 'PARSING_ERROR'
| 'VALID';
type FileInputState = 'IDLE' | 'INVALID_TYPE' | 'PARSING_ERROR' | 'VALID';
const fileInputState = ref<FileInputState>('IDLE');
const dropping = ref(false);
function updateFileInputState(state: FileInputState) {
fileInputState.value = state;
}
function toggleDropping() {
if (fileInputState.value === 'DROPPING') {
updateFileInputState('IDLE');
return;
}
updateFileInputState('DROPPING');
}
const isDropping = computed(() => fileInputState.value === 'DROPPING');
const toggleDropping = () => {
dropping.value = !dropping.value;
};
const isDropping = computed(() => dropping.value === true);
const file = ref<File>();
const safeFile = ref<GnosisSafe.BatchFile>(); // raw, type-safe file
Expand Down Expand Up @@ -114,6 +106,7 @@ watch(file, async () => {
function handleDrop(event: DragEvent) {
resetState();
dropping.value = false;
const _file = event.dataTransfer?.files?.[0];
if (!_file) return;
if (_file.type !== 'application/json') {
Expand Down Expand Up @@ -196,7 +189,7 @@ watch(finalTransaction, updateTransaction);
>
<div class="flex flex-col gap-1 items-center justify-center">
<i-ho-upload />
<span v-if="fileInputState === 'IDLE' || fileInputState === 'DROPPING'"
<span v-if="fileInputState === 'IDLE'"
>Click to select file, or drag n drop</span
>
<span v-if="fileInputState === 'INVALID_TYPE'"
Expand Down

0 comments on commit cff8986

Please sign in to comment.