From ea64b844856287783cdd3244a5ae2041d8bd1fe9 Mon Sep 17 00:00:00 2001 From: aptt Date: Wed, 18 Dec 2024 14:40:00 +0100 Subject: [PATCH] =?UTF-8?q?fix(frontend):=20=F0=9F=90=9B=20use=20swiss=20g?= =?UTF-8?q?rid=20coordinates?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/lib/certificate.ts | 4 +-- frontend/src/lib/hedera/getNfts.ts | 4 +-- .../mint/CertificateCreationForm.svelte | 34 ++++++++++--------- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/frontend/src/lib/certificate.ts b/frontend/src/lib/certificate.ts index a80a705..44017f1 100644 --- a/frontend/src/lib/certificate.ts +++ b/frontend/src/lib/certificate.ts @@ -1,6 +1,6 @@ export interface BidiCertificate { - latitude: number - longitude: number + swissGridE: number + swissGridN: number typeOfNaturalObject: string locationOwner: string operationsManager: string diff --git a/frontend/src/lib/hedera/getNfts.ts b/frontend/src/lib/hedera/getNfts.ts index 68111fd..265d01a 100644 --- a/frontend/src/lib/hedera/getNfts.ts +++ b/frontend/src/lib/hedera/getNfts.ts @@ -70,8 +70,8 @@ export const getNfts: GetNfts = async (options): Promise => { certificate: { dateOfWork: '1970-01-01', effectOnBiodiversity: '', - latitude: 0, - longitude: 0, + swissGridE: 0, + swissGridN: 0, locationOwner: '', operationsManager: '', typeOfNaturalObject: '', diff --git a/frontend/src/routes/dashboard/mint/CertificateCreationForm.svelte b/frontend/src/routes/dashboard/mint/CertificateCreationForm.svelte index c19bfa9..8b150d1 100644 --- a/frontend/src/routes/dashboard/mint/CertificateCreationForm.svelte +++ b/frontend/src/routes/dashboard/mint/CertificateCreationForm.svelte @@ -4,14 +4,18 @@ import Textarea from '$lib/components/Textarea.svelte' import { AccountId } from '@hashgraph/sdk' + const coordinatePattern = /\d{3}\s?\d{3}/ + let { onsubmit, }: { onsubmit: (options: { certificate: BidiCertificate; recipientAccountId: AccountId }) => void } = $props() - let latitudeString = $state('') - let longitudeString = $state('') + let swissGridEString = $state('') + const swissGridE = $derived(parseInt(swissGridEString.replace(/\s/g, ''))) + let swissGridNString = $state('') + const swissGridN = $derived(parseInt(swissGridNString.replace(/\s/g, ''))) let typeOfNaturalObject = $state('') let locationOwner = $state('') let operationsManager = $state('') @@ -26,19 +30,17 @@ event.preventDefault() // TODO: handle errors - const latitude = parseFloat(latitudeString) - if (isNaN(latitude)) { + if (isNaN(swissGridE)) { return } - const longitude = parseFloat(longitudeString) - if (isNaN(longitude)) { + if (isNaN(swissGridN)) { return } const certificate: BidiCertificate = { - latitude, - longitude, + swissGridE, + swissGridN, typeOfNaturalObject, locationOwner, operationsManager, @@ -60,19 +62,19 @@ Coordinates: