aboutsummaryrefslogtreecommitdiffstats
path: root/src/services
diff options
context:
space:
mode:
authorLibravatarLibravatar Biswakalyan Bhuyan <biswa@surgot.in> 2024-10-16 16:18:13 +0530
committerLibravatarLibravatar Biswakalyan Bhuyan <biswa@surgot.in> 2024-10-16 16:18:13 +0530
commit48400b7a4a15b1794f6b473a6a985fe937f23709 (patch)
tree7b00277d5f9b3f6911904129b8eb49685e4c92f1 /src/services
parent9b82cab815d31fb57d5a337debb59e3458af1f0b (diff)
downloadmall-app-48400b7a4a15b1794f6b473a6a985fe937f23709.tar.gz
mall-app-48400b7a4a15b1794f6b473a6a985fe937f23709.tar.bz2
mall-app-48400b7a4a15b1794f6b473a6a985fe937f23709.zip
Add emailService for OTP handling and invoice emailing
Diffstat (limited to 'src/services')
-rw-r--r--src/services/emailService.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/services/emailService.js b/src/services/emailService.js
new file mode 100644
index 0000000..af1bbd9
--- /dev/null
+++ b/src/services/emailService.js
@@ -0,0 +1,26 @@
+import axios from 'axios';
+
+const API_URL = 'https://yourapi.com/api/email';
+
+const generateOtp = () => Math.floor(100000 + Math.random() * 900000);
+
+export const sendOtp = async (email) => {
+ const otp = generateOtp();
+ await axios.post(`${API_URL}/send-otp`, { email, otp });
+ localStorage.setItem('otp', otp);
+};
+
+export const verifyOtp = (enteredOtp) => {
+ const savedOtp = localStorage.getItem('otp');
+ return enteredOtp === savedOtp;
+};
+
+export const sendInvoice = async (cart) => {
+ await axios.post(`${API_URL}/send-invoice`, { cart });
+};
+
+export default {
+ sendOtp,
+ verifyOtp,
+ sendInvoice,
+};