calcom/components/ui/AvatarGroup.tsx
Alex van Andel ffdf0b9217
Fixes user availability to be contextual to the user timezone (#1166)
* WIP, WIP, WIP, WIP

* Adds missing types

* Type fixes for useSlots

* Type fixes

* Fixes periodType 500 error when updating

* Adds missing dayjs plugin and type fixes

* An attempt was made to fix tests

* Save work in progress

* Added UTC overflow to days

* Update lib/availability.ts

Co-authored-by: Alex Johansson <alexander@n1s.se>

* No more magic numbers

* Fixed slots.test & added getWorkingHours.test

* Tests pass, simpler logic, profit?

* Timezone shifting!

* Forgot to unskip tests

* Updated the user page

* Added American seed user, some fixes

* tmp fix so to continue testing availability

* Removed timeZone parameter, fix defaultValue auto-scroll

Co-authored-by: Omar López <zomars@me.com>
Co-authored-by: Alex Johansson <alexander@n1s.se>
2021-11-18 01:03:19 +00:00

59 lines
1.9 KiB
TypeScript

import React from "react";
import classNames from "@lib/classNames";
import Avatar from "@components/ui/Avatar";
// import * as Tooltip from "@radix-ui/react-tooltip";
export type AvatarGroupProps = {
size: number;
truncateAfter?: number;
items: {
image: string;
title?: string;
alt?: string;
}[];
className?: string;
};
export const AvatarGroup = function AvatarGroup(props: AvatarGroupProps) {
/* const truncatedAvatars: string[] =
props.items.length > props.truncateAfter
? props.items
.slice(props.truncateAfter)
.map((item) => item.title)
.filter(Boolean)
: [];*/
return (
<ul className={classNames("flex -space-x-2 overflow-hidden", props.className)}>
{props.items.slice(0, props.truncateAfter).map((item, idx) => (
<li key={idx} className="inline-block">
<Avatar imageSrc={item.image} title={item.title} alt={item.alt || ""} size={props.size} />
</li>
))}
{/*props.items.length > props.truncateAfter && (
<li className="relative inline-block">
<Tooltip.Tooltip delayDuration="300">
<Tooltip.TooltipTrigger className="cursor-default">
<span className="w-16 absolute bottom-1.5 border-2 border-gray-300 flex-inline items-center text-white pt-4 text-2xl top-0 rounded-full block bg-neutral-600">+1</span>
</Tooltip.TooltipTrigger>
{truncatedAvatars.length !== 0 && (
<Tooltip.Content className="p-2 text-sm text-white rounded-sm shadow-sm bg-brand">
<Tooltip.Arrow />
<ul>
{truncatedAvatars.map((title) => (
<li key={title}>{title}</li>
))}
</ul>
</Tooltip.Content>
)}
</Tooltip.Tooltip>
</li>
)*/}
</ul>
);
};
export default AvatarGroup;