Skip to content

Commit

Permalink
Merge pull request #113 from Alonza0314/feat/frontend/subscriber_page…
Browse files Browse the repository at this point in the history
…_search_box

feat: add search box on subscriber page
  • Loading branch information
ianchen0119 authored Oct 7, 2024
2 parents 0279ebe + 1a4b969 commit 8b52b3c
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion frontend/src/pages/SubscriberList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
TableHead,
TableRow,
TablePagination,
TextField,
} from "@mui/material";

export default function SubscriberList() {
Expand All @@ -23,6 +24,7 @@ export default function SubscriberList() {
const [data, setData] = useState<Subscriber[]>([]);
const [limit, setLimit] = useState(50);
const [page, setPage] = useState(0);
const [searchTerm, setSearchTerm] = useState<string>("");

useEffect(() => {
console.log("get subscribers");
Expand Down Expand Up @@ -95,8 +97,25 @@ export default function SubscriberList() {
navigation("/subscriber/" + subscriber.ueId + "/" + subscriber.plmnID);
};

const filteredData = data.filter((subscriber) =>
subscriber.ueId?.toLowerCase().includes(searchTerm.toLowerCase()) ||
subscriber.plmnID?.toLowerCase().includes(searchTerm.toLowerCase())
);

const handleSearch = (event: React.ChangeEvent<HTMLInputElement>) => {
setSearchTerm(event.target.value);
};

const tableView = (
<React.Fragment>
<TextField
label="Search Subscriber"
variant="outlined"
value={searchTerm}
onChange={handleSearch}
fullWidth
margin="normal"
/>
<Table>
<TableHead>
<TableRow>
Expand All @@ -107,7 +126,7 @@ export default function SubscriberList() {
</TableRow>
</TableHead>
<TableBody>
{data.map((row, index) => (
{filteredData.map((row, index) => (
<TableRow key={index}>
<TableCell>{row.plmnID}</TableCell>
<TableCell>{row.ueId}</TableCell>
Expand Down

0 comments on commit 8b52b3c

Please sign in to comment.