diff --git a/apps/webapp/app/routes/resources.orgs.$organizationSlug.v3-access.tsx b/apps/webapp/app/routes/resources.orgs.$organizationSlug.v3-access.tsx deleted file mode 100644 index a16f691dc..000000000 --- a/apps/webapp/app/routes/resources.orgs.$organizationSlug.v3-access.tsx +++ /dev/null @@ -1,210 +0,0 @@ -import { Form } from "@remix-run/react"; -import { ActionFunctionArgs } from "@remix-run/server-runtime"; -import { PlainClient } from "@team-plain/typescript-sdk"; -import { z } from "zod"; -import { MainCenteredContainer } from "~/components/layout/AppLayout"; -import { Button, LinkButton } from "~/components/primitives/Buttons"; -import { Paragraph } from "~/components/primitives/Paragraph"; -import { TextLink } from "~/components/primitives/TextLink"; -import { prisma } from "~/db.server"; -import { env } from "~/env.server"; -import { useUser } from "~/hooks/useUser"; -import { redirectWithErrorMessage, redirectWithSuccessMessage } from "~/models/message.server"; -import { logger } from "~/services/logger.server"; -import { requireUser } from "~/services/session.server"; -import { organizationPath } from "~/utils/pathBuilder"; -import v3Icon from "~/assets/icons/v3.svg"; -import { CheckCircleIcon } from "@heroicons/react/20/solid"; - -const ParamSchema = z.object({ - organizationSlug: z.string(), -}); - -export const action = async ({ request, params }: ActionFunctionArgs) => { - if (request.method.toLowerCase() !== "post") { - return redirectWithErrorMessage("/", request, "Invalid request method"); - } - - const user = await requireUser(request); - const { organizationSlug } = ParamSchema.parse(params); - - const failedRedirectPath = organizationPath({ slug: organizationSlug }); - - try { - if (!env.PLAIN_API_KEY) { - return redirectWithErrorMessage( - failedRedirectPath, - request, - "Error requesting V3 access: Plain API key" - ); - } - - //mark them as having requested v3 - const organization = await prisma.organization.update({ - where: { - slug: organizationSlug, - members: { - some: { - userId: user.id, - }, - }, - }, - data: { - hasRequestedV3: true, - }, - }); - - //update Plain - const client = new PlainClient({ - apiKey: env.PLAIN_API_KEY, - }); - - const upsertCustomerRes = await client.upsertCustomer({ - identifier: { - emailAddress: user.email, - }, - onCreate: { - fullName: user.name ?? user.email, - email: { - email: user.email, - isVerified: true, - }, - }, - onUpdate: {}, - }); - - if (upsertCustomerRes.error) { - logger.error("Error upserting customer", upsertCustomerRes.error); - return redirectWithErrorMessage(failedRedirectPath, request, "Error requesting V3 access"); - } - - const groupResult = await client.addCustomerToCustomerGroups({ - customerId: upsertCustomerRes.data.customer.id, - customerGroupIdentifiers: [ - { - customerGroupKey: "interested-in-v3", - }, - ], - }); - - if (groupResult.error) { - logger.error("Error adding customer to group", groupResult.error); - return redirectWithErrorMessage(failedRedirectPath, request, "Error requesting V3 access"); - } - - const createThreadRes = await client.createThread({ - customerIdentifier: { - customerId: upsertCustomerRes.data.customer.id, - }, - title: "v3 early access request", - components: [ - { - componentText: { - text: `${upsertCustomerRes.data.customer.email.email} has been added to the v3 early access group`, - }, - }, - { - componentText: { - text: `Company: ${organization.title ?? "–"}`, - }, - }, - ], - }); - - if (createThreadRes.error) { - logger.error("Error creating thread", createThreadRes.error); - return redirectWithErrorMessage(failedRedirectPath, request, "Error requesting V3 access"); - } - - return redirectWithSuccessMessage( - organizationPath(organization), - request, - "V3 access requested" - ); - } catch (error) { - logger.error("Error requesting V3 access", { error }); - return redirectWithErrorMessage(failedRedirectPath, request, "Error requesting V3 access"); - } -}; - -export function RequestV3Access({ - hasRequestedV3, - organizationSlug, - projectsCount, -}: { - hasRequestedV3: boolean; - organizationSlug: string; - projectsCount: number; -}) { - const user = useUser(); - - if (hasRequestedV3) { - return ( - -
-
- v3 -
- -
-
- - We’ve received your request for v3 and we’ll notify you as soon as you have access. - We’re granting new users access every day so you won’t be waiting long. - - - Right now v3 is completely free to use but{" "} - - paid tiers - {" "} - will be introduced soon. - - - In the meantime, check out the{" "} - v3 docs, the{" "} - - v3 blog post - {" "} - and join our Discord. - -
-
- ); - } - - return ( - - v3 -
- {projectsCount > 0 ? ( - - You can no longer create v2 projects and your organization doesn't have access to v3 - yet. We are approving access requests daily. - - ) : ( - - Trigger.dev v3 is currently in Developer Preview and we’re operating a waitlist as we - focus on the platform’s reliability and scaleability. - - )} - - For more info, check out our{" "} - - v3 blog post - - . - -
- {projectsCount > 0 ? ( - - Cancel - - ) : null} - -
-
-
- ); -}