diff --git a/package-lock.json b/package-lock.json index df0e41d..9bbec9f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,12 +16,16 @@ "@testing-library/jest-dom": "^5.17.0", "@testing-library/user-event": "^13.5.0", "axios": "^1.7.2", + "chart.js": "^4.4.3", "class-variance-authority": "^0.7.0", "clsx": "^2.1.1", "faker": "^6.6.6", "install": "^0.13.0", "npm": "^10.8.1", "react": "^18.3.1", + "react-bootstrap": "^2.10.3", + "react-chartjs-2": "^5.2.0", + "react-chatbot-kit": "^2.2.2", "react-dom": "^18.3.1", "react-router-dom": "^6.23.1", "react-scripts": "5.0.1", @@ -3984,6 +3988,12 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@kurkle/color": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@kurkle/color/-/color-0.3.2.tgz", + "integrity": "sha512-fuscdXJ9G1qb7W8VdHi+IwRqij3lBkosAm4ydQtEmbY58OzHXqQhvlxqEkoz0yssNVn38bcpRWgA9PP+OGoisw==", + "license": "MIT" + }, "node_modules/@leichtgewicht/ip-codec": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/@leichtgewicht/ip-codec/-/ip-codec-2.0.5.tgz", @@ -4114,6 +4124,31 @@ } } }, + "node_modules/@popperjs/core": { + "version": "2.11.8", + "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.8.tgz", + "integrity": "sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/popperjs" + } + }, + "node_modules/@react-aria/ssr": { + "version": "3.9.4", + "resolved": "https://registry.npmjs.org/@react-aria/ssr/-/ssr-3.9.4.tgz", + "integrity": "sha512-4jmAigVq409qcJvQyuorsmBR4+9r3+JEC60wC+Y0MZV0HCtTmm8D9guYXlJMdx0SSkgj0hHAyFm/HvPNFofCoQ==", + "license": "Apache-2.0", + "dependencies": { + "@swc/helpers": "^0.5.0" + }, + "engines": { + "node": ">= 12" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0" + } + }, "node_modules/@remix-run/router": { "version": "1.16.1", "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.16.1.tgz", @@ -4123,6 +4158,48 @@ "node": ">=14.0.0" } }, + "node_modules/@restart/hooks": { + "version": "0.4.16", + "resolved": "https://registry.npmjs.org/@restart/hooks/-/hooks-0.4.16.tgz", + "integrity": "sha512-f7aCv7c+nU/3mF7NWLtVVr0Ra80RqsO89hO72r+Y/nvQr5+q0UFGkocElTH6MJApvReVh6JHUFYn2cw1WdHF3w==", + "license": "MIT", + "dependencies": { + "dequal": "^2.0.3" + }, + "peerDependencies": { + "react": ">=16.8.0" + } + }, + "node_modules/@restart/ui": { + "version": "1.6.9", + "resolved": "https://registry.npmjs.org/@restart/ui/-/ui-1.6.9.tgz", + "integrity": "sha512-mUbygUsJcRurjZCt1f77gg4DpheD1D+Sc7J3JjAkysUj7t8m4EBJVOqWC9788Qtbc69cJ+HlJc6jBguKwS8Mcw==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.21.0", + "@popperjs/core": "^2.11.6", + "@react-aria/ssr": "^3.5.0", + "@restart/hooks": "^0.4.9", + "@types/warning": "^3.0.0", + "dequal": "^2.0.3", + "dom-helpers": "^5.2.0", + "uncontrollable": "^8.0.1", + "warning": "^4.0.3" + }, + "peerDependencies": { + "react": ">=16.14.0", + "react-dom": ">=16.14.0" + } + }, + "node_modules/@restart/ui/node_modules/uncontrollable": { + "version": "8.0.4", + "resolved": "https://registry.npmjs.org/uncontrollable/-/uncontrollable-8.0.4.tgz", + "integrity": "sha512-ulRWYWHvscPFc0QQXvyJjY6LIXU56f0h8pQFvhxiKk5V1fcI8gp9Ht9leVAhrVjzqMw0BgjspBINx9r6oyJUvQ==", + "license": "MIT", + "peerDependencies": { + "react": ">=16.14.0" + } + }, "node_modules/@rollup/plugin-babel": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/@rollup/plugin-babel/-/plugin-babel-5.3.1.tgz", @@ -4465,6 +4542,15 @@ "url": "https://github.com/sponsors/gregberge" } }, + "node_modules/@swc/helpers": { + "version": "0.5.11", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.11.tgz", + "integrity": "sha512-YNlnKRWF2sVojTpIyzwou9XoTNbzbzONwRhOoniEioF1AtaitTvVZblaQRrAzChWQ1bLYyYSWzM18y4WwgzJ+A==", + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.4.0" + } + }, "node_modules/@testing-library/dom": { "version": "10.1.0", "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-10.1.0.tgz", @@ -4996,10 +5082,7 @@ "version": "15.7.12", "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.12.tgz", "integrity": "sha512-5zvhXYtRNRluoE/jAp4GVsSduVUzNWKkOZrCDBWYtE7biZywwdC2AcEzg+cSMLFRfVgeAFqpfNabiPjxFddV1Q==", - "dev": true, - "license": "MIT", - "optional": true, - "peer": true + "license": "MIT" }, "node_modules/@types/q": { "version": "1.5.8", @@ -5023,10 +5106,7 @@ "version": "18.3.3", "resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.3.tgz", "integrity": "sha512-hti/R0pS0q1/xx+TsI73XIqk26eBsISZ2R0wUijXIngRK9R/e7Xw/cXVxQK7R5JjW+SV4zGcn5hXjudkN/pLIw==", - "dev": true, "license": "MIT", - "optional": true, - "peer": true, "dependencies": { "@types/prop-types": "*", "csstype": "^3.0.2" @@ -5044,6 +5124,15 @@ "@types/react": "*" } }, + "node_modules/@types/react-transition-group": { + "version": "4.4.10", + "resolved": "https://registry.npmjs.org/@types/react-transition-group/-/react-transition-group-4.4.10.tgz", + "integrity": "sha512-hT/+s0VQs2ojCX823m60m5f0sL5idt9SO6Tj6Dg+rdphGPIeJbJ6CxvBYkgkGKrYeDjvIpKTR38UzmtHJOGW3Q==", + "license": "MIT", + "dependencies": { + "@types/react": "*" + } + }, "node_modules/@types/resolve": { "version": "1.17.1", "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz", @@ -5131,6 +5220,12 @@ "integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==", "license": "MIT" }, + "node_modules/@types/warning": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/warning/-/warning-3.0.3.tgz", + "integrity": "sha512-D1XC7WK8K+zZEveUPY+cf4+kgauk8N4eHr/XIHXGlGYkHLud6hK9lYfZk1ry1TNh798cZUCgb6MqGEG8DkJt6Q==", + "license": "MIT" + }, "node_modules/@types/ws": { "version": "8.5.10", "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.10.tgz", @@ -6816,6 +6911,18 @@ "node": ">=10" } }, + "node_modules/chart.js": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-4.4.3.tgz", + "integrity": "sha512-qK1gkGSRYcJzqrrzdR6a+I0vQ4/R+SoODXyAjscQ/4mzuNzySaMCd+hyVxitSY1+L2fjPD1Gbn+ibNqRmwQeLw==", + "license": "MIT", + "dependencies": { + "@kurkle/color": "^0.3.0" + }, + "engines": { + "pnpm": ">=8" + } + }, "node_modules/check-types": { "version": "11.2.3", "resolved": "https://registry.npmjs.org/check-types/-/check-types-11.2.3.tgz", @@ -6909,6 +7016,12 @@ "node": ">=6" } }, + "node_modules/classnames": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/classnames/-/classnames-2.5.1.tgz", + "integrity": "sha512-saHYOzhIQs6wy2sVxTM6bUDsQO4F50V9RQ22qBpEdCW+I+/Wmke2HOl6lS6dTpdxVhb88/I6+Hs+438c3lfUow==", + "license": "MIT" + }, "node_modules/clean-css": { "version": "5.3.3", "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-5.3.3.tgz", @@ -7964,6 +8077,16 @@ "utila": "~0.4" } }, + "node_modules/dom-helpers": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/dom-helpers/-/dom-helpers-5.2.1.tgz", + "integrity": "sha512-nRCa7CK3VTrM2NmGkIy4cbK7IZlgBE/PYMn55rrXefr5xXDP0LdtfPnblFDoVdcAfslJ7or6iqAUnx0CCGIWQA==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.8.7", + "csstype": "^3.0.2" + } + }, "node_modules/dom-serializer": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.4.1.tgz", @@ -10782,6 +10905,15 @@ "node": ">= 0.4" } }, + "node_modules/invariant": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz", + "integrity": "sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==", + "license": "MIT", + "dependencies": { + "loose-envify": "^1.0.0" + } + }, "node_modules/ipaddr.js": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-2.2.0.tgz", @@ -19085,6 +19217,25 @@ "react-is": "^16.13.1" } }, + "node_modules/prop-types-extra": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/prop-types-extra/-/prop-types-extra-1.1.1.tgz", + "integrity": "sha512-59+AHNnHYCdiC+vMwY52WmvP5dM3QLeoumYuEyceQDi9aEhtwN9zIQ2ZNo25sMyXnbh32h+P1ezDsUpUH3JAew==", + "license": "MIT", + "dependencies": { + "react-is": "^16.3.2", + "warning": "^4.0.0" + }, + "peerDependencies": { + "react": ">=0.14.0" + } + }, + "node_modules/prop-types-extra/node_modules/react-is": { + "version": "16.13.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", + "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", + "license": "MIT" + }, "node_modules/prop-types/node_modules/react-is": { "version": "16.13.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", @@ -19284,6 +19435,61 @@ "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==", "license": "MIT" }, + "node_modules/react-bootstrap": { + "version": "2.10.3", + "resolved": "https://registry.npmjs.org/react-bootstrap/-/react-bootstrap-2.10.3.tgz", + "integrity": "sha512-cc1KAaQyj6Gr3AfA0eRRiUMSlRi3brDVcjc/o0E9y9XNW7ISo8TITrq8G8G3QTFe7VIhCiDt38k99AEFoLOolw==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.24.7", + "@restart/hooks": "^0.4.9", + "@restart/ui": "^1.6.9", + "@types/react-transition-group": "^4.4.6", + "classnames": "^2.3.2", + "dom-helpers": "^5.2.1", + "invariant": "^2.2.4", + "prop-types": "^15.8.1", + "prop-types-extra": "^1.1.0", + "react-transition-group": "^4.4.5", + "uncontrollable": "^7.2.1", + "warning": "^4.0.3" + }, + "peerDependencies": { + "@types/react": ">=16.14.8", + "react": ">=16.14.0", + "react-dom": ">=16.14.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/react-chartjs-2": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/react-chartjs-2/-/react-chartjs-2-5.2.0.tgz", + "integrity": "sha512-98iN5aguJyVSxp5U3CblRLH67J8gkfyGNbiK3c+l1QI/G4irHMPQw44aEPmjVag+YKTyQ260NcF82GTQ3bdscA==", + "license": "MIT", + "peerDependencies": { + "chart.js": "^4.1.1", + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, + "node_modules/react-chatbot-kit": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/react-chatbot-kit/-/react-chatbot-kit-2.2.2.tgz", + "integrity": "sha512-8p/i0KkzkhoyG2XsL6Pb6f72k9j7GYNAc5SOa4f9OZwbCD3Q34uEruNPc06qa1wZHKfT6aFna19PA2plFuO2NA==", + "license": "MIT", + "dependencies": { + "react-conditionally-render": "^1.0.2" + } + }, + "node_modules/react-conditionally-render": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/react-conditionally-render/-/react-conditionally-render-1.0.2.tgz", + "integrity": "sha512-CtjIgaLHVDSgHis3gv/PT/8EnD6GPUL8PrhUjh7DP6S5Y3p56dGu7y2nVg6pYv1kv+fGznRhRmX3assr/vRw3A==", + "license": "ISC" + }, "node_modules/react-dev-utils": { "version": "12.0.1", "resolved": "https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-12.0.1.tgz", @@ -19496,6 +19702,12 @@ "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==", "license": "MIT" }, + "node_modules/react-lifecycles-compat": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz", + "integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA==", + "license": "MIT" + }, "node_modules/react-refresh": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.11.0.tgz", @@ -19610,6 +19822,22 @@ } } }, + "node_modules/react-transition-group": { + "version": "4.4.5", + "resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.5.tgz", + "integrity": "sha512-pZcd1MCJoiKiBR2NRxeCRg13uCXbydPnmB4EOeRrY7480qNWO8IIgQG6zlDkm6uRMsURXPuKq0GWtiM59a5Q6g==", + "license": "BSD-3-Clause", + "dependencies": { + "@babel/runtime": "^7.5.5", + "dom-helpers": "^5.0.1", + "loose-envify": "^1.4.0", + "prop-types": "^15.6.2" + }, + "peerDependencies": { + "react": ">=16.6.0", + "react-dom": ">=16.6.0" + } + }, "node_modules/read-cache": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz", @@ -21913,6 +22141,21 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/uncontrollable": { + "version": "7.2.1", + "resolved": "https://registry.npmjs.org/uncontrollable/-/uncontrollable-7.2.1.tgz", + "integrity": "sha512-svtcfoTADIB0nT9nltgjujTi7BzVmwjZClOmskKu/E8FW9BXzg9os8OLr4f8Dlnk0rYWJIWr4wv9eKUXiQvQwQ==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.6.3", + "@types/react": ">=16.9.11", + "invariant": "^2.2.4", + "react-lifecycles-compat": "^3.0.4" + }, + "peerDependencies": { + "react": ">=15.0.0" + } + }, "node_modules/underscore": { "version": "1.12.1", "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.12.1.tgz", @@ -22165,6 +22408,15 @@ "makeerror": "1.0.12" } }, + "node_modules/warning": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/warning/-/warning-4.0.3.tgz", + "integrity": "sha512-rpJyN222KWIvHJ/F53XSZv0Zl/accqHR8et1kpaMTD/fLCRxtV8iX8czMzY7sVZupTI3zcUTg8eycS2kNF9l6w==", + "license": "MIT", + "dependencies": { + "loose-envify": "^1.0.0" + } + }, "node_modules/watchpack": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.1.tgz", diff --git a/package.json b/package.json index 8700f5c..ce8b91b 100644 --- a/package.json +++ b/package.json @@ -11,12 +11,16 @@ "@testing-library/jest-dom": "^5.17.0", "@testing-library/user-event": "^13.5.0", "axios": "^1.7.2", + "chart.js": "^4.4.3", "class-variance-authority": "^0.7.0", "clsx": "^2.1.1", "faker": "^6.6.6", "install": "^0.13.0", "npm": "^10.8.1", "react": "^18.3.1", + "react-bootstrap": "^2.10.3", + "react-chartjs-2": "^5.2.0", + "react-chatbot-kit": "^2.2.2", "react-dom": "^18.3.1", "react-router-dom": "^6.23.1", "react-scripts": "5.0.1", diff --git a/src/App.js b/src/App.js index 7ebf167..a63fa40 100644 --- a/src/App.js +++ b/src/App.js @@ -14,6 +14,7 @@ import AdminOB from "./Pages/Admin/AdminOB"; import AdminMC from "./Pages/Admin/AdminMC"; import Home from "./Pages/Admin/Home"; +import Analysis from "./Pages/Admin/Analysis"; function App() { return ( @@ -36,6 +37,8 @@ function App() { } /> } /> } /> + + } /> diff --git a/src/Pages/Admin/AdminAO.jsx b/src/Pages/Admin/AdminAO.jsx index 0facd45..057422b 100644 --- a/src/Pages/Admin/AdminAO.jsx +++ b/src/Pages/Admin/AdminAO.jsx @@ -1,7 +1,9 @@ -import React from "react"; +import React from 'react' const AdminAO = () => { - return
AdminAO
; -}; + return ( +
AdminAO
+ ) +} -export default AdminAO; +export default AdminAO \ No newline at end of file diff --git a/src/Pages/Admin/Analysis.jsx b/src/Pages/Admin/Analysis.jsx new file mode 100644 index 0000000..03bd284 --- /dev/null +++ b/src/Pages/Admin/Analysis.jsx @@ -0,0 +1,182 @@ +import React, { useEffect, useState } from "react"; +import { Bar, Doughnut, Line, Pie } from "react-chartjs-2"; +import { + Chart as ChartJS, + ArcElement, + CategoryScale, + LinearScale, + BarElement, + LineElement, + PointElement, + Title, + Tooltip, + Legend, +} from "chart.js"; +import "react-chatbot-kit/build/main.css"; + +ChartJS.register( + ArcElement, + CategoryScale, + LinearScale, + BarElement, + LineElement, + PointElement, + Title, + Tooltip, + Legend +); + +const Dashboard = () => { + const [formData, setFormData] = useState(null); + const [selectedChart, setSelectedChart] = useState("bar"); + + useEffect(() => { + const storedFormData = JSON.parse(localStorage.getItem("completeFormData")); + setFormData(storedFormData); + }, []); + + if (!formData) { + return
Loading...
; + } + + const chartTypes = ["bar", "line", "pie", "doughnut"]; + + const chartComponents = { + bar: Bar, + line: Line, + pie: Pie, + doughnut: Doughnut, + }; + + const ChartComponent = chartComponents[selectedChart]; + + const getChartData = (data, labels, title) => ({ + labels, + datasets: [ + { + label: title, + data, + backgroundColor: [ + "#FF6384", + "#36A2EB", + "#FFCE56", + "#4BC0C0", + "#9966FF", + "#FF9F40", + "#FF6384", + "#36A2EB", + "#FFCE56", + "#4BC0C0", + ], + borderColor: "rgba(75, 192, 192, 1)", + borderWidth: 1, + }, + ], + }); + + const chartOptions = { + responsive: true, + maintainAspectRatio: false, + scales: { + y: { + beginAtZero: true, + }, + }, + }; + + const charts = [ + { + title: "Constitution", + data: getChartData( + Object.values(formData.constitution).map((v) => (v ? 1 : 0)), + Object.keys(formData.constitution), + "Constitution" + ), + }, + { + title: "Industry Classification", + data: getChartData( + Object.values(formData.industryClassification).map((v) => (v ? 1 : 0)), + Object.keys(formData.industryClassification), + "Industry Classification" + ), + }, + { + title: "Annual Turnover", + data: getChartData( + Object.values(formData.annualTurnover).map((v) => parseFloat(v) || 0), + Object.keys(formData.annualTurnover), + "Annual Turnover" + ), + }, + { + title: "Employment Details", + data: getChartData( + Object.values(formData.employmentDetails).map((v) => parseInt(v) || 0), + Object.keys(formData.employmentDetails), + "Employment Details" + ), + }, + { + title: "Market Catering", + data: getChartData( + [ + formData.marketCatering.domestic ? 1 : 0, + formData.marketCatering.global ? 1 : 0, + formData.marketCatering.both ? 1 : 0, + parseFloat(formData.marketCatering.percentExports) || 0, + parseFloat(formData.marketCatering.percentImports) || 0, + ], + ["Domestic", "Global", "Both", "% Exports", "% Imports"], + "Market Catering" + ), + }, + { + title: "Welfare Obligations", + data: getChartData( + Object.values(formData.welfareObligations).map( + (v) => parseFloat(v) || 0 + ), + Object.keys(formData.welfareObligations), + "Welfare Obligations" + ), + }, + ]; + + return ( +
+

+ Dashboard +

+
+ + +
+
+ {charts.map((chart, index) => ( +
+

{chart.title}

+
+ +
+
+ ))} +
+
+ ); +}; + +export default Dashboard; diff --git a/src/Pages/Admin/Home.jsx b/src/Pages/Admin/Home.jsx index c6dc2aa..22dc41b 100644 --- a/src/Pages/Admin/Home.jsx +++ b/src/Pages/Admin/Home.jsx @@ -1,6 +1,7 @@ import React from "react"; import { useNavigate } from "react-router-dom"; import "../../index.css"; +import Navbar from "./Navbar"; function Home() { const navigate = useNavigate(); @@ -10,7 +11,7 @@ function Home() { return (
- {/* */} +
diff --git a/src/Pages/Admin/Navbar.jsx b/src/Pages/Admin/Navbar.jsx new file mode 100644 index 0000000..b9d9de0 --- /dev/null +++ b/src/Pages/Admin/Navbar.jsx @@ -0,0 +1,71 @@ +import React from "react"; +import icci from "../../Assets/icci.jpg"; +const Navbar = () => { + return ( + + ); +}; + +export default Navbar; diff --git a/src/Pages/Client/NewMember/Membershipform.jsx b/src/Pages/Client/NewMember/Membershipform.jsx index 87ade51..5900261 100644 --- a/src/Pages/Client/NewMember/Membershipform.jsx +++ b/src/Pages/Client/NewMember/Membershipform.jsx @@ -1,6 +1,7 @@ import React, { useState } from "react"; -import Header from "../../../Assets/Formheader.png"; import { useNavigate } from "react-router-dom"; +import Header from "../../../Assets/Formheader.png"; + const Membershipform = () => { const navigate = useNavigate(); const currentDate = new Date().toLocaleDateString(); @@ -29,7 +30,57 @@ const Membershipform = () => { phoneMobile: "", email: "", website: "", + name: "", + designation: "", + pan: "", + aadhaar: "", + phone: "", + mailId: "", + mainCategory: "", + subCategory: "", + domestic: false, + global: false, + both: false, + percentExports: "", + percentImports: "", + countryName: "", + collaboratorName: "", + large: false, + medium: false, + small: false, + micro: false, + firstYear: "", + secondYear: "", + thirdYear: "", + directOffice: "", + directWorks: "", + indirectContractual: "", + indirectOutsourced: "", + esic: "", + epf: "", + branchesOutsideIndia: "", + associationDetails: "", + officeBearerDetails: "", + reasonForJoining: "", }); + const labels = [ + "Proprietary Firm", + "Partnership Firm LLP", + "Private Limited", + "Public Limited Unlisted", + "Public Limited Listed", + "Trust", + "Society", + "Associations", + ]; + const handleCheckboxChange = (event) => { + setIsMember(event.target.checked); + }; + + // Add handleYesChange function + const handleYesChange = () => { + setIsYesChecked(!isYesChecked); + }; const [legalInfo, setLegalInfo] = useState({ aadhaarCardNo: "", @@ -46,43 +97,26 @@ const Membershipform = () => { { name: "", designation: "", pan: "" }, { name: "", designation: "", pan: "" }, ]); - const [isYesChecked, setIsYesChecked] = useState(false); - - const handleYesChange = () => { - setIsYesChecked(!isYesChecked); - }; - const labels = [ - "Proprietary Firm", - "Partnership Firm LLP", - "Private Limited", - "Public Limited Unlisted", - "Public Limited Listed", - "Trust", - "Society", - "Associations", - ]; + const [isYesChecked, setIsYesChecked] = useState(false); + const [isMember, setIsMember] = useState(false); + const [image, setImage] = useState(null); const handleInputChange = (event) => { const { name, type, checked, value } = event.target; const inputValue = type === "checkbox" ? checked : value; - setFormData({ - ...formData, + setFormData((prevState) => ({ + ...prevState, [name]: inputValue, - }); + })); }; - const [isMember, setIsMember] = useState(false); - const handleCheckboxChange = (event) => { - setIsMember(event.target.checked); - }; const handleProfessionChange = (index, value) => { const newProfession = [...formData.profession]; newProfession[index] = value; setFormData({ ...formData, profession: newProfession }); }; - const [image, setImage] = useState(null); const handleImageUpload = (event) => { const file = event.target.files[0]; @@ -119,23 +153,68 @@ const Membershipform = () => { const handleSubmit = (e) => { e.preventDefault(); - const formDataWithDefaults = { + + const completeFormData = { ...formData, - applicantName: formData.applicantName || "Not provided", - profession: formData.profession.map((p) => p || "Not specified"), - establishmentYear: formData.establishmentYear || currentYear.toString(), - businessActivity: formData.businessActivity || "Not provided", - registeredOfficeAddress: - formData.registeredOfficeAddress || "Not provided", - officeAddress: formData.officeAddress || "Not provided", - worksFactoryAddress: formData.worksFactoryAddress || "Not provided", - phoneLandline: formData.phoneLandline || "Not provided", - phoneMobile: formData.phoneMobile || "Not provided", - email: formData.email || "Not provided", - website: formData.website || "Not provided", + legalInfo, + directors, + authorizedPerson: { + name: formData.name, + designation: formData.designation, + pan: formData.pan, + aadhaar: formData.aadhaar, + phone: formData.phone, + mailId: formData.mailId, + }, + industryCategory: { + mainCategory: formData.mainCategory, + subCategory: formData.subCategory, + }, + marketCatering: { + domestic: formData.domestic, + global: formData.global, + both: formData.both, + percentExports: formData.percentExports, + percentImports: formData.percentImports, + }, + foreignCollaboration: { + countryName: formData.countryName, + collaboratorName: formData.collaboratorName, + }, + industryClassification: { + large: formData.large, + medium: formData.medium, + small: formData.small, + micro: formData.micro, + }, + annualTurnover: { + firstYear: formData.firstYear, + secondYear: formData.secondYear, + thirdYear: formData.thirdYear, + }, + employmentDetails: { + directOffice: formData.directOffice, + directWorks: formData.directWorks, + indirectContractual: formData.indirectContractual, + indirectOutsourced: formData.indirectOutsourced, + }, + welfareObligations: { + esic: formData.esic, + epf: formData.epf, + }, + branchesOutsideIndia: formData.branchesOutsideIndia, + memberOfOtherAssociation: isMember, + otherAssociationDetails: formData.associationDetails, + holdOfficeBearerPosition: isYesChecked, + officeBearerDetails: formData.officeBearerDetails, + reasonForJoining: formData.reasonForJoining, + signature: image, }; - console.log("Form submitted:", formDataWithDefaults); - localStorage.setItem("formData", JSON.stringify(formDataWithDefaults)); + + // Store the complete form data in localStorage + localStorage.setItem("completeFormData", JSON.stringify(completeFormData)); + + console.log("Form submitted:", completeFormData); navigate("/membershipform2"); }; diff --git a/src/Pages/Client/NewMember/Membershipform2.jsx b/src/Pages/Client/NewMember/Membershipform2.jsx index 2dce135..5be34b2 100644 --- a/src/Pages/Client/NewMember/Membershipform2.jsx +++ b/src/Pages/Client/NewMember/Membershipform2.jsx @@ -18,6 +18,7 @@ const Membershipform2 = () => { }; const Handlesubmit = () => { var a = localStorage.getItem("formData"); + console.log("Checked Items:", checkedItems); Navigate("/submitted"); }; diff --git a/src/Pages/Client/NewMember/Submittedform.jsx b/src/Pages/Client/NewMember/Submittedform.jsx index 9fdbea2..a55cbc4 100644 --- a/src/Pages/Client/NewMember/Submittedform.jsx +++ b/src/Pages/Client/NewMember/Submittedform.jsx @@ -1,8 +1,8 @@ import React from "react"; const Submittedform = () => { - const formData = JSON.parse(localStorage.getItem("formData")); const formData2 = JSON.parse(localStorage.getItem("formData2")); + const storedFormData = JSON.parse(localStorage.getItem("completeFormData")); return (
@@ -12,7 +12,7 @@ const Submittedform = () => { Form Data 1: -
{JSON.stringify(formData, null, 2)}
+
{JSON.stringify(storedFormData, null, 2)}