Skip to content

Commit

Permalink
fix: handle edit service (#628)
Browse files Browse the repository at this point in the history
fix handle edit service
  • Loading branch information
rubenkristian committed Jan 9, 2023
1 parent e71125d commit 3a3f4b9
Showing 1 changed file with 34 additions and 29 deletions.
63 changes: 34 additions & 29 deletions src/views/Dashboard/Lab/Registration/Services/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -545,39 +545,44 @@ export default {
},
async prefillServicesForm(service) {
window.scrollTo({
top: 100,
behavior: "smooth"
})
const hexCheck = /^[0-9a-fA-F]+$/;
try {
window.scrollTo({
top: 100,
behavior: "smooth"
})
const formatPrice = price => {
return this.web3.utils.fromWei(String(price.replaceAll(",", ""), "ether"))
}
const formatPrice = (price, currency) => {
return this.web3.utils.fromWei(String(price.replaceAll(",", "")), currency === "USDT" || currency === "USDTE" || currency === "USDT.e" ? "mwei" : "ether")
}
const { category, description, dnaCollectionProcess, expectedDuration, image, longDescription, name, pricesByCurrency, testResultSample } = service.info
this.serviceId = service.id
this.document = {
category,
dnaCollectionProcess,
name,
description,
longDescription: this.web3.utils.hexToUtf8(longDescription),
currency: formatUSDTE(pricesByCurrency[0].currency),
price: formatPrice(pricesByCurrency[0].priceComponents[0].value),
qcPrice: formatPrice(pricesByCurrency[0].additionalPrices[0].value),
duration: expectedDuration.duration,
durationType: expectedDuration.durationType
}
const { category, description, dnaCollectionProcess, expectedDuration, image, longDescription, name, pricesByCurrency, testResultSample } = service.info
this.serviceId = service.id
this.document = {
category,
dnaCollectionProcess,
name,
description,
longDescription: hexCheck.test(longDescription) ? this.web3.utils.hexToUtf8(longDescription) : longDescription,
currency: formatUSDTE(pricesByCurrency[0].currency),
price: formatPrice(pricesByCurrency[0].priceComponents[0].value, pricesByCurrency[0].currency),
qcPrice: formatPrice(pricesByCurrency[0].additionalPrices[0].value, pricesByCurrency[0].currency),
duration: expectedDuration.duration,
durationType: expectedDuration.durationType
}
this.testResultSampleUrl = testResultSample
this.imageUrl = image
this.testResultSampleUrl = testResultSample
this.imageUrl = image
const res = await fetch(testResultSample)
const blob = await res.blob() // Gets the response and returns it as a blob
const file = new File([blob], `${name} Test result sample`, {type: "application/pdf"})
this.testResultSampleFile = file
this.isEdit = true
const res = await fetch(testResultSample)
const blob = await res.blob() // Gets the response and returns it as a blob
const file = new File([blob], `${name} Test result sample`, {type: "application/pdf"})
this.testResultSampleFile = file
this.isEdit = true
} catch (err) {
console.error(err)
}
},
async triggerCreateOrUpdate() {
Expand Down

0 comments on commit 3a3f4b9

Please sign in to comment.