2022-11-17 18:56:47 +00:00
|
|
|
import { zodResolver } from "@hookform/resolvers/zod";
|
2023-02-27 07:24:43 +00:00
|
|
|
import type { Prisma } from "@prisma/client";
|
2022-09-12 22:04:33 +00:00
|
|
|
import { useSession } from "next-auth/react";
|
|
|
|
import Link from "next/link";
|
|
|
|
import { useRouter } from "next/router";
|
2023-05-02 18:20:03 +00:00
|
|
|
import { useState, useLayoutEffect } from "react";
|
2022-09-12 22:04:33 +00:00
|
|
|
import { Controller, useForm } from "react-hook-form";
|
2022-11-17 18:56:47 +00:00
|
|
|
import { z } from "zod";
|
2022-09-12 22:04:33 +00:00
|
|
|
|
2022-11-11 20:38:21 +00:00
|
|
|
import { IS_TEAM_BILLING_ENABLED, WEBAPP_URL } from "@calcom/lib/constants";
|
2023-03-10 22:10:56 +00:00
|
|
|
import { getPlaceholderAvatar } from "@calcom/lib/defaultAvatarImage";
|
2022-09-12 22:04:33 +00:00
|
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
2023-03-03 23:20:13 +00:00
|
|
|
import { md } from "@calcom/lib/markdownIt";
|
2023-06-09 12:50:35 +00:00
|
|
|
import { markdownToSafeHTML } from "@calcom/lib/markdownToSafeHTML";
|
2022-09-12 22:04:33 +00:00
|
|
|
import objectKeys from "@calcom/lib/objectKeys";
|
2023-01-27 23:14:58 +00:00
|
|
|
import turndown from "@calcom/lib/turndownService";
|
2023-05-02 11:44:05 +00:00
|
|
|
import { MembershipRole } from "@calcom/prisma/enums";
|
2022-09-12 22:04:33 +00:00
|
|
|
import { trpc } from "@calcom/trpc/react";
|
2022-11-23 02:55:25 +00:00
|
|
|
import {
|
|
|
|
Avatar,
|
|
|
|
Button,
|
|
|
|
ConfirmationDialogContent,
|
|
|
|
Dialog,
|
|
|
|
DialogTrigger,
|
|
|
|
Form,
|
|
|
|
ImageUploader,
|
|
|
|
Label,
|
|
|
|
LinkIconButton,
|
|
|
|
Meta,
|
|
|
|
showToast,
|
|
|
|
TextField,
|
2023-01-25 01:08:10 +00:00
|
|
|
Editor,
|
2022-11-23 02:55:25 +00:00
|
|
|
} from "@calcom/ui";
|
2023-04-12 15:26:31 +00:00
|
|
|
import { ExternalLink, Link as LinkIcon, Trash2, LogOut } from "@calcom/ui/components/icon";
|
2022-09-12 22:04:33 +00:00
|
|
|
|
2023-01-05 17:00:16 +00:00
|
|
|
import { getLayout } from "../../../settings/layouts/SettingsLayout";
|
feat: Org settings - profile,appearance, child teams, create new child (#9231)
* 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
* 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
* A11ly
* Feedback
* 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 <udit.07814802719@cse.mait.ac.in>
* Missing changes to support orgs schema changes
* 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 <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
* feat: organization settings general and members page (#9266)
* feat: organization settings general page
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* feat: add members page
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* chore: remove
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* fix: use invalidate
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* fix: delete mutation
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* fix: remove organization id
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* chore
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* fix: use zod schema
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
---------
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* Type fixes
* 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
* Fix missing prop
---------
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
Co-authored-by: Leo Giovanetti <hello@leog.me>
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: zomars <zomars@me.com>
Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
2023-06-15 17:27:39 +00:00
|
|
|
import { extractDomainFromWebsiteUrl } from "../../organizations/lib/utils";
|
2023-01-05 17:00:16 +00:00
|
|
|
|
2022-11-17 18:56:47 +00:00
|
|
|
const regex = new RegExp("^[a-zA-Z0-9-]*$");
|
|
|
|
|
|
|
|
const teamProfileFormSchema = z.object({
|
|
|
|
name: z.string(),
|
|
|
|
slug: z
|
|
|
|
.string()
|
|
|
|
.regex(regex, {
|
|
|
|
message: "Url can only have alphanumeric characters(a-z, 0-9) and hyphen(-) symbol.",
|
|
|
|
})
|
|
|
|
.min(1, { message: "Url cannot be left empty" }),
|
|
|
|
logo: z.string(),
|
|
|
|
bio: z.string(),
|
|
|
|
});
|
2022-09-12 22:04:33 +00:00
|
|
|
|
|
|
|
const ProfileView = () => {
|
|
|
|
const { t } = useLocale();
|
|
|
|
const router = useRouter();
|
|
|
|
const utils = trpc.useContext();
|
|
|
|
const session = useSession();
|
2023-04-19 11:40:18 +00:00
|
|
|
const [firstRender, setFirstRender] = useState(true);
|
2023-05-09 17:08:14 +00:00
|
|
|
|
2023-05-02 18:20:03 +00:00
|
|
|
useLayoutEffect(() => {
|
|
|
|
document.body.focus();
|
|
|
|
}, []);
|
2022-09-12 22:04:33 +00:00
|
|
|
|
2022-11-10 23:40:01 +00:00
|
|
|
const mutation = trpc.viewer.teams.update.useMutation({
|
2022-09-12 22:04:33 +00:00
|
|
|
onError: (err) => {
|
|
|
|
showToast(err.message, "error");
|
|
|
|
},
|
|
|
|
async onSuccess() {
|
2022-11-10 23:40:01 +00:00
|
|
|
await utils.viewer.teams.get.invalidate();
|
2022-09-12 22:04:33 +00:00
|
|
|
showToast(t("your_team_updated_successfully"), "success");
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2022-11-17 18:56:47 +00:00
|
|
|
const form = useForm({
|
|
|
|
resolver: zodResolver(teamProfileFormSchema),
|
|
|
|
});
|
2022-09-12 22:04:33 +00:00
|
|
|
|
2022-11-10 23:40:01 +00:00
|
|
|
const { data: team, isLoading } = trpc.viewer.teams.get.useQuery(
|
|
|
|
{ teamId: Number(router.query.id) },
|
|
|
|
{
|
|
|
|
onError: () => {
|
|
|
|
router.push("/settings");
|
|
|
|
},
|
|
|
|
onSuccess: (team) => {
|
|
|
|
if (team) {
|
|
|
|
form.setValue("name", team.name || "");
|
2022-11-17 18:56:47 +00:00
|
|
|
form.setValue("slug", team.slug || "");
|
2022-11-10 23:40:01 +00:00
|
|
|
form.setValue("logo", team.logo || "");
|
|
|
|
form.setValue("bio", team.bio || "");
|
2022-11-11 20:38:21 +00:00
|
|
|
if (team.slug === null && (team?.metadata as Prisma.JsonObject)?.requestedSlug) {
|
2022-11-17 18:56:47 +00:00
|
|
|
form.setValue("slug", ((team?.metadata as Prisma.JsonObject)?.requestedSlug as string) || "");
|
2022-11-11 20:38:21 +00:00
|
|
|
}
|
2022-11-10 23:40:01 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
);
|
2022-09-12 22:04:33 +00:00
|
|
|
|
|
|
|
const isAdmin =
|
|
|
|
team && (team.membership.role === MembershipRole.OWNER || team.membership.role === MembershipRole.ADMIN);
|
|
|
|
|
2023-02-23 22:03:33 +00:00
|
|
|
const permalink = `${WEBAPP_URL}/team/${team?.slug}`;
|
2022-09-12 22:04:33 +00:00
|
|
|
|
2023-01-25 01:08:10 +00:00
|
|
|
const isBioEmpty = !team || !team.bio || !team.bio.replace("<p><br></p>", "").length;
|
|
|
|
|
2022-11-10 23:40:01 +00:00
|
|
|
const deleteTeamMutation = trpc.viewer.teams.delete.useMutation({
|
2022-09-12 22:04:33 +00:00
|
|
|
async onSuccess() {
|
2022-11-10 23:40:01 +00:00
|
|
|
await utils.viewer.teams.list.invalidate();
|
2022-11-10 20:23:56 +00:00
|
|
|
showToast(t("your_team_disbanded_successfully"), "success");
|
|
|
|
router.push(`${WEBAPP_URL}/teams`);
|
2022-09-12 22:04:33 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2022-11-10 23:40:01 +00:00
|
|
|
const removeMemberMutation = trpc.viewer.teams.removeMember.useMutation({
|
2022-09-12 22:04:33 +00:00
|
|
|
async onSuccess() {
|
2022-11-10 23:40:01 +00:00
|
|
|
await utils.viewer.teams.get.invalidate();
|
|
|
|
await utils.viewer.teams.list.invalidate();
|
2023-04-13 02:10:23 +00:00
|
|
|
await utils.viewer.eventTypes.invalidate();
|
2022-09-12 22:04:33 +00:00
|
|
|
showToast(t("success"), "success");
|
|
|
|
},
|
|
|
|
async onError(err) {
|
|
|
|
showToast(err.message, "error");
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2022-11-11 20:38:21 +00:00
|
|
|
const publishMutation = trpc.viewer.teams.publish.useMutation({
|
|
|
|
async onSuccess(data: { url?: string }) {
|
|
|
|
if (data.url) {
|
|
|
|
router.push(data.url);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
async onError(err) {
|
|
|
|
showToast(err.message, "error");
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2022-09-12 22:04:33 +00:00
|
|
|
function deleteTeam() {
|
|
|
|
if (team?.id) deleteTeamMutation.mutate({ teamId: team.id });
|
|
|
|
}
|
|
|
|
|
|
|
|
function leaveTeam() {
|
|
|
|
if (team?.id && session.data)
|
|
|
|
removeMemberMutation.mutate({
|
|
|
|
teamId: team.id,
|
|
|
|
memberId: session.data.user.id,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2022-12-07 20:53:44 +00:00
|
|
|
<Meta title={t("profile")} description={t("profile_team_description")} />
|
2022-09-12 22:04:33 +00:00
|
|
|
{!isLoading && (
|
|
|
|
<>
|
|
|
|
{isAdmin ? (
|
|
|
|
<Form
|
|
|
|
form={form}
|
|
|
|
handleSubmit={(values) => {
|
|
|
|
if (team) {
|
|
|
|
const variables = {
|
|
|
|
logo: values.logo,
|
|
|
|
name: values.name,
|
2022-11-17 18:56:47 +00:00
|
|
|
slug: values.slug,
|
2022-09-12 22:04:33 +00:00
|
|
|
bio: values.bio,
|
|
|
|
};
|
|
|
|
objectKeys(variables).forEach((key) => {
|
|
|
|
if (variables[key as keyof typeof variables] === team?.[key]) delete variables[key];
|
|
|
|
});
|
|
|
|
mutation.mutate({ id: team.id, ...variables });
|
|
|
|
}
|
|
|
|
}}>
|
|
|
|
<div className="flex items-center">
|
|
|
|
<Controller
|
|
|
|
control={form.control}
|
|
|
|
name="logo"
|
|
|
|
render={({ field: { value } }) => (
|
|
|
|
<>
|
|
|
|
<Avatar alt="" imageSrc={getPlaceholderAvatar(value, team?.name as string)} size="lg" />
|
2023-04-09 09:13:57 +00:00
|
|
|
<div className="ms-4">
|
2022-09-12 22:04:33 +00:00
|
|
|
<ImageUploader
|
|
|
|
target="avatar"
|
|
|
|
id="avatar-upload"
|
|
|
|
buttonMsg={t("update")}
|
|
|
|
handleAvatarChange={(newLogo) => {
|
|
|
|
form.setValue("logo", newLogo);
|
|
|
|
}}
|
|
|
|
imageSrc={value}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
|
2023-04-05 18:14:46 +00:00
|
|
|
<hr className="border-subtle my-8" />
|
2022-09-12 22:04:33 +00:00
|
|
|
|
|
|
|
<Controller
|
|
|
|
control={form.control}
|
|
|
|
name="name"
|
|
|
|
render={({ field: { value } }) => (
|
|
|
|
<div className="mt-8">
|
|
|
|
<TextField
|
|
|
|
name="name"
|
|
|
|
label={t("team_name")}
|
|
|
|
value={value}
|
|
|
|
onChange={(e) => {
|
|
|
|
form.setValue("name", e?.target.value);
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
<Controller
|
|
|
|
control={form.control}
|
2022-11-17 18:56:47 +00:00
|
|
|
name="slug"
|
2022-09-12 22:04:33 +00:00
|
|
|
render={({ field: { value } }) => (
|
|
|
|
<div className="mt-8">
|
|
|
|
<TextField
|
2022-11-17 18:56:47 +00:00
|
|
|
name="slug"
|
2022-09-12 22:04:33 +00:00
|
|
|
label={t("team_url")}
|
|
|
|
value={value}
|
feat: Org settings - profile,appearance, child teams, create new child (#9231)
* 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
* 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
* A11ly
* Feedback
* 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 <udit.07814802719@cse.mait.ac.in>
* Missing changes to support orgs schema changes
* 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 <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
* feat: organization settings general and members page (#9266)
* feat: organization settings general page
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* feat: add members page
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* chore: remove
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* fix: use invalidate
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* fix: delete mutation
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* fix: remove organization id
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* chore
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* fix: use zod schema
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
---------
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* Type fixes
* 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
* Fix missing prop
---------
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
Co-authored-by: Leo Giovanetti <hello@leog.me>
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: zomars <zomars@me.com>
Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
2023-06-15 17:27:39 +00:00
|
|
|
addOnLeading={
|
|
|
|
team.parent
|
|
|
|
? `${team.parent.slug}.${extractDomainFromWebsiteUrl}/`
|
|
|
|
: `${WEBAPP_URL}/team/`
|
|
|
|
}
|
2022-09-12 22:04:33 +00:00
|
|
|
onChange={(e) => {
|
2022-11-17 18:56:47 +00:00
|
|
|
form.clearErrors("slug");
|
|
|
|
form.setValue("slug", e?.target.value);
|
2022-09-12 22:04:33 +00:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
/>
|
2023-01-25 01:08:10 +00:00
|
|
|
<div className="mt-8">
|
|
|
|
<Label>{t("about")}</Label>
|
|
|
|
<Editor
|
|
|
|
getText={() => md.render(form.getValues("bio") || "")}
|
2023-01-27 23:14:58 +00:00
|
|
|
setText={(value: string) => form.setValue("bio", turndown(value))}
|
2023-01-25 01:08:10 +00:00
|
|
|
excludedToolbarItems={["blockType"]}
|
2023-03-03 23:20:13 +00:00
|
|
|
disableLists
|
2023-04-19 11:40:18 +00:00
|
|
|
firstRender={firstRender}
|
|
|
|
setFirstRender={setFirstRender}
|
2023-01-25 01:08:10 +00:00
|
|
|
/>
|
|
|
|
</div>
|
2023-04-05 18:14:46 +00:00
|
|
|
<p className="text-default mt-2 text-sm">{t("team_description")}</p>
|
2022-09-12 22:04:33 +00:00
|
|
|
<Button color="primary" className="mt-8" type="submit" loading={mutation.isLoading}>
|
|
|
|
{t("update")}
|
|
|
|
</Button>
|
2022-11-11 20:38:21 +00:00
|
|
|
{IS_TEAM_BILLING_ENABLED &&
|
|
|
|
team.slug === null &&
|
|
|
|
(team.metadata as Prisma.JsonObject)?.requestedSlug && (
|
|
|
|
<Button
|
|
|
|
color="secondary"
|
2023-06-22 22:25:37 +00:00
|
|
|
className="ml-2 mt-8"
|
2022-11-11 20:38:21 +00:00
|
|
|
type="button"
|
|
|
|
onClick={() => {
|
|
|
|
publishMutation.mutate({ teamId: team.id });
|
|
|
|
}}>
|
|
|
|
Publish
|
|
|
|
</Button>
|
|
|
|
)}
|
2022-09-12 22:04:33 +00:00
|
|
|
</Form>
|
|
|
|
) : (
|
|
|
|
<div className="flex">
|
|
|
|
<div className="flex-grow">
|
|
|
|
<div>
|
2023-04-05 18:14:46 +00:00
|
|
|
<Label className="text-emphasis">{t("team_name")}</Label>
|
|
|
|
<p className="text-default text-sm">{team?.name}</p>
|
2022-09-12 22:04:33 +00:00
|
|
|
</div>
|
2023-01-25 01:08:10 +00:00
|
|
|
{team && !isBioEmpty && (
|
2022-09-12 22:04:33 +00:00
|
|
|
<>
|
2023-04-05 18:14:46 +00:00
|
|
|
<Label className="text-emphasis mt-5">{t("about")}</Label>
|
2023-01-25 01:08:10 +00:00
|
|
|
<div
|
2023-06-05 05:51:19 +00:00
|
|
|
className=" text-subtle break-words text-sm [&_a]:text-blue-500 [&_a]:underline [&_a]:hover:text-blue-600"
|
2023-06-09 12:50:35 +00:00
|
|
|
dangerouslySetInnerHTML={{ __html: md.render(markdownToSafeHTML(team.bio)) }}
|
2023-01-25 01:08:10 +00:00
|
|
|
/>
|
2022-09-12 22:04:33 +00:00
|
|
|
</>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
<div className="">
|
2023-01-06 12:13:56 +00:00
|
|
|
<Link href={permalink} passHref={true} target="_blank">
|
2023-04-12 15:26:31 +00:00
|
|
|
<LinkIconButton Icon={ExternalLink}>{t("preview")}</LinkIconButton>
|
2022-09-12 22:04:33 +00:00
|
|
|
</Link>
|
|
|
|
<LinkIconButton
|
2023-04-12 15:26:31 +00:00
|
|
|
Icon={LinkIcon}
|
2022-09-12 22:04:33 +00:00
|
|
|
onClick={() => {
|
|
|
|
navigator.clipboard.writeText(permalink);
|
|
|
|
showToast("Copied to clipboard", "success");
|
|
|
|
}}>
|
|
|
|
{t("copy_link_team")}
|
|
|
|
</LinkIconButton>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)}
|
2023-04-05 18:14:46 +00:00
|
|
|
<hr className="border-subtle my-8 border" />
|
2022-09-12 22:04:33 +00:00
|
|
|
|
2023-04-05 18:14:46 +00:00
|
|
|
<div className="text-default mb-3 text-base font-semibold">{t("danger_zone")}</div>
|
2022-09-12 22:04:33 +00:00
|
|
|
{team?.membership.role === "OWNER" ? (
|
|
|
|
<Dialog>
|
|
|
|
<DialogTrigger asChild>
|
2023-04-12 15:26:31 +00:00
|
|
|
<Button color="destructive" className="border" StartIcon={Trash2}>
|
2022-11-22 19:18:47 +00:00
|
|
|
{t("disband_team")}
|
2022-09-12 22:04:33 +00:00
|
|
|
</Button>
|
|
|
|
</DialogTrigger>
|
|
|
|
<ConfirmationDialogContent
|
|
|
|
variety="danger"
|
|
|
|
title={t("disband_team")}
|
|
|
|
confirmBtnText={t("confirm_disband_team")}
|
|
|
|
onConfirm={deleteTeam}>
|
|
|
|
{t("disband_team_confirmation_message")}
|
|
|
|
</ConfirmationDialogContent>
|
|
|
|
</Dialog>
|
|
|
|
) : (
|
|
|
|
<Dialog>
|
|
|
|
<DialogTrigger asChild>
|
2023-04-12 15:26:31 +00:00
|
|
|
<Button color="destructive" className="border" StartIcon={LogOut}>
|
2022-09-12 22:04:33 +00:00
|
|
|
{t("leave_team")}
|
|
|
|
</Button>
|
|
|
|
</DialogTrigger>
|
|
|
|
<ConfirmationDialogContent
|
|
|
|
variety="danger"
|
|
|
|
title={t("leave_team")}
|
|
|
|
confirmBtnText={t("confirm_leave_team")}
|
|
|
|
onConfirm={leaveTeam}>
|
|
|
|
{t("leave_team_confirmation_message")}
|
|
|
|
</ConfirmationDialogContent>
|
|
|
|
</Dialog>
|
|
|
|
)}
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
ProfileView.getLayout = getLayout;
|
|
|
|
|
|
|
|
export default ProfileView;
|