add dropdown to switch between groups; remove select all button
This commit is contained in:
parent
b0c38934f8
commit
ad5ecf2d41
@ -9,6 +9,11 @@ import {
|
|||||||
FormGroup,
|
FormGroup,
|
||||||
Typography,
|
Typography,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
|
import React, { useState } from "react";
|
||||||
|
import { useAppSelector } from "../../redux/hooks";
|
||||||
|
import { selectFavorites } from "../../redux/slices/favoritesSlice";
|
||||||
|
import { selectTeam, selectUsers } from "../../redux/slices/usersSlice";
|
||||||
|
import GroupSelect from "../sidebar/GroupSelect";
|
||||||
import { SidebarUserObj } from "./Home";
|
import { SidebarUserObj } from "./Home";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@ -24,26 +29,39 @@ const CallFavouritesDialog: React.FC<Props> = ({
|
|||||||
onClose,
|
onClose,
|
||||||
users,
|
users,
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
|
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
|
console.log(users);
|
||||||
|
console.log(selectedValue);
|
||||||
onClose(selectedValue);
|
onClose(selectedValue);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const [group, setGroup] = useState<string>("Favorites");
|
||||||
|
|
||||||
|
const favoritesUuids = useAppSelector(selectFavorites);
|
||||||
|
const teamUuids = useAppSelector(selectTeam);
|
||||||
|
|
||||||
|
const groupMembersUuids: string[] =
|
||||||
|
group === "Favorites" ? favoritesUuids : teamUuids;
|
||||||
|
const groupMembers = useAppSelector((state) =>
|
||||||
|
selectUsers(state, groupMembersUuids)
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog onClose={handleClose} open={open} fullWidth maxWidth="sm">
|
<Dialog onClose={handleClose} open={open} fullWidth maxWidth="sm">
|
||||||
<DialogTitle>Select who to call:</DialogTitle>
|
<DialogTitle>Select who to call:</DialogTitle>
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
<FormControlLabel
|
<GroupSelect group={group} setGroup={setGroup} />
|
||||||
control={<Checkbox color="success" />}
|
|
||||||
label="Select everyone"
|
|
||||||
/>
|
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
<DialogContent sx={{ height: "40vh" }} dividers>
|
<DialogContent sx={{ height: "40vh" }} dividers>
|
||||||
<FormGroup>
|
<FormGroup>
|
||||||
{users.map((user) => (
|
{groupMembers.map(user => (
|
||||||
<FormControlLabel
|
<FormControlLabel
|
||||||
key={user.id}
|
key={user.uuid}
|
||||||
control={<Checkbox color="success" />}
|
|
||||||
label={user.name}
|
label={user.name}
|
||||||
|
control={
|
||||||
|
<Checkbox color="success" />
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
|
|||||||
Reference in New Issue
Block a user