Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions src/components/dashboard/system_options/EntityTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
useTheme,
VStack,
} from '@chakra-ui/react';
import { useEffect, useMemo, useRef, useState } from 'react';
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { FiArchive, FiEdit2, FiMapPin, FiTrash2, FiType } from 'react-icons/fi';
import { IoAdd, IoBookOutline, IoEllipsisHorizontal } from 'react-icons/io5';
import { LuInfo } from 'react-icons/lu';
Expand Down Expand Up @@ -146,7 +146,7 @@ const EntityTable: React.FC<EntityTableProps> = ({
return name.trim().substring(0, maxLength).trim();
};

const handleSaveEditedItem = () => {
const handleSaveEditedItem = useCallback(() => {
// Only require name to be present, abbreviation is now optional
if (!editingItem || !editingItem.name) return;

Expand Down Expand Up @@ -197,9 +197,16 @@ const EntityTable: React.FC<EntityTableProps> = ({
if (hasChanges) {
handleUpdateEntity(currentEditingItem);
}
};
}, [
editingItem,
items,
handleUpdateEntity,
maxAbbreviationLength,
maxFullNameLength,
entityType,
]);

const handleAddItem = () => {
const handleAddItem = useCallback(() => {
// Only require name to be present, abbreviation is now optional
if (!newItem.name) return;

Expand Down Expand Up @@ -244,7 +251,14 @@ const EntityTable: React.FC<EntityTableProps> = ({
});
setIsAddingItem(false);
setColorPickerOpen(null);
};
}, [
newItem,
maxAbbreviationLength,
maxFullNameLength,
handleUpdateEntity,
colorGroups,
entityType,
]);

const handleCancelEdit = () => {
setEditingItem(null);
Expand Down
116 changes: 57 additions & 59 deletions src/components/dashboard/user_management/EditableSubscriptionsCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
PopoverBody,
PopoverContent,
PopoverTrigger,
Portal,
Tag,
TagLabel,
Text,
Expand Down Expand Up @@ -321,64 +320,63 @@ const EditableSubscriptionsCell: React.FC<EditableSubscriptionsCellProps> = ({
</Box>
</PopoverTrigger>

<Portal>
<PopoverContent
width={
triggerRef.current?.offsetWidth
? `${triggerRef.current.offsetWidth}px`
: '100%'
}
borderColor="neutralGray.300"
ref={popoverRef}
zIndex={1}
mt="2px"
>
<PopoverBody p={0} maxHeight="300px" overflowY="auto" zIndex={1}>
{sortedSubjects.map((subject) => {
const isSelected = selectedSubjectIds.includes(subject.id);
const bgColor = subject.colorGroup.colorCodes[1];
const borderColor = subject.colorGroup.colorCodes[1];

return (
<Box
key={subject.id}
p={2.5}
pl={4}
display="flex"
alignItems="center"
_hover={{ bg: 'neutralGray.100' }}
onClick={(e) => handleSubjectChange(subject.id, e)}
cursor="pointer"
>
<Checkbox
isChecked={isSelected}
onChange={(e) => {
e.nativeEvent.stopPropagation();
handleSubjectChange(subject.id);
}}
mr={2}
_checked={{
'& .chakra-checkbox__control': {
bg: bgColor,
borderColor: borderColor,
},
}}
_hover={{
'& .chakra-checkbox__control': {
borderColor: borderColor,
bg: bgColor,
opacity: 0.7,
},
}}
borderColor={borderColor}
/>
<Text textStyle="label">{subject.name}</Text>
</Box>
);
})}
</PopoverBody>
</PopoverContent>
</Portal>
<PopoverContent
width={
triggerRef.current?.offsetWidth
? `${triggerRef.current.offsetWidth}px`
: '100%'
}
maxWidth="80vw"
borderColor="neutralGray.300"
ref={popoverRef}
zIndex={1}
mt="2px"
>
<PopoverBody p={0} maxHeight="300px" overflowY="auto" zIndex={1}>
{sortedSubjects.map((subject) => {
const isSelected = selectedSubjectIds.includes(subject.id);
const bgColor = subject.colorGroup.colorCodes[1];
const borderColor = subject.colorGroup.colorCodes[1];

return (
<Box
key={subject.id}
p={2.5}
pl={4}
display="flex"
alignItems="center"
_hover={{ bg: 'neutralGray.100' }}
onClick={(e) => handleSubjectChange(subject.id, e)}
cursor="pointer"
>
<Checkbox
isChecked={isSelected}
onChange={(e) => {
e.nativeEvent.stopPropagation();
handleSubjectChange(subject.id);
}}
mr={2}
_checked={{
'& .chakra-checkbox__control': {
bg: bgColor,
borderColor: borderColor,
},
}}
_hover={{
'& .chakra-checkbox__control': {
borderColor: borderColor,
bg: bgColor,
opacity: 0.7,
},
}}
borderColor={borderColor}
/>
<Text textStyle="label">{subject.name}</Text>
</Box>
);
})}
</PopoverBody>
</PopoverContent>
</Popover>
</Box>
);
Expand Down
1 change: 1 addition & 0 deletions src/components/dashboard/user_management/FilterPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export const FilterPopup: React.FC<FilterPopupProps> = ({
boxShadow="md"
border="1px solid"
borderColor="neutralGray.300"
zIndex={5000}
>
<Flex justifyContent="space-between" alignItems="center" mb={5}>
<Text textStyle="h3">Filter Options</Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export const UserManagementTable: React.FC<UserManagementTableProps> = ({
borderColor="neutralGray.300"
height="100%"
>
<HStack justify="space-between" mx={5} my={3}>
<HStack justify="space-between" mx={5} my={3} zIndex={5000}>
<Text textStyle="h2" fontSize="18px" fontWeight={700} lineHeight="33px">
User Management
</Text>
Expand Down Expand Up @@ -286,7 +286,7 @@ export const UserManagementTable: React.FC<UserManagementTableProps> = ({
<Thead
position="sticky"
top={0}
zIndex={1000} // Make sure it's above the popover for editing email subscriptions
zIndex={3000} // Make sure it's above the popover for editing email subscriptions but below the filter popup
bg="white"
boxShadow="0 1px 1px rgba(227, 227, 227, 1)"
>
Expand Down