diff options
Diffstat (limited to 'admin/src/pages/EnrollmentRequests/EnrollmentRequests.jsx')
-rw-r--r-- | admin/src/pages/EnrollmentRequests/EnrollmentRequests.jsx | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/admin/src/pages/EnrollmentRequests/EnrollmentRequests.jsx b/admin/src/pages/EnrollmentRequests/EnrollmentRequests.jsx index bd2b17b..eed7e64 100644 --- a/admin/src/pages/EnrollmentRequests/EnrollmentRequests.jsx +++ b/admin/src/pages/EnrollmentRequests/EnrollmentRequests.jsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, {useState} from 'react'; import Accordion from '../../components/Accordion/Accordion'; import Button from '../../components/Button/Button'; import Header from '../../components/Header/Header'; @@ -7,11 +7,12 @@ import { getUnverifiedUsers, updateUser, } from '../../services/apiservice'; -import {useQuery, useMutation} from 'react-query'; -import {useNavigate} from 'react-router-dom'; +import { useQuery, useMutation } from 'react-query'; +import { useNavigate } from 'react-router-dom'; import BackButton from '../../components/BackButton/BackButton'; -import {sendMessage} from '../../services/apiservice'; +import { sendMessage } from '../../services/apiservice'; import Spinner from '../../components/Spinner/Spinner'; +import TextField from '@mui/material/TextField'; import styles from './EnrollmentRequests.module.css'; import MessageModal from '../../components/Modal/MessageModal'; @@ -20,11 +21,11 @@ const EnrollmentRequests = () => { const navigate = useNavigate(); const [open, setOpen] = React.useState(false); const [message, setMessage] = React.useState(''); - const {data, refetch, isLoading} = useQuery('unverified', getUnverifiedUsers); + const { data, refetch, isLoading } = useQuery('unverified', getUnverifiedUsers); const deleteUse = useMutation((payload) => deleteUser(payload)); - const updateUse = useMutation((id) => updateUser(id, {verified: true}), { + const updateUse = useMutation((id) => updateUser(id, { verified: true }), { onSuccess: () => { refetch(); }, @@ -47,6 +48,21 @@ const EnrollmentRequests = () => { }); }; + const [inputText, setInputText] = useState(""); + + const inputHandler = (e) => { + const lowerCase = e.target.value.toLowerCase(); + setInputText(lowerCase); + }; + + const filteredData = data?.data?.filter((el) => { + if (inputText === '') { + return el; + } else { + return el.name.toLowerCase().includes(inputText); + } + }) + if (isLoading) { return <Spinner heading='Admin' />; } @@ -54,11 +70,17 @@ const EnrollmentRequests = () => { return ( <div className={styles.unverified_users}> <Header subheading='Admin' /> + <h1 className={styles.unverified_users__heading}>Search</h1> + <input + className={styles.input__search} + onChange={inputHandler} + placeholder="Enter name of user to search" + /> <BackButton onClick={() => navigate('/')} /> <h1 className={styles.unverified_users__heading}>Enrollment Requests</h1> <div className={styles.accordion}> - {data?.data.length !== 0 ? ( - data?.data.map((item) => ( + {data?.data?.length !== 0 ? ( + filteredData?.map((item) => ( <div className={styles.unverified_users__accordion} key={item._id}> <Accordion name={item.name} user={item} /> <Button |