feat: custom workspace slugs

This commit is contained in:
Henry
2025-01-23 22:22:29 +00:00
parent 0bd23d24ac
commit f78dd07c38
14 changed files with 57 additions and 58 deletions

View File

@@ -1,7 +1,7 @@
import Button from "~/components/Button";
import { useModal } from "~/providers/modal";
export function PremiumUsernameConfirmation({
export function CustomURLConfirmation({
workspacePublicId,
}: {
workspacePublicId: string;
@@ -16,7 +16,7 @@ export function PremiumUsernameConfirmation({
"Content-Type": "application/json",
},
body: JSON.stringify({
username: entityId,
slug: entityId,
workspacePublicId: workspacePublicId,
cancelUrl: "/settings",
successUrl: "/settings",
@@ -37,11 +37,11 @@ export function PremiumUsernameConfirmation({
<div className="p-5">
<div className="flex w-full flex-col justify-between pb-4">
<h2 className="text-md pb-4 font-medium text-neutral-900 dark:text-dark-1000">
{`Confirm username change`}
{`Confirm URL change`}
</h2>
<p className="text-sm font-medium text-light-900 dark:text-dark-900">
{
"As you are changing from a standard to a premium username, you will be taken to the checkout to upgrade."
"Custom URLs are a premium feature. You'll be directed to upgrade your account."
}
</p>
</div>

View File

@@ -14,11 +14,11 @@ const schema = z.object({
slug: z
.string()
.min(3, {
message: "Username must be at least 3 characters long",
message: "URL must be at least 3 characters long",
})
.max(24, { message: "Username cannot exceed 24 characters" })
.max(24, { message: "URL cannot exceed 24 characters" })
.regex(/^(?![-]+$)[a-zA-Z0-9-]+$/, {
message: "Username can only contain letters, numbers, and hyphens",
message: "URL can only contain letters, numbers, and hyphens",
}),
});
@@ -62,7 +62,7 @@ const UpdateWorkspaceUrlForm = ({
},
onError: () => {
showPopup({
header: "Error updating workspace username",
header: "Error updating workspace URL",
message: "Please try again later, or contact customer support.",
icon: "error",
});
@@ -87,8 +87,8 @@ const UpdateWorkspaceUrlForm = ({
const isWorkspaceSlugAvailable = checkWorkspaceSlugAvailability.data;
const onSubmit = (data: FormValues) => {
if (isWorkspaceSlugAvailable?.isPremium && workspacePlan !== "pro")
return openModal("PREMIUM_USERNAME", data.slug);
if (isWorkspaceSlugAvailable?.isAvailable && workspacePlan !== "pro")
return openModal("UPDATE_WORKSPACE_URL", data.slug);
updateWorkspaceSlug.mutate({
workspacePublicId,
@@ -115,7 +115,7 @@ const UpdateWorkspaceUrlForm = ({
}
prefix="kan.bn/"
iconRight={
isWorkspaceSlugAvailable?.isPremium ||
isWorkspaceSlugAvailable?.isAvailable ||
(workspacePlan === "pro" && slug === workspaceUrl) ? (
<HiMiniStar className="h-4 w-4 text-yellow-500" />
) : isWorkspaceSlugAvailable?.isAvailable ? (