From a6255fabfc8d00636d59f2d8a9b76caadfb17962 Mon Sep 17 00:00:00 2001 From: mukilan2815 Date: Wed, 3 Jul 2024 18:58:35 +0530 Subject: [PATCH] upto csrf --- package-lock.json | 10 + package.json | 1 + src/App.js | 6 + src/Components/ATable.jsx | 9 - src/Components/BTable.jsx | 7 - src/Components/CTable.jsx | 7 - src/Pages/Admin/Allmembers.jsx | 3 +- src/Pages/Admin/Analysis.jsx | 2 +- src/Pages/Admin/Approvalpage.jsx | 96 ++ src/Pages/Admin/LoginAdmin.jsx | 25 +- src/Pages/Admin/Memberlist.jsx | 0 src/Pages/Admin/Navbar.jsx | 8 + .../Client/ExistingMember/Formexisting.jsx | 1070 +++++++++++++++++ src/Pages/Client/NewMember/Membershipform.jsx | 2 +- 14 files changed, 1210 insertions(+), 36 deletions(-) delete mode 100644 src/Components/ATable.jsx delete mode 100644 src/Components/BTable.jsx delete mode 100644 src/Components/CTable.jsx create mode 100644 src/Pages/Admin/Approvalpage.jsx delete mode 100644 src/Pages/Admin/Memberlist.jsx create mode 100644 src/Pages/Client/ExistingMember/Formexisting.jsx diff --git a/package-lock.json b/package-lock.json index f2e5678..5339c4c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,6 +24,7 @@ "clsx": "^2.1.1", "dayjs": "^1.11.11", "install": "^0.13.0", + "js-cookie": "^3.0.5", "mantine-react-table": "^1.3.4", "npm": "^10.8.1", "react": "^18.3.1", @@ -15001,6 +15002,15 @@ "jiti": "bin/jiti.js" } }, + "node_modules/js-cookie": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/js-cookie/-/js-cookie-3.0.5.tgz", + "integrity": "sha512-cEiJEAEoIbWfCZYKWhVwFuvPX1gETRYPw6LlaTKoxD3s2AkXzkCjnp6h0V77ozyqj0jakteJ4YqDJT830+lVGw==", + "license": "MIT", + "engines": { + "node": ">=14" + } + }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", diff --git a/package.json b/package.json index 763248d..dde71d3 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "clsx": "^2.1.1", "dayjs": "^1.11.11", "install": "^0.13.0", + "js-cookie": "^3.0.5", "mantine-react-table": "^1.3.4", "npm": "^10.8.1", "react": "^18.3.1", diff --git a/src/App.js b/src/App.js index bd10e63..08a1f9e 100644 --- a/src/App.js +++ b/src/App.js @@ -10,6 +10,8 @@ import Home from "./Pages/Admin/Home"; import Analysis from "./Pages/Admin/Analysis"; import LoginAdmin from "./Pages/Admin/LoginAdmin"; import Allmembers from "./Pages/Admin/Allmembers"; +import Formexisting from "./Pages/Client/ExistingMember/Formexisting"; +import Approvalpage from "./Pages/Admin/Approvalpage"; function App() { return ( @@ -30,6 +32,10 @@ function App() { } /> } /> } /> + } /> + + {/* {exiting user} */} + } /> diff --git a/src/Components/ATable.jsx b/src/Components/ATable.jsx deleted file mode 100644 index b161890..0000000 --- a/src/Components/ATable.jsx +++ /dev/null @@ -1,9 +0,0 @@ -import React from 'react' - -const ATable = () => { - return ( -
ATable
- ) -} - -export default ATable \ No newline at end of file diff --git a/src/Components/BTable.jsx b/src/Components/BTable.jsx deleted file mode 100644 index 30c3cd4..0000000 --- a/src/Components/BTable.jsx +++ /dev/null @@ -1,7 +0,0 @@ -import React from "react"; - -const BTable = () => { - return
BTable
; -}; - -export default BTable; diff --git a/src/Components/CTable.jsx b/src/Components/CTable.jsx deleted file mode 100644 index 1a6ae69..0000000 --- a/src/Components/CTable.jsx +++ /dev/null @@ -1,7 +0,0 @@ -import React from "react"; - -const CTable = () => { - return
CTable
; -}; - -export default CTable; diff --git a/src/Pages/Admin/Allmembers.jsx b/src/Pages/Admin/Allmembers.jsx index ca5ead5..ebd53fc 100644 --- a/src/Pages/Admin/Allmembers.jsx +++ b/src/Pages/Admin/Allmembers.jsx @@ -20,7 +20,7 @@ const Allmembers = () => { const fetchData = async () => { try { const response = await fetch( - "http://192.168.169.17:8000/membershipform/" + "http://192.168.169.82:8000/membershipform/" ); const jsonData = await response.json(); setData(jsonData); @@ -112,7 +112,6 @@ const Allmembers = () => { state: { globalFilter: "", }, - // Add other configurations as needed... }); return ( diff --git a/src/Pages/Admin/Analysis.jsx b/src/Pages/Admin/Analysis.jsx index ba085c2..2ca977e 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.17:8000/membershipform/") + .get("http://192.168.169.82: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 new file mode 100644 index 0000000..c09ef02 --- /dev/null +++ b/src/Pages/Admin/Approvalpage.jsx @@ -0,0 +1,96 @@ +import React, { useEffect, useState } from "react"; +import axios from "axios"; +import Cookies from "js-cookie"; + +const ApprovalPage = () => { + const [applications, setApplications] = useState([]); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + + useEffect(() => { + const fetchApplications = async () => { + try { + const csrfToken = Cookies.get("csrftoken") + // if (!csrfToken) { + // console.log("Retrying to fetch CSRF token..."); + // setTimeout(fetchApplications, 1000); + // return; + // } + console.log("CSRF Token:", csrfToken); + + const response = await axios.get( + "http://192.168.169.82:8000/approval/", + { + withCredentials: true, + headers: { + "X-CSRFToken": csrfToken, + }, + } + ); + setApplications(response.data); + } catch (error) { + console.error("Error fetching data:", error); + setError(error.message); + } finally { + setLoading(false); + } + }; + + fetchApplications(); + }, []); + + if (loading) { + return
Loading...
; + } + + if (error) { + return
Error: {error}
; + } + + return ( +
+

Approval Page

+
+ + + + + + + + + + + {applications.map((application, index) => ( + + + + + + + ))} + +
S.NoName of ApplicantStatus AdmittedAccept/Reject
{index + 1} + {application.NameofApplicant} + + {application.form_status} + + + +
+
+
+ ); +}; + +export default ApprovalPage; diff --git a/src/Pages/Admin/LoginAdmin.jsx b/src/Pages/Admin/LoginAdmin.jsx index 2bf0f3d..64bedb6 100644 --- a/src/Pages/Admin/LoginAdmin.jsx +++ b/src/Pages/Admin/LoginAdmin.jsx @@ -1,29 +1,36 @@ import React, { useState } from "react"; -import { Link, useNavigate } from "react-router-dom"; +import { useNavigate } from "react-router-dom"; import icci from "../../Assets/icci.jpg"; import axios from "axios"; const LoginAdmin = () => { const navigate = useNavigate(); const [error, setError] = useState(null); + const [loading, setLoading] = useState(false); const handleSubmit = async (e) => { e.preventDefault(); + setLoading(true); const formData = new FormData(e.target); const username = formData.get("username"); const password = formData.get("password"); try { - const response = await axios.post("http://192.168.169.17:8000/login/", { - username, - password, - }); - const token = response.data.token; - localStorage.setItem("token", token); + const response = await axios.post( + "http://192.168.169.82:8000/login/", + { username, password }, + { withCredentials: true } + ); - navigate("/admin"); + if (response.status === 200) { + navigate("/adminhome"); + } else { + setError("Invalid username or password"); + } } catch (error) { setError("Invalid username or password"); + } finally { + setLoading(false); } }; @@ -75,7 +82,7 @@ const LoginAdmin = () => { /> - + {error &&
{error}
}
diff --git a/src/Pages/Client/ExistingMember/Formexisting.jsx b/src/Pages/Client/ExistingMember/Formexisting.jsx new file mode 100644 index 0000000..7532fe8 --- /dev/null +++ b/src/Pages/Client/ExistingMember/Formexisting.jsx @@ -0,0 +1,1070 @@ +import React, { useState } from "react"; +import { useNavigate } from "react-router-dom"; +import Header from "../../../Assets/Formheader.png"; +import icci from "../../../Assets/Formheader.png"; +import axios from "axios"; + +const Formexisting = () => { + const navigate = useNavigate(); + const currentDate = new Date().toLocaleDateString(); + const currentYear = new Date().getFullYear(); + const [checkedItems, setCheckedItems] = useState({}); + const [files, setFiles] = useState({}); + const [image, setImage] = useState(null); + const [isMember, setIsMember] = useState(false); + const [isYesChecked, setIsYesChecked] = useState(false); + const [directors, setDirectors] = useState([]); + + const handleYesChange = (event) => { + setIsYesChecked(event.target.checked); + }; + + const [formData, setFormData] = useState({ + NameofApplicant: "John Doe", + constitution: "Individual", + profession1: "Software Developer", + YearofEstablishment: "2010", + Businessactivity: "Software Development and Consulting", + Registerofficeaddress: "1234 Software St, Tech City", + Addressforcommunication_office: "1234 Software St, Tech City", + Addressforcommunication_work: "5678 Development Ave, Tech Park", + Communicationdetails_landline: "123-456-7890", + Communicationdetails_mobile: "098-765-4321", + Communicationdetails_email: "contact@techcompany.com", + Communicationdetails_web: "https://www.techcompany.com", + Legalinfo_aadhar: "123456789101", + Legalinfo_pancard: "ABCDE1234F", + Legalinfo_GSTNo: "22AAAAA0000A1Z5", + Legalinfo_CompanyFirmRegNo: "C12345678901234", + Legalinfo_SocietyAssociationRegNo: "12345678901234", + Personauthorized_Name: "Jane Doe", + Personauthorized_Designation: "CTO", + personauthorized_pan: "BCDEA1234G", + personauthorized_aadhar: "432167890123", + personauthorized_phone: "098-765-4321", + personauthorized_email: "jane.doe@techcompany.com", + Maincategory: "IT and Software", + Subcategory: "Software Development", + Cateringtomarket: "Global", + Percentageofimports: "10%", + Percentageofexports: "50%", + Foreigncollaboration_country: "USA", + Foreigncollaboration_collaborator: "GlobalTech Inc", + Classificationofindustry: "Large", + Annualturnover_year1: "10", + Annualturnover_year2: "1200000", + Annualturnover_year3: "150", + Noofpersonsemployed_direct: "50", + Noofpersonsemployed_works: "200", + Noofpersonsemployed_indirect: "100", + Noofpersonsemployed_outsourced: "30", + ESIC: "Yes", + EPF: "Yes", + Detailsofbranches: "Tech City, Tech Park", + Memberofanyother: "Yes", + association_name: "Tech Industry Association", + is_office_bearer: "No", + association_position: "", + reason_for_joining_chamber: "Networking and Business Opportunities", + e_sign: null, + IncomeandExpenditure: null, + incometaxtpan: null, + FactoryRegistrationCertificate: null, + MemorandumArticleofAssociation: null, + GSTINRegistrationCopy: null, + IECodeCertificate: null, + ProfessionalCertificate: null, + CopyofLandDocument: null, + LandHolding: null, + passportsizephoto: null, + DirectorsPartners: null, + form_status: "pending", + Reasonforrejection: "", + }); + + const [legalInfo, setLegalInfo] = "Your legal information here."; + + const labels = [ + "Proprietary Firm", + "Partnership Firm LLP", + "Private Limited", + "Public Limited Unlisted", + "Public Limited Listed", + "Trust", + "Society", + "Associations", + ]; + + const [documentOptions, setDocOpt] = useState([ + { + name: "Income Tax PAN Number", + pName: "incometaxtpan", + checked: false, + }, + { + name: "Factory Registration Certificate", + pName: "FactoryRegistrationCertificate", + checked: false, + }, + { + name: "Memorandum & Article of Association", + pName: "MemorandumArticleofAssociation", + checked: false, + }, + { + name: "GSTIN Registration Copy (Compulsory)", + pName: "GSTINRegistrationCopy", + checked: false, + }, + { + name: "IE Code Certificate", + pName: "IECodeCertificate", + checked: false, + }, + { + name: "Professional Certificate", + pName: "ProfessionalCertificate", + checked: false, + }, + { + name: "Copy of Land Document", + pName: "CopyofLandDocument", + checked: false, + }, + { + name: "Copy of Land Holding (Patta)", + pName: "LandHolding", + checked: false, + }, + ]); + + const handleCheckboxChange = (e) => { + setDocOpt( + documentOptions.map((doc) => { + if (doc.name === e.target.name) { + console.log( + `${doc.name} is ${doc.checked ? "checked" : "unchecked"}` + ); + return { + ...doc, + checked: !doc.checked, + }; + } + return doc; + }) + ); + }; + + const handleFileChange = (event) => { + const { name, file: selectedFiles } = event.target; + const file = event.target.files[0]; + setFormData((prevState) => ({ + ...prevState, + [name]: file, + })); + }; + + const handleInputChange = (event) => { + const { name, type, checked, value } = event.target; + const inputValue = type === "checkbox" ? checked : value; + + setFormData((prevState) => ({ + ...prevState, + [name]: inputValue, + })); + }; + + const handleProfessionChange = (index, value) => { + const newProfession = [...formData.profession]; + newProfession[index] = value; + setFormData({ ...formData, profession: newProfession }); + }; + + const handleImageUpload = (event) => { + const file = event.target.files[0]; + if (file) { + const reader = new FileReader(); + reader.onloadend = () => { + setImage(reader.result); + }; + reader.readAsDataURL(file); + setFormData({ + ...formData, + e_sign: file, + }); + } + }; + + const handleConstitutionChange = (e) => { + const { name, checked } = e.target; + setFormData({ + ...formData, + constitution: { ...formData.constitution, [name]: checked }, + }); + }; + + const handleLegalInfoChange = (e) => { + const { name, value } = e.target; + setLegalInfo((prevState) => ({ + ...prevState, + [name]: value, + })); + }; + + const handleDirectorChange = (index, field, value) => { + const newDirectors = [...directors]; + newDirectors[index][field] = value; + setDirectors(newDirectors); + }; + + const handleSubmit = async (e) => { + try { + e.preventDefault(); + + const response = await axios.post( + "http://192.168.169.82:8000/membershipform/", + formData, + { + headers: { + "Content-Type": "multipart/form-data", + }, + } + ); + console.log(response); + navigate("/adminhome"); + } catch (error) { + console.log(error); + } + }; + + return ( +
+
+
+ Header +
+
+
+
+
Date:
+ +
+ +
+
+ 1. Name of Applicant: +
+ +
+ +
+
+ +
+ Individual + +
+
+ {formData.constitution.individual && ( +
+ + {[0, 1, 2].map((index) => ( +
+ {index + 1} + + handleProfessionChange(index, e.target.value) + } + className="border rounded border-black flex-grow" + /> +
+ ))} +
+ )} + {labels.map((label, index) => ( +
+ + +
+ ))} +
+ +
+
+ 3. Year of Establishment: +
+ +
+ +
+
+
+ 4. Business Activity: +
+ +
+
+
+ 5. Registered Office Address: +
+ +
+
+
+ 6. Address for Communication - Office: +
+ +
+
+
+ Works/Factory: +
+ +
+
+ +
+
+
7. Communication Details
+
+
+
+
Phone Landline:
+ +
+
+
Phone Mobile:
+ +
+
+
Email ID:
+ +
+
+
Website:
+ +
+
+
+
+ +
+

8. Legal Information:

+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +

+ 9. List of Directors/ Partners/ Office Bearers/ Trustees: +

+ + + + + + + + + + + {directors.map((director, index) => ( + + + + + + + ))} + +
Sl. NoName of the PersonDesignationPAN
{index + 1}. + + handleDirectorChange(index, "name", e.target.value) + } + className="w-full border-b-2 outline-none border-blue-700 border-dotted rounded py-1" + /> + + + handleDirectorChange( + index, + "designation", + e.target.value + ) + } + className="w-full border-b-2 outline-none border-blue-700 border-dotted rounded py-1" + /> + + + handleDirectorChange(index, "pan", e.target.value) + } + className="w-full border-b-2 outline-none border-blue-700 border-dotted rounded py-1" + /> +
+
+
+
+
10. Details of the Person Authorized:
+
+
+
+
Name:
+ +
+
+
Designation:
+ +
+
+
PAN:
+ +
+
+
Aadhaar:
+ +
+
+
Phone:
+ +
+
+
Mail Id:
+ +
+
+
+ +
+
+
11. Category of Industry/Trade/Services:
+
+
+
+
Main Category:
+ +
+
+
Sub Category:
+ +
+
+
+ +
+
+
12. Catering to Market:
+
+
+
+
Domestic:
+ +
+
+
Global:
+ +
+
+
Both:
+ +
+ +
+
% of Exports:
+ +
+
+
% of Imports:
+ +
+
+ +
+
13. Foreign Collaboration if any:
+
+
+
+
Name of the Country:
+ +
+
+
+ Name of the Collaborator / Joint Venture: +
+ +
+
+ +
+
14. Classification of Industry:
+
+
+
+
Large:
+ +
+
+
Medium:
+ +
+
+
Small:
+ +
+
+
Micro:
+ +
+
+
+ +
+
+ 15. Annul Turnover for the last three years (Rs in million): +
+
+
+
1st Year
+ +
+
+
2nd Year
+ +
+
+
3rd Year
+ +
+
+
+ +
+
+
+ 16. No of Persons Employed: +
+
+
+
Direct - Office:
+ +
+
+
Works:
+ +
+
+
+ Indirect - Contractual: +
+ +
+
+
Outsourced:
+ +
+
+
+ +
+
17. Welfare Obligations:
+
+
+
ESIC:
+ +
+
+
EPF:
+ +
+
+
+ +
+
+ 18. Details of branches / Outlet outside India: +
+ +
+ +
+
+ 19. Are you member of any other Association : +
+
+
+ + +
+
+ setIsMember(false)} + /> + +
+
+ {isMember && ( +
+
+ If yes, mention details: +
+ +
+ )} +
+ +
+
+
+ 20. Do you hold any Office Bearers position in any Association +
+
+
+ + +
+
+ + +
+
+
+
+ {isYesChecked && ( +
+
+ If yes - mention the Association Name & position: +
+ +
+ )} +
+
+ +
+
21. Reason for Joining Chamber :
+ +
+
+ {image && ( + Uploaded + )} + +
+ Signature of Authorized person with seal +
+
+
+ + + +
+ +
+ {documentOptions.map((item, index) => ( + + ))} +
+
+ + {documentOptions.map( + (item, index) => + item.checked && ( +
+ + +
+ ) + )} + +
+ + +
+ +
+ + +
+ + +
+
+
+
+ ); +}; + +export default Formexisting; diff --git a/src/Pages/Client/NewMember/Membershipform.jsx b/src/Pages/Client/NewMember/Membershipform.jsx index bae1425..66dcac7 100644 --- a/src/Pages/Client/NewMember/Membershipform.jsx +++ b/src/Pages/Client/NewMember/Membershipform.jsx @@ -222,7 +222,7 @@ const Membershipform = () => { e.preventDefault(); const response = await axios.post( - "http://192.168.169.17:8000/membershipform/", + "http://192.168.169.82:8000/membershipform/", formData, { headers: {