2023-07-27 14:06:39 +00:00
|
|
|
import type { DehydratedState } from "@tanstack/react-query";
|
2022-04-25 04:33:00 +00:00
|
|
|
import classNames from "classnames";
|
2023-07-27 14:06:39 +00:00
|
|
|
import type { GetServerSideProps, InferGetServerSidePropsType } from "next";
|
2021-09-06 13:51:15 +00:00
|
|
|
import Link from "next/link";
|
2022-02-01 21:48:40 +00:00
|
|
|
import { Toaster } from "react-hot-toast";
|
2023-07-27 14:06:39 +00:00
|
|
|
import type { z } from "zod";
|
2021-09-22 19:52:38 +00:00
|
|
|
|
2022-05-27 15:37:02 +00:00
|
|
|
import {
|
|
|
|
sdkActionManager,
|
|
|
|
useEmbedNonStylesConfig,
|
|
|
|
useEmbedStyles,
|
|
|
|
useIsEmbed,
|
|
|
|
} from "@calcom/embed-core/embed-iframe";
|
2023-07-31 20:27:22 +00:00
|
|
|
import { getSlugOrRequestedSlug } from "@calcom/features/ee/organizations/lib/orgDomains";
|
feat: Organizations (#8993)
* Initial commit
* Adding feature flag
* feat: Orgs Schema Changing `scopedMembers` to `orgUsers` (#9209)
* Change scopedMembers to orgMembers
* Change to orgUsers
* Letting duplicate slugs for teams to support orgs
* Covering null on unique clauses
* Supporting having the orgId in the session cookie
* feat: organization event type filter (#9253)
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* Missing changes to support orgs schema changes
* 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 <55134778+sean-brydon@users.noreply.github.com>
* 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 <55134778+sean-brydon@users.noreply.github.com>
* Vercel subdomain creation in PROD only
* Making sure we let localhost still work
* Feedback
* Type check fixes
* feat: Organization branding in side menu (#9279)
* 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
* Org branding provider used in shell sidebar
* Using meta component for head/descr
* Missing i18n strings
* Feedback
* Making an org avatar (temp)
* Using org avatar (temp)
* Not showing org logo if not set
* User onboarding with org branding (slug)
* Check for subteams slug clashes with usernames
* Fixing create teams onsuccess
* feedback
* Feedback
* Org public profile
* Public profiles for team event types
* Added setup profile alert
* Using org avatar on subteams avatar
* Making sure we show the set up profile on org only
* Profile username availability rely on org hook
* Update apps/web/pages/team/[slug].tsx
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* Update apps/web/pages/team/[slug].tsx
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
---------
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* feat: Organization support for event types page (#9449)
* 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
* Org branding provider used in shell sidebar
* Using meta component for head/descr
* Missing i18n strings
* Feedback
* Making an org avatar (temp)
* Using org avatar (temp)
* Not showing org logo if not set
* User onboarding with org branding (slug)
* Check for subteams slug clashes with usernames
* Fixing create teams onsuccess
* feedback
* Feedback
* Org public profile
* Public profiles for team event types
* Added setup profile alert
* Using org avatar on subteams avatar
* Processing orgs and children as profile options
* Reverting change not belonging to this PR
* Making sure we show the set up profile on org only
* Removing console.log
* Comparing memberships to choose the highest one
---------
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* Type errors
* Refactor and type fixes
* Update orgDomains.ts
* Feedback
* Reverting
* NIT
* fix issue getting org slug from domain
* Improving orgDomains util
* Host comes with port
* Update useRouterQuery.ts
* Feedback
* Feedback
* Feedback
* Feedback: SSR for user event-types to have org context
* chore: Cache node_modules (#9492)
* Adding check for cache hit
* Adding a separate install step first
* Put the restore cache steps back
* Revert the uses type for restoring cache
* Added step to restore nm cache
* Removed the cache-hit check
* Comments and naming
* Removed extra install command
* Updated the name of the linting step to be more clear
* Removes the need for useEffect here
* Feedback
* Feedback
* Cookie domain needs a dot
* Type fix
* Update apps/web/public/static/locales/en/common.json
Co-authored-by: Omar López <zomars@me.com>
* Update packages/emails/src/templates/OrganizationAccountVerifyEmail.tsx
* Feedback
---------
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
Co-authored-by: zomars <zomars@me.com>
Co-authored-by: Efraín Rochín <roae.85@gmail.com>
Co-authored-by: Keith Williams <keithwillcode@gmail.com>
2023-06-14 21:40:20 +00:00
|
|
|
import { orgDomainConfig } from "@calcom/features/ee/organizations/lib/orgDomains";
|
2022-12-22 19:06:26 +00:00
|
|
|
import { EventTypeDescriptionLazy as EventTypeDescription } from "@calcom/features/eventtypes/components";
|
2022-10-24 22:20:41 +00:00
|
|
|
import EmptyPage from "@calcom/features/eventtypes/components/EmptyPage";
|
2023-07-25 21:48:09 +00:00
|
|
|
import { getUsernameList } from "@calcom/lib/defaultEvents";
|
2022-03-31 08:45:47 +00:00
|
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
2023-08-02 09:35:48 +00:00
|
|
|
import { useRouterQuery } from "@calcom/lib/hooks/useRouterQuery";
|
2022-07-28 19:58:26 +00:00
|
|
|
import useTheme from "@calcom/lib/hooks/useTheme";
|
2023-03-28 09:40:13 +00:00
|
|
|
import { markdownToSafeHTML } from "@calcom/lib/markdownToSafeHTML";
|
2023-05-15 07:44:23 +00:00
|
|
|
import { stripMarkdown } from "@calcom/lib/stripMarkdown";
|
2022-07-28 19:58:26 +00:00
|
|
|
import prisma from "@calcom/prisma";
|
2023-07-27 14:06:39 +00:00
|
|
|
import type { EventType, User } from "@calcom/prisma/client";
|
2022-07-28 19:58:26 +00:00
|
|
|
import { baseEventTypeSelect } from "@calcom/prisma/selects";
|
2022-10-14 16:24:43 +00:00
|
|
|
import { EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";
|
2023-07-31 20:27:22 +00:00
|
|
|
import { Avatar, HeadSeo, UnpublishedEntity } from "@calcom/ui";
|
2023-05-17 12:47:44 +00:00
|
|
|
import { Verified, ArrowRight } from "@calcom/ui/components/icon";
|
2022-03-31 08:45:47 +00:00
|
|
|
|
2023-02-16 22:39:57 +00:00
|
|
|
import type { EmbedProps } from "@lib/withEmbedSsr";
|
2021-09-22 19:52:38 +00:00
|
|
|
|
2023-04-18 18:45:32 +00:00
|
|
|
import PageWrapper from "@components/PageWrapper";
|
|
|
|
|
2021-10-20 16:00:11 +00:00
|
|
|
import { ssrInit } from "@server/lib/ssr";
|
|
|
|
|
2023-07-27 14:06:39 +00:00
|
|
|
export function UserPage(props: InferGetServerSidePropsType<typeof getServerSideProps>) {
|
2023-07-31 20:27:22 +00:00
|
|
|
const { users, profile, eventTypes, markdownStrippedBio, entity } = props;
|
2023-08-15 00:44:09 +00:00
|
|
|
|
2022-04-06 17:20:30 +00:00
|
|
|
const [user] = users; //To be used when we only have a single user, not dynamic group
|
2023-07-27 14:06:39 +00:00
|
|
|
useTheme(profile.theme);
|
2021-10-12 13:11:33 +00:00
|
|
|
const { t } = useLocale();
|
2022-06-15 20:54:31 +00:00
|
|
|
|
2023-01-25 01:08:10 +00:00
|
|
|
const isBioEmpty = !user.bio || !user.bio.replace("<p><br></p>", "").length;
|
|
|
|
|
2022-10-19 21:25:03 +00:00
|
|
|
const isEmbed = useIsEmbed(props.isEmbed);
|
2022-03-31 08:45:47 +00:00
|
|
|
const eventTypeListItemEmbedStyles = useEmbedStyles("eventTypeListItem");
|
2022-04-25 04:33:00 +00:00
|
|
|
const shouldAlignCentrallyInEmbed = useEmbedNonStylesConfig("align") !== "left";
|
|
|
|
const shouldAlignCentrally = !isEmbed || shouldAlignCentrallyInEmbed;
|
2023-08-02 09:35:48 +00:00
|
|
|
const {
|
|
|
|
// So it doesn't display in the Link (and make tests fail)
|
|
|
|
user: _user,
|
|
|
|
orgSlug: _orgSlug,
|
|
|
|
...query
|
|
|
|
} = useRouterQuery();
|
|
|
|
const nameOrUsername = user.name || user.username || "";
|
2022-04-14 02:47:34 +00:00
|
|
|
|
2023-05-24 23:35:44 +00:00
|
|
|
/*
|
2023-04-16 21:58:47 +00:00
|
|
|
const telemetry = useTelemetry();
|
|
|
|
useEffect(() => {
|
2022-06-02 16:19:01 +00:00
|
|
|
if (top !== window) {
|
|
|
|
//page_view will be collected automatically by _middleware.ts
|
|
|
|
telemetry.event(telemetryEventTypes.embedView, collectPageParameters("/[user]"));
|
|
|
|
}
|
2023-04-16 21:58:47 +00:00
|
|
|
}, [telemetry, router.asPath]); */
|
2023-07-31 20:27:22 +00:00
|
|
|
|
|
|
|
if (entity?.isUnpublished) {
|
|
|
|
return (
|
|
|
|
<div className="flex h-full min-h-[100dvh] items-center justify-center">
|
|
|
|
<UnpublishedEntity {...entity} />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-10-24 22:20:41 +00:00
|
|
|
const isEventListEmpty = eventTypes.length === 0;
|
2021-07-11 19:35:56 +00:00
|
|
|
return (
|
2021-08-12 17:05:46 +00:00
|
|
|
<>
|
2021-08-27 12:35:20 +00:00
|
|
|
<HeadSeo
|
2023-07-27 14:06:39 +00:00
|
|
|
title={profile.name}
|
2023-07-25 21:48:09 +00:00
|
|
|
description={markdownStrippedBio}
|
2022-10-18 17:46:22 +00:00
|
|
|
meeting={{
|
2023-07-25 21:48:09 +00:00
|
|
|
title: markdownStrippedBio,
|
2022-10-18 17:46:22 +00:00
|
|
|
profile: { name: `${profile.name}`, image: null },
|
2023-07-25 21:48:09 +00:00
|
|
|
users: [{ username: `${user.username}`, name: `${user.name}` }],
|
2022-10-18 17:46:22 +00:00
|
|
|
}}
|
2023-08-15 00:44:09 +00:00
|
|
|
nextSeoProps={{
|
|
|
|
noindex: !profile.allowSEOIndexing,
|
|
|
|
nofollow: !profile.allowSEOIndexing,
|
|
|
|
}}
|
2021-08-27 12:35:20 +00:00
|
|
|
/>
|
2022-04-25 04:33:00 +00:00
|
|
|
|
2023-04-05 18:14:46 +00:00
|
|
|
<div className={classNames(shouldAlignCentrally ? "mx-auto" : "", isEmbed ? "max-w-3xl" : "")}>
|
2022-04-25 04:33:00 +00:00
|
|
|
<main
|
|
|
|
className={classNames(
|
|
|
|
shouldAlignCentrally ? "mx-auto" : "",
|
2023-04-20 22:33:49 +00:00
|
|
|
isEmbed ? "border-booker border-booker-width bg-default rounded-md border" : "",
|
2023-06-22 22:25:37 +00:00
|
|
|
"max-w-3xl px-4 py-24"
|
2022-04-25 04:33:00 +00:00
|
|
|
)}>
|
2023-07-27 14:06:39 +00:00
|
|
|
<div className="mb-8 text-center">
|
|
|
|
<Avatar imageSrc={profile.image} size="xl" alt={profile.name} />
|
2023-08-22 11:03:00 +00:00
|
|
|
<h1 className="font-cal text-emphasis mb-1 text-3xl" data-testid="name-title">
|
2023-07-27 14:06:39 +00:00
|
|
|
{profile.name}
|
|
|
|
{user.verified && (
|
|
|
|
<Verified className=" mx-1 -mt-1 inline h-6 w-6 fill-blue-500 text-white dark:text-black" />
|
2023-01-25 01:08:10 +00:00
|
|
|
)}
|
2023-07-27 14:06:39 +00:00
|
|
|
</h1>
|
|
|
|
{!isBioEmpty && (
|
|
|
|
<>
|
|
|
|
<div
|
|
|
|
className=" text-subtle break-words text-sm [&_a]:text-blue-500 [&_a]:underline [&_a]:hover:text-blue-600"
|
|
|
|
dangerouslySetInnerHTML={{ __html: props.safeBio }}
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
</div>
|
2023-04-05 18:14:46 +00:00
|
|
|
|
2022-08-24 20:18:42 +00:00
|
|
|
<div
|
2023-04-05 18:14:46 +00:00
|
|
|
className={classNames("rounded-md ", !isEventListEmpty && "border-subtle border")}
|
2022-08-24 20:18:42 +00:00
|
|
|
data-testid="event-types">
|
2022-03-10 19:21:27 +00:00
|
|
|
{user.away ? (
|
2023-04-05 18:14:46 +00:00
|
|
|
<div className="overflow-hidden rounded-sm border ">
|
|
|
|
<div className="text-muted p-8 text-center">
|
|
|
|
<h2 className="font-cal text-default mb-2 text-3xl">😴{" " + t("user_away")}</h2>
|
2022-05-20 07:06:21 +00:00
|
|
|
<p className="mx-auto max-w-md">{t("user_away_description") as string}</p>
|
2022-03-10 19:21:27 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
) : (
|
2022-02-11 14:34:12 +00:00
|
|
|
eventTypes.map((type) => (
|
|
|
|
<div
|
|
|
|
key={type.id}
|
2022-03-31 08:45:47 +00:00
|
|
|
style={{ display: "flex", ...eventTypeListItemEmbedStyles }}
|
2023-04-22 15:47:15 +00:00
|
|
|
className="bg-default border-subtle dark:bg-muted dark:hover:bg-emphasis hover:bg-muted group relative border-b first:rounded-t-md last:rounded-b-md last:border-b-0">
|
2023-04-12 15:26:31 +00:00
|
|
|
<ArrowRight className="text-emphasis absolute right-4 top-4 h-4 w-4 opacity-0 transition-opacity group-hover:opacity-100" />
|
2022-03-05 15:28:24 +00:00
|
|
|
{/* Don't prefetch till the time we drop the amount of javascript in [user][type] page which is impacting score for [user] page */}
|
2023-03-08 15:46:23 +00:00
|
|
|
<div className="block w-full p-5">
|
|
|
|
<Link
|
|
|
|
prefetch={false}
|
|
|
|
href={{
|
|
|
|
pathname: `/${user.username}/${type.slug}`,
|
|
|
|
query,
|
|
|
|
}}
|
|
|
|
passHref
|
|
|
|
onClick={async () => {
|
|
|
|
sdkActionManager?.fire("eventTypeSelected", {
|
|
|
|
eventType: type,
|
|
|
|
});
|
|
|
|
}}
|
|
|
|
data-testid="event-type-link">
|
|
|
|
<div className="flex flex-wrap items-center">
|
2023-04-05 18:14:46 +00:00
|
|
|
<h2 className=" text-default pr-2 text-sm font-semibold">{type.title}</h2>
|
2023-03-08 15:46:23 +00:00
|
|
|
</div>
|
2023-04-13 02:10:23 +00:00
|
|
|
<EventTypeDescription eventType={type} isPublic={true} />
|
2023-03-08 15:46:23 +00:00
|
|
|
</Link>
|
|
|
|
</div>
|
2021-08-12 17:05:46 +00:00
|
|
|
</div>
|
2022-03-10 19:21:27 +00:00
|
|
|
))
|
|
|
|
)}
|
2022-02-11 14:34:12 +00:00
|
|
|
</div>
|
2023-04-05 18:14:46 +00:00
|
|
|
|
2023-07-27 14:06:39 +00:00
|
|
|
{isEventListEmpty && <EmptyPage name={profile.name || "User"} />}
|
2022-02-11 14:34:12 +00:00
|
|
|
</main>
|
|
|
|
<Toaster position="bottom-right" />
|
|
|
|
</div>
|
2021-08-12 17:05:46 +00:00
|
|
|
</>
|
2021-06-22 17:42:32 +00:00
|
|
|
);
|
2021-03-22 13:48:48 +00:00
|
|
|
}
|
|
|
|
|
2023-06-21 21:12:12 +00:00
|
|
|
UserPage.isBookingPage = true;
|
|
|
|
UserPage.PageWrapper = PageWrapper;
|
2023-04-17 12:16:54 +00:00
|
|
|
|
2022-10-14 16:24:43 +00:00
|
|
|
const getEventTypesWithHiddenFromDB = async (userId: number) => {
|
|
|
|
return (
|
|
|
|
await prisma.eventType.findMany({
|
|
|
|
where: {
|
|
|
|
AND: [
|
|
|
|
{
|
|
|
|
teamId: null,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
OR: [
|
|
|
|
{
|
|
|
|
userId,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
users: {
|
|
|
|
some: {
|
|
|
|
id: userId,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
orderBy: [
|
2021-10-08 11:43:48 +00:00
|
|
|
{
|
2022-10-14 16:24:43 +00:00
|
|
|
position: "desc",
|
2021-10-08 11:43:48 +00:00
|
|
|
},
|
|
|
|
{
|
2022-10-14 16:24:43 +00:00
|
|
|
id: "asc",
|
2021-10-08 11:43:48 +00:00
|
|
|
},
|
|
|
|
],
|
2022-10-14 16:24:43 +00:00
|
|
|
select: {
|
|
|
|
...baseEventTypeSelect,
|
|
|
|
metadata: true,
|
2021-11-15 12:25:49 +00:00
|
|
|
},
|
2022-10-14 16:24:43 +00:00
|
|
|
})
|
|
|
|
).map((eventType) => ({
|
|
|
|
...eventType,
|
|
|
|
metadata: EventTypeMetaDataSchema.parse(eventType.metadata),
|
|
|
|
}));
|
2022-04-06 17:20:30 +00:00
|
|
|
};
|
|
|
|
|
2023-07-27 14:06:39 +00:00
|
|
|
export type UserPageProps = {
|
|
|
|
trpcState: DehydratedState;
|
|
|
|
profile: {
|
|
|
|
name: string;
|
|
|
|
image: string;
|
|
|
|
theme: string | null;
|
|
|
|
brandColor: string;
|
|
|
|
darkBrandColor: string;
|
2023-08-15 00:44:09 +00:00
|
|
|
allowSEOIndexing: boolean;
|
2023-07-27 14:06:39 +00:00
|
|
|
};
|
|
|
|
users: Pick<User, "away" | "name" | "username" | "bio" | "verified">[];
|
|
|
|
themeBasis: string | null;
|
|
|
|
markdownStrippedBio: string;
|
|
|
|
safeBio: string;
|
2023-07-31 20:27:22 +00:00
|
|
|
entity: {
|
|
|
|
isUnpublished?: boolean;
|
|
|
|
orgSlug?: string | null;
|
|
|
|
name?: string | null;
|
|
|
|
};
|
2023-07-27 14:06:39 +00:00
|
|
|
eventTypes: ({
|
|
|
|
descriptionAsSafeHTML: string;
|
|
|
|
metadata: z.infer<typeof EventTypeMetaDataSchema>;
|
|
|
|
} & Pick<
|
|
|
|
EventType,
|
|
|
|
| "id"
|
|
|
|
| "title"
|
|
|
|
| "slug"
|
|
|
|
| "length"
|
|
|
|
| "hidden"
|
|
|
|
| "requiresConfirmation"
|
2023-07-31 17:51:11 +00:00
|
|
|
| "requiresBookerEmailVerification"
|
2023-07-27 14:06:39 +00:00
|
|
|
| "price"
|
|
|
|
| "currency"
|
|
|
|
| "recurringEvent"
|
|
|
|
>)[];
|
|
|
|
} & EmbedProps;
|
|
|
|
|
|
|
|
export const getServerSideProps: GetServerSideProps<UserPageProps> = async (context) => {
|
2022-04-06 17:20:30 +00:00
|
|
|
const ssr = await ssrInit(context);
|
2023-07-31 20:27:22 +00:00
|
|
|
const { currentOrgDomain, isValidOrgDomain } = orgDomainConfig(
|
|
|
|
context.req.headers.host ?? "",
|
|
|
|
context.params?.orgSlug
|
|
|
|
);
|
2022-04-06 17:20:30 +00:00
|
|
|
const usernameList = getUsernameList(context.query.user as string);
|
|
|
|
const dataFetchStart = Date.now();
|
2023-03-09 12:17:13 +00:00
|
|
|
const usersWithoutAvatar = await prisma.user.findMany({
|
2022-04-06 17:20:30 +00:00
|
|
|
where: {
|
|
|
|
username: {
|
|
|
|
in: usernameList,
|
|
|
|
},
|
2023-07-31 20:27:22 +00:00
|
|
|
organization: isValidOrgDomain && currentOrgDomain ? getSlugOrRequestedSlug(currentOrgDomain) : null,
|
2022-04-06 17:20:30 +00:00
|
|
|
},
|
|
|
|
select: {
|
|
|
|
id: true,
|
|
|
|
username: true,
|
|
|
|
email: true,
|
|
|
|
name: true,
|
|
|
|
bio: true,
|
2022-04-25 04:33:00 +00:00
|
|
|
brandColor: true,
|
|
|
|
darkBrandColor: true,
|
feat: Organizations (#8993)
* Initial commit
* Adding feature flag
* feat: Orgs Schema Changing `scopedMembers` to `orgUsers` (#9209)
* Change scopedMembers to orgMembers
* Change to orgUsers
* Letting duplicate slugs for teams to support orgs
* Covering null on unique clauses
* Supporting having the orgId in the session cookie
* feat: organization event type filter (#9253)
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* Missing changes to support orgs schema changes
* 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 <55134778+sean-brydon@users.noreply.github.com>
* 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 <55134778+sean-brydon@users.noreply.github.com>
* Vercel subdomain creation in PROD only
* Making sure we let localhost still work
* Feedback
* Type check fixes
* feat: Organization branding in side menu (#9279)
* 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
* Org branding provider used in shell sidebar
* Using meta component for head/descr
* Missing i18n strings
* Feedback
* Making an org avatar (temp)
* Using org avatar (temp)
* Not showing org logo if not set
* User onboarding with org branding (slug)
* Check for subteams slug clashes with usernames
* Fixing create teams onsuccess
* feedback
* Feedback
* Org public profile
* Public profiles for team event types
* Added setup profile alert
* Using org avatar on subteams avatar
* Making sure we show the set up profile on org only
* Profile username availability rely on org hook
* Update apps/web/pages/team/[slug].tsx
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* Update apps/web/pages/team/[slug].tsx
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
---------
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* feat: Organization support for event types page (#9449)
* 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
* Org branding provider used in shell sidebar
* Using meta component for head/descr
* Missing i18n strings
* Feedback
* Making an org avatar (temp)
* Using org avatar (temp)
* Not showing org logo if not set
* User onboarding with org branding (slug)
* Check for subteams slug clashes with usernames
* Fixing create teams onsuccess
* feedback
* Feedback
* Org public profile
* Public profiles for team event types
* Added setup profile alert
* Using org avatar on subteams avatar
* Processing orgs and children as profile options
* Reverting change not belonging to this PR
* Making sure we show the set up profile on org only
* Removing console.log
* Comparing memberships to choose the highest one
---------
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* Type errors
* Refactor and type fixes
* Update orgDomains.ts
* Feedback
* Reverting
* NIT
* fix issue getting org slug from domain
* Improving orgDomains util
* Host comes with port
* Update useRouterQuery.ts
* Feedback
* Feedback
* Feedback
* Feedback: SSR for user event-types to have org context
* chore: Cache node_modules (#9492)
* Adding check for cache hit
* Adding a separate install step first
* Put the restore cache steps back
* Revert the uses type for restoring cache
* Added step to restore nm cache
* Removed the cache-hit check
* Comments and naming
* Removed extra install command
* Updated the name of the linting step to be more clear
* Removes the need for useEffect here
* Feedback
* Feedback
* Cookie domain needs a dot
* Type fix
* Update apps/web/public/static/locales/en/common.json
Co-authored-by: Omar López <zomars@me.com>
* Update packages/emails/src/templates/OrganizationAccountVerifyEmail.tsx
* Feedback
---------
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
Co-authored-by: zomars <zomars@me.com>
Co-authored-by: Efraín Rochín <roae.85@gmail.com>
Co-authored-by: Keith Williams <keithwillcode@gmail.com>
2023-06-14 21:40:20 +00:00
|
|
|
organizationId: true,
|
2023-07-31 20:27:22 +00:00
|
|
|
organization: {
|
|
|
|
select: {
|
|
|
|
slug: true,
|
|
|
|
name: true,
|
|
|
|
},
|
|
|
|
},
|
2022-04-06 17:20:30 +00:00
|
|
|
theme: true,
|
|
|
|
away: true,
|
|
|
|
verified: true,
|
|
|
|
allowDynamicBooking: true,
|
2023-08-15 00:44:09 +00:00
|
|
|
allowSEOIndexing: true,
|
2022-04-06 17:20:30 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2023-07-25 21:48:09 +00:00
|
|
|
const isDynamicGroup = usersWithoutAvatar.length > 1;
|
|
|
|
if (isDynamicGroup) {
|
|
|
|
return {
|
|
|
|
redirect: {
|
|
|
|
permanent: false,
|
|
|
|
destination: `/${usernameList.join("+")}/dynamic`,
|
|
|
|
},
|
|
|
|
} as {
|
|
|
|
redirect: {
|
|
|
|
permanent: false;
|
|
|
|
destination: string;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-03-09 12:17:13 +00:00
|
|
|
const users = usersWithoutAvatar.map((user) => ({
|
|
|
|
...user,
|
2023-07-11 14:23:07 +00:00
|
|
|
avatar: `/${user.username}/avatar.png`,
|
2023-03-09 12:17:13 +00:00
|
|
|
}));
|
|
|
|
|
feat: Organizations (#8993)
* Initial commit
* Adding feature flag
* feat: Orgs Schema Changing `scopedMembers` to `orgUsers` (#9209)
* Change scopedMembers to orgMembers
* Change to orgUsers
* Letting duplicate slugs for teams to support orgs
* Covering null on unique clauses
* Supporting having the orgId in the session cookie
* feat: organization event type filter (#9253)
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* Missing changes to support orgs schema changes
* 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 <55134778+sean-brydon@users.noreply.github.com>
* 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 <55134778+sean-brydon@users.noreply.github.com>
* Vercel subdomain creation in PROD only
* Making sure we let localhost still work
* Feedback
* Type check fixes
* feat: Organization branding in side menu (#9279)
* 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
* Org branding provider used in shell sidebar
* Using meta component for head/descr
* Missing i18n strings
* Feedback
* Making an org avatar (temp)
* Using org avatar (temp)
* Not showing org logo if not set
* User onboarding with org branding (slug)
* Check for subteams slug clashes with usernames
* Fixing create teams onsuccess
* feedback
* Feedback
* Org public profile
* Public profiles for team event types
* Added setup profile alert
* Using org avatar on subteams avatar
* Making sure we show the set up profile on org only
* Profile username availability rely on org hook
* Update apps/web/pages/team/[slug].tsx
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* Update apps/web/pages/team/[slug].tsx
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
---------
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* feat: Organization support for event types page (#9449)
* 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
* Org branding provider used in shell sidebar
* Using meta component for head/descr
* Missing i18n strings
* Feedback
* Making an org avatar (temp)
* Using org avatar (temp)
* Not showing org logo if not set
* User onboarding with org branding (slug)
* Check for subteams slug clashes with usernames
* Fixing create teams onsuccess
* feedback
* Feedback
* Org public profile
* Public profiles for team event types
* Added setup profile alert
* Using org avatar on subteams avatar
* Processing orgs and children as profile options
* Reverting change not belonging to this PR
* Making sure we show the set up profile on org only
* Removing console.log
* Comparing memberships to choose the highest one
---------
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* Type errors
* Refactor and type fixes
* Update orgDomains.ts
* Feedback
* Reverting
* NIT
* fix issue getting org slug from domain
* Improving orgDomains util
* Host comes with port
* Update useRouterQuery.ts
* Feedback
* Feedback
* Feedback
* Feedback: SSR for user event-types to have org context
* chore: Cache node_modules (#9492)
* Adding check for cache hit
* Adding a separate install step first
* Put the restore cache steps back
* Revert the uses type for restoring cache
* Added step to restore nm cache
* Removed the cache-hit check
* Comments and naming
* Removed extra install command
* Updated the name of the linting step to be more clear
* Removes the need for useEffect here
* Feedback
* Feedback
* Cookie domain needs a dot
* Type fix
* Update apps/web/public/static/locales/en/common.json
Co-authored-by: Omar López <zomars@me.com>
* Update packages/emails/src/templates/OrganizationAccountVerifyEmail.tsx
* Feedback
---------
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
Co-authored-by: zomars <zomars@me.com>
Co-authored-by: Efraín Rochín <roae.85@gmail.com>
Co-authored-by: Keith Williams <keithwillcode@gmail.com>
2023-06-14 21:40:20 +00:00
|
|
|
if (!users.length || (!isValidOrgDomain && !users.some((user) => user.organizationId === null))) {
|
2022-04-06 17:20:30 +00:00
|
|
|
return {
|
|
|
|
notFound: true,
|
2022-10-19 21:25:03 +00:00
|
|
|
} as {
|
|
|
|
notFound: true;
|
2022-04-06 17:20:30 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
const [user] = users; //to be used when dealing with single user, not dynamic group
|
2022-04-25 04:33:00 +00:00
|
|
|
|
2023-07-25 21:48:09 +00:00
|
|
|
const profile = {
|
2023-07-27 14:06:39 +00:00
|
|
|
name: user.name || user.username || "",
|
2023-07-25 21:48:09 +00:00
|
|
|
image: user.avatar,
|
|
|
|
theme: user.theme,
|
|
|
|
brandColor: user.brandColor,
|
|
|
|
darkBrandColor: user.darkBrandColor,
|
2023-08-15 00:44:09 +00:00
|
|
|
allowSEOIndexing: user.allowSEOIndexing ?? true,
|
2023-07-25 21:48:09 +00:00
|
|
|
};
|
2022-04-06 17:20:30 +00:00
|
|
|
|
2023-07-25 21:48:09 +00:00
|
|
|
const eventTypesWithHidden = await getEventTypesWithHiddenFromDB(user.id);
|
2022-03-04 10:03:10 +00:00
|
|
|
const dataFetchEnd = Date.now();
|
|
|
|
if (context.query.log === "1") {
|
|
|
|
context.res.setHeader("X-Data-Fetch-Time", `${dataFetchEnd - dataFetchStart}ms`);
|
|
|
|
}
|
2022-02-01 21:48:40 +00:00
|
|
|
const eventTypesRaw = eventTypesWithHidden.filter((evt) => !evt.hidden);
|
|
|
|
|
|
|
|
const eventTypes = eventTypesRaw.map((eventType) => ({
|
|
|
|
...eventType,
|
2022-10-14 16:24:43 +00:00
|
|
|
metadata: EventTypeMetaDataSchema.parse(eventType.metadata || {}),
|
2023-03-28 09:40:13 +00:00
|
|
|
descriptionAsSafeHTML: markdownToSafeHTML(eventType.description),
|
2022-02-01 21:48:40 +00:00
|
|
|
}));
|
2021-10-08 11:43:48 +00:00
|
|
|
|
2023-03-28 09:40:13 +00:00
|
|
|
const safeBio = markdownToSafeHTML(user.bio) || "";
|
|
|
|
|
2023-05-15 07:44:23 +00:00
|
|
|
const markdownStrippedBio = stripMarkdown(user?.bio || "");
|
2023-07-31 20:27:22 +00:00
|
|
|
const org = usersWithoutAvatar[0].organization;
|
2023-06-21 21:12:12 +00:00
|
|
|
|
2021-06-22 17:42:32 +00:00
|
|
|
return {
|
|
|
|
props: {
|
2023-07-27 14:06:39 +00:00
|
|
|
users: users.map((user) => ({
|
|
|
|
name: user.name,
|
|
|
|
username: user.username,
|
|
|
|
bio: user.bio,
|
|
|
|
away: user.away,
|
|
|
|
verified: user.verified,
|
|
|
|
})),
|
2023-07-31 20:27:22 +00:00
|
|
|
entity: {
|
|
|
|
isUnpublished: org?.slug === null,
|
|
|
|
orgSlug: currentOrgDomain,
|
|
|
|
name: org?.name ?? null,
|
|
|
|
},
|
2023-07-27 14:06:39 +00:00
|
|
|
eventTypes,
|
2023-03-28 09:40:13 +00:00
|
|
|
safeBio,
|
2022-04-25 04:33:00 +00:00
|
|
|
profile,
|
2023-05-16 19:41:47 +00:00
|
|
|
// Dynamic group has no theme preference right now. It uses system theme.
|
2023-07-25 21:48:09 +00:00
|
|
|
themeBasis: user.username,
|
2021-10-20 16:00:11 +00:00
|
|
|
trpcState: ssr.dehydrate(),
|
2023-05-15 07:44:23 +00:00
|
|
|
markdownStrippedBio,
|
2021-06-22 17:42:32 +00:00
|
|
|
},
|
|
|
|
};
|
2021-10-08 11:43:48 +00:00
|
|
|
};
|
2023-06-21 21:12:12 +00:00
|
|
|
|
|
|
|
export default UserPage;
|