New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: Sorting & finding by username (ID) admin interface #1778
feature: Sorting & finding by username (ID) admin interface #1778
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you
@@ -35,7 +35,7 @@ import { | |||
} from "@tanstack/react-table"; | |||
import { Filter } from "lucide-react"; | |||
import { useTranslation } from "next-i18next"; | |||
import { ChangeEvent, ReactNode, useState } from "react"; | |||
import { ChangeEvent, Dispatch, ReactNode, SetStateAction, useRef, useState } from "react"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are all of these imports used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AbdBarho Not all of them are used, I'll remove them now. My first attempt used Dispatch and SetStateAction but I changed approaches at some point
@@ -198,13 +200,13 @@ const FilterModal = ({ | |||
value: string; | |||
}) => { | |||
const { isOpen, onOpen, onClose } = useDisclosure(); | |||
|
|||
const initialFocusRef = useRef(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the purpose of this ref?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AbdBarho That ref is for auto-focusing on the text input when the filter button is clicked. That way you can start typing as soon as the parent div/button is clicked
@@ -59,7 +61,7 @@ export type DataTableProps<T> = { | |||
filterValues?: FilterItem[]; | |||
onNextClick?: () => void; | |||
onPreviousClick?: () => void; | |||
onFilterChange?: (items: FilterItem[]) => void; | |||
onFilterChange?: (items: FilterItem[], filterByColumn?: string) => void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need filterByColumn here? Isn't id
in FilterItem
enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went and removed it
website/src/components/UserTable.tsx
Outdated
@@ -47,17 +50,23 @@ const columns: DataTableColumnDef<User>[] = [ | |||
export const UserTable = memo(function UserTable() { | |||
const { pagination, resetCursor, toNextPage, toPreviousPage } = useCursorPagination(); | |||
const [filterValues, setFilterValues] = useState<FilterItem[]>([]); | |||
const handleFilterValuesChange = (values: FilterItem[]) => { | |||
const [filterOption, setFilterOption] = useState<string>("display_name"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You dont need this state. The last FilterItem is the column you want, so just discard the rest values and keep the last one only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went and removed the state and used the last FilterItem
❌ pre-commit failed. |
❌ pre-commit failed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, look good now
Ah you need to update the
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
Feature changes for #1615
sort_filter.mov