+15




![kodiakhq[bot]](/avatar/78f03f45def735066748285e1c83c542df49e7b0562b0a8da815d5b24845d135?size=40)




Joe Au-Yeung
Peer Richelsen
Syed Ali Shahbaz
sean-brydon
kodiakhq[bot]
gitstart
Nitesh Singh
Thiago Nascimbeni
Grace Nshokano
Matheus Muniz
Hariom Balhara
CarinaWolli
Omar López
gitstart
Jeroen Reumkens
John Afolabi
Noah
GitStart
Udit Takkar
alannnc
Nafees Nazik
Carina Wollendorfer
Dallen Pyrah
Alex van Andel
Bailey Pumfleet
0c78dbea27
* 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 <[email protected]> Co-authored-by: Joe Au-Yeung <[email protected]> * 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 <[email protected]> Co-authored-by: Syed Ali Shahbaz <[email protected]> Co-authored-by: sean-brydon <[email protected]> * 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 <[email protected]> Co-authored-by: Nitesh Singh <[email protected]> Co-authored-by: Thiago Nascimbeni <[email protected]> Co-authored-by: Grace Nshokano <[email protected]> Co-authored-by: Matheus Muniz <[email protected]> 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 <[email protected]> * 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 <[email protected]> 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 <[email protected]> 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 <[email protected]> Co-authored-by: gitstart <[email protected]> Co-authored-by: Grace Nshokano <[email protected]> Co-authored-by: Nitesh Singh <[email protected]> Co-authored-by: Matheus Muniz <[email protected]> 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: commitc3cb839027Author: Bailey Pumfleet <[email protected]> Date: Wed Sep 14 17:13:13 2022 +0100 Remove outline from user dropdown trigger (#4470) commit91c39a0306Author: Sascha Schworm <[email protected]> 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 <[email protected]> Co-authored-by: Joe Au-Yeung <[email protected]> commitf1c15f4e8aAuthor: alannnc <[email protected]> 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> commit3f29df16adAuthor: Alex van Andel <[email protected]> Date: Wed Sep 14 16:40:56 2022 +0100 KBar included @calcom/ui/v2/core -> Shell -> KBar -> Shell -> ... (#4469) commit3a06947c8aAuthor: Syed Ali Shahbaz <[email protected]> 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> commitf486b0242fAuthor: Nafees Nazik <[email protected]> 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> commit9bc2676822Author: GitStart <[email protected]> Date: Wed Sep 14 12:41:47 2022 +0100 remove "Weve changed billing for teams" banner in teams (#4432) Co-authored-by: gitstart <[email protected]> Co-authored-by: gitstart <[email protected]> Co-authored-by: Grace Nshokano <[email protected]> Co-authored-by: Nitesh Singh <[email protected]> Co-authored-by: Matheus Muniz <[email protected]> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> commit5c72aa3497Author: Nafees Nazik <[email protected]> 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> commit09da911bf9Author: Dallen Pyrah <[email protected]> Date: Wed Sep 14 05:02:26 2022 -0600 Adds rescheduling dropdown to past unconfirmed bookings (#3726) Co-authored-by: Omar López <[email protected]> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> commit2fbaec41c9Author: Carina Wollendorfer <[email protected]> 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 <[email protected]> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> commit3bada22900Author: Nafees Nazik <[email protected]> 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> commit45059554b6Author: Hariom Balhara <[email protected]> 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> commit8b69359ccbAuthor: alannnc <[email protected]> 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> commitb457125915Author: Udit Takkar <[email protected]> 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 <[email protected]> commit01e0fed3c5Author: GitStart <[email protected]> Date: Wed Sep 14 10:28:23 2022 +0100 Updating language in settings needs a reload to be translated (#4431) Co-authored-by: gitstart <[email protected]> Co-authored-by: Nitesh Singh <[email protected]> Co-authored-by: Thiago Nascimbeni <[email protected]> Co-authored-by: Grace Nshokano <[email protected]> Co-authored-by: Matheus Muniz <[email protected]> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> commitc09107cec8Author: Noah <[email protected]> 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> commit2f9905e548Author: Hariom Balhara <[email protected]> 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> commitab4d910564Author: sean-brydon <[email protected]> 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> commit34bca4984fAuthor: John Afolabi <[email protected]> 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 <[email protected]> Co-authored-by: Syed Ali Shahbaz <[email protected]> Co-authored-by: sean-brydon <[email protected]> commit0907d154c7Author: Jeroen Reumkens <[email protected]> Date: Wed Sep 14 09:15:13 2022 +0200 feat: 4232 - new theme toggle design. (#4371) Co-authored-by: Peer Richelsen <[email protected]> Co-authored-by: Joe Au-Yeung <[email protected]> commit6f807930f6Author: sean-brydon <[email protected]> Date: Tue Sep 13 21:13:24 2022 +0100 Tidy up settings calendars (#4430) * Fix types * Cleanup Co-authored-by: sean-brydon <[email protected]> Co-authored-by: Jeroen Reumkens <[email protected]> Co-authored-by: Peer Richelsen <[email protected]> Co-authored-by: John Afolabi <[email protected]> Co-authored-by: Syed Ali Shahbaz <[email protected]> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> Co-authored-by: Hariom Balhara <[email protected]> Co-authored-by: Noah <[email protected]> Co-authored-by: GitStart <[email protected]> Co-authored-by: gitstart <[email protected]> Co-authored-by: Nitesh Singh <[email protected]> Co-authored-by: Thiago Nascimbeni <[email protected]> Co-authored-by: Grace Nshokano <[email protected]> Co-authored-by: Matheus Muniz <[email protected]> Co-authored-by: Udit Takkar <[email protected]> Co-authored-by: alannnc <[email protected]> Co-authored-by: Nafees Nazik <[email protected]> Co-authored-by: Carina Wollendorfer <[email protected]> Co-authored-by: CarinaWolli <[email protected]> Co-authored-by: Dallen Pyrah <[email protected]> Co-authored-by: Omar López <[email protected]> Co-authored-by: gitstart <[email protected]> Co-authored-by: Alex van Andel <[email protected]> Co-authored-by: Bailey Pumfleet <[email protected]>
101 lines
2.1 KiB
TypeScript
101 lines
2.1 KiB
TypeScript
import { Prisma, UserPlan } from "@prisma/client";
|
|
|
|
import prisma, { baseEventTypeSelect } from "@calcom/prisma";
|
|
|
|
export type TeamWithMembers = Awaited<ReturnType<typeof getTeamWithMembers>>;
|
|
|
|
export async function getTeamWithMembers(id?: number, slug?: string) {
|
|
const userSelect = Prisma.validator<Prisma.UserSelect>()({
|
|
username: true,
|
|
email: true,
|
|
name: true,
|
|
id: true,
|
|
plan: true,
|
|
bio: true,
|
|
avatar: true,
|
|
});
|
|
|
|
const teamSelect = Prisma.validator<Prisma.TeamSelect>()({
|
|
id: true,
|
|
name: true,
|
|
slug: true,
|
|
logo: true,
|
|
bio: true,
|
|
hideBranding: true,
|
|
members: {
|
|
select: {
|
|
user: {
|
|
select: userSelect,
|
|
},
|
|
},
|
|
},
|
|
eventTypes: {
|
|
where: {
|
|
hidden: false,
|
|
},
|
|
select: {
|
|
users: {
|
|
select: userSelect,
|
|
},
|
|
...baseEventTypeSelect,
|
|
},
|
|
},
|
|
});
|
|
|
|
const team = await prisma.team.findUnique({
|
|
where: id ? { id } : { slug },
|
|
select: teamSelect,
|
|
});
|
|
|
|
if (!team) return null;
|
|
|
|
const memberships = await prisma.membership.findMany({
|
|
where: {
|
|
teamId: team.id,
|
|
},
|
|
});
|
|
|
|
const members = team.members.map((obj) => {
|
|
const membership = memberships.find((membership) => obj.user.id === membership.userId);
|
|
return {
|
|
...obj.user,
|
|
isMissingSeat: obj.user.plan === UserPlan.FREE,
|
|
role: membership?.role,
|
|
accepted: membership?.accepted,
|
|
disableImpersonation: membership?.disableImpersonation,
|
|
};
|
|
});
|
|
|
|
return { ...team, members };
|
|
}
|
|
// also returns team
|
|
export async function isTeamAdmin(userId: number, teamId: number) {
|
|
return (
|
|
(await prisma.membership.findFirst({
|
|
where: {
|
|
userId,
|
|
teamId,
|
|
OR: [{ role: "ADMIN" }, { role: "OWNER" }],
|
|
},
|
|
})) || false
|
|
);
|
|
}
|
|
export async function isTeamOwner(userId: number, teamId: number) {
|
|
return !!(await prisma.membership.findFirst({
|
|
where: {
|
|
userId,
|
|
teamId,
|
|
role: "OWNER",
|
|
},
|
|
}));
|
|
}
|
|
|
|
export async function isTeamMember(userId: number, teamId: number) {
|
|
return !!(await prisma.membership.findFirst({
|
|
where: {
|
|
userId,
|
|
teamId,
|
|
},
|
|
}));
|
|
}
|