feat: booking filters [CAL-1801] (#9692)
* feat: booking filters Signed-off-by: Udit Takkar <[email protected]> * fix: responsive issues Signed-off-by: Udit Takkar <[email protected]> * fix: only show accepted members in filter Signed-off-by: Udit Takkar <[email protected]> * chore: translations Signed-off-by: Udit Takkar <[email protected]> * fix: remove organizer default Signed-off-by: Udit Takkar <[email protected]> * chore Signed-off-by: Udit Takkar <[email protected]> * fix: remove locationValues Signed-off-by: Udit Takkar <[email protected]> * fix: remove unused and mobile Signed-off-by: Udit Takkar <[email protected]> --------- Signed-off-by: Udit Takkar <[email protected]> Co-authored-by: Leo Giovanetti <[email protected]>
This commit is contained in:
1 parent
bfc2b8df34
commit
8d7b2cfe51
14 files changed
+274
-275
No files matched your search
@@ -173,8 +173,6 @@ export const EditLocationDialog = (props: ISetLocationDialog) => {
|
||||
}
|
||||
);
|
||||
|
||||
console.log(defaultLocation);
|
||||
|
||||
const LocationOptions = (() => {
|
||||
if (eventLocationType && eventLocationType.organizerInputType && LocationInput) {
|
||||
if (!eventLocationType.variable) {
|
||||
|
||||
@@ -352,6 +352,7 @@
|
||||
"no_status_bookings_yet_description": "You have no {{status}} bookings. {{description}}",
|
||||
"event_between_users": "{{eventName}} between {{host}} and {{attendeeName}}",
|
||||
"bookings": "Bookings",
|
||||
"booking_not_found": "Booking not found",
|
||||
"bookings_description": "See upcoming and past events booked through your event type links.",
|
||||
"upcoming_bookings": "As soon as someone books a time with you it will show up here.",
|
||||
"recurring_bookings": "As soon as someone books a recurring meeting with you it will show up here.",
|
||||
@@ -504,6 +505,7 @@
|
||||
"additional_guests": "Add guests",
|
||||
"your_name": "Your name",
|
||||
"your_full_name": "Your full name",
|
||||
"no_name":"No name",
|
||||
"email_address": "Email address",
|
||||
"enter_valid_email": "Please enter a valid email",
|
||||
"location": "Location",
|
||||
@@ -551,6 +553,9 @@
|
||||
"members": "Members",
|
||||
"organization_members": "Organization members",
|
||||
"member": "Member",
|
||||
"number_member_one": "{{count}} member",
|
||||
"number_member_other": "{{count}} members",
|
||||
"number_selected": "{{count}} selected",
|
||||
"owner": "Owner",
|
||||
"admin": "Admin",
|
||||
"administrator_user": "Administrator user",
|
||||
@@ -657,6 +662,7 @@
|
||||
"event_type_updated_successfully": "{{eventTypeTitle}} event type updated successfully",
|
||||
"event_type_deleted_successfully": "Event type deleted successfully",
|
||||
"hours": "Hours",
|
||||
"people": "People",
|
||||
"your_email": "Your Email",
|
||||
"change_avatar": "Change Avatar",
|
||||
"language": "Language",
|
||||
@@ -1543,6 +1549,7 @@
|
||||
"apps_settings": "Apps settings",
|
||||
"fill_this_field": "Please fill in this field",
|
||||
"options": "Options",
|
||||
"no_options_available":"No options available",
|
||||
"enter_option": "Enter Option {{index}}",
|
||||
"add_an_option": "Add an option",
|
||||
"radio": "Radio",
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
import { create } from "zustand";
|
||||
|
||||
import type { SVGComponent } from "@calcom/types/SVGComponent";
|
||||
import { User, Link } from "@calcom/ui/components/icon";
|
||||
|
||||
interface addFilterOption {
|
||||
StartIcon?: SVGComponent;
|
||||
label: "people" | "event_type" | "date_range" | "location";
|
||||
}
|
||||
|
||||
export type BookingMultiFilterStore = {
|
||||
addFilterOptions: addFilterOption[];
|
||||
toggleOption: (option: addFilterOption) => void;
|
||||
isFilterActive: (label: addFilterOption["label"]) => boolean;
|
||||
};
|
||||
|
||||
export const useBookingMultiFilterStore = create<BookingMultiFilterStore>((set, get) => ({
|
||||
addFilterOptions: [
|
||||
{
|
||||
label: "people",
|
||||
StartIcon: User,
|
||||
},
|
||||
{
|
||||
label: "event_type",
|
||||
StartIcon: Link,
|
||||
},
|
||||
// {
|
||||
// label: "date_range",
|
||||
// StartIcon: Calendar,
|
||||
// },
|
||||
// {
|
||||
// label: "location",
|
||||
// StartIcon: MapPin,
|
||||
// },
|
||||
],
|
||||
isFilterActive: (label: addFilterOption["label"]) => {
|
||||
return !get().addFilterOptions.some((option) => option.label === label);
|
||||
},
|
||||
setState: (state: BookingMultiFilterStore) => set(state),
|
||||
toggleOption: (option: addFilterOption) => {
|
||||
const availableOptions = get().addFilterOptions;
|
||||
const foundOption = availableOptions.find((activeOption) => activeOption.label === option.label);
|
||||
|
||||
if (foundOption) {
|
||||
set({
|
||||
addFilterOptions: availableOptions.filter((activeOption) => activeOption.label !== foundOption.label),
|
||||
});
|
||||
} else {
|
||||
set({ addFilterOptions: [...availableOptions, option] });
|
||||
}
|
||||
},
|
||||
}));
|
||||
@@ -51,20 +51,28 @@ export const EventTypeFilter = () => {
|
||||
});
|
||||
|
||||
if (!eventTypes.data) return null;
|
||||
const isEmpty = eventTypes.data.length === 0;
|
||||
|
||||
const isNotEmpty = eventTypes.data.length > 0;
|
||||
const getTextForPopover = () => {
|
||||
const eventTypeIds = query.eventTypeIds;
|
||||
if (eventTypeIds) {
|
||||
return `${t("event_type")}: ${t("number_selected", { count: eventTypeIds.length })}`;
|
||||
}
|
||||
return `${t("event_type")}: ${t("all")}`;
|
||||
};
|
||||
|
||||
return eventTypes.status === "success" && isNotEmpty ? (
|
||||
<AnimatedPopover text={t("event_type")}>
|
||||
<div className="">
|
||||
return (
|
||||
<AnimatedPopover text={getTextForPopover()}>
|
||||
<div>
|
||||
{groupedEventTypes &&
|
||||
!isEmpty &&
|
||||
Object.keys(groupedEventTypes).map((teamName) => (
|
||||
<Fragment key={teamName}>
|
||||
<div className="text-subtle p-4 text-xs font-medium uppercase leading-none">
|
||||
<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) => (
|
||||
<div key={eventType.id} className="item-center flex px-4 py-1.5">
|
||||
<div key={eventType.id} className="flex items-center px-4 py-1.5">
|
||||
<Checkbox
|
||||
checked={query.eventTypeIds?.includes(eventType.id)}
|
||||
onChange={(e) => {
|
||||
@@ -80,7 +88,10 @@ export const EventTypeFilter = () => {
|
||||
))}
|
||||
</Fragment>
|
||||
))}
|
||||
{isEmpty && (
|
||||
<h2 className="text-default px-4 py-2 text-sm font-medium">{t("no_options_available")}</h2>
|
||||
)}
|
||||
</div>
|
||||
</AnimatedPopover>
|
||||
) : null;
|
||||
);
|
||||
};
|
||||
@@ -1,51 +1,135 @@
|
||||
import type { ReactNode } from "react";
|
||||
import { Fragment } from "react";
|
||||
import { useState } from "react";
|
||||
import { shallow } from "zustand/shallow";
|
||||
|
||||
import { useFilterQuery } from "@calcom/features/bookings/lib/useFilterQuery";
|
||||
import {
|
||||
TeamsFilter,
|
||||
FilterCheckboxFieldsContainer,
|
||||
FilterCheckboxField,
|
||||
} from "@calcom/features/filters/components/TeamsFilter";
|
||||
import { WEBAPP_URL } from "@calcom/lib/constants";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import {
|
||||
Dropdown,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownItem,
|
||||
DropdownMenuTrigger,
|
||||
AnimatedPopover,
|
||||
Avatar,
|
||||
FilterSearchField,
|
||||
Tooltip,
|
||||
} from "@calcom/ui";
|
||||
import { Plus } from "@calcom/ui/components/icon";
|
||||
|
||||
import { useBookingMultiFilterStore } from "../BookingMultiFiltersStore";
|
||||
import { EventTypeFilter } from "./EventTypeFilter";
|
||||
import { PeopleFilter } from "./PeopleFilter";
|
||||
import { TeamsMemberFilter } from "./TeamFilter";
|
||||
|
||||
type FilterTypes = "teams" | "people" | "eventType";
|
||||
const PeopleFilter = () => {
|
||||
const { t } = useLocale();
|
||||
const { data: query, pushItemToKey, removeItemByKeyAndValue, removeByKey } = useFilterQuery();
|
||||
const [searchText, setSearchText] = useState("");
|
||||
|
||||
type Filter = {
|
||||
name: FilterTypes;
|
||||
controllingQueryParams?: string[]; // this is what the filter controls - but also we show the filter if any of these query params are present
|
||||
component: ReactNode;
|
||||
showByDefault?: boolean;
|
||||
const members = trpc.viewer.teams.listMembers.useQuery({});
|
||||
|
||||
const filteredMembers = members?.data
|
||||
?.filter((member) => member.accepted)
|
||||
?.filter((member) =>
|
||||
searchText.trim() !== ""
|
||||
? member?.name?.toLowerCase()?.includes(searchText.toLowerCase()) ||
|
||||
member?.username?.toLowerCase()?.includes(searchText.toLowerCase())
|
||||
: true
|
||||
);
|
||||
|
||||
const getTextForPopover = () => {
|
||||
const userIds = query.userIds;
|
||||
if (userIds) {
|
||||
return `${t("people")}: ${t("number_selected", { count: userIds.length })}`;
|
||||
}
|
||||
return `${t("people")}: ${t("all")}`;
|
||||
};
|
||||
|
||||
return (
|
||||
<AnimatedPopover text={getTextForPopover()}>
|
||||
<FilterSearchField onChange={(e) => setSearchText(e.target.value)} placeholder={t("search")} />
|
||||
<FilterCheckboxFieldsContainer>
|
||||
{filteredMembers?.map((member) => (
|
||||
<FilterCheckboxField
|
||||
key={member.id}
|
||||
id={member.id.toString()}
|
||||
label={member?.name ?? member.username ?? t("no_name")}
|
||||
checked={!!query.userIds?.includes(member.id)}
|
||||
onChange={(e) => {
|
||||
if (e.target.checked) {
|
||||
pushItemToKey("userIds", member.id);
|
||||
} else if (!e.target.checked) {
|
||||
removeItemByKeyAndValue("userIds", member.id);
|
||||
}
|
||||
}}
|
||||
icon={
|
||||
<Avatar
|
||||
alt={`${member?.id} avatar`}
|
||||
imageSrc={member.username ? `${WEBAPP_URL}/${member.username}/avatar.png` : undefined}
|
||||
size="xs"
|
||||
/>
|
||||
}
|
||||
/>
|
||||
))}
|
||||
{filteredMembers?.length === 0 && (
|
||||
<h2 className="text-default px-4 py-2 text-sm font-medium">{t("no_options_available")}</h2>
|
||||
)}
|
||||
</FilterCheckboxFieldsContainer>
|
||||
</AnimatedPopover>
|
||||
);
|
||||
};
|
||||
|
||||
const filters: Filter[] = [
|
||||
{
|
||||
name: "teams",
|
||||
component: <TeamsMemberFilter />,
|
||||
controllingQueryParams: ["teamId"],
|
||||
showByDefault: true,
|
||||
},
|
||||
{
|
||||
name: "people",
|
||||
component: <PeopleFilter />,
|
||||
controllingQueryParams: ["usersId"],
|
||||
showByDefault: true,
|
||||
},
|
||||
{
|
||||
name: "eventType",
|
||||
component: <EventTypeFilter />,
|
||||
controllingQueryParams: ["eventTypeId"],
|
||||
showByDefault: true,
|
||||
},
|
||||
];
|
||||
|
||||
export function FiltersContainer() {
|
||||
const { t } = useLocale();
|
||||
|
||||
const [addFilterOptions, toggleOption, isFilterActive] = useBookingMultiFilterStore((state) => [
|
||||
state.addFilterOptions,
|
||||
state.toggleOption,
|
||||
state.isFilterActive,
|
||||
shallow,
|
||||
]);
|
||||
|
||||
const isPeopleFilterActive = isFilterActive("people");
|
||||
const isEventTypeFilterActive = isFilterActive("event_type");
|
||||
|
||||
return (
|
||||
<div className="flex w-full space-x-2 rtl:space-x-reverse">
|
||||
{filters.map((filter) => {
|
||||
if (!filter.showByDefault) {
|
||||
// TODO: check if any of the controllingQueryParams are present in the query params and show the filter if so
|
||||
// TODO: Also check state to see if the user has toggled the filter
|
||||
return null;
|
||||
}
|
||||
return <Fragment key={filter.name}>{filter.component}</Fragment>;
|
||||
})}
|
||||
{addFilterOptions.length > 0 && (
|
||||
<Dropdown>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<div className="hover:border-emphasis border-default text-default hover:text-emphasis mb-4 flex h-9 max-h-72 items-center justify-between whitespace-nowrap rounded-md border px-3 py-2 text-sm hover:cursor-pointer focus:border-neutral-300 focus:outline-none focus:ring-2 focus:ring-neutral-800 focus:ring-offset-1">
|
||||
<Plus className="mr-2 h-4 w-4" />
|
||||
<Tooltip content={t("add_filter")}>
|
||||
<div>{t("add_filter")}</div>
|
||||
</Tooltip>
|
||||
</div>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent className="w-56">
|
||||
{addFilterOptions?.map((option) => (
|
||||
<DropdownMenuItem key={option.label}>
|
||||
<DropdownItem
|
||||
type="button"
|
||||
StartIcon={option.StartIcon}
|
||||
onClick={() => {
|
||||
toggleOption(option);
|
||||
}}>
|
||||
{t(option.label)}
|
||||
</DropdownItem>
|
||||
</DropdownMenuItem>
|
||||
))}
|
||||
</DropdownMenuContent>
|
||||
</Dropdown>
|
||||
)}
|
||||
|
||||
{isPeopleFilterActive && <PeopleFilter />}
|
||||
{isEventTypeFilterActive && <EventTypeFilter />}
|
||||
|
||||
<TeamsFilter />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
import { useState } from "react";
|
||||
|
||||
import { WEBAPP_URL } from "@calcom/lib/constants";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { AnimatedPopover, Avatar } from "@calcom/ui";
|
||||
import { User } from "@calcom/ui/components/icon";
|
||||
|
||||
import { useFilterQuery } from "../lib/useFilterQuery";
|
||||
|
||||
export const PeopleFilter = () => {
|
||||
const { t } = useLocale();
|
||||
const { data: query, pushItemToKey, removeItemByKeyAndValue, removeByKey } = useFilterQuery();
|
||||
const { data } = trpc.viewer.teams.listMembers.useQuery({});
|
||||
const [dropdownTitle, setDropdownTitle] = useState<string>(t("all_users_filter_label"));
|
||||
|
||||
if (!data || !data.length) return null;
|
||||
|
||||
// Get user names from query
|
||||
const userNames = data?.filter((user) => query.userIds?.includes(user.id)).map((user) => user.name);
|
||||
|
||||
return (
|
||||
<AnimatedPopover text={userNames && userNames.length > 0 ? `${userNames.join(", ")}` : dropdownTitle}>
|
||||
<div className="item-center focus-within:bg-subtle hover:bg-muted flex px-4 py-[6px] hover:cursor-pointer">
|
||||
<div className="text-default flex h-6 w-6 items-center justify-center ltr:mr-2 rtl:ml-2">
|
||||
<User className="h-5 w-5" />
|
||||
</div>
|
||||
<label htmlFor="allUsers" className="text-default mr-auto self-center truncate text-sm font-medium">
|
||||
{t("all_users_filter_label")}
|
||||
</label>
|
||||
|
||||
<input
|
||||
id="allUsers"
|
||||
type="checkbox"
|
||||
checked={!query.userIds}
|
||||
onChange={() => {
|
||||
setDropdownTitle(t("all_users_filter_label"));
|
||||
// Always clear userIds on toggle as this is the toggle box for all users. No params means we are currently selecting all users
|
||||
removeByKey("userIds");
|
||||
}}
|
||||
className="text-primary-600 focus:ring-primary-500 border-default inline-flex h-4 w-4 place-self-center justify-self-end rounded "
|
||||
/>
|
||||
</div>
|
||||
{data &&
|
||||
data.map((user) => (
|
||||
<div
|
||||
className="item-center focus-within:bg-subtle hover:bg-muted flex px-4 py-[6px] hover:cursor-pointer"
|
||||
key={`${user.id}`}>
|
||||
<Avatar
|
||||
imageSrc={WEBAPP_URL + `/${user.username}/avatar.png`}
|
||||
size="sm"
|
||||
alt={`${user.name} Avatar`}
|
||||
gravatarFallbackMd5="fallback"
|
||||
className="self-center"
|
||||
asChild
|
||||
/>
|
||||
<label
|
||||
htmlFor={user.name ?? "NamelessUser"}
|
||||
className="text-default ml-2 mr-auto self-center truncate text-sm font-medium hover:cursor-pointer">
|
||||
{user.name}
|
||||
</label>
|
||||
|
||||
<input
|
||||
id={user.name ?? "NamelessUser"}
|
||||
name={user.name ?? "NamelessUser"}
|
||||
type="checkbox"
|
||||
checked={query.userIds?.includes(user.id)}
|
||||
onChange={(e) => {
|
||||
setDropdownTitle(user.name ?? "NamelessUser");
|
||||
if (e.target.checked) {
|
||||
pushItemToKey("userIds", user.id);
|
||||
} else if (!e.target.checked) {
|
||||
removeItemByKeyAndValue("userIds", user.id);
|
||||
}
|
||||
}}
|
||||
className="text-primary-600 focus:ring-primary-500 border-default inline-flex h-4 w-4 place-self-center justify-self-end rounded "
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
</AnimatedPopover>
|
||||
);
|
||||
};
|
||||
@@ -1,116 +0,0 @@
|
||||
import { useSession } from "next-auth/react";
|
||||
import { useState } from "react";
|
||||
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { AnimatedPopover, Avatar } from "@calcom/ui";
|
||||
import { Layers, User } from "@calcom/ui/components/icon";
|
||||
|
||||
import { useFilterQuery } from "../lib/useFilterQuery";
|
||||
|
||||
export const TeamsMemberFilter = () => {
|
||||
const { t } = useLocale();
|
||||
const session = useSession();
|
||||
const {
|
||||
data: query,
|
||||
pushItemToKey,
|
||||
removeItemByKeyAndValue,
|
||||
removeByKey,
|
||||
removeAllQueryParams,
|
||||
} = useFilterQuery();
|
||||
const { data } = trpc.viewer.teams.list.useQuery();
|
||||
const [dropdownTitle, setDropdownTitle] = useState<string>(t("all_bookings_filter_label"));
|
||||
|
||||
if (!data || !data.length) return null;
|
||||
|
||||
// get team names from query
|
||||
const teamNames = data?.filter((team) => query.teamIds?.includes(team.id)).map((team) => team.name);
|
||||
|
||||
return (
|
||||
<AnimatedPopover text={teamNames && teamNames.length > 0 ? `${teamNames.join(", ")}` : dropdownTitle}>
|
||||
<div className="item-center focus-within:bg-subtle hover:bg-muted flex px-4 py-[6px] hover:cursor-pointer">
|
||||
<div className="text-default flex h-6 w-6 items-center justify-center ltr:mr-2 rtl:ml-2">
|
||||
<Layers className="h-5 w-5" />
|
||||
</div>
|
||||
<label
|
||||
htmlFor="allBookings"
|
||||
className="text-default mr-auto self-center truncate text-sm font-medium">
|
||||
{t("all_bookings_filter_label")}
|
||||
</label>
|
||||
|
||||
<input
|
||||
id="allBookings"
|
||||
type="checkbox"
|
||||
checked={!query.teamIds && !query.userIds?.includes(session.data?.user.id || 0)}
|
||||
onChange={() => {
|
||||
setDropdownTitle(t("all_bookings_filter_label"));
|
||||
removeAllQueryParams();
|
||||
}}
|
||||
className="text-primary-600 focus:ring-primary-500 border-default inline-flex h-4 w-4 place-self-center justify-self-end rounded "
|
||||
/>
|
||||
</div>
|
||||
<div className="item-center focus-within:bg-subtle hover:bg-muted flex px-4 py-[6px] hover:cursor-pointer">
|
||||
<div className="text-default flex h-6 w-6 items-center justify-center ltr:mr-2 rtl:ml-2">
|
||||
<User className="h-5 w-5" />
|
||||
</div>
|
||||
<label
|
||||
htmlFor="yourBookings"
|
||||
className="text-default mr-auto self-center truncate text-sm font-medium">
|
||||
{t("your_bookings_filter_label")}
|
||||
</label>
|
||||
|
||||
<input
|
||||
id="yourBookings"
|
||||
type="checkbox"
|
||||
disabled={session.status === "loading"}
|
||||
checked={!!query.userIds?.includes(session.data?.user.id || 0)}
|
||||
onChange={(e) => {
|
||||
setDropdownTitle(t("your_bookings_filter_label"));
|
||||
if (e.target.checked) {
|
||||
pushItemToKey("userIds", session.data?.user.id || 0);
|
||||
} else if (!e.target.checked) {
|
||||
removeItemByKeyAndValue("userIds", session.data?.user.id || 0);
|
||||
}
|
||||
}}
|
||||
className="text-primary-600 focus:ring-primary-500 border-default inline-flex h-4 w-4 place-self-center justify-self-end rounded "
|
||||
/>
|
||||
</div>
|
||||
{data &&
|
||||
data.map((team) => (
|
||||
<div
|
||||
className="item-center focus-within:bg-subtle hover:bg-muted flex px-4 py-[6px] hover:cursor-pointer"
|
||||
key={`${team.id}`}>
|
||||
<Avatar
|
||||
imageSrc={team.logo}
|
||||
size="sm"
|
||||
alt={`${team.name} Avatar`}
|
||||
gravatarFallbackMd5="fallback"
|
||||
className="self-center"
|
||||
asChild
|
||||
/>
|
||||
<label
|
||||
htmlFor={team.name}
|
||||
className="text-default ml-2 mr-auto select-none self-center truncate text-sm font-medium hover:cursor-pointer">
|
||||
{team.name}
|
||||
</label>
|
||||
|
||||
<input
|
||||
id={team.name}
|
||||
name={team.name}
|
||||
type="checkbox"
|
||||
checked={query.teamIds?.includes(team.id)}
|
||||
onChange={(e) => {
|
||||
setDropdownTitle(team.name);
|
||||
if (e.target.checked) {
|
||||
pushItemToKey("teamIds", team.id);
|
||||
} else if (!e.target.checked) {
|
||||
removeItemByKeyAndValue("teamIds", team.id);
|
||||
}
|
||||
}}
|
||||
className="text-primary-600 focus:ring-primary-500 border-default inline-flex h-4 w-4 place-self-center justify-self-end rounded "
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
</AnimatedPopover>
|
||||
);
|
||||
};
|
||||
@@ -37,9 +37,9 @@ export default function BookingLayout({
|
||||
return (
|
||||
<Shell {...rest} hideHeadingOnMobile>
|
||||
<div className="flex max-w-6xl flex-col">
|
||||
<div className="flex flex-col lg:flex-row">
|
||||
<div className="flex flex-col flex-wrap lg:flex-row">
|
||||
<HorizontalTabs tabs={tabs} />
|
||||
<div className="overflow-x-auto lg:ml-auto">
|
||||
<div className="max-w-full overflow-x-auto xl:ml-auto">
|
||||
<FiltersContainer />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -2,13 +2,14 @@ import { useSession } from "next-auth/react";
|
||||
import type { ReactNode, InputHTMLAttributes } from "react";
|
||||
import { forwardRef } from "react";
|
||||
|
||||
import { classNames } from "@calcom/lib";
|
||||
import { getPlaceholderAvatar } from "@calcom/lib/defaultAvatarImage";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { useTypedQuery } from "@calcom/lib/hooks/useTypedQuery";
|
||||
import { teamMetadataSchema } from "@calcom/prisma/zod-utils";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import type { RouterOutputs } from "@calcom/trpc/react";
|
||||
import { AnimatedPopover, Avatar, Divider, VerticalDivider } from "@calcom/ui";
|
||||
import { AnimatedPopover, Avatar, Divider, Tooltip, VerticalDivider } from "@calcom/ui";
|
||||
import { Layers, User } from "@calcom/ui/components/icon";
|
||||
|
||||
import { filterQuerySchema } from "../lib/getTeamsFiltersFromQuery";
|
||||
@@ -68,7 +69,7 @@ export const TeamsFilter = ({
|
||||
onChange={(e) => {
|
||||
removeAllQueryParams();
|
||||
}}
|
||||
label={t("all_apps")}
|
||||
label={t("all")}
|
||||
/>
|
||||
|
||||
<FilterCheckboxField
|
||||
@@ -116,8 +117,19 @@ export const TeamsFilter = ({
|
||||
);
|
||||
};
|
||||
|
||||
export const FilterCheckboxFieldsContainer = ({ children }: { children: ReactNode }) => {
|
||||
return <div className="flex flex-col gap-0.5 [&>*:first-child]:mt-1 [&>*:last-child]:mb-1">{children}</div>;
|
||||
export const FilterCheckboxFieldsContainer = ({
|
||||
children,
|
||||
className,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
className?: string;
|
||||
}) => {
|
||||
return (
|
||||
<div
|
||||
className={classNames("flex flex-col gap-0.5 [&>*:first-child]:mt-1 [&>*:last-child]:mb-1", className)}>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
type Props = InputHTMLAttributes<HTMLInputElement> & {
|
||||
@@ -127,15 +139,17 @@ type Props = InputHTMLAttributes<HTMLInputElement> & {
|
||||
|
||||
export const FilterCheckboxField = forwardRef<HTMLInputElement, Props>(({ label, icon, ...rest }, ref) => {
|
||||
return (
|
||||
<div className="hover:bg-subtle flex items-center py-2 pl-3 pr-2.5 hover:cursor-pointer">
|
||||
<label className="flex w-full items-center justify-between hover:cursor-pointer">
|
||||
<div className="flex items-center">
|
||||
<div className="hover:bg-muted flex items-center py-2 pl-3 pr-2.5 hover:cursor-pointer">
|
||||
<label className="flex w-full max-w-full items-center justify-between hover:cursor-pointer">
|
||||
<div className="flex items-center truncate">
|
||||
<div className="text-default flex h-4 w-4 items-center justify-center ltr:mr-2 rtl:ml-2">
|
||||
{icon}
|
||||
</div>
|
||||
<label htmlFor={rest.id} className="text-default cursor-pointer truncate text-sm font-medium">
|
||||
{label}
|
||||
</label>
|
||||
<Tooltip content={label}>
|
||||
<label htmlFor={rest.id} className="text-default me-1 cursor-pointer truncate text-sm font-medium">
|
||||
{label}
|
||||
</label>
|
||||
</Tooltip>
|
||||
</div>
|
||||
<div className="flex h-5 items-center">
|
||||
<input
|
||||
|
||||
@@ -40,7 +40,8 @@ export const DropdownMenuContent = forwardRef<HTMLDivElement, DropdownMenuConten
|
||||
sideOffset={sideOffset}
|
||||
className={classNames(
|
||||
"shadow-dropdown w-50 bg-default border-subtle relative z-10 ml-1.5 origin-top-right rounded-md border text-sm",
|
||||
"[&>*:first-child]:mt-1 [&>*:last-child]:mb-1"
|
||||
"[&>*:first-child]:mt-1 [&>*:last-child]:mb-1",
|
||||
props.className
|
||||
)}
|
||||
ref={forwardedRef}>
|
||||
{children}
|
||||
|
||||
@@ -16,6 +16,7 @@ export {
|
||||
TextField,
|
||||
InputFieldWithSelect,
|
||||
NumberInput,
|
||||
FilterSearchField,
|
||||
} from "./inputs/Input";
|
||||
export { Label } from "./inputs/Label";
|
||||
export { Select, SelectField, SelectWithValidation, getReactSelectProps } from "./select";
|
||||
|
||||
@@ -8,7 +8,7 @@ import { getErrorFromUnknown } from "@calcom/lib/errors";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
|
||||
import { Alert, showToast, Skeleton, Tooltip, UnstyledSelect } from "../../..";
|
||||
import { Eye, EyeOff, X } from "../../icon";
|
||||
import { Eye, EyeOff, X, Search } from "../../icon";
|
||||
import { HintsOrErrors } from "./HintOrErrors";
|
||||
import { Label } from "./Label";
|
||||
|
||||
@@ -411,3 +411,23 @@ export const NumberInput = forwardRef<HTMLInputElement, InputFieldProps>(functio
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
export const FilterSearchField = forwardRef<HTMLInputElement, InputFieldProps>(function TextField(
|
||||
props,
|
||||
ref
|
||||
) {
|
||||
return (
|
||||
<div
|
||||
dir="ltr"
|
||||
className="focus-within:ring-brand-default group relative mx-3 mb-1 mt-2.5 flex items-center rounded-md focus-within:outline-none focus-within:ring-2">
|
||||
<div className="addon-wrapper border-default [input:hover_+_&]:border-emphasis [input:hover_+_&]:border-l-default [&:has(+_input:hover)]:border-emphasis [&:has(+_input:hover)]:border-r-default flex h-7 items-center justify-center rounded-l-md border border-r-0">
|
||||
<Search className="ms-3 h-4 w-4" />
|
||||
</div>
|
||||
<Input
|
||||
ref={ref}
|
||||
className="disabled:bg-subtle disabled:hover:border-subtle !my-0 h-7 rounded-l-none border-l-0 !ring-0 disabled:cursor-not-allowed"
|
||||
{...props}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
@@ -11,13 +11,17 @@ export const AnimatedPopover = ({
|
||||
count,
|
||||
popoverTriggerClassNames,
|
||||
children,
|
||||
Trigger,
|
||||
defaultOpen,
|
||||
}: {
|
||||
text: string;
|
||||
count?: number;
|
||||
children: React.ReactNode;
|
||||
popoverTriggerClassNames?: string;
|
||||
Trigger?: React.ReactNode;
|
||||
defaultOpen?: boolean;
|
||||
}) => {
|
||||
const [open, setOpen] = React.useState(false);
|
||||
const [open, setOpen] = React.useState(defaultOpen ?? false);
|
||||
const ref = React.useRef<HTMLDivElement>(null);
|
||||
// calculate which aligment to open the popover with based on which half of the screen it is on (left or right)
|
||||
const [align, setAlign] = React.useState<"start" | "end">("start");
|
||||
@@ -42,7 +46,7 @@ export const AnimatedPopover = ({
|
||||
}, [setAlign]);
|
||||
|
||||
return (
|
||||
<Popover.Root onOpenChange={setOpen} modal={true}>
|
||||
<Popover.Root defaultOpen={defaultOpen} onOpenChange={setOpen} modal={true}>
|
||||
<Popover.Trigger asChild>
|
||||
<div
|
||||
ref={ref}
|
||||
@@ -50,19 +54,23 @@ export const AnimatedPopover = ({
|
||||
"hover:border-emphasis border-default text-default hover:text-emphasis radix-state-open:border-emphasis radix-state-open:outline-none radix-state-open:ring-2 radix-state-open:ring-emphasis mb-4 flex h-9 max-h-72 items-center justify-between whitespace-nowrap rounded-md border px-3 py-2 text-sm hover:cursor-pointer",
|
||||
popoverTriggerClassNames
|
||||
)}>
|
||||
<div className="max-w-36 flex items-center">
|
||||
<Tooltip content={text}>
|
||||
<div className="select-none truncate font-medium">
|
||||
{text}
|
||||
{count && count > 0 && (
|
||||
<div className="flex h-4 w-4 items-center justify-center rounded-full">{count}</div>
|
||||
)}
|
||||
</div>
|
||||
</Tooltip>
|
||||
<ChevronDown
|
||||
className={classNames("ml-2 w-4 transition-transform duration-150", open && "rotate-180")}
|
||||
/>
|
||||
</div>
|
||||
{Trigger ? (
|
||||
Trigger
|
||||
) : (
|
||||
<div className="max-w-36 flex items-center">
|
||||
<Tooltip content={text}>
|
||||
<div className="select-none truncate font-medium">
|
||||
{text}
|
||||
{count && count > 0 && (
|
||||
<div className="flex h-4 w-4 items-center justify-center rounded-full">{count}</div>
|
||||
)}
|
||||
</div>
|
||||
</Tooltip>
|
||||
<ChevronDown
|
||||
className={classNames("ml-2 w-4 transition-transform duration-150", open && "rotate-180")}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</Popover.Trigger>
|
||||
<Popover.Content side="bottom" align={align} asChild>
|
||||
|
||||
@@ -36,6 +36,7 @@ export {
|
||||
getReactSelectProps,
|
||||
ColorPicker,
|
||||
FormStep,
|
||||
FilterSearchField,
|
||||
Dropdown,
|
||||
DropdownItem,
|
||||
DropdownMenuContent,
|
||||
|
||||
Reference in new issue
Block a user