Skip to content

Commit

Permalink
feat(proof): fetch and insert proof data to 'add single price' page w…
Browse files Browse the repository at this point in the history
…hen using 'add the price' button (#584)

Co-authored-by: Raphael Odini <[email protected]>
  • Loading branch information
odin-h and raphodn authored Jun 5, 2024
1 parent 226c3d9 commit 004cef2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/components/PriceAddButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default {
computed: {
getAddUrl() {
if (this.proofId) {
return `${this.ADD_PRICE_BASE_URL}?proof=${this.proofId}`
return `${this.ADD_PRICE_BASE_URL}?proof_id=${this.proofId}`
}
return `${this.ADD_PRICE_BASE_URL}?code=${this.productCode}`
}
Expand Down
21 changes: 16 additions & 5 deletions src/views/AddPriceSingle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,8 @@ export default {
else {
this.setProductCode(this.$route.query.code)
}
} else if (this.$route.query.proof) {
this.handleProofSelected(this.$route.query.proof)
} else if (this.$route.query.proof_id) {
this.getProofById(this.$route.query.proof_id)
}
this.initPriceSingleForm()
},
Expand Down Expand Up @@ -446,18 +446,29 @@ export default {
showUserRecentProofs() {
this.userRecentProofsDialog = true
},
handleProofSelected(proofId) {
this.addPriceSingleForm.proof_id = proofId
handleProofSelected(proof) {
this.addPriceSingleForm.proof_id = proof.id
this.addPriceSingleForm.date = new Date(proof.created).toISOString().split('T')[0]
// this.proofDateSuccessMessage = true
this.proofImagePreview = this.getProofUrl(proof)
this.proofSelectedSuccessMessage = true
this.proofSelectedMessage = true
},
handleRecentProofSelected(selectedProof) {
this.handleProofSelected(selectedProof.id)
this.handleProofSelected(selectedProof)
this.proofImagePreview = this.getProofUrl(selectedProof)
},
getProofUrl(proof) {
return `${import.meta.env.VITE_OPEN_PRICES_APP_URL}/img/${proof.file_path}`
},
getProofById(proofId) {
this.loading = true
api.getProofById(proofId)
.then(proof => {
this.handleProofSelected(proof)
this.loading = false
})
},
newProof(source) {
if (source === 'gallery') {
ExifReader.load(this.proofImage[0]).then((tags) => {
Expand Down

0 comments on commit 004cef2

Please sign in to comment.