fix: vercel subdomain version (#10790)

* Standarizing org subdomain url

* fix: upgrading vercel subdomain version
This commit is contained in:
Leo Giovanetti 2023-08-15 17:44:48 -03:00 committed by GitHub
parent 3cab37ed8d
commit 20c45b5d88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 26 additions and 18 deletions

View File

@ -12,6 +12,7 @@ import { z } from "zod";
import type { EventLocationType } from "@calcom/app-store/locations";
import { getEventLocationType, MeetLocationType, LocationType } from "@calcom/app-store/locations";
import useLockedFieldsManager from "@calcom/features/ee/managed-event-types/hooks/useLockedFieldsManager";
import { useOrgBranding } from "@calcom/features/ee/organizations/context/provider";
import cx from "@calcom/lib/classNames";
import { CAL_URL } from "@calcom/lib/constants";
import { useLocale } from "@calcom/lib/hooks/useLocale";
@ -116,6 +117,7 @@ export const EventSetupTab = (
const [editingLocationType, setEditingLocationType] = useState<string>("");
const [selectedLocation, setSelectedLocation] = useState<LocationOption | undefined>(undefined);
const [multipleDuration, setMultipleDuration] = useState(eventType.metadata?.multipleDuration);
const orgBranding = useOrgBranding();
const locationOptions = props.locationOptions.map((locationOption) => {
const options = locationOption.options.filter((option) => {
@ -385,6 +387,9 @@ export const EventSetupTab = (
const lengthLockedProps = shouldLockDisableProps("length");
const descriptionLockedProps = shouldLockDisableProps("description");
const urlPrefix = orgBranding
? orgBranding?.fullDomain.replace(/^(https?:|)\/\//, "")
: `${CAL_URL?.replace(/^(https?:|)\/\//, "")}`;
return (
<div>
@ -413,10 +418,10 @@ export const EventSetupTab = (
defaultValue={eventType.slug}
addOnLeading={
<>
{CAL_URL?.replace(/^(https?:|)\/\//, "")}/
{urlPrefix}/
{!isManagedEventType
? team
? "team/" + team.slug
? (orgBranding ? "" : "team/") + team.slug
: eventType.users[0].username
: t("username_placeholder")}
/

View File

@ -65,7 +65,7 @@ export const UsernameAvailabilityField = ({
setInputUsernameValue={onChange}
onSuccessMutation={onSuccessMutation}
onErrorMutation={onErrorMutation}
addOnLeading={usernamePrefix}
addOnLeading={`${usernamePrefix}/`}
/>
);
}}

View File

@ -737,7 +737,9 @@ const EventTypeListHeading = ({
</span>
)}
{profile?.slug && (
<Link href={`${CAL_URL}/${profile.slug}`} className="text-subtle block text-xs">
<Link
href={`${orgBranding ? orgBranding.fullDomain : CAL_URL}/${profile.slug}`}
className="text-subtle block text-xs">
{`${bookerUrl.replace("https://", "").replace("http://", "")}/${profile.slug}`}
</Link>
)}

View File

@ -57,7 +57,7 @@ export default function OtherTeamListItem(props: Props) {
<span className="text-muted block text-xs">
{team.slug
? orgBranding
? `${orgBranding.fullDomain}${team.slug}`
? `${orgBranding.fullDomain}/${team.slug}`
: `${process.env.NEXT_PUBLIC_WEBSITE_URL}/team/${team.slug}`
: "Unpublished team"}
</span>
@ -81,8 +81,8 @@ export default function OtherTeamListItem(props: Props) {
`${
orgBranding
? `${orgBranding.fullDomain}`
: process.env.NEXT_PUBLIC_WEBSITE_URL + "/team/"
}${team.slug}`
: process.env.NEXT_PUBLIC_WEBSITE_URL + "/team"
}/${team.slug}`
);
showToast(t("link_copied"), "success");
}}
@ -119,8 +119,8 @@ export default function OtherTeamListItem(props: Props) {
href={`${
orgBranding
? `${orgBranding.fullDomain}`
: `${process.env.NEXT_PUBLIC_WEBSITE_URL}/team/other/`
}${team.slug}`}
: `${process.env.NEXT_PUBLIC_WEBSITE_URL}/team/other`
}/${team.slug}`}
StartIcon={ExternalLink}>
{t("preview_team") as string}
</DropdownItem>

View File

@ -111,8 +111,9 @@ export const CreateANewTeamForm = () => {
placeholder="acme"
label={t("team_url")}
addOnLeading={`${
orgBranding?.fullDomain.replace("https://", "").replace("http://", "") ??
`${extractDomainFromWebsiteUrl}/team/`
orgBranding
? orgBranding.fullDomain.replace("https://", "").replace("http://", "") + "/"
: `${extractDomainFromWebsiteUrl}/team/`
}`}
defaultValue={value}
onChange={(e) => {

View File

@ -103,7 +103,7 @@ export default function TeamListItem(props: Props) {
<span className="text-muted block text-xs">
{team.slug
? orgBranding
? `${orgBranding.fullDomain}${team.slug}`
? `${orgBranding.fullDomain}/${team.slug}`
: `${process.env.NEXT_PUBLIC_WEBSITE_URL}/team/${team.slug}`
: "Unpublished team"}
</span>
@ -238,8 +238,8 @@ export default function TeamListItem(props: Props) {
`${
orgBranding
? `${orgBranding.fullDomain}`
: process.env.NEXT_PUBLIC_WEBSITE_URL + "/team/"
}${team.slug}`
: process.env.NEXT_PUBLIC_WEBSITE_URL + "/team"
}/${team.slug}`
);
showToast(t("link_copied"), "success");
}}
@ -278,8 +278,8 @@ export default function TeamListItem(props: Props) {
href={`${
orgBranding
? `${orgBranding.fullDomain}`
: `${process.env.NEXT_PUBLIC_WEBSITE_URL}/team/`
}${team.slug}`}
: `${process.env.NEXT_PUBLIC_WEBSITE_URL}/team`
}/${team.slug}`}
StartIcon={ExternalLink}>
{t("preview_team") as string}
</DropdownItem>

View File

@ -227,7 +227,7 @@ const ProfileView = () => {
value={value}
addOnLeading={
team.parent && orgBranding
? getOrgFullDomain(orgBranding?.slug, { protocol: false })
? getOrgFullDomain(orgBranding?.slug, { protocol: false }) + "/"
: `${WEBAPP_URL}/team/`
}
onChange={(e) => {

View File

@ -29,7 +29,7 @@ type CreateOptions = {
const vercelCreateDomain = async (domain: string) => {
const response = await fetch(
`https://api.vercel.com/v8/projects/${process.env.PROJECT_ID_VERCEL}/domains?teamId=${process.env.TEAM_ID_VERCEL}`,
`https://api.vercel.com/v9/projects/${process.env.PROJECT_ID_VERCEL}/domains?teamId=${process.env.TEAM_ID_VERCEL}`,
{
body: JSON.stringify({ name: `${domain}.${subdomainSuffix()}` }),
headers: {