* Initial commit * Adding feature flag * Desktop first banner, mobile pending * Removing dead code and img * AppInstallButtonBase * WIP * Adds Email verification template+translations for organizations (#9202) * feat: Orgs Schema Changing `scopedMembers` to `orgUsers` (#9209) * Change scopedMembers to orgMembers * Change to orgUsers * First step done * Merge branch 'feat/organizations-onboarding' of github.com:calcom/cal.com into feat/organizations-onboarding * Session logic to show org label * Step 2 done, avatar not working * List orgs and list teams specific if orgs exist * Conditionally show org - fix settings layout - add labels for all pages * Profile Page + update * Org specific team creation * appearance page * Ensure members cant of org cant update settings in UI * Fix update handler imports * hide billing on sub teams * Update profile slug page * Letting duplicate slugs for teams to support orgs * Add slug coliisions for org * Covering null on unique clauses * Covering null on unique clauses * Extract to utils * Update settings to use subdomain path in team url , team + org * Supporting having the orgId in the session cookie * Onboarding admins step * Last step to create teams * Update handler comments * Upgrade ORG banner - disabled team banner for child teams * Handle publishing ORGS * Fix licenese issue * Update packages/trpc/server/routers/viewer/teams/create.handler.ts * Split into function calls to make this file more explisit * Update parents stripe sub not teamID * Moving change password handler, improving verifying code flow * Clearing error before submitting * Reverting email testing api changes * Reverting having the banner for now * Consistent exported components * Remove unneeded files from banner * Removing uneeded code * Fixing avatar selector * Using meta component for head/descr * Missing i18n strings * Create org membership also - billing portal page * A11ly * Hide create team if no valid permisisons * Get Org members router * Handle updating subscription if orgId * Fix double upgrade banner * Update constants * Feedback * Copy change * Making an org avatar (temp) * Add slug colission detection for user and team name * Fix Import * Remove update password func * Fix module import over relative * feat: organization event type filter (#9253) Signed-off-by: Udit Takkar <[email protected]> * Missing changes to support orgs schema changes * Fix import again * Throw no team found before auth error * Check if invited found user is already in differnt org * feat: organization settings general page Signed-off-by: Udit Takkar <[email protected]> * feat: add members page Signed-off-by: Udit Takkar <[email protected]> * chore: remove Signed-off-by: Udit Takkar <[email protected]> * fix: use invalidate Signed-off-by: Udit Takkar <[email protected]> * Move to for of loop to throw errors in usenamelist * fix: delete mutation Signed-off-by: Udit Takkar <[email protected]> * fix: remove organization id Signed-off-by: Udit Takkar <[email protected]> * chore Signed-off-by: Udit Takkar <[email protected]> * Remove app install button sa its in 9337 * Remove i18n key not being used * feat: Onboarding process to create an organization (#9184) * Desktop first banner, mobile pending * Removing dead code and img * WIP * Adds Email verification template+translations for organizations (#9202) * First step done * Merge branch 'feat/organizations-onboarding' of github.com:calcom/cal.com into feat/organizations-onboarding * Step 2 done, avatar not working * Covering null on unique clauses * Onboarding admins step * Last step to create teams * Moving change password handler, improving verifying code flow * Clearing error before submitting * Reverting email testing api changes * Reverting having the banner for now * Consistent exported components * Remove unneeded files from banner * Removing uneeded code * Fixing avatar selector * Using meta component for head/descr * Missing i18n strings * Feedback * Making an org avatar (temp) * Check for subteams slug clashes with usernames * Fixing create teams onsuccess * feedback * Making sure we check requestedSlug now --------- Co-authored-by: sean-brydon <[email protected]> * feat: [CAL-1816] Organization subdomain support (#9345) * Desktop first banner, mobile pending * Removing dead code and img * WIP * Adds Email verification template+translations for organizations (#9202) * First step done * Merge branch 'feat/organizations-onboarding' of github.com:calcom/cal.com into feat/organizations-onboarding * Step 2 done, avatar not working * Covering null on unique clauses * Onboarding admins step * Last step to create teams * Moving change password handler, improving verifying code flow * Clearing error before submitting * Reverting email testing api changes * Reverting having the banner for now * Consistent exported components * Remove unneeded files from banner * Removing uneeded code * Fixing avatar selector * Using meta component for head/descr * Missing i18n strings * Feedback * Making an org avatar (temp) * Check for subteams slug clashes with usernames * Fixing create teams onsuccess * Covering users and subteams, excluding non-org users * Unpublished teams shows correctly * Create subdomain in Vercel * feedback * Renaming Vercel env vars * Vercel domain check before creation * Supporting cal-staging.com * Change to have vercel detect it * vercel domain check data message error * Remove check domain * Making sure we check requestedSlug now * Feedback and unneeded code * Reverting unneeded changes * Unneeded changes --------- Co-authored-by: sean-brydon <[email protected]> * Vercel subdomain creation in PROD only * Fix router * fix: use zod schema Signed-off-by: Udit Takkar <[email protected]> * feat: organization settings general and members page (#9266) * feat: organization settings general page Signed-off-by: Udit Takkar <[email protected]> * feat: add members page Signed-off-by: Udit Takkar <[email protected]> * chore: remove Signed-off-by: Udit Takkar <[email protected]> * fix: use invalidate Signed-off-by: Udit Takkar <[email protected]> * fix: delete mutation Signed-off-by: Udit Takkar <[email protected]> * fix: remove organization id Signed-off-by: Udit Takkar <[email protected]> * chore Signed-off-by: Udit Takkar <[email protected]> * fix: use zod schema Signed-off-by: Udit Takkar <[email protected]> --------- Signed-off-by: Udit Takkar <[email protected]> * Type fixes * Use org Stripe product when upgrading * Removed unused code * UI completed * Reverting changes * Update UsernameTextfield.tsx * More reverts * Update next-auth-options.ts * Update common.json * Type fixes * Include invite token for orgs * Update org schema * Make token settings optional as it isnt used in orgs yet * Reverts * Add correct array logic and move to controlled component * Fix toggle group default | Update toggle group bg * Darkmode toggle group * Distinct user * Hide modal if no org members * Extract toggle logic * Update packages/features/ee/organizations/components/TeamInviteFromOrg.tsx * remove yarn.lock from commit * Fix types * Add getMember router back * As a query lol * Fix types * Fix accepted param defaulting to true as we want both * Fix list not pulling back people who have not joined the org yet * Fix tests to handle invite a existing org user to a team * Fix test * Fix an error sometimes when existing org user is invited * Updates radix & fixes bug --------- Signed-off-by: Udit Takkar <[email protected]> Co-authored-by: Leo Giovanetti <[email protected]> Co-authored-by: Joe Au-Yeung <[email protected]> Co-authored-by: Udit Takkar <[email protected]> Co-authored-by: Udit Takkar <[email protected]> Co-authored-by: zomars <[email protected]> Co-authored-by: Joe Au-Yeung <[email protected]> Co-authored-by: Hariom Balhara <[email protected]> Co-authored-by: Shivam Kalra <[email protected]>
104 lines
3.4 KiB
TypeScript
104 lines
3.4 KiB
TypeScript
import type { PropsWithChildren } from "react";
|
|
import { useState } from "react";
|
|
|
|
import classNames from "@calcom/lib/classNames";
|
|
import type { RouterOutputs } from "@calcom/trpc";
|
|
import { Avatar, TextField } from "@calcom/ui";
|
|
|
|
type TeamInviteFromOrgProps = PropsWithChildren<{
|
|
selectedEmails?: string | string[];
|
|
handleOnChecked: (usersEmail: string) => void;
|
|
orgMembers?: RouterOutputs["viewer"]["organizations"]["getMembers"];
|
|
}>;
|
|
|
|
const keysToCheck = ["name", "email", "username"] as const; // array of keys to check
|
|
|
|
export default function TeamInviteFromOrg({
|
|
handleOnChecked,
|
|
selectedEmails,
|
|
orgMembers,
|
|
}: TeamInviteFromOrgProps) {
|
|
const [searchQuery, setSearchQuery] = useState("");
|
|
|
|
const filteredMembers = orgMembers?.filter((member) => {
|
|
if (!searchQuery) {
|
|
return true; // return all members if searchQuery is empty
|
|
}
|
|
const { user } = member ?? {}; // destructuring with default value in case member is undefined
|
|
return keysToCheck.some((key) => user?.[key]?.toLowerCase().includes(searchQuery.toLowerCase()));
|
|
});
|
|
|
|
return (
|
|
<div className="bg-muted border-subtle flex flex-col rounded-md border p-4">
|
|
<div className="-my-1">
|
|
<TextField placeholder="Search..." onChange={(e) => setSearchQuery(e.target.value)} />
|
|
</div>
|
|
<hr className="border-subtle -mx-4 mt-2" />
|
|
<div className="scrollbar min-h-48 flex max-h-48 flex-col space-y-0.5 overflow-y-scroll pt-2">
|
|
<>
|
|
{filteredMembers &&
|
|
filteredMembers.map((member) => {
|
|
const isSelected = Array.isArray(selectedEmails)
|
|
? selectedEmails.includes(member.user.email)
|
|
: selectedEmails === member.user.email;
|
|
return (
|
|
<UserToInviteItem
|
|
key={member.user.id}
|
|
member={member}
|
|
isSelected={isSelected}
|
|
onChange={() => handleOnChecked(member.user.email)}
|
|
/>
|
|
);
|
|
})}
|
|
</>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
function UserToInviteItem({
|
|
member,
|
|
isSelected,
|
|
onChange,
|
|
}: {
|
|
member: RouterOutputs["viewer"]["organizations"]["getMembers"][number];
|
|
isSelected: boolean;
|
|
onChange: () => void;
|
|
}) {
|
|
return (
|
|
<div
|
|
key={member.userId}
|
|
onClick={() => onChange()} // We handle this on click on the div also - for a11y we handle it with label and checkbox below
|
|
className={classNames(
|
|
"flex cursor-pointer items-center rounded-md py-1 px-2",
|
|
isSelected ? "bg-emphasis" : "hover:bg-subtle "
|
|
)}>
|
|
<div className="flex items-center space-x-2 rtl:space-x-reverse">
|
|
<Avatar
|
|
size="sm"
|
|
alt="Users avatar"
|
|
asChild
|
|
imageSrc={`/api/user/${member.user.username}`}
|
|
gravatarFallbackMd5="hash"
|
|
/>
|
|
<label
|
|
htmlFor={`${member.user.id}`}
|
|
className="text-emphasis cursor-pointer text-sm font-medium leading-none">
|
|
{member.user.name || member.user.email || "Nameless User"}
|
|
</label>
|
|
</div>
|
|
<div className="ml-auto">
|
|
<input
|
|
id={`${member.user.id}`}
|
|
checked={isSelected}
|
|
type="checkbox"
|
|
className="text-primary-600 focus:ring-primary-500 border-default hover:bg-subtle inline-flex h-4 w-4 place-self-center justify-self-end rounded checked:bg-gray-800"
|
|
onChange={() => {
|
|
onChange();
|
|
}}
|
|
/>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|