Skip to content

Commit

Permalink
replace jquery from insturctor list with react state
Browse files Browse the repository at this point in the history
  • Loading branch information
harsh183 committed Jun 2, 2024
1 parent cd7f52e commit ab62e43
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/screens/Admin/Instructors/InstructorList.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React, { useState, useEffect } from 'react';
import $ from 'jquery';
import { Button } from 'semantic-ui-react';
import { search } from 'utils';
import * as KeyCode from 'keycode-js';
import { AdminListItem } from '../Components';

export default function InstructorList({ instructors, loading, currUni, onInactive }) {
const [result, setResult] = useState([]);
const [searchText, setSearchText] = useState("");

useEffect(() => {
setResult(instructors);
Expand All @@ -15,7 +15,7 @@ export default function InstructorList({ instructors, loading, currUni, onInacti
const onSearch = (keyCode) => {
if (keyCode === KeyCode.KEY_RETURN) {
setResult(
search.getResults(instructors, $('#inst-filter')[0].value, [
search.getResults(instructors, searchText, [
'firstName',
'lastName',
'email',
Expand All @@ -26,7 +26,7 @@ export default function InstructorList({ instructors, loading, currUni, onInacti

const onReset = () => {
setResult(instructors);
$('#inst-filter')[0].value = '';
setSearchText('');
};

return (
Expand All @@ -36,6 +36,8 @@ export default function InstructorList({ instructors, loading, currUni, onInacti
<input
id="inst-filter"
placeholder="Name or email"
value={searchText}
onChange={(e) => setSearchText(e.target.value)}
onKeyDown={({ keyCode }) => {
return onSearch(keyCode);
}}
Expand Down

0 comments on commit ab62e43

Please sign in to comment.