From 98bc97ea118e07f13c31c709800861dc92c7b7c0 Mon Sep 17 00:00:00 2001 From: mukilan2815 Date: Mon, 22 Jul 2024 15:51:48 +0530 Subject: [PATCH] chore: Update API endpoints to use new server IP address --- src/Pages/Admin/Allmembers.jsx | 2 +- src/Pages/Admin/Analysis.jsx | 2 +- src/Pages/Admin/Approvalpage.jsx | 8 +++-- src/Pages/Admin/Home.jsx | 16 +++++++--- src/Pages/Admin/LoginAdmin.jsx | 2 +- .../Client/ExistingMember/Formexisting.jsx | 22 ++++++++++---- src/Pages/Client/ExistingMember/Login.jsx | 30 +++++++++++++++++-- src/Pages/Client/NewMember/Membershipform.jsx | 5 +--- src/Pages/Client/NewMember/Payment.jsx | 2 -- 9 files changed, 66 insertions(+), 23 deletions(-) diff --git a/src/Pages/Admin/Allmembers.jsx b/src/Pages/Admin/Allmembers.jsx index 34420a1..48dc90e 100644 --- a/src/Pages/Admin/Allmembers.jsx +++ b/src/Pages/Admin/Allmembers.jsx @@ -22,7 +22,7 @@ const Allmembers = () => { try { const response = await fetch( - "http://192.168.169.77:8000/membershipform/", + "http://192.168.12.72:8000/membershipform/", { headers: { Authorization: token, diff --git a/src/Pages/Admin/Analysis.jsx b/src/Pages/Admin/Analysis.jsx index 5b3383c..54176aa 100644 --- a/src/Pages/Admin/Analysis.jsx +++ b/src/Pages/Admin/Analysis.jsx @@ -33,7 +33,7 @@ const Dashboard = () => { useEffect(() => { axios - .get("http://192.168.169.77:8000/membershipform/") + .get("http://192.168.12.72:8000/membershipform/") .then((response) => { console.log("API response:", response.data); // Debugging log setFormData(response.data); diff --git a/src/Pages/Admin/Approvalpage.jsx b/src/Pages/Admin/Approvalpage.jsx index 20c6051..eb8f245 100644 --- a/src/Pages/Admin/Approvalpage.jsx +++ b/src/Pages/Admin/Approvalpage.jsx @@ -14,7 +14,7 @@ const ApprovalPage = () => { setLoading(true); try { const token = localStorage.getItem("token"); - const response = await axios.get("http://192.168.169.77:8000/approval/", { + const response = await axios.get("http://192.168.12.72:8000/approval/", { headers: { Authorization: `Token ${token}`, }, @@ -24,6 +24,8 @@ const ApprovalPage = () => { setPendingApplications(response.data.pending); setRejectedApplications(response.data.rejected); setApprovedApplications(response.data.approved); + + console.log("Rejected Applications:", response.data.rejected); // Add this line to verify rejected applications } catch (error) { console.error("Error fetching data:", error); setError(error.message); @@ -40,7 +42,7 @@ const ApprovalPage = () => { try { const token = localStorage.getItem("token"); await axios.post( - "http://192.168.169.77:8000/approval/", + "http://192.168.12.72:8000/approval/", { fid, status: "accepted" }, { headers: { @@ -60,7 +62,7 @@ const ApprovalPage = () => { try { const token = localStorage.getItem("token"); await axios.post( - "http://192.168.169.77:8000/approval/", + "http://192.168.12.72:8000/approval/", { fid, reason }, { headers: { diff --git a/src/Pages/Admin/Home.jsx b/src/Pages/Admin/Home.jsx index 22dc41b..09b8782 100644 --- a/src/Pages/Admin/Home.jsx +++ b/src/Pages/Admin/Home.jsx @@ -1,10 +1,18 @@ -import React from "react"; +import React, { useEffect } from "react"; import { useNavigate } from "react-router-dom"; import "../../index.css"; import Navbar from "./Navbar"; + function Home() { const navigate = useNavigate(); + useEffect(() => { + const token = localStorage.getItem("token"); // Adjust the key name as necessary + if (!token) { + navigate("/adminlogin"); + } + }, [navigate]); + const handleMembership = () => { navigate("/membership"); }; @@ -12,14 +20,14 @@ function Home() { return (
-
-
+
+

The Indian Chamber of Commerce and Industry
- Branding coimbatore is our business + Branding Coimbatore is our business .

diff --git a/src/Pages/Admin/LoginAdmin.jsx b/src/Pages/Admin/LoginAdmin.jsx index b57abea..0347aaf 100644 --- a/src/Pages/Admin/LoginAdmin.jsx +++ b/src/Pages/Admin/LoginAdmin.jsx @@ -16,7 +16,7 @@ const LoginAdmin = () => { const password = formData.get("password"); try { - const response = await axios.post("http://192.168.169.77:8000/login/", { + const response = await axios.post("http://192.168.12.72:8000/login/", { username, password, }); diff --git a/src/Pages/Client/ExistingMember/Formexisting.jsx b/src/Pages/Client/ExistingMember/Formexisting.jsx index e0d150c..00ea754 100644 --- a/src/Pages/Client/ExistingMember/Formexisting.jsx +++ b/src/Pages/Client/ExistingMember/Formexisting.jsx @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React, { useState, useEffect } from "react"; import { useNavigate } from "react-router-dom"; import Header from "../../../Assets/Formheader.png"; import icci from "../../../Assets/Formheader.png"; @@ -83,6 +83,16 @@ const Formexisting = () => { }); const [legalInfo, setLegalInfo] = "Your legal information here."; + useEffect(() => { + const storedData = localStorage.getItem("formData"); + if (storedData) { + const parsedData = JSON.parse(storedData); + setFormData((prevState) => ({ + ...prevState, + ...parsedData, + })); + } + }, []); const labels = [ "Proprietary Firm", @@ -94,7 +104,9 @@ const Formexisting = () => { "Society", "Associations", ]; - + useEffect(() => { + localStorage.setItem("formData", JSON.stringify(formData)); + }, [formData]); const [documentOptions, setDocOpt] = useState([ { name: "Income Tax PAN Number", @@ -221,8 +233,8 @@ const Formexisting = () => { try { e.preventDefault(); - const response = await axios.post( - "http://192.168.169.77:8000/membershipform/", + const response = await axios.put( + "http://192.168.12.72:8000/existinglogin/", formData, { headers: { @@ -262,7 +274,7 @@ const Formexisting = () => { diff --git a/src/Pages/Client/ExistingMember/Login.jsx b/src/Pages/Client/ExistingMember/Login.jsx index 0ca0cbb..510d288 100644 --- a/src/Pages/Client/ExistingMember/Login.jsx +++ b/src/Pages/Client/ExistingMember/Login.jsx @@ -1,12 +1,35 @@ -import React from "react"; +import React, { useState } from "react"; import icci from "../../../Assets/icci.jpg"; +import axios from "axios"; +import { useNavigate } from "react-router-dom"; const Login = () => { + const navigate = useNavigate(); + const [email, setemail] = useState(); + const [aadhar, setaadhar] = useState(); + const [error, setError] = useState(); + const handleSubmit = async (e) => { + e.preventDefault(); + try { + const response = await axios.post( + "http://192.168.12.72:8000/existinglogin/", + { + email, + aadhar, + } + ); + console.log(response.data); + localStorage.setItem("Data", JSON.stringify(response.data)); + navigate("/formexisting"); + } catch (error) { + setError("Invalid username or password"); + } + }; return (
Chamber -

+

Log in to your account

@@ -27,6 +50,7 @@ const Login = () => { type="email" autocomplete="email" required + onChange={(e) => setemail(e.target.value)} className="block px-3 w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6" />
@@ -46,6 +70,7 @@ const Login = () => { type="aadhar" autocomplete="aadhar" required + onChange={(e) => setaadhar(e.target.value)} className="block px-3 w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6" />
@@ -54,6 +79,7 @@ const Login = () => {