From 0c78dbea27434674bea1f8e326a4fd685c1f98c1 Mon Sep 17 00:00:00 2001 From: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com> Date: Thu, 15 Sep 2022 05:47:59 -0400 Subject: [PATCH] Create New Team (#4450) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 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 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 Co-authored-by: Nitesh Singh Co-authored-by: Thiago Nascimbeni Co-authored-by: Grace Nshokano 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 * 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 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 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 Co-authored-by: gitstart Co-authored-by: Grace Nshokano Co-authored-by: Nitesh Singh 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 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 Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com> commit f1c15f4e8a0f55b0b43c041b279973ac85e78534 Author: alannnc 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 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 Co-authored-by: gitstart Co-authored-by: Grace Nshokano Co-authored-by: Nitesh Singh 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 Date: Wed Sep 14 05:02:26 2022 -0600 Adds rescheduling dropdown to past unconfirmed bookings (#3726) Co-authored-by: Omar López 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 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 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 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 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 Co-authored-by: Nitesh Singh Co-authored-by: Thiago Nascimbeni Co-authored-by: Grace Nshokano 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 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 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 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 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 Date: Wed Sep 14 09:15:13 2022 +0200 feat: 4232 - new theme toggle design. (#4371) Co-authored-by: Peer Richelsen 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 Co-authored-by: Peer Richelsen Co-authored-by: John Afolabi 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 Co-authored-by: Noah Co-authored-by: GitStart <1501599+gitstart@users.noreply.github.com> Co-authored-by: gitstart Co-authored-by: Nitesh Singh Co-authored-by: Thiago Nascimbeni Co-authored-by: Grace Nshokano 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 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 Co-authored-by: Dallen Pyrah Co-authored-by: Omar López Co-authored-by: gitstart Co-authored-by: Alex van Andel Co-authored-by: Bailey Pumfleet --- .../v2/settings/teams/new/[[...step]].tsx | 114 +++++++++++++ apps/web/public/static/locales/en/common.json | 3 +- .../components/MemberInvitationModal.tsx | 37 ++--- .../teams/components/v2/AddNewTeamMembers.tsx | 125 ++++++++++++++ .../ee/teams/components/v2/CreateNewTeam.tsx | 102 ++++++++++++ packages/lib/server/queries/teams/index.ts | 1 + packages/trpc/server/routers/viewer/teams.tsx | 7 +- packages/ui/v2/core/Dialog.tsx | 2 +- .../ui/v2/core/layouts/SettingsLayout.tsx | 155 +++++++++--------- 9 files changed, 445 insertions(+), 101 deletions(-) create mode 100644 apps/web/pages/v2/settings/teams/new/[[...step]].tsx create mode 100644 packages/features/ee/teams/components/v2/AddNewTeamMembers.tsx create mode 100644 packages/features/ee/teams/components/v2/CreateNewTeam.tsx diff --git a/apps/web/pages/v2/settings/teams/new/[[...step]].tsx b/apps/web/pages/v2/settings/teams/new/[[...step]].tsx new file mode 100644 index 0000000000..dffcd03c64 --- /dev/null +++ b/apps/web/pages/v2/settings/teams/new/[[...step]].tsx @@ -0,0 +1,114 @@ +import Head from "next/head"; +import { useRouter } from "next/router"; +import { useState } from "react"; +import { z } from "zod"; + +// import TeamGeneralSettings from "@calcom/features/teams/createNewTeam/TeamGeneralSettings"; +import AddNewTeamMembers from "@calcom/features/ee/teams/components/v2/AddNewTeamMembers"; +import CreateNewTeam from "@calcom/features/ee/teams/components/v2/CreateNewTeam"; +import { useLocale } from "@calcom/lib/hooks/useLocale"; + +import { StepCard } from "@components/getting-started/components/StepCard"; +import { Steps } from "@components/getting-started/components/Steps"; + +const INITIAL_STEP = "create-a-new-team"; +// TODO: Add teams general settings "general-settings" +const steps = ["create-a-new-team", "add-team-members"] as const; + +const stepTransform = (step: typeof steps[number]) => { + const stepIndex = steps.indexOf(step); + if (stepIndex > -1) { + return steps[stepIndex]; + } + return INITIAL_STEP; +}; + +const stepRouteSchema = z.object({ + step: z.array(z.enum(steps)).default([INITIAL_STEP]), +}); + +const CreateNewTeamPage = () => { + const router = useRouter(); + + const { t } = useLocale(); + const [teamId, setTeamId] = useState(); + + const result = stepRouteSchema.safeParse(router.query); + const currentStep = result.success ? result.data.step[0] : INITIAL_STEP; + + const headers = [ + { + title: `${t("create_a_new_team")}`, + subtitle: [`${t("create_a_new_team_description")}`], + }, + // { + // title: `${t("general_settings")}`, + // subtitle: [`${t("general_settings_description")}`], + // }, + { + title: `${t("add_team_members")}`, + subtitle: [`${t("add_team_members_description")}`], + }, + ]; + + const goToIndex = (index: number) => { + const newStep = steps[index]; + router.push( + { + pathname: `/settings/teams/new/${stepTransform(newStep)}`, + }, + undefined + ); + }; + + const currentStepIndex = steps.indexOf(currentStep); + + return ( +
+ + {t("create_a_new_team")} + + + +
+
+
+
+
+

+ {headers[currentStepIndex]?.title || "Undefined title"} +

+ +

+ {headers[currentStepIndex]?.subtitle} +

+
+ +
+ + {currentStep === "create-a-new-team" && ( + { + goToIndex(1); + }} + setTeamId={(teamId: number) => setTeamId(teamId)} + /> + )} + + {/* {currentStep === "general-settings" && ( + goToIndex(2)} /> + )} */} + + {currentStep === "add-team-members" && teamId && } + +
+
+
+
+ ); +}; + +export default CreateNewTeamPage; diff --git a/apps/web/public/static/locales/en/common.json b/apps/web/public/static/locales/en/common.json index 0b732f3a8b..9d658d6fde 100644 --- a/apps/web/public/static/locales/en/common.json +++ b/apps/web/public/static/locales/en/common.json @@ -498,7 +498,7 @@ "lets_create_first_administrator_user": "Let's create the first administrator user.", "new_member": "New Member", "invite": "Invite", - "invite_new_member": "Invite a new member", + "invite_new_member": "Invite a new team member", "invite_new_team_member": "Invite someone to your team.", "change_member_role": "Change team member role", "disable_cal_branding": "Disable Cal branding", @@ -1240,6 +1240,7 @@ "password_updated":"Password updated!", "pending_payment": "Pending payment", "confirmation_page_rainbow": "Token gate your event with tokens or NFTs on Ethereum, Polygon, and more.", + "not_on_cal": "Not on Cal.com", "no_calendar_installed": "No calendar installed", "no_calendar_installed_description": "You have not yet connected any of your calendars", "add_a_calendar": "Add a calendar" diff --git a/packages/features/ee/teams/components/MemberInvitationModal.tsx b/packages/features/ee/teams/components/MemberInvitationModal.tsx index 33d9d0d05c..26096e5bdb 100644 --- a/packages/features/ee/teams/components/MemberInvitationModal.tsx +++ b/packages/features/ee/teams/components/MemberInvitationModal.tsx @@ -66,20 +66,19 @@ export default function MemberInvitationModal(props: MemberInvitationModalProps) return ( - -
-
- -
-
- -
-

{t("invite_new_team_member")}

-
-
-
+ + Note: This will cost an extra seat ($12/m) on + your subscription if this invitee does not have a pro account.{" "} + + Learn More + + + }>
-
-
{errorMessage && (

diff --git a/packages/features/ee/teams/components/v2/AddNewTeamMembers.tsx b/packages/features/ee/teams/components/v2/AddNewTeamMembers.tsx new file mode 100644 index 0000000000..c61a5e2403 --- /dev/null +++ b/packages/features/ee/teams/components/v2/AddNewTeamMembers.tsx @@ -0,0 +1,125 @@ +import { Suspense, useState } from "react"; + +import MemberInvitationModal from "@calcom/features/ee/teams/components/MemberInvitationModal"; +import { classNames } from "@calcom/lib"; +import { WEBAPP_URL } from "@calcom/lib/constants"; +import { useLocale } from "@calcom/lib/hooks/useLocale"; +import { trpc } from "@calcom/trpc/react"; +import { Icon } from "@calcom/ui"; +import { Button, Avatar, Badge } from "@calcom/ui/v2"; +import { SkeletonContainer, SkeletonText } from "@calcom/ui/v2"; + +const AddNewTeamMemberSkeleton = () => { + return ( + +

+
+

+ +

+
+ +
+
+
+ + ); +}; + +const AddNewTeamMembers = (props: { teamId: number }) => { + const { t } = useLocale(); + const utils = trpc.useContext(); + + const { data: team, isLoading } = trpc.useQuery(["viewer.teams.get", { teamId: props.teamId }]); + const removeMemberMutation = trpc.useMutation("viewer.teams.removeMember", { + onSuccess() { + utils.invalidateQueries(["viewer.teams.get", { teamId: props.teamId }]); + utils.invalidateQueries(["viewer.teams.list"]); + }, + }); + + const [memberInviteModal, setMemberInviteModal] = useState(false); + + if (isLoading) return ; + + return ( + }> + <> + <> +
    + {team?.members.map((member, index) => ( +
  • +
    + +
    +
    +

    {member?.name || t("team_member")}

    + {/* Assume that the first member of the team is the creator */} + {index === 0 && {t("you")}} + {!member.accepted && {t("pending")}} + {member.role === "MEMBER" && {t("member")}} + {member.role === "ADMIN" && {t("admin")}} +
    + {member.username ? ( +

    {`${WEBAPP_URL}/${member?.username}`}

    + ) : ( +

    {t("not_on_cal")}

    + )} +
    +
    + {member.role !== "OWNER" && ( +
  • + ))} +
+ + + + + {team && ( + setMemberInviteModal(false)} + team={team} + currentMember={team?.membership.role} + /> + )} + +
+ + + +
+ ); +}; + +export default AddNewTeamMembers; diff --git a/packages/features/ee/teams/components/v2/CreateNewTeam.tsx b/packages/features/ee/teams/components/v2/CreateNewTeam.tsx new file mode 100644 index 0000000000..204279a69e --- /dev/null +++ b/packages/features/ee/teams/components/v2/CreateNewTeam.tsx @@ -0,0 +1,102 @@ +import { useForm, Controller } from "react-hook-form"; + +import { WEBAPP_URL } from "@calcom/lib/constants"; +import { useLocale } from "@calcom/lib/hooks/useLocale"; +import { trpc } from "@calcom/trpc/react"; +import { Icon } from "@calcom/ui"; +import { Button, Avatar } from "@calcom/ui/v2"; +import ImageUploader from "@calcom/ui/v2/core/ImageUploader"; +import { Form, TextField } from "@calcom/ui/v2/core/form/fields"; + +const CreateANewTeamForm = (props: { nextStep: () => void; setTeamId: (teamId: number) => void }) => { + const { t } = useLocale(); + const utils = trpc.useContext(); + + const createTeamMutation = trpc.useMutation("viewer.teams.create", { + onSuccess(data) { + utils.invalidateQueries(["viewer.teams.list"]); + props.setTeamId(data.id); + props.nextStep(); + }, + }); + + const formMethods = useForm(); + + return ( + { + createTeamMutation.mutate({ + name: values.name, + slug: values.slug || null, + logo: values.logo || null, + }); + }}> +
+ ( + { + formMethods.setValue("name", e?.target.value); + }} + /> + )} + /> +
+ +
+ ( + { + formMethods.setValue("slug", e?.target.value); + }} + /> + )} + /> +
+
+ ( +
+ +
+ { + formMethods.setValue("avatar", newAvatar); + }} + imageSrc={value} + /> +
+
+ )} + /> +
+ + {createTeamMutation.isError &&

{createTeamMutation.error.message}

} + + ); +}; + +export default CreateANewTeamForm; diff --git a/packages/lib/server/queries/teams/index.ts b/packages/lib/server/queries/teams/index.ts index 52eff691b8..26baea66da 100644 --- a/packages/lib/server/queries/teams/index.ts +++ b/packages/lib/server/queries/teams/index.ts @@ -12,6 +12,7 @@ export async function getTeamWithMembers(id?: number, slug?: string) { id: true, plan: true, bio: true, + avatar: true, }); const teamSelect = Prisma.validator()({ diff --git a/packages/trpc/server/routers/viewer/teams.tsx b/packages/trpc/server/routers/viewer/teams.tsx index 046b8306c9..0ff27f690d 100644 --- a/packages/trpc/server/routers/viewer/teams.tsx +++ b/packages/trpc/server/routers/viewer/teams.tsx @@ -79,13 +79,15 @@ export const viewerTeamsRouter = createProtectedRouter() .mutation("create", { input: z.object({ name: z.string(), + slug: z.string().optional().nullable(), + logo: z.string().optional().nullable(), }), async resolve({ ctx, input }) { if (ctx.user.plan === "FREE") { throw new TRPCError({ code: "UNAUTHORIZED", message: "You need a team plan." }); } - const slug = slugify(input.name); + const slug = input.slug || slugify(input.name); const nameCollisions = await ctx.prisma.team.count({ where: { @@ -100,6 +102,7 @@ export const viewerTeamsRouter = createProtectedRouter() data: { name: input.name, slug: slug, + logo: input.logo || null, }, }); @@ -114,6 +117,8 @@ export const viewerTeamsRouter = createProtectedRouter() // Sync Services: Close.com closeComUpsertTeamUser(createTeam, ctx.user, MembershipRole.OWNER); + + return createTeam; }, }) // Allows team owner to update team metadata diff --git a/packages/ui/v2/core/Dialog.tsx b/packages/ui/v2/core/Dialog.tsx index 8996eb1ed4..4cda477eb3 100644 --- a/packages/ui/v2/core/Dialog.tsx +++ b/packages/ui/v2/core/Dialog.tsx @@ -64,7 +64,7 @@ type DialogContentProps = React.ComponentProps { const tabsWithPermissions = useTabs(); const [teamMenuState, setTeamMenuState] = useState<{ teamId: number | undefined; teamMenuOpen: boolean }[]>(); + const [isLoading, setIsLoading] = useState(true); const { data: teams } = trpc.useQuery(["viewer.teams.list"]); @@ -159,23 +160,13 @@ const SettingsSidebarContainer = ({ className = "" }) => { {teams && teamMenuState && - teams.map((team, index: number) => ( - - setTeamMenuState([ - ...teamMenuState, - (teamMenuState[index] = { - ...teamMenuState[index], - teamMenuOpen: !teamMenuState[index].teamMenuOpen, - }), - ]) - }> - -
+ teams.map((team, index: number) => { + if (teamMenuState.some((teamState) => teamState.teamId === team.id)) + return ( + setTeamMenuState([ ...teamMenuState, (teamMenuState[index] = { @@ -184,74 +175,90 @@ const SettingsSidebarContainer = ({ className = "" }) => { }), ]) }> -
- {teamMenuState[index].teamMenuOpen ? ( - - ) : ( - + +
+ setTeamMenuState([ + ...teamMenuState, + (teamMenuState[index] = { + ...teamMenuState[index], + teamMenuOpen: !teamMenuState[index].teamMenuOpen, + }), + ]) + }> +
+ {teamMenuState[index].teamMenuOpen ? ( + + ) : ( + + )} +
+ {team.logo && ( + {team.name + )} +

{team.name}

+ {!team.accepted && ( + + Inv. + + )} +
+
+ + {team.accepted && ( + )} -
- {team.logo && ( - {team.name - )} -

{team.name}

- {!team.accepted && ( - - Inv. - - )} -
-
- - {team.accepted && ( - - )} - - {(team.role === MembershipRole.OWNER || team.role === MembershipRole.ADMIN) && ( - <> - {/* TODO */} - {/* + {/* TODO */} + {/* */} - - {/* TODO: Implement saml configuration page */} - {/* + {/* TODO: Implement saml configuration page */} + {/* */} - - )} - -
- ))} -
- -

{t("add_a_team")}

-
+ + )} + + + ); + })} + );