mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-05-19 07:58:46 -05:00
ba0c89fc6c
Replace custom SVG icons and @mui/icons-material with lucide-react for consistent, lightweight icon management across the application. ## Changes - Add lucide-react package and remove @mui/icons-material - Create theme-aware Icon wrapper component with color resolution - Create iconMap.js for legacy icon name mappings - Migrate 64 components to use new Icon component - Remove 74 unused SVG files from assets/icons/ ## Benefits - Consistent icon API across the application - Smaller bundle size with tree-shakeable imports - Theme-aware color support via MUI theme paths - Simpler maintenance with single icon library
128 lines
2.9 KiB
React
128 lines
2.9 KiB
React
// Components
|
|
import Stack from "@mui/material/Stack";
|
|
import Typography from "@mui/material/Typography";
|
|
import Divider from "@mui/material/Divider";
|
|
import Icon from "../Icon";
|
|
import Search from "../Inputs/Search/index.jsx";
|
|
|
|
// Utils
|
|
import { useState, useEffect } from "react";
|
|
import { useTheme } from "@mui/material/styles";
|
|
import PropTypes from "prop-types";
|
|
|
|
const NotificationConfig = ({
|
|
notifications,
|
|
setMonitor,
|
|
setNotifications,
|
|
//FieldWrapper's props
|
|
gap,
|
|
labelMb,
|
|
labelFontWeight,
|
|
labelVariant,
|
|
labelSx = {},
|
|
sx = {},
|
|
}) => {
|
|
// Local state
|
|
const [notificationsSearch, setNotificationsSearch] = useState("");
|
|
const [selectedNotifications, setSelectedNotifications] = useState([]);
|
|
|
|
const handleSearch = (value) => {
|
|
setSelectedNotifications(value);
|
|
setMonitor((prev) => {
|
|
return {
|
|
...prev,
|
|
notifications: value.map((notification) => notification._id),
|
|
};
|
|
});
|
|
};
|
|
|
|
// Handlers
|
|
const handleDelete = (id) => {
|
|
const updatedNotifications = selectedNotifications.filter(
|
|
(notification) => notification._id !== id
|
|
);
|
|
|
|
setSelectedNotifications(updatedNotifications);
|
|
setMonitor((prev) => {
|
|
return {
|
|
...prev,
|
|
notifications: updatedNotifications.map((notification) => notification._id),
|
|
};
|
|
});
|
|
};
|
|
|
|
// Setup
|
|
const theme = useTheme();
|
|
|
|
useEffect(() => {
|
|
if (setNotifications) {
|
|
const toSet = setNotifications.map((notification) => {
|
|
return notifications.find((n) => n._id === notification);
|
|
});
|
|
setSelectedNotifications(toSet);
|
|
}
|
|
}, [setNotifications, notifications]);
|
|
|
|
return (
|
|
<Stack gap={theme.spacing(6)}>
|
|
<Search
|
|
type="notifications"
|
|
label="Notifications"
|
|
options={notifications}
|
|
filteredBy="notificationName"
|
|
multiple={true}
|
|
value={selectedNotifications}
|
|
inputValue={notificationsSearch}
|
|
handleInputChange={setNotificationsSearch}
|
|
handleChange={(value) => {
|
|
handleSearch(value);
|
|
}}
|
|
labelMb={labelMb}
|
|
labelVariant={labelVariant}
|
|
labelFontWeight={labelFontWeight}
|
|
labelSx={labelSx}
|
|
gap={gap}
|
|
sx={{
|
|
...sx,
|
|
}}
|
|
/>
|
|
<Stack
|
|
flex={1}
|
|
width="100%"
|
|
>
|
|
{selectedNotifications.map((notification, index) => (
|
|
<Stack
|
|
direction="row"
|
|
alignItems="center"
|
|
key={notification._id}
|
|
width="100%"
|
|
>
|
|
<Typography
|
|
flexGrow={1} // <-- This will take up all available horizontal space
|
|
>
|
|
{notification.notificationName}
|
|
</Typography>
|
|
<Icon
|
|
name="Trash2"
|
|
size={20}
|
|
onClick={() => {
|
|
handleDelete(notification._id);
|
|
}}
|
|
style={{ cursor: "pointer" }}
|
|
/>
|
|
{index < selectedNotifications.length - 1 && <Divider />}
|
|
</Stack>
|
|
))}
|
|
</Stack>
|
|
</Stack>
|
|
);
|
|
};
|
|
|
|
NotificationConfig.propTypes = {
|
|
notifications: PropTypes.array,
|
|
setMonitor: PropTypes.func,
|
|
setNotifications: PropTypes.array,
|
|
};
|
|
|
|
export default NotificationConfig;
|