From c336c62c32ca96f831437daccb54cdc0629cb00a Mon Sep 17 00:00:00 2001 From: ennucore Date: Sat, 17 Dec 2022 19:37:20 +0100 Subject: [PATCH] Awesome QR at checkout --- .idea/workspace.xml | 28 +++++++----- package-lock.json | 27 +++++++++++ package.json | 1 + src/components/ZonePricing.vue | 4 +- src/result.ts | 29 ++++++++++++ src/views/Checkout.vue | 82 ++++++++++++++++++++++++++++++++-- 6 files changed, 154 insertions(+), 17 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 646205b..dd5367e 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,15 +1,13 @@ - - + - - - - - - + + + + + @@ -178,6 +183,7 @@ - \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 22d8327..2af726e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "@popperjs/core": "^2.11.6", "axios": "^1.2.1", "bulma": "^0.9.4", + "qr-code-styling": "^1.6.0-rc.1", "sass": "^1.56.2", "vue": "^3.2.45", "vue-contenteditable": "^4.1.0", @@ -2122,6 +2123,19 @@ "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" }, + "node_modules/qr-code-styling": { + "version": "1.6.0-rc.1", + "resolved": "https://registry.npmjs.org/qr-code-styling/-/qr-code-styling-1.6.0-rc.1.tgz", + "integrity": "sha512-ModRIiW6oUnsP18QzrRYZSc/CFKFKIdj7pUs57AEVH20ajlglRpN3HukjHk0UbNMTlKGuaYl7Gt6/O5Gg2NU2Q==", + "dependencies": { + "qrcode-generator": "^1.4.3" + } + }, + "node_modules/qrcode-generator": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/qrcode-generator/-/qrcode-generator-1.4.4.tgz", + "integrity": "sha512-HM7yY8O2ilqhmULxGMpcHSF1EhJJ9yBj8gvDEuZ6M+KGJ0YY2hKpnXvRD+hZPLrDVck3ExIGhmPtSdcjC+guuw==" + }, "node_modules/queue-microtask": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", @@ -4154,6 +4168,19 @@ "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" }, + "qr-code-styling": { + "version": "1.6.0-rc.1", + "resolved": "https://registry.npmjs.org/qr-code-styling/-/qr-code-styling-1.6.0-rc.1.tgz", + "integrity": "sha512-ModRIiW6oUnsP18QzrRYZSc/CFKFKIdj7pUs57AEVH20ajlglRpN3HukjHk0UbNMTlKGuaYl7Gt6/O5Gg2NU2Q==", + "requires": { + "qrcode-generator": "^1.4.3" + } + }, + "qrcode-generator": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/qrcode-generator/-/qrcode-generator-1.4.4.tgz", + "integrity": "sha512-HM7yY8O2ilqhmULxGMpcHSF1EhJJ9yBj8gvDEuZ6M+KGJ0YY2hKpnXvRD+hZPLrDVck3ExIGhmPtSdcjC+guuw==" + }, "queue-microtask": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", diff --git a/package.json b/package.json index d8d2fcd..26ac2fc 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "@popperjs/core": "^2.11.6", "axios": "^1.2.1", "bulma": "^0.9.4", + "qr-code-styling": "^1.6.0-rc.1", "sass": "^1.56.2", "vue": "^3.2.45", "vue-contenteditable": "^4.1.0", diff --git a/src/components/ZonePricing.vue b/src/components/ZonePricing.vue index 27c417f..a568bdd 100644 --- a/src/components/ZonePricing.vue +++ b/src/components/ZonePricing.vue @@ -26,7 +26,7 @@ - {{ '*'.repeat(zone.length_1) + zone.zone }} + {{ '*'.repeat(zone.length_1) + '.' + zone.zone }} {{ zone.price_auction_1 }} @@ -35,7 +35,7 @@ - {{ '*'.repeat(zone.length_2) + zone.zone }} + {{ '*'.repeat(zone.length_2) + '.' + zone.zone }} {{ zone.price_auction_2 }} diff --git a/src/result.ts b/src/result.ts index 151b865..f251e05 100644 --- a/src/result.ts +++ b/src/result.ts @@ -28,6 +28,10 @@ export class Result { canBuy(): boolean { return this.buy_price !== undefined && this.buy_price !== null; } + + zone(): string { + return this.domain.split('.').slice(1).join('.'); + } } const sleep = (milliseconds: number) => { @@ -53,3 +57,28 @@ export async function get_domain_result(domain: string) { } return new Result(domain, 5, 3); } + +export class TonLink { + address: string; + sum?: number; + message: string; + + constructor(address: string, message: string, sum?: number) { + this.address = address; + this.sum = sum; + this.message = message; + } + + getLink(): string { + let link = `ton://${this.address}/transfer?message=${this.message}`; + if (this.sum !== undefined) { + link += `&amount=${this.sum}`; + } + return link; + } +} + +// Get the link for buying a domain +export function get_ton_link(res: Result) { + return new TonLink(res.zone(), res.buy_price!, 'b/' + res.domain); +} diff --git a/src/views/Checkout.vue b/src/views/Checkout.vue index 411e6f1..6ba5d9d 100644 --- a/src/views/Checkout.vue +++ b/src/views/Checkout.vue @@ -1,15 +1,22 @@ - \ No newline at end of file