fix: improve filters at /bookings (#18581)
* fix: improve filters at /bookings * fix type
This commit is contained in:
1 parent
8761b91f71
commit
1ffb376789
5 files changed
+47
-24
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { useSession } from "next-auth/react";
|
||||
import { Fragment, useMemo } from "react";
|
||||
import { Fragment, useMemo, useState } from "react";
|
||||
|
||||
import {
|
||||
FilterCheckboxField,
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import type { RouterOutputs } from "@calcom/trpc/react";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { FilterSearchField } from "@calcom/ui";
|
||||
import { AnimatedPopover, Divider, Icon } from "@calcom/ui";
|
||||
|
||||
import { groupBy } from "../groupBy";
|
||||
@@ -33,6 +34,7 @@ export const EventTypeFilter = () => {
|
||||
const { t } = useLocale();
|
||||
const { data: user } = useSession();
|
||||
const { data: query, pushItemToKey, removeItemByKeyAndValue, removeAllQueryParams } = useFilterQuery();
|
||||
const [search, setSearch] = useState("");
|
||||
|
||||
const eventTypes = trpc.viewer.eventTypes.listWithTeam.useQuery(undefined, {
|
||||
enabled: !!user,
|
||||
@@ -68,6 +70,11 @@ export const EventTypeFilter = () => {
|
||||
<AnimatedPopover text={getTextForPopover()} prefix={`${t("event_type")}: `}>
|
||||
{!isEmpty ? (
|
||||
<FilterCheckboxFieldsContainer>
|
||||
<FilterSearchField
|
||||
placeholder={t("search")}
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
/>
|
||||
<FilterCheckboxField
|
||||
id="all"
|
||||
icon={<Icon name="link" className="h-4 w-4" />}
|
||||
@@ -82,20 +89,22 @@ export const EventTypeFilter = () => {
|
||||
<div className="text-subtle px-4 py-2 text-xs font-medium uppercase leading-none">
|
||||
{teamName === "user_own_event_types" ? t("individual") : teamName}
|
||||
</div>
|
||||
{groupedEventTypes[teamName].map((eventType) => (
|
||||
<FilterCheckboxField
|
||||
key={eventType.id}
|
||||
checked={query.eventTypeIds?.includes(eventType.id)}
|
||||
onChange={(e) => {
|
||||
if (e.target.checked) {
|
||||
pushItemToKey("eventTypeIds", eventType.id);
|
||||
} else if (!e.target.checked) {
|
||||
removeItemByKeyAndValue("eventTypeIds", eventType.id);
|
||||
}
|
||||
}}
|
||||
label={eventType.title}
|
||||
/>
|
||||
))}
|
||||
{groupedEventTypes[teamName]
|
||||
.filter((eventType) => eventType.title.toLowerCase().includes(search.toLowerCase()))
|
||||
.map((eventType) => (
|
||||
<FilterCheckboxField
|
||||
key={eventType.id}
|
||||
checked={query.eventTypeIds?.includes(eventType.id)}
|
||||
onChange={(e) => {
|
||||
if (e.target.checked) {
|
||||
pushItemToKey("eventTypeIds", eventType.id);
|
||||
} else if (!e.target.checked) {
|
||||
removeItemByKeyAndValue("eventTypeIds", eventType.id);
|
||||
}
|
||||
}}
|
||||
label={eventType.title}
|
||||
/>
|
||||
))}
|
||||
</Fragment>
|
||||
))}
|
||||
</FilterCheckboxFieldsContainer>
|
||||
|
||||
@@ -24,7 +24,7 @@ export const PeopleFilter = () => {
|
||||
const debouncedSearch = useDebounce(searchText, 500);
|
||||
|
||||
const queryMembers = trpc.viewer.teams.legacyListMembers.useInfiniteQuery(
|
||||
{ limit: 10, searchText: debouncedSearch },
|
||||
{ limit: 10, searchText: debouncedSearch, includeEmail: true },
|
||||
{
|
||||
enabled: true,
|
||||
getNextPageParam: (lastPage) => lastPage.nextCursor,
|
||||
|
||||
Reference in new issue
Block a user