Skip to content

Commit

Permalink
validate image upload
Browse files Browse the repository at this point in the history
  • Loading branch information
yuetloo committed Jun 7, 2023
1 parent 1515683 commit 5481962
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion vue-app/src/locales/cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,7 @@
"donation": "捐款细节",
"team": "团队",
"links": "链接",
"images": "图片",
"image": "图片",
"review": "审查",
"submit": "提交"
}
Expand Down
2 changes: 1 addition & 1 deletion vue-app/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,7 @@
"donation": "Donation details",
"team": "Team details",
"links": "Links",
"images": "Images",
"image": "Images",
"review": "Review",
"submit": "Submit"
}
Expand Down
2 changes: 1 addition & 1 deletion vue-app/src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,7 @@
"donation": "Detalles de la donación",
"team": "Detalles del equipo",
"links": "Enlaces",
"images": "Imágenes",
"image": "Imágenes",
"review": "Revisa",
"submit": "Enviar"
}
Expand Down
15 changes: 12 additions & 3 deletions vue-app/src/views/JoinView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -772,25 +772,32 @@ const rules = computed(() => {
image: {
bannerHash: {
required,
validIpfsHash: isIPFS.cid,
validIpfsHash,
$autoDirty: true,
},
thumbnailHash: {
required,
validIpfsHash: isIPFS.cid,
validIpfsHash,
$autoDirty: true,
},
},
}
})
const v$ = useVuelidate(rules, form)
const currentStep = ref<number>(0)
const steps = ['project', 'donation', 'team', 'links', 'images', 'review', 'submit', 'confirm']
const steps = ['project', 'donation', 'team', 'links', 'image', 'review', 'submit', 'confirm']
const stepNames = steps.slice(0, steps.length - 1)
const showSummaryPreview = ref(false)
const isWaiting = ref(false)
const txHash = ref('')
const txError = ref('')
function validIpfsHash(hash: string): boolean {
const isValid = Boolean(hash) && isIPFS.cid(hash)
return isValid
}
const isNavDisabled = computed<boolean>(
() => !isStepValid(currentStep.value) && currentStep.value !== form.furthestStep,
)
Expand Down Expand Up @@ -860,6 +867,7 @@ function saveFormData(updateFurthest?: boolean): void {
// Callback from IpfsImageUpload component
function handleUpload(key, value) {
form.image[key] = value
v$.value.image[key].$touch()
saveFormData(false)
}
Expand All @@ -872,6 +880,7 @@ function isStepValid(step: number): boolean {
return isLinkStepValid()
}
const stepName: string = steps[step]
return !v$.value[stepName]?.$invalid
}
Expand Down

0 comments on commit 5481962

Please sign in to comment.