diff options
author | rohan09-raj <[email protected]> | 2022-08-14 00:19:58 +0530 |
---|---|---|
committer | rohan09-raj <[email protected]> | 2022-08-14 00:19:58 +0530 |
commit | 4e99bfe1878620769d48532b182692e51c7266ef (patch) | |
tree | c3b02c73fd5f9fba85461e00db9905ee1371a8a0 /admin/src | |
parent | 3673947d4905948de2e466a813019b1de9629bd2 (diff) |
admin panel and api integration
Diffstat (limited to 'admin/src')
25 files changed, 400 insertions, 90 deletions
diff --git a/admin/src/App.css b/admin/src/App.css deleted file mode 100644 index 74b5e05..0000000 --- a/admin/src/App.css +++ /dev/null @@ -1,38 +0,0 @@ -.App { - text-align: center; -} - -.App-logo { - height: 40vmin; - pointer-events: none; -} - -@media (prefers-reduced-motion: no-preference) { - .App-logo { - animation: App-logo-spin infinite 20s linear; - } -} - -.App-header { - background-color: #282c34; - min-height: 100vh; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - font-size: calc(10px + 2vmin); - color: white; -} - -.App-link { - color: #61dafb; -} - -@keyframes App-logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } -} diff --git a/admin/src/App.js b/admin/src/App.js index 3784575..6d24fc0 100644 --- a/admin/src/App.js +++ b/admin/src/App.js @@ -1,23 +1,9 @@ -import logo from './logo.svg'; -import './App.css'; +import Index from './routes'; function App() { return ( - <div className="App"> - <header className="App-header"> - <img src={logo} className="App-logo" alt="logo" /> - <p> - Edit <code>src/App.js</code> and save to reload. - </p> - <a - className="App-link" - href="https://reactjs.org" - target="_blank" - rel="noopener noreferrer" - > - Learn React - </a> - </header> + <div className='App'> + <Index /> </div> ); } diff --git a/admin/src/App.test.js b/admin/src/App.test.js deleted file mode 100644 index 1f03afe..0000000 --- a/admin/src/App.test.js +++ /dev/null @@ -1,8 +0,0 @@ -import { render, screen } from '@testing-library/react'; -import App from './App'; - -test('renders learn react link', () => { - render(<App />); - const linkElement = screen.getByText(/learn react/i); - expect(linkElement).toBeInTheDocument(); -}); diff --git a/admin/src/components/Accordion/Accordion.jsx b/admin/src/components/Accordion/Accordion.jsx new file mode 100644 index 0000000..fefd39b --- /dev/null +++ b/admin/src/components/Accordion/Accordion.jsx @@ -0,0 +1,35 @@ +import React, {useState} from 'react'; + +import styles from './Accordion.module.css'; + +const Accordion = ({name, user}) => { + const [isActive, setIsActive] = useState(false); + + return ( + <div className={styles.accordion}> + <div + className={styles.accordion__title} + onClick={() => setIsActive(!isActive)} + > + <h2>{name}</h2> + <div>❯</div> + </div> + {isActive && ( + <div className={styles.accordion__content}> + <div>Indian Resident : {user.indianResident}</div> + <div>Name : {user.name}</div> + <div>Gender : {user.gender}</div> + <div>Date of Birth : {user.dob}</div> + <div>Mobile Number : {user.mobile}</div> + <div>Email : {user.email}</div> + <div>Address : {user.address}</div> + <div>Photograph : {user.photo}</div> + <div>Documents : {user.documents.doc1}</div> + <div>Biometrics : {user.biometrics.bio1}</div> + </div> + )} + </div> + ); +}; + +export default Accordion; diff --git a/admin/src/components/Accordion/Accordion.module.css b/admin/src/components/Accordion/Accordion.module.css new file mode 100644 index 0000000..86a1c7b --- /dev/null +++ b/admin/src/components/Accordion/Accordion.module.css @@ -0,0 +1,29 @@ +.accordion { + width: 600px; + margin: 2rem auto; +} + +.accordion__title { + display: flex; + flex-direction: row; + justify-content: space-between; + cursor: pointer; + background-color: #2c3e50; + color: #ecf0f1; + border-radius: 10px; + box-shadow: 0 4px 4px -2px rgba(0, 0, 0, 0.5); +} + +.accordion__title:hover { + background-color: #17212b; +} + +.accordion__title, +.accordion__content { + padding: 1rem; +} + +.accordion__content { + background-color: #ecf0f1; + border-radius: 10px; +} diff --git a/admin/src/components/Button/Button.jsx b/admin/src/components/Button/Button.jsx new file mode 100644 index 0000000..ed8bc20 --- /dev/null +++ b/admin/src/components/Button/Button.jsx @@ -0,0 +1,20 @@ +import React from 'react'; + +import styles from './Button.module.css'; + +const Button = ({title, onClick, color}) => { + return ( + <> + <button + className={ + color === 'green' ? styles.button__green : styles.button__red + } + onClick={onClick} + > + {title} + </button> + </> + ); +}; + +export default Button; diff --git a/admin/src/components/Button/Button.module.css b/admin/src/components/Button/Button.module.css new file mode 100644 index 0000000..3de7c54 --- /dev/null +++ b/admin/src/components/Button/Button.module.css @@ -0,0 +1,19 @@ +.button__green { + font-size: 1rem; + margin: 8px; + padding: 20px 30px; + border: none; + border-radius: 10px; + background-color: rgb(35, 151, 35); + color: #fff; +} + +.button__red { + font-size: 1rem; + margin: 8px; + padding: 20px 30px; + border: none; + border-radius: 10px; + background-color: #ff3333; + color: #fff; +} diff --git a/admin/src/components/Card/Card.jsx b/admin/src/components/Card/Card.jsx new file mode 100644 index 0000000..9460955 --- /dev/null +++ b/admin/src/components/Card/Card.jsx @@ -0,0 +1,13 @@ +import React from 'react' +import styles from './Card.module.css' + +const Card = ({ title, image, onClick }) => { + return ( + <div onClick={ onClick } className={styles.card}> + <img className={styles.card__image} src={image} alt="" /> + <h2 className={styles.card__title}>{title}</h2> + </div> + ) +} + +export default Card diff --git a/admin/src/components/Card/Card.module.css b/admin/src/components/Card/Card.module.css new file mode 100644 index 0000000..e351fd5 --- /dev/null +++ b/admin/src/components/Card/Card.module.css @@ -0,0 +1,26 @@ +@import '../../styles/GlobalVariables.css'; + +.card { + height: 300px; + width: 300px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + border: 3px solid var(--color-black); + border-radius: 10px; + margin: 30px; + transition: 0.2s all; + cursor: pointer; + color: var(--color-black); + text-decoration-line: none; +} + +.card:active { + transform: scale(0.98); + box-shadow: 3px 2px 22px 1px var(--color-shadow); +} + +.card__title { + margin: 15px 0px; +} diff --git a/admin/src/components/Header/Header.jsx b/admin/src/components/Header/Header.jsx new file mode 100644 index 0000000..d90aafe --- /dev/null +++ b/admin/src/components/Header/Header.jsx @@ -0,0 +1,13 @@ +import React from 'react' +import styles from './Header.module.css' + +const Header = ({ subheading }) => { + return ( + <header className={styles.header}> + <h1 className={styles.header__heading}>AADHAAR</h1> + <h3 className={styles.header__subheading}>{subheading}</h3> + </header> + ) +} + +export default Header diff --git a/admin/src/components/Header/Header.module.css b/admin/src/components/Header/Header.module.css new file mode 100644 index 0000000..8e6084f --- /dev/null +++ b/admin/src/components/Header/Header.module.css @@ -0,0 +1,20 @@ +@import '../../styles/GlobalVariables.css'; + +.header { + font-family: 'Fredoka One', cursive; + display: flex; + flex-direction: column; + align-items: center; + margin: 20px; + padding: 20px; +} + +.header__heading { + font-size: var(--font-large); + font-weight: 400; +} + +.header__subheading { + font-size: var(--font-medium); + font-weight: 400; +} diff --git a/admin/src/index.css b/admin/src/index.css index ec2585e..89ba707 100644 --- a/admin/src/index.css +++ b/admin/src/index.css @@ -1,10 +1,17 @@ -body { +* { margin: 0; + padding: 0; + box-sizing: border-box; +} + +body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; + height: 100%; + width: 100%; } code { diff --git a/admin/src/index.js b/admin/src/index.js index d563c0f..f3e19c1 100644 --- a/admin/src/index.js +++ b/admin/src/index.js @@ -2,16 +2,18 @@ import React from 'react'; import ReactDOM from 'react-dom/client'; import './index.css'; import App from './App'; -import reportWebVitals from './reportWebVitals'; +import {BrowserRouter} from 'react-router-dom'; +import {QueryClient, QueryClientProvider} from 'react-query'; + +const queryClient = new QueryClient(); const root = ReactDOM.createRoot(document.getElementById('root')); root.render( <React.StrictMode> - <App /> + <BrowserRouter> + <QueryClientProvider client={queryClient}> + <App /> + </QueryClientProvider> + </BrowserRouter> </React.StrictMode> ); - -// If you want to start measuring performance in your app, pass a function -// to log results (for example: reportWebVitals(console.log)) -// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals -reportWebVitals(); diff --git a/admin/src/logo.svg b/admin/src/logo.svg deleted file mode 100644 index 9dfc1c0..0000000 --- a/admin/src/logo.svg +++ /dev/null @@ -1 +0,0 @@ -<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3"><g fill="#61DAFB"><path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/><circle cx="420.9" cy="296.5" r="45.7"/><path d="M520.5 78.1z"/></g></svg>
\ No newline at end of file diff --git a/admin/src/pages/Home/Home.jsx b/admin/src/pages/Home/Home.jsx new file mode 100644 index 0000000..b8d556e --- /dev/null +++ b/admin/src/pages/Home/Home.jsx @@ -0,0 +1,30 @@ +import React from 'react'; +import {Link} from 'react-router-dom'; + +import Card from '../../components/Card/Card'; +import Header from '../../components/Header/Header'; +import styles from './Home.module.css'; + +const Home = ({page, setPage}) => { + return ( + <> + <Header subheading='Admin' /> + <div className={styles.card__container}> + <Link to='/verified'> + <Card + title='Verified' + image={`${process.env.PUBLIC_URL}/assets/images/verified.svg`} + /> + </Link> + <Link to='/unverified'> + <Card + title='Unverified' + image={`${process.env.PUBLIC_URL}/assets/images/unverified.svg`} + /> + </Link> + </div> + </> + ); +}; + +export default Home; diff --git a/admin/src/pages/Home/Home.module.css b/admin/src/pages/Home/Home.module.css new file mode 100644 index 0000000..de1cead --- /dev/null +++ b/admin/src/pages/Home/Home.module.css @@ -0,0 +1,4 @@ +.card__container { + display: flex; + justify-content: center; +} diff --git a/admin/src/pages/UnverifiedUsers/UnverifiedUsers.jsx b/admin/src/pages/UnverifiedUsers/UnverifiedUsers.jsx new file mode 100644 index 0000000..67de506 --- /dev/null +++ b/admin/src/pages/UnverifiedUsers/UnverifiedUsers.jsx @@ -0,0 +1,50 @@ +import React, {useEffect} from 'react'; +import Accordion from '../../components/Accordion/Accordion'; +import Button from '../../components/Button/Button'; +import Header from '../../components/Header/Header'; +import { + deleteUser, + getUnverifiedUsers, + updateUser, +} from '../../services/apiservice'; +import {useQuery, useMutation} from 'react-query'; + +import styles from './UnverifiedUsers.module.css'; + +const UnverifiedUsers = () => { + const {data} = useQuery('unverified', getUnverifiedUsers); + const deleteUse = useMutation((id) => deleteUser(id)); + const updateUse = useMutation((id) => updateUser(id, {verified: true})); + + useEffect(() => {}, [data]); + + return ( + <div className={styles.unverified_users}> + <Header subheading='Admin' /> + <h1 className={styles.unverified_users__heading}>Unverified Users</h1> + <div className='accordion'> + {data?.data.length !== 0 ? ( + data?.data.map((item) => ( + <div className={styles.unverified_users__accordion} key={item._id}> + <Accordion name={item.name} user={item} /> + <Button + title='Accept' + color='green' + onClick={() => updateUse.mutate(item._id)} + /> + <Button + title='Reject' + color='red' + onClick={() => deleteUse.mutate(item._id)} + /> + </div> + )) + ) : ( + <div className={styles.unverified_users__nodata}>No Data Found</div> + )} + </div> + </div> + ); +}; + +export default UnverifiedUsers; diff --git a/admin/src/pages/UnverifiedUsers/UnverifiedUsers.module.css b/admin/src/pages/UnverifiedUsers/UnverifiedUsers.module.css new file mode 100644 index 0000000..652fe52 --- /dev/null +++ b/admin/src/pages/UnverifiedUsers/UnverifiedUsers.module.css @@ -0,0 +1,21 @@ +.unverified_users { + display: flex; + flex-direction: column; + justify-content: center; +} + +.unverified_users__heading { + text-align: center; +} + +.unverified_users__accordion { + display: flex; + justify-content: center; + align-items: center; + width: 80%; +} + +.unverified_users__nodata { + margin: 20px; + text-align: center; +} diff --git a/admin/src/pages/VerifiedUsers/VerifiedUsers.jsx b/admin/src/pages/VerifiedUsers/VerifiedUsers.jsx new file mode 100644 index 0000000..12d1317 --- /dev/null +++ b/admin/src/pages/VerifiedUsers/VerifiedUsers.jsx @@ -0,0 +1,31 @@ +import React from 'react'; +import Accordion from '../../components/Accordion/Accordion'; +import Header from '../../components/Header/Header'; +import {getVerifiedUsers} from '../../services/apiservice'; +import {useQuery} from 'react-query'; + +import styles from './VerifiedUsers.module.css'; + +const VerifiedUsers = () => { + const {data} = useQuery('verified', getVerifiedUsers); + + return ( + <div className={styles.verified_users}> + <Header subheading='Admin' /> + <h1 className={styles.verified_users__heading}>Verified Users</h1> + <div className='accordion'> + {data?.data.length !== 0 ? ( + data?.data.map((item) => ( + <div> + <Accordion name={item.name} user={item} /> + </div> + )) + ) : ( + <div className={styles.verified_users__nodata}>No Data Found</div> + )} + </div> + </div> + ); +}; + +export default VerifiedUsers; diff --git a/admin/src/pages/VerifiedUsers/VerifiedUsers.module.css b/admin/src/pages/VerifiedUsers/VerifiedUsers.module.css new file mode 100644 index 0000000..f558e85 --- /dev/null +++ b/admin/src/pages/VerifiedUsers/VerifiedUsers.module.css @@ -0,0 +1,14 @@ +.verified_users { + display: flex; + flex-direction: column; + justify-content: center; +} + +.verified_users__heading { + text-align: center; +} + +.verified_users__nodata { + margin: 20px; + text-align: center; +} diff --git a/admin/src/reportWebVitals.js b/admin/src/reportWebVitals.js deleted file mode 100644 index 5253d3a..0000000 --- a/admin/src/reportWebVitals.js +++ /dev/null @@ -1,13 +0,0 @@ -const reportWebVitals = onPerfEntry => { - if (onPerfEntry && onPerfEntry instanceof Function) { - import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { - getCLS(onPerfEntry); - getFID(onPerfEntry); - getFCP(onPerfEntry); - getLCP(onPerfEntry); - getTTFB(onPerfEntry); - }); - } -}; - -export default reportWebVitals; diff --git a/admin/src/routes/index.js b/admin/src/routes/index.js new file mode 100644 index 0000000..a42c529 --- /dev/null +++ b/admin/src/routes/index.js @@ -0,0 +1,22 @@ +import React from 'react'; +import {Route, Routes} from 'react-router-dom'; + +import Home from '../pages/Home/Home'; +import UnverifiedUsers from '../pages/UnverifiedUsers/UnverifiedUsers'; +import VerifiedUsers from '../pages/VerifiedUsers/VerifiedUsers'; + +const Index = () => { + return ( + <Routes> + <Route exact path='/' element={<Home />} /> + <Route path='verified'> + <Route index element={<VerifiedUsers />} /> + </Route> + <Route path='unverified'> + <Route index element={<UnverifiedUsers />} /> + </Route> + </Routes> + ); +}; + +export default Index; diff --git a/admin/src/services/apiservice.js b/admin/src/services/apiservice.js new file mode 100644 index 0000000..0fbb614 --- /dev/null +++ b/admin/src/services/apiservice.js @@ -0,0 +1,25 @@ +import axios from 'axios'; + +const apiClient = axios.create({ + baseURL: 'http://localhost:5000', +}); + +export const getVerifiedUsers = async () => { + const response = await apiClient.get('/verifiedusers'); + return response; +}; + +export const getUnverifiedUsers = async () => { + const response = await apiClient.get('/unverifiedusers'); + return response; +}; + +export const updateUser = async (id, payload) => { + const response = await apiClient.patch(`/user/${id}`, payload); + return response; +}; + +export const deleteUser = async (id) => { + const response = await apiClient.delete(`/user/${id}`); + return response; +}; diff --git a/admin/src/setupTests.js b/admin/src/setupTests.js deleted file mode 100644 index 8f2609b..0000000 --- a/admin/src/setupTests.js +++ /dev/null @@ -1,5 +0,0 @@ -// jest-dom adds custom jest matchers for asserting on DOM nodes. -// allows you to do things like: -// expect(element).toHaveTextContent(/react/i) -// learn more: https://github.com/testing-library/jest-dom -import '@testing-library/jest-dom'; diff --git a/admin/src/styles/GlobalVariables.css b/admin/src/styles/GlobalVariables.css new file mode 100644 index 0000000..a1e3384 --- /dev/null +++ b/admin/src/styles/GlobalVariables.css @@ -0,0 +1,8 @@ +:root { + --color-black: #000; + --color-shadow: rgba(0, 0, 0, 0.24); + + --font-large: 4rem; + --font-medium: 2rem; + --font-medium-s: 1.25rem; +} |