diff --git a/signer-service/src/api/controllers/email.controller.js b/signer-service/src/api/controllers/email.controller.js
index 45f9f7a6..3d0dd6d6 100644
--- a/signer-service/src/api/controllers/email.controller.js
+++ b/signer-service/src/api/controllers/email.controller.js
@@ -4,7 +4,8 @@ const { storeDataInGoogleSpreadsheet } = require('./googleSpreadsheet.controller
// These are the headers for the Google Spreadsheet
const EMAIL_SHEET_HEADER_VALUES = [
'timestamp',
- 'email'
+ 'email',
+ 'transactionId'
];
exports.EMAIL_SHEET_HEADER_VALUES = EMAIL_SHEET_HEADER_VALUES;
diff --git a/src/components/EmailForm/index.tsx b/src/components/EmailForm/index.tsx
index 1bedf5b5..06c6a4d9 100644
--- a/src/components/EmailForm/index.tsx
+++ b/src/components/EmailForm/index.tsx
@@ -1,9 +1,13 @@
import { useMutation } from '@tanstack/react-query';
import { useForm } from 'react-hook-form';
-import { storeUserEmailInBackend } from '../../services/storage/storeUserEmailInBackend';
+import { storeUserEmailInBackend } from '../../services/storage/remote';
import { TextInput } from '../../components/TextInput';
-export const EmailForm = () => {
+interface EmailFormProps {
+ transactionId?: string;
+}
+
+export const EmailForm = ({ transactionId }: EmailFormProps) => {
const { register, handleSubmit } = useForm();
const {
@@ -16,7 +20,12 @@ export const EmailForm = () => {
});
const onSubmit = handleSubmit((data) => {
- saveUserEmailMutation({ email: data.email });
+ if (!transactionId) {
+ console.error('Transaction ID is missing');
+ return;
+ }
+
+ saveUserEmailMutation({ email: data.email, transactionId });
});
const FormButtonSection = () => {
diff --git a/src/pages/failure/index.tsx b/src/pages/failure/index.tsx
index 0c6bc266..4eb07043 100644
--- a/src/pages/failure/index.tsx
+++ b/src/pages/failure/index.tsx
@@ -30,7 +30,7 @@ export const FailurePage = ({ finishOfframping, transactionId }: FailurePageProp
If you continue to experience issues, contact support on:
-
+
diff --git a/src/pages/success/index.tsx b/src/pages/success/index.tsx
index e1d9298b..ba761923 100644
--- a/src/pages/success/index.tsx
+++ b/src/pages/success/index.tsx
@@ -29,7 +29,7 @@ export const SuccessPage = ({ finishOfframping, transactionId }: SuccessPageProp
If your transaction is not completed after 60 minutes please contact support on:
-
+
diff --git a/src/services/storage/remote.ts b/src/services/storage/remote.ts
index 7150daf1..4aa7aecb 100644
--- a/src/services/storage/remote.ts
+++ b/src/services/storage/remote.ts
@@ -1,7 +1,7 @@
import { SIGNING_SERVICE_URL } from '../../constants/constants';
// These are the headers for the Google Spreadsheet
-type Data = {
+interface DumpData {
timestamp: string;
polygonAddress: string;
stellarEphemeralPublicKey: string;
@@ -11,10 +11,15 @@ type Data = {
spacewalkRedeemTx: string;
stellarOfframpTx: string;
stellarCleanupTx: string;
-};
+}
+
+interface EmailData {
+ email: string;
+ transactionId: string;
+}
-export async function storeDataInBackend(data: Data) {
- const response = await fetch(`${SIGNING_SERVICE_URL}/v1/storage/create`, {
+async function sendRequestToBackend(endpoint: string, data: EmailData | DumpData) {
+ const response = await fetch(endpoint, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
@@ -23,6 +28,19 @@ export async function storeDataInBackend(data: Data) {
});
if (!response.ok) {
- throw new Error(`Error while sending data to storage endpoint`);
+ throw new Error(`Error while sending data to ${endpoint}`);
}
+
+ return await response.json();
+}
+
+export async function storeDataInBackend(data: DumpData) {
+ const endpoint = `${SIGNING_SERVICE_URL}/v1/storage/create`;
+ return await sendRequestToBackend(endpoint, data);
+}
+
+export async function storeUserEmailInBackend(data: EmailData) {
+ const endpoint = `${SIGNING_SERVICE_URL}/v1/email/create`;
+ const payload = { ...data, timestamp: new Date().toISOString() };
+ return await sendRequestToBackend(endpoint, payload);
}
diff --git a/src/services/storage/storeUserEmailInBackend.ts b/src/services/storage/storeUserEmailInBackend.ts
deleted file mode 100644
index bc46e18e..00000000
--- a/src/services/storage/storeUserEmailInBackend.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import { SIGNING_SERVICE_URL } from '../../constants/constants';
-
-// These are the headers for the Google Spreadsheet
-type Data = {
- email: string;
-};
-
-export async function storeUserEmailInBackend(data: Data) {
- const response = await fetch(`${SIGNING_SERVICE_URL}/v1/email/create`, {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify({ ...data, timestamp: new Date().toISOString() }),
- });
-
- if (!response.ok) {
- throw new Error(`Error while sending data to email endpoint`);
- }
-
- return await response.json();
-}