Feat/i18n crowdin (#752)

* feat: add crowdin and supported languages

* fix: main branch name

* feat: test crowdin integration

* feat: add crowdin config skeleton

* feat: update crowdin.yml

* fix: remove ro translation

* test: en translation

* test: en translation

* New Crowdin translations by Github Action (#735)

Co-authored-by: Crowdin Bot <[email protected]>

* test: en translation

* fix: separate upload/download workflows

* wip

* New Crowdin translations by Github Action (#738)

Co-authored-by: Crowdin Bot <[email protected]>

* wip

* wip

* wip

* wip

* wip

* typo

* wip

* wip

* update crowdin config

* update

* chore: support i18n de,es,fr,it,pt,ru,ro,en

* chore: extract i18n strings

* chore: extract booking components strings for i18n

* wip

* extract more strings

* wip

* fallback to getServerSideProps for now

* New Crowdin translations by Github Action (#874)

Co-authored-by: Crowdin Bot <[email protected]>

* fix: minor fixes on the datepicker

* fix: add dutch lang

* fix: linting issues

* fix: string

* fix: update GHA

* cleanup trpc

* fix linting

Co-authored-by: Peer Richelsen <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Crowdin Bot <[email protected]>
Co-authored-by: Bailey Pumfleet <[email protected]>
This commit is contained in:
authored and GitHub committed 2021-10-08 14:43:48 +03:00
1 parent 33a683d4b0
commit 2c9b301b77
46 files changed
+2805 -1876

No files matched your search

+11 -4
View File
@@ -5,11 +5,13 @@ import Link from "next/link";
import { useRouter } from "next/router";
import React, { FC } from "react";
import { useLocale } from "@lib/hooks/useLocale";
import { useSlots } from "@lib/hooks/useSlots";
import Loader from "@components/Loader";
type AvailableTimesProps = {
localeProp: string;
workingHours: {
days: number[];
startTime: number;
@@ -27,6 +29,7 @@ type AvailableTimesProps = {
};
const AvailableTimes: FC<AvailableTimesProps> = ({
localeProp,
date,
eventLength,
eventTypeId,
@@ -36,6 +39,7 @@ const AvailableTimes: FC<AvailableTimesProps> = ({
users,
schedulingType,
}) => {
const { t } = useLocale({ localeProp: localeProp });
const router = useRouter();
const { rescheduleUid } = router.query;
@@ -53,8 +57,11 @@ const AvailableTimes: FC<AvailableTimesProps> = ({
<div className="sm:pl-4 mt-8 sm:mt-0 text-center sm:w-1/3 md:-mb-5">
<div className="text-gray-600 font-light text-lg mb-4 text-left">
<span className="w-1/2 dark:text-white text-gray-600">
<strong>{date.format("dddd")}</strong>
<span className="text-gray-500">{date.format(", DD MMMM")}</span>
<strong>{t(date.format("dddd").toLowerCase())}</strong>
<span className="text-gray-500">
{date.format(", DD ")}
{t(date.format("MMMM").toLowerCase())}
</span>
</span>
</div>
<div className="md:max-h-[364px] overflow-y-auto">
@@ -90,7 +97,7 @@ const AvailableTimes: FC<AvailableTimesProps> = ({
})}
{!loading && !error && !slots.length && (
<div className="w-full h-full flex flex-col justify-center content-center items-center -mt-4">
<h1 className="my-6 text-xl text-black dark:text-white">All booked today.</h1>
<h1 className="my-6 text-xl text-black dark:text-white">{t("all_booked_today")}</h1>
</div>
)}
@@ -103,7 +110,7 @@ const AvailableTimes: FC<AvailableTimesProps> = ({
<ExclamationIcon className="h-5 w-5 text-yellow-400" aria-hidden="true" />
</div>
<div className="ml-3">
<p className="text-sm text-yellow-700">Could not load the available time slots.</p>
<p className="text-sm text-yellow-700">{t("slots_load_fail")}</p>
</div>
</div>
</div>
+9 -4
View File
@@ -6,6 +6,7 @@ import utc from "dayjs/plugin/utc";
import { useEffect, useState } from "react";
import classNames from "@lib/classNames";
import { useLocale } from "@lib/hooks/useLocale";
import getSlots from "@lib/slots";
dayjs.extend(dayjsBusinessDays);
@@ -13,6 +14,7 @@ dayjs.extend(utc);
dayjs.extend(timezone);
const DatePicker = ({
localeProp,
weekStart,
onDatePicked,
workingHours,
@@ -26,6 +28,7 @@ const DatePicker = ({
periodCountCalendarDays,
minimumBookingNotice,
}) => {
const { t } = useLocale({ localeProp: localeProp });
const [days, setDays] = useState<({ disabled: boolean; date: number } | null)[]>([]);
const [selectedMonth, setSelectedMonth] = useState<number | null>(
@@ -135,8 +138,10 @@ const DatePicker = ({
}>
<div className="flex text-gray-600 font-light text-xl mb-4">
<span className="w-1/2 text-gray-600 dark:text-white">
<strong className="text-gray-900 dark:text-white">{inviteeDate().format("MMMM")}</strong>
<span className="text-gray-500"> {inviteeDate().format("YYYY")}</span>
<strong className="text-gray-900 dark:text-white">
{t(inviteeDate().format("MMMM").toLowerCase())}
</strong>{" "}
<span className="text-gray-500">{inviteeDate().format("YYYY")}</span>
</span>
<div className="w-1/2 text-right text-gray-600 dark:text-gray-400">
<button
@@ -153,11 +158,11 @@ const DatePicker = ({
</div>
</div>
<div className="grid grid-cols-7 gap-4 text-center border-b border-t dark:border-gray-800 sm:border-0">
{["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
{["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
.sort((a, b) => (weekStart.startsWith(a) ? -1 : weekStart.startsWith(b) ? 1 : 0))
.map((weekDay) => (
<div key={weekDay} className="uppercase text-gray-500 text-xs tracking-widest my-4">
{weekDay}
{t(weekDay.toLowerCase()).substring(0, 3)}
</div>
))}
</div>
+7 -4
View File
@@ -4,10 +4,12 @@ import { FC, useEffect, useState } from "react";
import TimezoneSelect, { ITimezoneOption } from "react-timezone-select";
import classNames from "@lib/classNames";
import { useLocale } from "@lib/hooks/useLocale";
import { is24h, timeZone } from "../../lib/clock";
type Props = {
localeProp: string;
onSelectTimeZone: (selectedTimeZone: string) => void;
onToggle24hClock: (is24hClock: boolean) => void;
};
@@ -15,6 +17,7 @@ type Props = {
const TimeOptions: FC<Props> = (props) => {
const [selectedTimeZone, setSelectedTimeZone] = useState("");
const [is24hClock, setIs24hClock] = useState(false);
const { t } = useLocale({ localeProp: props.localeProp });
useEffect(() => {
setIs24hClock(is24h());
@@ -35,11 +38,11 @@ const TimeOptions: FC<Props> = (props) => {
return selectedTimeZone !== "" ? (
<div className="absolute z-10 w-full max-w-80 rounded-sm border border-gray-200 dark:bg-gray-700 dark:border-0 bg-white px-4 py-2">
<div className="flex mb-4">
<div className="w-1/2 dark:text-white text-gray-600 font-medium">Time Options</div>
<div className="w-1/2 dark:text-white text-gray-600 font-medium">{t("time_options")}</div>
<div className="w-1/2">
<Switch.Group as="div" className="flex items-center justify-end">
<Switch.Label as="span" className="mr-3">
<span className="text-sm dark:text-white text-gray-500">am/pm</span>
<span className="text-sm dark:text-white text-gray-500">{t("am_pm")}</span>
</Switch.Label>
<Switch
checked={is24hClock}
@@ -48,7 +51,7 @@ const TimeOptions: FC<Props> = (props) => {
is24hClock ? "bg-black" : "dark:bg-gray-600 bg-gray-200",
"relative inline-flex flex-shrink-0 h-5 w-8 border-2 border-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-black"
)}>
<span className="sr-only">Use setting</span>
<span className="sr-only">{t("use_setting")}</span>
<span
aria-hidden="true"
className={classNames(
@@ -58,7 +61,7 @@ const TimeOptions: FC<Props> = (props) => {
/>
</Switch>
<Switch.Label as="span" className="ml-3">
<span className="text-sm dark:text-white text-gray-500">24h</span>
<span className="text-sm dark:text-white text-gray-500">{t("24_h")}</span>
</Switch.Label>
</Switch.Group>
</div>
+14 -6
View File
@@ -10,6 +10,7 @@ import { FormattedNumber, IntlProvider } from "react-intl";
import { asStringOrNull } from "@lib/asStringOrNull";
import { timeZone } from "@lib/clock";
import { useLocale } from "@lib/hooks/useLocale";
import useTheme from "@lib/hooks/useTheme";
import { isBrandingHidden } from "@lib/isBrandingHidden";
import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@lib/telemetry";
@@ -29,10 +30,11 @@ dayjs.extend(customParseFormat);
type Props = AvailabilityTeamPageProps | AvailabilityPageProps;
const AvailabilityPage = ({ profile, eventType, workingHours }: Props) => {
const AvailabilityPage = ({ profile, eventType, workingHours, localeProp }: Props) => {
const router = useRouter();
const { rescheduleUid } = router.query;
const { isReady } = useTheme(profile.theme);
const { t, locale } = useLocale({ localeProp });
const selectedDate = useMemo(() => {
const dateString = asStringOrNull(router.query.date);
@@ -88,8 +90,8 @@ const AvailabilityPage = ({ profile, eventType, workingHours }: Props) => {
return (
<>
<HeadSeo
title={`${rescheduleUid ? "Reschedule" : ""} ${eventType.title} | ${profile.name}`}
description={`${rescheduleUid ? "Reschedule" : ""} ${eventType.title}`}
title={`${rescheduleUid ? t("reschedule") : ""} ${eventType.title} | ${profile.name}`}
description={`${rescheduleUid ? t("reschedule") : ""} ${eventType.title}`}
name={profile.name}
avatar={profile.image}
/>
@@ -122,7 +124,7 @@ const AvailabilityPage = ({ profile, eventType, workingHours }: Props) => {
{eventType.title}
<div>
<ClockIcon className="inline-block w-4 h-4 mr-1 -mt-1" />
{eventType.length} minutes
{eventType.length} {t("minutes")}
</div>
{eventType.price > 0 && (
<div>
@@ -166,7 +168,7 @@ const AvailabilityPage = ({ profile, eventType, workingHours }: Props) => {
</h1>
<p className="px-2 py-1 mb-1 -ml-2 text-gray-500">
<ClockIcon className="inline-block w-4 h-4 mr-1 -mt-1" />
{eventType.length} minutes
{eventType.length} {t("minutes")}
</p>
{eventType.price > 0 && (
<p className="px-2 py-1 mb-1 -ml-2 text-gray-500">
@@ -186,6 +188,7 @@ const AvailabilityPage = ({ profile, eventType, workingHours }: Props) => {
<p className="mt-3 mb-8 text-gray-600 dark:text-gray-200">{eventType.description}</p>
</div>
<DatePicker
localeProp={locale}
date={selectedDate}
periodType={eventType?.periodType}
periodStartDate={eventType?.periodStartDate}
@@ -205,6 +208,7 @@ const AvailabilityPage = ({ profile, eventType, workingHours }: Props) => {
{selectedDate && (
<AvailableTimes
localeProp={locale}
workingHours={workingHours}
timeFormat={timeFormat}
minimumBookingNotice={eventType.minimumBookingNotice}
@@ -237,7 +241,11 @@ const AvailabilityPage = ({ profile, eventType, workingHours }: Props) => {
)}
</Collapsible.Trigger>
<Collapsible.Content>
<TimeOptions onSelectTimeZone={handleSelectTimeZone} onToggle24hClock={handleToggle24hClock} />
<TimeOptions
localeProp={locale}
onSelectTimeZone={handleSelectTimeZone}
onToggle24hClock={handleToggle24hClock}
/>
</Collapsible.Content>
</Collapsible.Root>
);
+31 -21
View File
@@ -20,6 +20,7 @@ import { createPaymentLink } from "@ee/lib/stripe/client";
import { asStringOrNull } from "@lib/asStringOrNull";
import { timeZone } from "@lib/clock";
import { useLocale } from "@lib/hooks/useLocale";
import useTheme from "@lib/hooks/useTheme";
import { LocationType } from "@lib/location";
import createBooking from "@lib/mutations/bookings/create-booking";
@@ -36,6 +37,7 @@ import { TeamBookingPageProps } from "../../../pages/team/[slug]/book";
type BookingPageProps = BookPageProps | TeamBookingPageProps;
const BookingPage = (props: BookingPageProps) => {
const { t } = useLocale({ localeProp: props.localeProp });
const router = useRouter();
const { rescheduleUid } = router.query;
const { isReady } = useTheme(props.profile.theme);
@@ -67,8 +69,8 @@ const BookingPage = (props: BookingPageProps) => {
// TODO: Move to translations
const locationLabels = {
[LocationType.InPerson]: "Link or In-person meeting",
[LocationType.Phone]: "Phone call",
[LocationType.InPerson]: t("in_person_meeting"),
[LocationType.Phone]: t("phone_call"),
[LocationType.GoogleMeet]: "Google Meet",
[LocationType.Zoom]: "Zoom Video",
[LocationType.Daily]: "Daily.co Video",
@@ -85,7 +87,7 @@ const BookingPage = (props: BookingPageProps) => {
const data = event.target["custom_" + input.id];
if (data) {
if (input.type === EventTypeCustomInputType.BOOL) {
return input.label + "\n" + (data.checked ? "Yes" : "No");
return input.label + "\n" + (data.checked ? t("yes") : t("no"));
} else {
return input.label + "\n" + data.value;
}
@@ -94,7 +96,7 @@ const BookingPage = (props: BookingPageProps) => {
.join("\n\n");
}
if (!!notes && !!event.target.notes.value) {
notes += "\n\nAdditional notes:\n" + event.target.notes.value;
notes += `\n\n${t("additional_notes")}:\n` + event.target.notes.value;
} else {
notes += event.target.notes.value;
}
@@ -185,8 +187,16 @@ const BookingPage = (props: BookingPageProps) => {
<div>
<Head>
<title>
{rescheduleUid ? "Reschedule" : "Confirm"} your {props.eventType.title} with {props.profile.name} |
Cal.com
{rescheduleUid
? t("booking_reschedule_confirmation", {
eventTypeTitle: props.eventType.title,
profileName: props.profile.name,
})
: t("booking_confirmation", {
eventTypeTitle: props.eventType.title,
profileName: props.profile.name,
})}{" "}
| Cal.com
</title>
<link rel="icon" href="/favicon.ico" />
</Head>
@@ -215,7 +225,7 @@ const BookingPage = (props: BookingPageProps) => {
</h1>
<p className="mb-2 text-gray-500">
<ClockIcon className="inline-block w-4 h-4 mr-1 -mt-1" />
{props.eventType.length} minutes
{props.eventType.length} {t("minutes")}
</p>
{props.eventType.price > 0 && (
<p className="px-2 py-1 mb-1 -ml-2 text-gray-500">
@@ -244,8 +254,8 @@ const BookingPage = (props: BookingPageProps) => {
<div className="sm:w-1/2 sm:pl-8 sm:pr-4">
<form onSubmit={bookingHandler}>
<div className="mb-4">
<label htmlFor="name" className="block text-sm font-medium text-gray-700 dark:text-white">
Your name
<label htmlFor="name" className="block text-sm font-medium dark:text-white text-gray-700">
{t("your_name")}
</label>
<div className="mt-1">
<input
@@ -262,8 +272,8 @@ const BookingPage = (props: BookingPageProps) => {
<div className="mb-4">
<label
htmlFor="email"
className="block text-sm font-medium text-gray-700 dark:text-white">
Email address
className="block text-sm font-medium dark:text-white text-gray-700">
{t("email_address")}
</label>
<div className="mt-1">
<input
@@ -281,7 +291,7 @@ const BookingPage = (props: BookingPageProps) => {
{locations.length > 1 && (
<div className="mb-4">
<span className="block text-sm font-medium text-gray-700 dark:text-white">
Location
{t("location")}
</span>
{locations.map((location) => (
<label key={location.type} className="block">
@@ -306,12 +316,12 @@ const BookingPage = (props: BookingPageProps) => {
<label
htmlFor="phone"
className="block text-sm font-medium text-gray-700 dark:text-white">
Phone Number
{t("phone_number")}
</label>
<div className="mt-1">
<PhoneInput
name="phone"
placeholder="Enter phone number"
placeholder={t("enter_phone_number")}
id="phone"
required
className="block w-full border-gray-300 rounded-md shadow-sm dark:bg-black dark:text-white dark:border-gray-900 focus:ring-black focus:border-black sm:text-sm"
@@ -390,7 +400,7 @@ const BookingPage = (props: BookingPageProps) => {
onClick={toggleGuestEmailInput}
htmlFor="guests"
className="block mb-1 text-sm font-medium text-blue-500 dark:text-white hover:cursor-pointer">
+ Additional Guests
{t("additional_guests")}
</label>
)}
{guestToggle && (
@@ -430,24 +440,24 @@ const BookingPage = (props: BookingPageProps) => {
<label
htmlFor="notes"
className="block mb-1 text-sm font-medium text-gray-700 dark:text-white">
Additional notes
{t("additional_notes")}
</label>
<textarea
name="notes"
id="notes"
rows={3}
className="block w-full border-gray-300 rounded-md shadow-sm dark:bg-black dark:text-white dark:border-gray-900 focus:ring-black focus:border-black sm:text-sm"
placeholder="Please share anything that will help prepare for our meeting."
className="shadow-sm dark:bg-black dark:text-white dark:border-gray-900 focus:ring-black focus:border-black block w-full sm:text-sm border-gray-300 rounded-md"
placeholder={t("share_additional_notes")}
defaultValue={props.booking ? props.booking.description : ""}
/>
</div>
<div className="flex items-start space-x-2">
{/* TODO: add styling props to <Button variant="" color="" /> and get rid of btn-primary */}
<Button type="submit" loading={loading}>
{rescheduleUid ? "Reschedule" : "Confirm"}
{rescheduleUid ? t("reschedule") : t("confirm")}
</Button>
<Button color="secondary" type="button" onClick={() => router.back()}>
Cancel
{t("cancel")}
</Button>
</div>
</form>
@@ -459,7 +469,7 @@ const BookingPage = (props: BookingPageProps) => {
</div>
<div className="ml-3">
<p className="text-sm text-yellow-700">
Could not {rescheduleUid ? "reschedule" : "book"} the meeting.
{rescheduleUid ? t("reschedule_fail") : t("booking_fail")}
</p>
</div>
</div>
@@ -3,10 +3,13 @@ import { CheckIcon } from "@heroicons/react/solid";
import * as DialogPrimitive from "@radix-ui/react-dialog";
import React, { PropsWithChildren } from "react";
import { useLocale } from "@lib/hooks/useLocale";
import { DialogClose, DialogContent } from "@components/Dialog";
import { Button } from "@components/ui/Button";
export type ConfirmationDialogContentProps = {
localeProp: string;
confirmBtnText?: string;
cancelBtnText?: string;
onConfirm?: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
@@ -15,7 +18,15 @@ export type ConfirmationDialogContentProps = {
};
export default function ConfirmationDialogContent(props: PropsWithChildren<ConfirmationDialogContentProps>) {
const { title, variety, confirmBtnText = "Confirm", cancelBtnText = "Cancel", onConfirm, children } = props;
const { t } = useLocale({ localeProp: props.localeProp });
const {
title,
variety,
confirmBtnText = t("confirm"),
cancelBtnText = t("cancel"),
onConfirm,
children,
} = props;
return (
<DialogContent>
@@ -5,6 +5,7 @@ import React from "react";
import { FormattedNumber, IntlProvider } from "react-intl";
import classNames from "@lib/classNames";
import { useLocale } from "@lib/hooks/useLocale";
const eventTypeData = Prisma.validator<Prisma.EventTypeArgs>()({
select: {
@@ -20,11 +21,14 @@ const eventTypeData = Prisma.validator<Prisma.EventTypeArgs>()({
type EventType = Prisma.EventTypeGetPayload<typeof eventTypeData>;
export type EventTypeDescriptionProps = {
localeProp: string;
eventType: EventType;
className?: string;
};
export const EventTypeDescription = ({ eventType, className }: EventTypeDescriptionProps) => {
export const EventTypeDescription = ({ localeProp, eventType, className }: EventTypeDescriptionProps) => {
const { t } = useLocale({ localeProp });
return (
<>
<div className={classNames("text-neutral-500 dark:text-white", className)}>
@@ -41,13 +45,13 @@ export const EventTypeDescription = ({ eventType, className }: EventTypeDescript
{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" />
{eventType.schedulingType === SchedulingType.ROUND_ROBIN && "Round Robin"}
{eventType.schedulingType === SchedulingType.COLLECTIVE && "Collective"}
{eventType.schedulingType === SchedulingType.ROUND_ROBIN && t("round_robin")}
{eventType.schedulingType === SchedulingType.COLLECTIVE && t("collective")}
</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" />
1-on-1
{t("1_on_1")}
</li>
)}
{eventType.price > 0 && (
+19 -18
View File
@@ -1,21 +1,22 @@
import React, { SyntheticEvent, useState } from "react";
import { ErrorCode } from "@lib/auth";
import { useLocale } from "@lib/hooks/useLocale";
import Modal from "@components/Modal";
const errorMessages: { [key: string]: string } = {
[ErrorCode.IncorrectPassword]: "Current password is incorrect",
[ErrorCode.NewPasswordMatchesOld]:
"New password matches your old password. Please choose a different password.",
};
const ChangePasswordSection = () => {
const ChangePasswordSection = ({ localeProp }: { localeProp: string }) => {
const [oldPassword, setOldPassword] = useState("");
const [newPassword, setNewPassword] = useState("");
const [successModalOpen, setSuccessModalOpen] = useState(false);
const [errorMessage, setErrorMessage] = useState<string | null>(null);
const [isSubmitting, setIsSubmitting] = useState(false);
const { t } = useLocale({ localeProp });
const errorMessages: { [key: string]: string } = {
[ErrorCode.IncorrectPassword]: t("current_incorrect_password"),
[ErrorCode.NewPasswordMatchesOld]: t("new_password_matches_old_password"),
};
const closeSuccessModal = () => {
setSuccessModalOpen(false);
@@ -48,10 +49,10 @@ const ChangePasswordSection = () => {
}
const body = await response.json();
setErrorMessage(errorMessages[body.error] || "Something went wrong. Please try again");
setErrorMessage(errorMessages[body.error] || `${t("something_went_wrong")}${t("please_try_again")}`);
} catch (err) {
console.error("Error changing password", err);
setErrorMessage("Something went wrong. Please try again");
console.error(t("error_changing_password"), err);
setErrorMessage(`${t("something_went_wrong")}${t("please_try_again")}`);
} finally {
setIsSubmitting(false);
}
@@ -60,14 +61,14 @@ const ChangePasswordSection = () => {
return (
<>
<div className="mt-6">
<h2 className="font-cal text-lg leading-6 font-medium text-gray-900">Change Password</h2>
<h2 className="font-cal text-lg leading-6 font-medium text-gray-900">{t("change_password")}</h2>
</div>
<form className="divide-y divide-gray-200 lg:col-span-9" onSubmit={changePasswordHandler}>
<div className="py-6 lg:pb-8">
<div className="flex">
<div className="w-1/2 mr-2">
<label htmlFor="current_password" className="block text-sm font-medium text-gray-700">
Current Password
{t("current_password")}
</label>
<div className="mt-1">
<input
@@ -78,13 +79,13 @@ const ChangePasswordSection = () => {
id="current_password"
required
className="shadow-sm focus:ring-black focus:border-black block w-full sm:text-sm border-gray-300 rounded-sm"
placeholder="Your old password"
placeholder={t("your_old_password")}
/>
</div>
</div>
<div className="w-1/2 ml-2">
<label htmlFor="new_password" className="block text-sm font-medium text-gray-700">
New Password
{t("new_password")}
</label>
<div className="mt-1">
<input
@@ -95,7 +96,7 @@ const ChangePasswordSection = () => {
required
onInput={(e) => setNewPassword(e.currentTarget.value)}
className="shadow-sm focus:ring-black focus:border-black block w-full sm:text-sm border-gray-300 rounded-sm"
placeholder="Your super secure new password"
placeholder={t("super_secure_new_password")}
/>
</div>
</div>
@@ -105,15 +106,15 @@ const ChangePasswordSection = () => {
<button
type="submit"
className="ml-2 bg-neutral-900 border border-transparent rounded-sm shadow-sm py-2 px-4 inline-flex justify-center text-sm font-medium text-white hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-black">
Save
{t("save")}
</button>
</div>
<hr className="mt-4" />
</div>
</form>
<Modal
heading="Password updated successfully"
description="Your password has been successfully changed."
heading={t("password_updated_successfully")}
description={t("password_has_been_changed")}
open={successModalOpen}
handleClose={closeSuccessModal}
/>
+12 -12
View File
@@ -1,6 +1,7 @@
import { SyntheticEvent, useState } from "react";
import { ErrorCode } from "@lib/auth";
import { useLocale } from "@lib/hooks/useLocale";
import { Dialog, DialogContent } from "@components/Dialog";
import Button from "@components/ui/Button";
@@ -18,12 +19,14 @@ interface DisableTwoFactorAuthModalProps {
* Called when the user disables two-factor auth
*/
onDisable: () => void;
localeProp: string;
}
const DisableTwoFactorAuthModal = ({ onDisable, onCancel }: DisableTwoFactorAuthModalProps) => {
const DisableTwoFactorAuthModal = ({ onDisable, onCancel, localeProp }: DisableTwoFactorAuthModalProps) => {
const [password, setPassword] = useState("");
const [isDisabling, setIsDisabling] = useState(false);
const [errorMessage, setErrorMessage] = useState<string | null>(null);
const { t } = useLocale({ localeProp });
async function handleDisable(e: SyntheticEvent) {
e.preventDefault();
@@ -43,13 +46,13 @@ const DisableTwoFactorAuthModal = ({ onDisable, onCancel }: DisableTwoFactorAuth
const body = await response.json();
if (body.error === ErrorCode.IncorrectPassword) {
setErrorMessage("Password is incorrect.");
setErrorMessage(t("incorrect_password"));
} else {
setErrorMessage("Something went wrong.");
setErrorMessage(t("something_went_wrong"));
}
} catch (e) {
setErrorMessage("Something went wrong.");
console.error("Error disabling two-factor authentication", e);
setErrorMessage(t("something_went_wrong"));
console.error(t("error_disabling_2fa"), e);
} finally {
setIsDisabling(false);
}
@@ -58,15 +61,12 @@ const DisableTwoFactorAuthModal = ({ onDisable, onCancel }: DisableTwoFactorAuth
return (
<Dialog open={true}>
<DialogContent>
<TwoFactorModalHeader
title="Disable two-factor authentication"
description="If you need to disable 2FA, we recommend re-enabling it as soon as possible."
/>
<TwoFactorModalHeader title={t("disable_2fa")} description={t("disable_2fa_recommendation")} />
<form onSubmit={handleDisable}>
<div className="mb-4">
<label htmlFor="password" className="mt-4 block text-sm font-medium text-gray-700">
Password
{t("password")}
</label>
<div className="mt-1">
<input
@@ -90,10 +90,10 @@ const DisableTwoFactorAuthModal = ({ onDisable, onCancel }: DisableTwoFactorAuth
className="ml-2"
onClick={handleDisable}
disabled={password.length === 0 || isDisabling}>
Disable
{t("disable")}
</Button>
<Button color="secondary" onClick={onCancel}>
Cancel
{t("cancel")}
</Button>
</div>
</DialogContent>
+19 -19
View File
@@ -1,6 +1,7 @@
import React, { SyntheticEvent, useState } from "react";
import { ErrorCode } from "@lib/auth";
import { useLocale } from "@lib/hooks/useLocale";
import { Dialog, DialogContent } from "@components/Dialog";
import Button from "@components/ui/Button";
@@ -18,6 +19,7 @@ interface EnableTwoFactorModalProps {
* Called when the user enables two-factor auth
*/
onEnable: () => void;
localeProp: string;
}
enum SetupStep {
@@ -45,7 +47,7 @@ const WithStep = ({
return step === current ? children : null;
};
const EnableTwoFactorModal = ({ onEnable, onCancel }: EnableTwoFactorModalProps) => {
const EnableTwoFactorModal = ({ onEnable, onCancel, localeProp }: EnableTwoFactorModalProps) => {
const [step, setStep] = useState(SetupStep.ConfirmPassword);
const [password, setPassword] = useState("");
const [totpCode, setTotpCode] = useState("");
@@ -53,6 +55,7 @@ const EnableTwoFactorModal = ({ onEnable, onCancel }: EnableTwoFactorModalProps)
const [secret, setSecret] = useState("");
const [isSubmitting, setIsSubmitting] = useState(false);
const [errorMessage, setErrorMessage] = useState<string | null>(null);
const { t } = useLocale({ localeProp });
async function handleSetup(e: SyntheticEvent) {
e.preventDefault();
@@ -76,13 +79,13 @@ const EnableTwoFactorModal = ({ onEnable, onCancel }: EnableTwoFactorModalProps)
}
if (body.error === ErrorCode.IncorrectPassword) {
setErrorMessage("Password is incorrect.");
setErrorMessage(t("incorrect_password"));
} else {
setErrorMessage("Something went wrong.");
setErrorMessage(t("something_went_wrong"));
}
} catch (e) {
setErrorMessage("Something went wrong.");
console.error("Error setting up two-factor authentication", e);
setErrorMessage(t("something_went_wrong"));
console.error(t("error_enabling_2fa"), e);
} finally {
setIsSubmitting(false);
}
@@ -108,13 +111,13 @@ const EnableTwoFactorModal = ({ onEnable, onCancel }: EnableTwoFactorModalProps)
}
if (body.error === ErrorCode.IncorrectTwoFactorCode) {
setErrorMessage("Code is incorrect. Please try again.");
setErrorMessage(`${t("code_is_incorrect")} ${t("please_try_again")}`);
} else {
setErrorMessage("Something went wrong.");
setErrorMessage(t("something_went_wrong"));
}
} catch (e) {
setErrorMessage("Something went wrong.");
console.error("Error enabling up two-factor authentication", e);
setErrorMessage(t("something_went_wrong"));
console.error(t("error_enabling_2fa"), e);
} finally {
setIsSubmitting(false);
}
@@ -123,16 +126,13 @@ const EnableTwoFactorModal = ({ onEnable, onCancel }: EnableTwoFactorModalProps)
return (
<Dialog open={true}>
<DialogContent>
<TwoFactorModalHeader
title="Enable two-factor authentication"
description={setupDescriptions[step]}
/>
<TwoFactorModalHeader title={t("enable_2fa")} description={setupDescriptions[step]} />
<WithStep step={SetupStep.ConfirmPassword} current={step}>
<form onSubmit={handleSetup}>
<div className="mb-4">
<label htmlFor="password" className="mt-4 block text-sm font-medium text-gray-700">
Password
{t("password")}
</label>
<div className="mt-1">
<input
@@ -162,7 +162,7 @@ const EnableTwoFactorModal = ({ onEnable, onCancel }: EnableTwoFactorModalProps)
<form onSubmit={handleEnable}>
<div className="mb-4">
<label htmlFor="code" className="mt-4 block text-sm font-medium text-gray-700">
Code
{t("code")}
</label>
<div className="mt-1">
<input
@@ -191,12 +191,12 @@ const EnableTwoFactorModal = ({ onEnable, onCancel }: EnableTwoFactorModalProps)
className="ml-2"
onClick={handleSetup}
disabled={password.length === 0 || isSubmitting}>
Continue
{t("continue")}
</Button>
</WithStep>
<WithStep step={SetupStep.DisplayQrCode} current={step}>
<Button type="submit" className="ml-2" onClick={() => setStep(SetupStep.EnterTotpCode)}>
Continue
{t("continue")}
</Button>
</WithStep>
<WithStep step={SetupStep.EnterTotpCode} current={step}>
@@ -205,11 +205,11 @@ const EnableTwoFactorModal = ({ onEnable, onCancel }: EnableTwoFactorModalProps)
className="ml-2"
onClick={handleEnable}
disabled={totpCode.length !== 6 || isSubmitting}>
Enable
{t("enable")}
</Button>
</WithStep>
<Button color="secondary" onClick={onCancel}>
Cancel
{t("cancel")}
</Button>
</div>
</DialogContent>
+15 -6
View File
@@ -1,37 +1,45 @@
import { useState } from "react";
import { useLocale } from "@lib/hooks/useLocale";
import Badge from "@components/ui/Badge";
import Button from "@components/ui/Button";
import DisableTwoFactorModal from "./DisableTwoFactorModal";
import EnableTwoFactorModal from "./EnableTwoFactorModal";
const TwoFactorAuthSection = ({ twoFactorEnabled }: { twoFactorEnabled: boolean }) => {
const TwoFactorAuthSection = ({
twoFactorEnabled,
localeProp,
}: {
twoFactorEnabled: boolean;
localeProp: string;
}) => {
const [enabled, setEnabled] = useState(twoFactorEnabled);
const [enableModalOpen, setEnableModalOpen] = useState(false);
const [disableModalOpen, setDisableModalOpen] = useState(false);
const { t, locale } = useLocale({ localeProp });
return (
<>
<div className="flex flex-row items-center">
<h2 className="font-cal text-lg leading-6 font-medium text-gray-900">Two-Factor Authentication</h2>
<h2 className="font-cal text-lg leading-6 font-medium text-gray-900">{t("2fa")}</h2>
<Badge className="text-xs ml-2" variant={enabled ? "success" : "gray"}>
{enabled ? "Enabled" : "Disabled"}
</Badge>
</div>
<p className="mt-1 text-sm text-gray-500">
Add an extra layer of security to your account in case your password is stolen.
</p>
<p className="mt-1 text-sm text-gray-500">{t("add_an_extra_layer_of_security")}</p>
<Button
className="mt-6"
type="submit"
onClick={() => (enabled ? setDisableModalOpen(true) : setEnableModalOpen(true))}>
{enabled ? "Disable" : "Enable"} Two-Factor Authentication
{enabled ? "Disable" : "Enable"} {t("2fa")}
</Button>
{enableModalOpen && (
<EnableTwoFactorModal
localeProp={locale}
onEnable={() => {
setEnabled(true);
setEnableModalOpen(false);
@@ -42,6 +50,7 @@ const TwoFactorAuthSection = ({ twoFactorEnabled }: { twoFactorEnabled: boolean
{disableModalOpen && (
<DisableTwoFactorModal
localeProp={locale}
onDisable={() => {
setEnabled(false);
setDisableModalOpen(false);
+44 -28
View File
@@ -1,6 +1,7 @@
import { ArrowLeftIcon, PlusIcon, TrashIcon } from "@heroicons/react/outline";
import React, { useEffect, useRef, useState } from "react";
import { useLocale } from "@lib/hooks/useLocale";
import { Member } from "@lib/member";
import { Team } from "@lib/team";
@@ -16,7 +17,11 @@ import ErrorAlert from "@components/ui/alerts/Error";
import MemberList from "./MemberList";
export default function EditTeam(props: { team: Team | undefined | null; onCloseEdit: () => void }) {
export default function EditTeam(props: {
localeProp: string;
team: Team | undefined | null;
onCloseEdit: () => void;
}) {
const [members, setMembers] = useState([]);
const nameRef = useRef<HTMLInputElement>() as React.MutableRefObject<HTMLInputElement>;
@@ -30,6 +35,7 @@ export default function EditTeam(props: { team: Team | undefined | null; onClose
const [inviteModalTeam, setInviteModalTeam] = useState<Team | null | undefined>();
const [errorMessage, setErrorMessage] = useState("");
const [imageSrc, setImageSrc] = useState<string>("");
const { t, locale } = useLocale({ localeProp: props.localeProp });
const loadMembers = () =>
fetch("/api/teams/" + props.team?.id + "/membership")
@@ -132,19 +138,19 @@ export default function EditTeam(props: { team: Team | undefined | null; onClose
size="sm"
StartIcon={ArrowLeftIcon}
onClick={() => props.onCloseEdit()}>
Back
{t("back")}
</Button>
</div>
<div>
<div className="pb-5 pr-4 sm:pb-6">
<h3 className="text-lg font-bold leading-6 text-gray-900">{props.team?.name}</h3>
<div className="max-w-xl mt-2 text-sm text-gray-500">
<p>Manage your team</p>
<p>{t("manage_your_team")}</p>
</div>
</div>
</div>
<hr className="mt-2" />
<h3 className="font-cal font-bold leading-6 text-gray-900 mt-7 text-md">Profile</h3>
<h3 className="font-cal font-bold leading-6 text-gray-900 mt-7 text-md">{t("profile")}</h3>
<form className="divide-y divide-gray-200 lg:col-span-9" onSubmit={updateTeamHandler}>
{hasErrors && <ErrorAlert message={errorMessage} />}
<div className="py-6 lg:pb-8">
@@ -152,18 +158,22 @@ export default function EditTeam(props: { team: Team | undefined | null; onClose
<div className="flex-grow space-y-6">
<div className="block sm:flex">
<div className="w-full mb-6 sm:w-1/2 sm:mr-2">
<UsernameInput ref={teamUrlRef} defaultValue={props.team?.slug} label={"My team URL"} />
<UsernameInput
ref={teamUrlRef}
defaultValue={props.team?.slug}
label={t("my_team_url")}
/>
</div>
<div className="w-full sm:w-1/2 sm:ml-2">
<label htmlFor="name" className="block text-sm font-medium text-gray-700">
Team name
{t("team_name")}
</label>
<input
ref={nameRef}
type="text"
name="name"
id="name"
placeholder="Your team name"
placeholder={t("your_team_name")}
required
className="block w-full px-3 py-2 mt-1 border border-gray-300 rounded-sm shadow-sm focus:outline-none focus:ring-neutral-500 focus:border-neutral-500 sm:text-sm"
defaultValue={props.team?.name}
@@ -172,7 +182,7 @@ export default function EditTeam(props: { team: Team | undefined | null; onClose
</div>
<div>
<label htmlFor="about" className="block text-sm font-medium text-gray-700">
About
{t("about")}
</label>
<div className="mt-1">
<textarea
@@ -182,9 +192,7 @@ export default function EditTeam(props: { team: Team | undefined | null; onClose
rows={3}
defaultValue={props.team?.bio}
className="block w-full mt-1 border-gray-300 rounded-sm shadow-sm focus:ring-neutral-500 focus:border-neutral-500 sm:text-sm"></textarea>
<p className="mt-2 text-sm text-gray-500">
A few sentences about your team. This will appear on your team&apos;s URL page.
</p>
<p className="mt-2 text-sm text-gray-500">{t("team_description")}</p>
</div>
</div>
<div>
@@ -206,7 +214,7 @@ export default function EditTeam(props: { team: Team | undefined | null; onClose
<ImageUploader
target="logo"
id="logo-upload"
buttonMsg={imageSrc !== "" ? "Edit logo" : "Upload a logo"}
buttonMsg={imageSrc !== "" ? t("edit_logo") : t("upload_a_logo")}
handleAvatarChange={handleLogoChange}
imageSrc={imageSrc ?? props.team?.logo}
/>
@@ -214,20 +222,25 @@ export default function EditTeam(props: { team: Team | undefined | null; onClose
<hr className="mt-6" />
</div>
<div className="flex justify-between mt-7">
<h3 className="font-cal font-bold leading-6 text-gray-900 text-md">Members</h3>
<h3 className="font-cal font-bold leading-6 text-gray-900 text-md">{t("members")}</h3>
<div className="relative flex items-center">
<Button
type="button"
color="secondary"
StartIcon={PlusIcon}
onClick={() => onInviteMember(props.team)}>
New Member
{t("new_member")}
</Button>
</div>
</div>
<div>
{!!members.length && (
<MemberList members={members} onRemoveMember={onRemoveMember} onChange={loadMembers} />
<MemberList
localeProp={locale}
members={members}
onRemoveMember={onRemoveMember}
onChange={loadMembers}
/>
)}
<hr className="mt-6" />
</div>
@@ -245,14 +258,14 @@ export default function EditTeam(props: { team: Team | undefined | null; onClose
</div>
<div className="ml-3 text-sm">
<label htmlFor="hide-branding" className="font-medium text-gray-700">
Disable Cal.com branding
{t("disable_cal_branding")}
</label>
<p className="text-gray-500">Hide all Cal.com branding from your public pages.</p>
<p className="text-gray-500">{t("disable_cal_branding_description")}</p>
</div>
</div>
<hr className="mt-6" />
</div>
<h3 className="font-bold leading-6 text-gray-900 mt-7 text-md">Danger Zone</h3>
<h3 className="font-bold leading-6 text-gray-900 mt-7 text-md">{t("danger_zone")}</h3>
<div>
<div className="relative flex items-start">
<Dialog>
@@ -262,16 +275,15 @@ export default function EditTeam(props: { team: Team | undefined | null; onClose
}}
className="btn-sm btn-white">
<TrashIcon className="group-hover:text-red text-gray-700 w-3.5 h-3.5 mr-2 inline-block" />
Disband Team
{t("disband_team")}
</DialogTrigger>
<ConfirmationDialogContent
localeProp={locale}
variety="danger"
title="Disband Team"
confirmBtnText="Yes, disband team"
cancelBtnText="Cancel"
title={t("disband_team")}
confirmBtnText={t("confirm_disband_team")}
onConfirm={() => deleteTeam()}>
Are you sure you want to disband this team? Anyone who you&apos;ve shared this team
link with will no longer be able to book using it.
{t("disband_team_confirmation_message")}
</ConfirmationDialogContent>
</Dialog>
</div>
@@ -281,19 +293,23 @@ export default function EditTeam(props: { team: Team | undefined | null; onClose
<hr className="mt-8" />
<div className="flex justify-end py-4">
<Button type="submit" color="primary">
Save
{t("save")}
</Button>
</div>
</div>
</form>
<Modal
heading="Team updated successfully"
description="Your team has been updated successfully."
heading={t("team_updated_successfully")}
description={t("your_team_updated_successfully")}
open={successModalOpen}
handleClose={closeSuccessModal}
/>
{showMemberInvitationModal && (
<MemberInvitationModal team={inviteModalTeam} onExit={onMemberInvitationModalExit} />
<MemberInvitationModal
localeProp={locale}
team={inviteModalTeam}
onExit={onMemberInvitationModalExit}
/>
)}
</div>
</div>
+16 -10
View File
@@ -1,12 +1,18 @@
import { UsersIcon } from "@heroicons/react/outline";
import { useState } from "react";
import { useLocale } from "@lib/hooks/useLocale";
import { Team } from "@lib/team";
import Button from "@components/ui/Button";
export default function MemberInvitationModal(props: { team: Team | undefined | null; onExit: () => void }) {
export default function MemberInvitationModal(props: {
localeProp: string;
team: Team | undefined | null;
onExit: () => void;
}) {
const [errorMessage, setErrorMessage] = useState("");
const { t } = useLocale({ localeProp: props.localeProp });
const handleError = async (res: Response) => {
const responseData = await res.json();
@@ -64,10 +70,10 @@ export default function MemberInvitationModal(props: { team: Team | undefined |
</div>
<div className="mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left">
<h3 className="text-lg font-medium leading-6 text-gray-900" id="modal-title">
Invite a new member
{t("invite_new_member")}
</h3>
<div>
<p className="text-sm text-gray-400">Invite someone to your team.</p>
<p className="text-sm text-gray-400">{t("invite_new_team_member")}</p>
</div>
</div>
</div>
@@ -75,7 +81,7 @@ export default function MemberInvitationModal(props: { team: Team | undefined |
<div>
<div className="mb-4">
<label htmlFor="inviteUser" className="block text-sm font-medium text-gray-700">
Email or Username
{t("email_or_username")}
</label>
<input
type="text"
@@ -88,13 +94,13 @@ export default function MemberInvitationModal(props: { team: Team | undefined |
</div>
<div className="mb-4">
<label className="block mb-2 text-sm font-medium tracking-wide text-gray-700" htmlFor="role">
Role
{t("role")}
</label>
<select
id="role"
className="block w-full mt-1 border-gray-300 rounded-md shadow-sm focus:ring-black focus:border-black sm:text-sm">
<option value="MEMBER">Member</option>
<option value="OWNER">Owner</option>
<option value="MEMBER">{t("member")}</option>
<option value="OWNER">{t("owner")}</option>
</select>
</div>
<div className="relative flex items-start">
@@ -109,7 +115,7 @@ export default function MemberInvitationModal(props: { team: Team | undefined |
</div>
<div className="ml-2 text-sm">
<label htmlFor="sendInviteEmail" className="font-medium text-gray-700">
Send an invite email
{t("send_invite_email")}
</label>
</div>
</div>
@@ -122,10 +128,10 @@ export default function MemberInvitationModal(props: { team: Team | undefined |
)}
<div className="mt-5 sm:mt-4 sm:flex sm:flex-row-reverse">
<Button type="submit" color="primary" className="ml-2">
Invite
{t("invite")}
</Button>
<Button type="button" color="secondary" onClick={props.onExit}>
Cancel
{t("cancel")}
</Button>
</div>
</form>
+5
View File
@@ -1,12 +1,16 @@
import { useLocale } from "@lib/hooks/useLocale";
import { Member } from "@lib/member";
import MemberListItem from "./MemberListItem";
export default function MemberList(props: {
localeProp: string;
members: Member[];
onRemoveMember: (text: Member) => void;
onChange: (text: string) => void;
}) {
const { locale } = useLocale({ localeProp: props.localeProp });
const selectAction = (action: string, member: Member) => {
switch (action) {
case "remove":
@@ -20,6 +24,7 @@ export default function MemberList(props: {
<ul className="px-4 mb-2 bg-white border divide-y divide-gray-200 rounded">
{props.members.map((member) => (
<MemberListItem
localeProp={locale}
onChange={props.onChange}
key={member.id}
member={member}
+12 -9
View File
@@ -1,6 +1,7 @@
import { DotsHorizontalIcon, UserRemoveIcon } from "@heroicons/react/outline";
import { useState } from "react";
import { useLocale } from "@lib/hooks/useLocale";
import { Member } from "@lib/member";
import { Dialog, DialogTrigger } from "@components/Dialog";
@@ -11,11 +12,13 @@ import Button from "@components/ui/Button";
import Dropdown, { DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "../ui/Dropdown";
export default function MemberListItem(props: {
localeProp: string;
member: Member;
onActionSelect: (text: string) => void;
onChange: (text: string) => void;
}) {
const [member] = useState(props.member);
const { t, locale } = useLocale({ localeProp: props.localeProp });
return (
member && (
@@ -41,21 +44,21 @@ export default function MemberListItem(props: {
{props.member.role === "INVITEE" && (
<>
<span className="self-center h-6 px-3 py-1 mr-2 text-xs text-yellow-700 capitalize rounded-md bg-yellow-50">
Pending
{t("pending")}
</span>
<span className="self-center h-6 px-3 py-1 mr-4 text-xs text-pink-700 capitalize rounded-md bg-pink-50">
Member
{t("member")}
</span>
</>
)}
{props.member.role === "MEMBER" && (
<span className="self-center h-6 px-3 py-1 mr-4 text-xs text-pink-700 capitalize rounded-md bg-pink-50">
Member
{t("member")}
</span>
)}
{props.member.role === "OWNER" && (
<span className="self-center h-6 px-3 py-1 mr-4 text-xs text-blue-700 capitalize rounded-md bg-blue-50">
Owner
{t("owner")}
</span>
)}
<Dropdown>
@@ -73,16 +76,16 @@ export default function MemberListItem(props: {
color="warn"
StartIcon={UserRemoveIcon}
className="w-full">
Remove User
{t("remove_member")}
</Button>
</DialogTrigger>
<ConfirmationDialogContent
localeProp={locale}
variety="danger"
title="Remove member"
confirmBtnText="Yes, remove member"
cancelBtnText="Cancel"
title={t("remove_member")}
confirmBtnText={t("confirm_remove_member")}
onConfirm={() => props.onActionSelect("remove")}>
Are you sure you want to remove this member from the team?
{t("remove_member_confirmation_message")}
</ConfirmationDialogContent>
</Dialog>
</DropdownMenuItem>
+5
View File
@@ -1,12 +1,16 @@
import { useLocale } from "@lib/hooks/useLocale";
import { Team } from "@lib/team";
import TeamListItem from "./TeamListItem";
export default function TeamList(props: {
localeProp: string;
teams: Team[];
onChange: () => void;
onEditTeam: (text: Team) => void;
}) {
const { locale } = useLocale({ localeProp: props.localeProp });
const selectAction = (action: string, team: Team) => {
switch (action) {
case "edit":
@@ -30,6 +34,7 @@ export default function TeamList(props: {
<ul className="px-4 mb-2 bg-white border divide-y divide-gray-200 rounded">
{props.teams.map((team: Team) => (
<TeamListItem
localeProp={locale}
onChange={props.onChange}
key={team.id}
team={team}
+16 -12
View File
@@ -8,6 +8,7 @@ import {
import Link from "next/link";
import { useState } from "react";
import { useLocale } from "@lib/hooks/useLocale";
import showToast from "@lib/notification";
import { Dialog, DialogTrigger } from "@components/Dialog";
@@ -30,12 +31,14 @@ interface Team {
}
export default function TeamListItem(props: {
localeProp: string;
onChange: () => void;
key: number;
team: Team;
onActionSelect: (text: string) => void;
}) {
const [team, setTeam] = useState<Team | null>(props.team);
const { t, locale } = useLocale({ localeProp: props.localeProp });
const acceptInvite = () => invitationResponse(true);
const declineInvite = () => invitationResponse(false);
@@ -79,24 +82,24 @@ export default function TeamListItem(props: {
{props.team.role === "INVITEE" && (
<div>
<Button type="button" color="secondary" onClick={declineInvite}>
Reject
{t("reject")}
</Button>
<Button type="button" color="primary" className="ml-1" onClick={acceptInvite}>
Accept
{t("accept")}
</Button>
</div>
)}
{props.team.role === "MEMBER" && (
<div>
<Button type="button" color="primary" onClick={declineInvite}>
Leave
{t("leave")}
</Button>
</div>
)}
{props.team.role === "OWNER" && (
<div className="flex space-x-4">
<span className="self-center h-6 px-3 py-1 text-xs text-gray-700 capitalize rounded-md bg-gray-50">
Owner
{t("owner")}
</span>
<Tooltip content="Copy link">
<Button
@@ -104,7 +107,7 @@ export default function TeamListItem(props: {
navigator.clipboard.writeText(
process.env.NEXT_PUBLIC_APP_URL + "/team/" + props.team.slug
);
showToast("Link copied!", "success");
showToast(t("link_copied"), "success");
}}
size="icon"
color="minimal"
@@ -124,14 +127,16 @@ export default function TeamListItem(props: {
className="w-full"
onClick={() => props.onActionSelect("edit")}
StartIcon={PencilAltIcon}>
Edit team
{" "}
{t("edit_team")}
</Button>
</DropdownMenuItem>
<DropdownMenuItem>
<Link href={`${process.env.NEXT_PUBLIC_APP_URL}/team/${props.team.slug}`} passHref={true}>
<a target="_blank">
<Button type="button" color="minimal" className="w-full" StartIcon={ExternalLinkIcon}>
Preview team page
{" "}
{t("preview_team")}
</Button>
</a>
</Link>
@@ -146,17 +151,16 @@ export default function TeamListItem(props: {
color="warn"
StartIcon={TrashIcon}
className="w-full">
Disband Team
{t("disband_team")}
</Button>
</DialogTrigger>
<ConfirmationDialogContent
localeProp={locale}
variety="danger"
title="Disband Team"
confirmBtnText="Yes, disband team"
cancelBtnText="Cancel"
confirmBtnText={t("confirm_disband_team")}
onConfirm={() => props.onActionSelect("disband")}>
Are you sure you want to disband this team? Anyone who you&apos;ve shared this team
link with will no longer be able to book using it.
{t("disband_team_confirmation_message")}
</ConfirmationDialogContent>
</Dialog>
</DropdownMenuItem>
+6 -2
View File
@@ -4,11 +4,15 @@ import classnames from "classnames";
import Link from "next/link";
import React from "react";
import { useLocale } from "@lib/hooks/useLocale";
import Avatar from "@components/ui/Avatar";
import Button from "@components/ui/Button";
import Text from "@components/ui/Text";
const Team = ({ team }) => {
const Team = ({ team, localeProp }) => {
const { t } = useLocale({ localeProp: localeProp });
const Member = ({ member }) => {
const classes = classnames(
"group",
@@ -71,7 +75,7 @@ const Team = ({ team }) => {
{team.eventTypes.length > 0 && (
<aside className="text-center dark:text-white mt-8">
<Button color="secondary" href={`/team/${team.slug}`} shallow={true} StartIcon={ArrowLeftIcon}>
Go back
{t("go_back")}
</Button>
</aside>
)}