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