2021-09-24 17:03:09 +00:00
|
|
|
import { ClockIcon, CreditCardIcon, UserIcon, UsersIcon } from "@heroicons/react/solid";
|
2021-09-22 19:52:38 +00:00
|
|
|
import { SchedulingType } from "@prisma/client";
|
2021-09-22 18:36:13 +00:00
|
|
|
import { Prisma } from "@prisma/client";
|
2021-09-22 19:52:38 +00:00
|
|
|
import React from "react";
|
2021-09-22 18:36:13 +00:00
|
|
|
import { FormattedNumber, IntlProvider } from "react-intl";
|
|
|
|
|
2021-09-22 19:52:38 +00:00
|
|
|
import classNames from "@lib/classNames";
|
2021-10-08 11:43:48 +00:00
|
|
|
import { useLocale } from "@lib/hooks/useLocale";
|
2021-09-22 19:52:38 +00:00
|
|
|
|
2021-09-22 18:36:13 +00:00
|
|
|
const eventTypeData = Prisma.validator<Prisma.EventTypeArgs>()({
|
|
|
|
select: {
|
|
|
|
id: true,
|
|
|
|
length: true,
|
|
|
|
price: true,
|
|
|
|
currency: true,
|
|
|
|
schedulingType: true,
|
|
|
|
description: true,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
type EventType = Prisma.EventTypeGetPayload<typeof eventTypeData>;
|
2021-09-14 08:45:28 +00:00
|
|
|
|
|
|
|
export type EventTypeDescriptionProps = {
|
|
|
|
eventType: EventType;
|
|
|
|
className?: string;
|
|
|
|
};
|
|
|
|
|
2021-10-12 13:11:33 +00:00
|
|
|
export const EventTypeDescription = ({ eventType, className }: EventTypeDescriptionProps) => {
|
|
|
|
const { t } = useLocale();
|
2021-10-08 11:43:48 +00:00
|
|
|
|
2021-09-14 08:45:28 +00:00
|
|
|
return (
|
2021-09-24 17:03:09 +00:00
|
|
|
<>
|
|
|
|
<div className={classNames("text-neutral-500 dark:text-white", className)}>
|
|
|
|
{eventType.description && (
|
2021-12-13 11:01:33 +00:00
|
|
|
<h2 className="opacity-60 text-ellipsis overflow-hidden max-w-[280px] sm:max-w-[500px]">
|
2021-09-24 11:28:57 +00:00
|
|
|
{eventType.description.substring(0, 100)}
|
2021-12-07 10:08:25 +00:00
|
|
|
{eventType.description.length > 100 && "..."}
|
2021-09-24 17:03:09 +00:00
|
|
|
</h2>
|
|
|
|
)}
|
|
|
|
<ul className="flex mt-2 space-x-4 ">
|
|
|
|
<li className="flex whitespace-nowrap">
|
|
|
|
<ClockIcon className="inline mt-0.5 mr-1.5 h-4 w-4 text-neutral-400" aria-hidden="true" />
|
|
|
|
{eventType.length}m
|
|
|
|
</li>
|
|
|
|
{eventType.schedulingType ? (
|
|
|
|
<li className="flex whitespace-nowrap">
|
|
|
|
<UsersIcon className="inline mt-0.5 mr-1.5 h-4 w-4 text-neutral-400" aria-hidden="true" />
|
2021-10-08 11:43:48 +00:00
|
|
|
{eventType.schedulingType === SchedulingType.ROUND_ROBIN && t("round_robin")}
|
|
|
|
{eventType.schedulingType === SchedulingType.COLLECTIVE && t("collective")}
|
2021-09-24 17:03:09 +00:00
|
|
|
</li>
|
|
|
|
) : (
|
|
|
|
<li className="flex whitespace-nowrap">
|
|
|
|
<UserIcon className="inline mt-0.5 mr-1.5 h-4 w-4 text-neutral-400" aria-hidden="true" />
|
2021-10-08 11:43:48 +00:00
|
|
|
{t("1_on_1")}
|
2021-09-24 17:03:09 +00:00
|
|
|
</li>
|
|
|
|
)}
|
|
|
|
{eventType.price > 0 && (
|
|
|
|
<li className="flex whitespace-nowrap">
|
|
|
|
<CreditCardIcon className="inline mt-0.5 mr-1.5 h-4 w-4 text-neutral-400" aria-hidden="true" />
|
|
|
|
<IntlProvider locale="en">
|
|
|
|
<FormattedNumber
|
|
|
|
value={eventType.price / 100.0}
|
|
|
|
style="currency"
|
|
|
|
currency={eventType.currency.toUpperCase()}
|
|
|
|
/>
|
|
|
|
</IntlProvider>
|
|
|
|
</li>
|
|
|
|
)}
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</>
|
2021-09-14 08:45:28 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default EventTypeDescription;
|