cal.pub0.org/packages/features/ee/teams/components/MemberInvitationModal.tsx

143 lines
4.6 KiB
TypeScript
Raw Normal View History

V2 settings teams (Profil, Members, Appearance View) (#4350) * add team profile * first version for team members page * finish up design of member list item * fix dialog buttons * add missing seats and upgrading information * add v2 dialog for changing role * finish basic version of member's schedule * remove modalContainer * design fixes team profile page * show only team info to non admins * allow all member to check availabilities * make time available heading sticky * add dropdown for mobile view * create team appearance view * finish appearance page * use settings layout and add danger zone for member * add fallback logo * Add teams to sidebar and fix UI * add team invitations * Clean up * code clean up * add impersontation and disable autofocus on calendar * improve team info * refactor teaminvitelist code and fix leaving a team * add team pages to settings shell * add link to create new team * small fixes * clean up comments * V2 Multi-select (Team Select) (#4324) * --init * design improved * further fine tuning * more fixes * removed extra JSX tag * added story * NIT * revert to use of CheckedTeamSelect * Removes comments Co-authored-by: Peer Richelsen <peeroke@gmail.com> * fix: toggle alligment (#4361) * fix: add checked tranform for switch (#4357) * fixed input size on mobile, fixed settings (#4360) * fix image uploader button in safari * code clean up * fixing type errors * Moved v2 team components to features Adds deprecation notices * Update SettingsLayout.tsx * Migrated to features and build fixes Co-authored-by: CarinaWolli <wollencarina@gmail.com> Co-authored-by: Joe Au-Yeung <j.auyeung419@gmail.com> Co-authored-by: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com> Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com> Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com> Co-authored-by: zomars <zomars@me.com>
2022-09-12 22:04:33 +00:00
import { MembershipRole } from "@prisma/client";
import React, { useState, SyntheticEvent, useMemo } from "react";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { TeamWithMembers } from "@calcom/lib/server/queries/teams";
import { trpc } from "@calcom/trpc/react";
import { Icon } from "@calcom/ui/Icon";
import { Button, Dialog, DialogContent, DialogFooter, Select, TextField } from "@calcom/ui/v2";
type MemberInvitationModalProps = {
isOpen: boolean;
team: TeamWithMembers | null;
currentMember: MembershipRole;
onExit: () => void;
};
type MembershipRoleOption = {
value: MembershipRole;
label?: string;
};
const _options: MembershipRoleOption[] = [{ value: "MEMBER" }, { value: "ADMIN" }, { value: "OWNER" }];
export default function MemberInvitationModal(props: MemberInvitationModalProps) {
const [errorMessage, setErrorMessage] = useState("");
const { t, i18n } = useLocale();
const utils = trpc.useContext();
const options = useMemo(() => {
_options.forEach((option, i) => {
_options[i].label = t(option.value.toLowerCase());
});
return _options;
}, [t]);
const inviteMemberMutation = trpc.useMutation("viewer.teams.inviteMember", {
async onSuccess() {
await utils.invalidateQueries(["viewer.teams.get"]);
props.onExit();
},
async onError(err) {
setErrorMessage(err.message);
},
});
function inviteMember(e: SyntheticEvent) {
e.preventDefault();
if (!props.team) return;
const target = e.target as typeof e.target & {
elements: {
role: { value: MembershipRole };
inviteUser: { value: string };
sendInviteEmail: { checked: boolean };
};
};
inviteMemberMutation.mutate({
teamId: props.team.id,
language: i18n.language,
role: target.elements["role"].value,
usernameOrEmail: target.elements["inviteUser"].value,
sendEmailInvitation: target.elements["sendInviteEmail"].checked,
});
}
return (
<Dialog open={props.isOpen} onOpenChange={props.onExit}>
Create New Team (#4450) * Add link to new teams * Create new team * Invite team members * Bug fix * Tidy up settings calendars (#4430) * feat: 4232 - new theme toggle design. (#4371) Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com> * fix: Select dropdown styling (#4358) * fix: select dropdown styling * change check icon * Revert select component, update v2 select * Updates the background color to match figma design Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com> Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com> * Fix input height 36px (#4425) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * Fix crash due to some props being undefined (#4427) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * Improve event type item description visibility (#4404) * Make event type description more visible * Delete unneeded import Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * Updating language in settings needs a reload to be translated (#4431) Co-authored-by: gitstart <gitstart@users.noreply.github.com> Co-authored-by: Nitesh Singh <nitesh.singh@gitstart.dev> Co-authored-by: Thiago Nascimbeni <tnascimbeni@gmail.com> Co-authored-by: Grace Nshokano <grace.devolop@gmail.com> Co-authored-by: Matheus Muniz <87545749+matheusmuniz03@users.noreply.github.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * fix: remove i18n from title and description (#4354) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> Co-authored-by: Hariom Balhara <hariombalhara@gmail.com> * Fix styles and remove temporarily elements (#4448) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * Fix deletion of route (#4466) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * feat: make toggle button default (#4437) * feat: make switch default * fix: refetch invalidated query * React-query caching the previous isDefault state. * fix: switch label color Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * Refactor skeleton loader files to v2 folders (#4447) * create v2 skeleton loaders * add depreciation notice to old skeleton loader files Co-authored-by: CarinaWolli <wollencarina@gmail.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * Adds rescheduling dropdown to past unconfirmed bookings (#3726) Co-authored-by: Omar López <zomars@me.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * fix: add a consistent key to the day ranges list (#4401) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * remove "Weve changed billing for teams" banner in teams (#4432) Co-authored-by: gitstart <gitstart@users.noreply.github.com> Co-authored-by: gitstart <gitstart@gitstart.com> Co-authored-by: Grace Nshokano <grace.devolop@gmail.com> Co-authored-by: Nitesh Singh <nitesh.singh@gitstart.dev> Co-authored-by: Matheus Muniz <87545749+matheusmuniz03@users.noreply.github.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * fix: remove name prop from NumberWidget (#4346) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * Fix bug * Fix bug * Squashed commit of the following: commit c3cb83902732478db06bf80bcc66fd8b0818995f Author: Bailey Pumfleet <pumfleet@hey.com> Date: Wed Sep 14 17:13:13 2022 +0100 Remove outline from user dropdown trigger (#4470) commit 91c39a030698c7068ffddb57767d255de5c7c409 Author: Sascha Schworm <1959209+saschaschworm@users.noreply.github.com> Date: Wed Sep 14 18:09:00 2022 +0200 feat: Exchange with NTLM support (#4127) * add exchange package * fix conflicts * add setup page for v2 * refactor setup page for v1 * return exchange error messages to user if applicable Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com> commit f1c15f4e8a0f55b0b43c041b279973ac85e78534 Author: alannnc <alannnc@gmail.com> Date: Wed Sep 14 10:57:20 2022 -0500 4382 onboarding fix the disabled state of the username in step 1 (#4451) * Convert username availability premium to v2 * Update Username Availability to v2 design Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> commit 3f29df16add8984bb0b0a6b406b9192c0d54d501 Author: Alex van Andel <me@alexvanandel.com> Date: Wed Sep 14 16:40:56 2022 +0100 KBar included @calcom/ui/v2/core -> Shell -> KBar -> Shell -> ... (#4469) commit 3a06947c8ad612b49dd6dffac313d6748be55691 Author: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com> Date: Wed Sep 14 19:14:42 2022 +0530 fixes active state of select options (#4456) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> commit f486b0242f8ccfac27cb2bde2fe21f067f73e80c Author: Nafees Nazik <84864519+G3root@users.noreply.github.com> Date: Wed Sep 14 17:28:59 2022 +0530 fix: remove name prop from NumberWidget (#4346) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> commit 9bc2676822e50cc20e0ca1d68a55ebfd113da55e Author: GitStart <1501599+gitstart@users.noreply.github.com> Date: Wed Sep 14 12:41:47 2022 +0100 remove "Weve changed billing for teams" banner in teams (#4432) Co-authored-by: gitstart <gitstart@users.noreply.github.com> Co-authored-by: gitstart <gitstart@gitstart.com> Co-authored-by: Grace Nshokano <grace.devolop@gmail.com> Co-authored-by: Nitesh Singh <nitesh.singh@gitstart.dev> Co-authored-by: Matheus Muniz <87545749+matheusmuniz03@users.noreply.github.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> commit 5c72aa349797030363cd4d8cbd430de06c7b55f1 Author: Nafees Nazik <84864519+G3root@users.noreply.github.com> Date: Wed Sep 14 17:00:25 2022 +0530 fix: add a consistent key to the day ranges list (#4401) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> commit 09da911bf9230e570ee23faf3b336ad09d7d888b Author: Dallen Pyrah <dallenpyrah@gmail.com> Date: Wed Sep 14 05:02:26 2022 -0600 Adds rescheduling dropdown to past unconfirmed bookings (#3726) Co-authored-by: Omar López <zomars@me.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> commit 2fbaec41c96c45c7d48976967baee6df961afc66 Author: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com> Date: Wed Sep 14 06:35:40 2022 -0400 Refactor skeleton loader files to v2 folders (#4447) * create v2 skeleton loaders * add depreciation notice to old skeleton loader files Co-authored-by: CarinaWolli <wollencarina@gmail.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> commit 3bada22900785978b17a0f53a57f6b62288dbcd2 Author: Nafees Nazik <84864519+G3root@users.noreply.github.com> Date: Wed Sep 14 15:54:41 2022 +0530 feat: make toggle button default (#4437) * feat: make switch default * fix: refetch invalidated query * React-query caching the previous isDefault state. * fix: switch label color Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> commit 45059554b6758ece73ba5d6583ac949148f7cdfe Author: Hariom Balhara <hariombalhara@gmail.com> Date: Wed Sep 14 15:40:52 2022 +0530 Fix deletion of route (#4466) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> commit 8b69359ccb92d7af62475525df47992a2906e4eb Author: alannnc <alannnc@gmail.com> Date: Wed Sep 14 04:55:49 2022 -0500 Fix styles and remove temporarily elements (#4448) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> commit b4571259155e5c512969de60934ace1761af45c8 Author: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com> Date: Wed Sep 14 15:12:48 2022 +0530 fix: remove i18n from title and description (#4354) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> Co-authored-by: Hariom Balhara <hariombalhara@gmail.com> commit 01e0fed3c5a253ab2510766f23180ae1b7f4e508 Author: GitStart <1501599+gitstart@users.noreply.github.com> Date: Wed Sep 14 10:28:23 2022 +0100 Updating language in settings needs a reload to be translated (#4431) Co-authored-by: gitstart <gitstart@users.noreply.github.com> Co-authored-by: Nitesh Singh <nitesh.singh@gitstart.dev> Co-authored-by: Thiago Nascimbeni <tnascimbeni@gmail.com> Co-authored-by: Grace Nshokano <grace.devolop@gmail.com> Co-authored-by: Matheus Muniz <87545749+matheusmuniz03@users.noreply.github.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> commit c09107cec8bf4c2234484794d5a4ed3d3859e268 Author: Noah <hi@noahflk.com> Date: Wed Sep 14 11:08:50 2022 +0200 Improve event type item description visibility (#4404) * Make event type description more visible * Delete unneeded import Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> commit 2f9905e548d019e670de1a8044b0ff7ed704f28f Author: Hariom Balhara <hariombalhara@gmail.com> Date: Wed Sep 14 14:16:42 2022 +0530 Fix crash due to some props being undefined (#4427) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> commit ab4d9105649d82e545da8efe4e16d041c3e14a4a Author: sean-brydon <55134778+sean-brydon@users.noreply.github.com> Date: Wed Sep 14 09:18:40 2022 +0100 Fix input height 36px (#4425) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> commit 34bca4984fdfb648a4966b9ca806fd8a31a52e82 Author: John Afolabi <johnafolabi.da@gmail.com> Date: Wed Sep 14 08:27:00 2022 +0100 fix: Select dropdown styling (#4358) * fix: select dropdown styling * change check icon * Revert select component, update v2 select * Updates the background color to match figma design Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com> Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com> commit 0907d154c764770151b133fa3ef9c9154ca4c7d4 Author: Jeroen Reumkens <hello@jeroenreumkens.nl> Date: Wed Sep 14 09:15:13 2022 +0200 feat: 4232 - new theme toggle design. (#4371) Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com> commit 6f807930f61b58f6d0c0d7e797cacee362e7cd58 Author: sean-brydon <55134778+sean-brydon@users.noreply.github.com> Date: Tue Sep 13 21:13:24 2022 +0100 Tidy up settings calendars (#4430) * Fix types * Cleanup Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com> Co-authored-by: Jeroen Reumkens <hello@jeroenreumkens.nl> Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: John Afolabi <johnafolabi.da@gmail.com> Co-authored-by: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> Co-authored-by: Hariom Balhara <hariombalhara@gmail.com> Co-authored-by: Noah <hi@noahflk.com> Co-authored-by: GitStart <1501599+gitstart@users.noreply.github.com> Co-authored-by: gitstart <gitstart@users.noreply.github.com> Co-authored-by: Nitesh Singh <nitesh.singh@gitstart.dev> Co-authored-by: Thiago Nascimbeni <tnascimbeni@gmail.com> Co-authored-by: Grace Nshokano <grace.devolop@gmail.com> Co-authored-by: Matheus Muniz <87545749+matheusmuniz03@users.noreply.github.com> Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com> Co-authored-by: alannnc <alannnc@gmail.com> Co-authored-by: Nafees Nazik <84864519+G3root@users.noreply.github.com> Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com> Co-authored-by: CarinaWolli <wollencarina@gmail.com> Co-authored-by: Dallen Pyrah <dallenpyrah@gmail.com> Co-authored-by: Omar López <zomars@me.com> Co-authored-by: gitstart <gitstart@gitstart.com> Co-authored-by: Alex van Andel <me@alexvanandel.com> Co-authored-by: Bailey Pumfleet <pumfleet@hey.com>
2022-09-15 09:47:59 +00:00
<DialogContent
type="creation"
useOwnActionButtons
title={t("invite_new_member")}
description={
<span className=" text-sm leading-tight text-gray-500">
Note: This will <span className="font-medium text-gray-900">cost an extra seat ($12/m)</span> on
your subscription if this invitee does not have a pro account.{" "}
<a href="#" className="underline">
Learn More
</a>
</span>
}>
V2 settings teams (Profil, Members, Appearance View) (#4350) * add team profile * first version for team members page * finish up design of member list item * fix dialog buttons * add missing seats and upgrading information * add v2 dialog for changing role * finish basic version of member's schedule * remove modalContainer * design fixes team profile page * show only team info to non admins * allow all member to check availabilities * make time available heading sticky * add dropdown for mobile view * create team appearance view * finish appearance page * use settings layout and add danger zone for member * add fallback logo * Add teams to sidebar and fix UI * add team invitations * Clean up * code clean up * add impersontation and disable autofocus on calendar * improve team info * refactor teaminvitelist code and fix leaving a team * add team pages to settings shell * add link to create new team * small fixes * clean up comments * V2 Multi-select (Team Select) (#4324) * --init * design improved * further fine tuning * more fixes * removed extra JSX tag * added story * NIT * revert to use of CheckedTeamSelect * Removes comments Co-authored-by: Peer Richelsen <peeroke@gmail.com> * fix: toggle alligment (#4361) * fix: add checked tranform for switch (#4357) * fixed input size on mobile, fixed settings (#4360) * fix image uploader button in safari * code clean up * fixing type errors * Moved v2 team components to features Adds deprecation notices * Update SettingsLayout.tsx * Migrated to features and build fixes Co-authored-by: CarinaWolli <wollencarina@gmail.com> Co-authored-by: Joe Au-Yeung <j.auyeung419@gmail.com> Co-authored-by: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com> Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com> Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com> Co-authored-by: zomars <zomars@me.com>
2022-09-12 22:04:33 +00:00
<form onSubmit={inviteMember}>
<div className="space-y-4">
<TextField
label={t("email_or_username")}
id="inviteUser"
name="inviteUser"
placeholder="email@example.com"
required
/>
<div>
<label className="mb-1 block text-sm font-medium tracking-wide text-gray-700" htmlFor="role">
{t("role")}
</label>
<Select
defaultValue={options[0]}
options={props.currentMember !== MembershipRole.OWNER ? options.slice(0, 2) : options}
id="role"
name="role"
className="mt-1 block w-full rounded-sm border-gray-300 text-sm"
/>
</div>
<div className="relative flex items-start">
<div className="flex h-5 items-center">
<input
type="checkbox"
name="sendInviteEmail"
defaultChecked
id="sendInviteEmail"
className="rounded-sm border-gray-300 text-sm text-black"
/>
</div>
<div className="text-sm ltr:ml-2 rtl:mr-2">
<label htmlFor="sendInviteEmail" className="font-medium text-gray-700">
{t("send_invite_email")}
</label>
</div>
</div>
</div>
{errorMessage && (
<p className="text-sm text-red-700">
<span className="font-bold">Error: </span>
{errorMessage}
</p>
)}
<DialogFooter>
<Button type="button" color="secondary" onClick={props.onExit}>
{t("cancel")}
</Button>
<Button
type="submit"
color="primary"
className="ltr:ml-2 rtl:mr-2"
data-testid="invite-new-member-button">
{t("invite")}
</Button>
</DialogFooter>
</form>
</DialogContent>
</Dialog>
);
}