Skip to content

Commit 3dc7243

Browse files
committed
Registration done
1 parent d355260 commit 3dc7243

File tree

5 files changed

+51
-8
lines changed

5 files changed

+51
-8
lines changed

.env

Whitespace-only changes.

server/src/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ const express = require("express");
22
const slashes = require("connect-slashes");
33
const cors = require("cors");
44
const mongoose = require("mongoose");
5-
65
const { sendOTP, verifyOTP } = require("../apis/smsAPI");
76

8-
97
const PORT = process.argv[2] || process.env.PORT || 5000;
108
const CODE_LENGTH = process.env.CODE_LENGTH;
119

src/components/DashLeft/DashLeft.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const DashLeft = () => {
1313
const [usdVal, setUsdVal] = useState({});
1414
const dummyMatic = "3260.351432121505620812986766";
1515
var myHeaders = new Headers();
16-
myHeaders.append("X-CoinAPI-Key", "272E2537-42DC-4DE3-BB31-89072ACE051D");
16+
myHeaders.append("X-CoinAPI-Key", "647D5F57-3B4D-47C1-9DD1-96D18F069E07");
1717

1818
var requestOptions = {
1919
method: "GET",

src/pages/api/otpVerification.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const sendOTP = async phone => {
1212

1313
const response = await customAxios.post('/apis/sendOTP', {phone});
1414
// console.log(response);
15-
console.log(response.data.data.message);
15+
console.log(response.data.data);
1616

1717
if(response.status === 400 || response.status === 500)
1818
return false;

src/pages/registration.jsx

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ import React from "react";
66
import { useState } from "react";
77
// import { useMetamaskAuth, withConnectedRoute } from "../auth/authConfig";
88
import { JUST_LOGGED_IN } from "../constants/routes";
9+
import axios from "axios";
910
import AddImages from "./addImages";
10-
import { sendOTP, verifyOTP } from "./api/otpVerification";
11+
const API_URL = process.env.SERVER_URL || "";
1112

1213
// import { ToastContainer, toast } from "react-toastify";
1314
// import "react-toastify/dist/ReactToastify.css";
1415

15-
const invalidNumber = () => {toast("Enter a Valid No.")};
16+
const invalidNumber = () => {
17+
toast("Enter a Valid No.");
18+
};
1619

1720
// import { sendOTP, verifyOTP } from "../pages/api/otpVerification.js";
1821

@@ -21,18 +24,59 @@ const Registration = () => {
2124

2225
const router = useRouter();
2326
const [date, setDate] = useState(null);
27+
const [receivedOtp, setReceivedOtp] = useState("");
28+
// const [inputOtp, setInputOTP] = useState('');
29+
const [successVerify, setSuccessVerify] = useState("");
2430
const [otp, setOTP] = useState("");
2531
const [isDisabled, setIsDisabled] = useState(false);
2632
const [phone, setPhone] = useState("");
2733
const [isOtpVerified, setIsOtpVerified] = useState(false);
2834
const [correctOtp, setCorrectOtp] = useState(false);
2935

36+
const customAxios = axios.create({
37+
baseURL: API_URL,
38+
});
39+
40+
const sendOTP = async (phone) => {
41+
console.log("Hii");
42+
43+
const response = await customAxios.post("/apis/sendOTP", { phone });
44+
setReceivedOtp(response.data.data);
45+
console.log(response.data.data);
46+
47+
if (response.status === 400 || response.status === 500) return false;
48+
return true;
49+
};
50+
51+
const verifyOTP = async (phone, code) => {
52+
const response = await customAxios.post("/apis/verifyOTP", { phone, code });
53+
console.log(response.data.success);
54+
setSuccessVerify(response.data.success);
55+
console.log("Check")
56+
57+
// console.log (inputOtp === receivedOtp)
58+
if (response.status === 400 || response.data.success === false)
59+
return false;
60+
return true;
61+
};
62+
63+
if (typeof window !== "undefined") {
64+
window.sendOTP = sendOTP;
65+
window.verifyOTP = verifyOTP;
66+
}
67+
3068
const onClickOtp = () => {
3169
sendOTP(phone);
3270
};
3371

3472
const onCreateAccountHandler = (e) => {
3573
e.preventDefault();
74+
if (e.target.firstName.value.trim() === undefined || e.target.lastName.value.trim() === undefined){
75+
return;
76+
}
77+
else{
78+
console.log("SUCCESS LOGIN");
79+
}
3680
console.log(e.target.firstName.value);
3781
console.log(e.target.lastName.value);
3882

@@ -48,6 +92,7 @@ const Registration = () => {
4892

4993
const onClickVerify = () => {
5094
verifyOTP(phone, otp);
95+
// setInputOTP(otp);
5196
if (verifyOTP) {
5297
setCorrectOtp(true);
5398
}
@@ -165,9 +210,9 @@ const Registration = () => {
165210
<div className="flex flex-row mt-[40px] items-center font-medium">
166211
<button
167212
type="submit"
168-
disabled={!correctOtp}
213+
disabled={!successVerify}
169214
className={
170-
correctOtp
215+
successVerify
171216
? "bg-blue py-[8px] px-[24px] rounded-lg text-white"
172217
: "bg-gray-400 py-[8px] px-[24px] rounded-lg text-white"
173218
}

0 commit comments

Comments
 (0)