add search to call group dialog
This commit is contained in:
parent
fea1a6aae5
commit
c21e4785ce
@ -7,6 +7,7 @@ import {
|
||||
DialogTitle,
|
||||
FormControlLabel,
|
||||
FormGroup,
|
||||
TextField,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import React, { useState } from "react";
|
||||
@ -37,6 +38,16 @@ const CallFavouritesDialog: React.FC<Props> = ({
|
||||
};
|
||||
|
||||
const [group, setGroup] = useState<string>("Favorites");
|
||||
const [inputText, setInputText] = useState<string>("");
|
||||
const [checkedUuids, setCheckedUuids] = useState<string[]>([]);
|
||||
|
||||
const handleCheck = (uuid: string, checked: boolean) => {
|
||||
if (checked) {
|
||||
setCheckedUuids(checkedUuids.concat([uuid]));
|
||||
} else {
|
||||
setCheckedUuids(checkedUuids.filter(id => id != uuid));
|
||||
}
|
||||
};
|
||||
|
||||
const favoritesUuids = useAppSelector(selectFavorites);
|
||||
const teamUuids = useAppSelector(selectTeam);
|
||||
@ -54,13 +65,33 @@ const CallFavouritesDialog: React.FC<Props> = ({
|
||||
<GroupSelect group={group} setGroup={setGroup} />
|
||||
</DialogContent>
|
||||
<DialogContent sx={{ height: "40vh" }} dividers>
|
||||
<TextField
|
||||
label="Search"
|
||||
variant="outlined"
|
||||
placeholder="Person"
|
||||
fullWidth
|
||||
sx={{ pb: 1 }}
|
||||
onChange={(e) => {
|
||||
setInputText(e.target.value);
|
||||
}}
|
||||
/>
|
||||
<FormGroup>
|
||||
{groupMembers.map(user => (
|
||||
{groupMembers.filter(member => (
|
||||
member.name.toLowerCase().slice(0, inputText.length) == inputText.toLowerCase().slice(0, inputText.length)
|
||||
)).map(member => (
|
||||
<FormControlLabel
|
||||
key={user.uuid}
|
||||
label={user.name}
|
||||
key={member.uuid}
|
||||
label={member.name}
|
||||
sx={{ pl: 1 }}
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
onChange={(e: any) => {
|
||||
handleCheck(member.uuid, e.target.checked);
|
||||
console.log(checkedUuids);
|
||||
}}
|
||||
control={
|
||||
<Checkbox color="success" />
|
||||
<Checkbox
|
||||
color="success"
|
||||
checked={checkedUuids.includes(member.uuid)}/>
|
||||
}
|
||||
/>
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user