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 the 'add the price' button
  • Loading branch information
odin-h authored May 23, 2024
1 parent 2092f48 commit c29e744
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/views/AddPriceSingle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ export default {
this.setProductCode(this.$route.query.code)
}
} else if (this.$route.query.proof) {
this.handleProofSelected(this.$route.query.proof)
this.getProofById(this.$route.query.proof);
}
this.initPriceSingleForm()
},
Expand Down Expand Up @@ -412,18 +412,28 @@ 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.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

2 comments on commit c29e744

@odin-h
Copy link
Collaborator Author

@odin-h odin-h commented on c29e744 May 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solves the missing proof image from #557 and also inserts the proof created date to the form

@raphodn
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hum i'm surprised you're allowed to push to the master branch directly ??
the workflow is to open a PR from a branch..

Please sign in to comment.