import { ChevronDown, SortAsc, SortDesc } from 'lucide-react' import { useEffect, useRef, useState } from 'react' import { useRowSelection } from 'react-data-grid' import { Button, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from 'ui' // [Joshen] Currently not being used, refer to Users.utils -> formatUserColumns for more info export const SelectHeaderCell = ({ selectedUsers, allRowsSelected, }: { selectedUsers: Set allRowsSelected: boolean }) => { const inputRef = useRef(null) const [isRowSelected, onRowSelectionChange] = useRowSelection() const isIndeterminate = selectedUsers.size > 0 && !allRowsSelected useEffect(() => { if (inputRef.current) inputRef.current.indeterminate = isIndeterminate }, [isIndeterminate]) return (
onRowSelectionChange({ type: 'HEADER', checked: e.target.checked })} />
) } export const HeaderCell = ({ col, specificFilterColumn, setSortByValue, }: { col: any specificFilterColumn: string setSortByValue: (value: string) => void }) => { const ref = useRef(0) const [open, setOpen] = useState(false) useEffect(() => { ref.current = Number(new Date()) }, [open]) return (

{col.name}

{specificFilterColumn === 'freeform' && ['created_at', 'email', 'phone'].includes(col.id) && ( { // [Joshen] This is a temp hack between the DropdownMenu and react data grid // as the header cell is selectable, which takes the focus away from the dropdown menu // causing it to close immediately. if (val === false && Number(new Date()) - ref.current > 100) setOpen(val) }} >
) }