diff --git a/apps/web/src/components/NewWorkspaceForm.tsx b/apps/web/src/components/NewWorkspaceForm.tsx index d40bbe0a..14b7c2c3 100644 --- a/apps/web/src/components/NewWorkspaceForm.tsx +++ b/apps/web/src/components/NewWorkspaceForm.tsx @@ -25,9 +25,9 @@ export function NewWorkspaceForm() { switchWorkspace({ publicId: values.publicId, name: values.name, - // description: values.description, - // slug: values.slug, - // plan: values.plan, + description: values.description, + slug: values.slug, + plan: values.plan, }); closeModal(); } diff --git a/apps/web/src/pages/api/stripe/create_checkout_session.ts b/apps/web/src/pages/api/stripe/create_checkout_session.ts index 942dae36..bd298d7d 100644 --- a/apps/web/src/pages/api/stripe/create_checkout_session.ts +++ b/apps/web/src/pages/api/stripe/create_checkout_session.ts @@ -17,7 +17,7 @@ const stripe = new Stripe(stripeSecretKey, { apiVersion: "2024-12-18.acacia", }); -const usernameSchema = z +const workspaceSlugSchema = z .string() .min(3) .max(24) @@ -26,7 +26,7 @@ const usernameSchema = z interface CheckoutSessionRequest { successUrl: string; cancelUrl: string; - username: string; + slug: string; workspacePublicId: string; stripeCustomerId: string; } @@ -63,9 +63,9 @@ export default async function handler(req: NextRequest) { } const body = (await req.json()) as CheckoutSessionRequest; - const { successUrl, cancelUrl, username, workspacePublicId } = body; + const { successUrl, cancelUrl, slug, workspacePublicId } = body; - if (!successUrl || !cancelUrl || !username || !workspacePublicId) { + if (!successUrl || !cancelUrl || !slug || !workspacePublicId) { return new Response( JSON.stringify({ error: "Missing required fields" }), { @@ -75,10 +75,10 @@ export default async function handler(req: NextRequest) { ); } - const usernameResult = usernameSchema.safeParse(username); + const slugResult = workspaceSlugSchema.safeParse(slug); - if (!usernameResult.success) { - return new Response(JSON.stringify({ error: "Invalid username" }), { + if (!slugResult.success) { + return new Response(JSON.stringify({ error: "Invalid workspace slug" }), { status: 400, headers: { "Content-Type": "application/json" }, }); @@ -109,7 +109,7 @@ export default async function handler(req: NextRequest) { cancel_url: `${process.env.WEBSITE_URL}${cancelUrl}`, customer: user.stripeCustomerId ?? undefined, metadata: { - username, + workspaceSlug: slug, workspacePublicId, }, }); diff --git a/apps/web/src/pages/api/stripe/webhook.ts b/apps/web/src/pages/api/stripe/webhook.ts index f68836e2..41b59f3d 100644 --- a/apps/web/src/pages/api/stripe/webhook.ts +++ b/apps/web/src/pages/api/stripe/webhook.ts @@ -54,9 +54,9 @@ export default async function handler(req: NextRequest) { const metaData = checkoutSession.metadata; - if (metaData?.workspacePublicId && metaData.username) { + if (metaData?.workspacePublicId && metaData.workspaceSlug) { await workspaceRepo.update(db, metaData.workspacePublicId, { - slug: metaData.username, + slug: metaData.workspaceSlug, plan: "pro", }); } diff --git a/apps/web/src/providers/workspace.tsx b/apps/web/src/providers/workspace.tsx index ec84db5a..58a5b46a 100644 --- a/apps/web/src/providers/workspace.tsx +++ b/apps/web/src/providers/workspace.tsx @@ -13,10 +13,10 @@ interface WorkspaceContextProps { interface Workspace { name: string; - description: string | null; + description: string | null | undefined; publicId: string; - slug: string; - plan: "free" | "pro" | "enterprise"; + slug: string | undefined; + plan: "free" | "pro" | "enterprise" | undefined; } const initialWorkspace: Workspace = { diff --git a/apps/web/src/views/board/index.tsx b/apps/web/src/views/board/index.tsx index e1642a65..1b095cf9 100644 --- a/apps/web/src/views/board/index.tsx +++ b/apps/web/src/views/board/index.tsx @@ -21,7 +21,6 @@ import { useModal } from "~/providers/modal"; import { useWorkspace } from "~/providers/workspace"; import { api } from "~/utils/api"; import { formatToArray } from "~/utils/helpers"; -import createClient from "~/utils/supabase/client"; import { getPublicUrl } from "~/utils/supabase/getPublicUrl"; import BoardDropdown from "./components/BoardDropdown"; import { DeleteBoardConfirmation } from "./components/DeleteBoardConfirmation"; @@ -36,7 +35,6 @@ import VisibilityButton from "./components/VisibilityButton"; type PublicListId = string; export default function BoardPage() { - const supabase = createClient(); const params = useParams() as { boardId: string[] } | null; const router = useRouter(); const { boardData, setBoardData, updateCard, updateList } = useBoard(); diff --git a/apps/web/src/views/boards/components/BoardsList.tsx b/apps/web/src/views/boards/components/BoardsList.tsx index 22a94aba..c4f5a682 100644 --- a/apps/web/src/views/boards/components/BoardsList.tsx +++ b/apps/web/src/views/boards/components/BoardsList.tsx @@ -1,15 +1,15 @@ import Link from "next/link"; -import { api } from "~/utils/api"; -import { useWorkspace } from "~/providers/workspace"; import PatternedBackground from "~/components/PatternedBackground"; +import { useWorkspace } from "~/providers/workspace"; +import { api } from "~/utils/api"; export function BoardsList() { const { workspace } = useWorkspace(); const { data, isLoading } = api.board.all.useQuery( - { workspacePublicId: workspace?.publicId }, - { enabled: workspace?.publicId ? true : false }, + { workspacePublicId: workspace.publicId }, + { enabled: workspace.publicId ? true : false }, ); if (isLoading) @@ -29,7 +29,7 @@ export function BoardsList() {
+
{board.name}
{ - "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." }