Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

use plain to handle submissions

Steven Tey8ba50892c462
diff --git a/apps/web/app/admin.dub.co/(dashboard)/revenue/page.tsx b/apps/web/app/admin.dub.co/(dashboard)/revenue/page.tsx
index 0355521a8d..2986549813 100644
--- a/apps/web/app/admin.dub.co/(dashboard)/revenue/page.tsx
+++ b/apps/web/app/admin.dub.co/(dashboard)/revenue/page.tsx
@@ -26,7 +26,16 @@ async function RevenueRSC() {
)
.then((res) => res.json())
.catch(() => {
- return { data: { recurring_revenue: [] } };
+ return {
+ data: {
+ recurring_revenue:
+ // dummy data for this year
+ Array.from({ length: 12 }, (_, i) => ({
+ date: new Date(new Date().setMonth(i)),
+ value: 0,
+ })),
+ },
+ };
});
return <RevenueClient data={res.data.recurring_revenue} />;
diff --git a/apps/web/app/api/support/route.ts b/apps/web/app/api/support/route.ts
index 465b6d25db..1d80dc27d2 100644
--- a/apps/web/app/api/support/route.ts
+++ b/apps/web/app/api/support/route.ts
@@ -49,7 +49,5 @@ export const POST = withSession(async ({ req, session }) => {
attachmentIds,
});
- console.log({ res });
-
return NextResponse.json(res);
});
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/oauth-apps/[appId]/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/oauth-apps/[appId]/page-client.tsx
index 05987a759a..dd657f03d4 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/oauth-apps/[appId]/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/oauth-apps/[appId]/page-client.tsx
@@ -126,20 +126,9 @@ export default function OAuthAppManagePageClient({ appId }: { appId: string }) {
workspaceId: workspaceId!,
appId,
});
-
setOpenPopover(false);
}}
/>
- <Button
- text="Remove application"
- variant="danger-outline"
- icon={<Trash className="h-4 w-4" />}
- className="h-9 justify-start px-2"
- onClick={() => {
- setShowRemoveOAuthAppModal(true);
- }}
- />
-
{!oAuthApp?.verified && (
<Button
text="Submit for review"
@@ -147,10 +136,20 @@ export default function OAuthAppManagePageClient({ appId }: { appId: string }) {
icon={<Upload className="h-4 w-4" />}
className="h-9 justify-start px-2"
onClick={() => {
+ setOpenPopover(false);
setShowSubmitOAuthAppModal(true);
}}
/>
)}
+ <Button
+ text="Remove application"
+ variant="danger-outline"
+ icon={<Trash className="h-4 w-4" />}
+ className="h-9 justify-start px-2"
+ onClick={() => {
+ setShowRemoveOAuthAppModal(true);
+ }}
+ />
</div>
}
align="end"
diff --git a/apps/web/lib/actions/submit-oauth-app-for-review.ts b/apps/web/lib/actions/submit-oauth-app-for-review.ts
index 17baaf0b09..0e53731c3f 100644
--- a/apps/web/lib/actions/submit-oauth-app-for-review.ts
+++ b/apps/web/lib/actions/submit-oauth-app-for-review.ts
@@ -1,7 +1,8 @@
"use server";
+import { plain, upsertPlainCustomer } from "@/lib/plain";
import { prisma } from "@/lib/prisma";
-import { sendEmail } from "emails";
+import { ComponentDividerSpacingSize } from "@team-plain/typescript-sdk";
import { ratelimit } from "../upstash";
import z from "../zod";
import { authActionClient } from "./safe-action";
@@ -16,7 +17,7 @@ const schema = z.object({
export const submitOAuthAppForReview = authActionClient
.schema(schema)
.action(async ({ ctx, parsedInput }) => {
- const { workspace } = ctx;
+ const { user, workspace } = ctx;
const { message, integrationId } = parsedInput;
const integration = await prisma.integration.findFirstOrThrow({
@@ -36,10 +37,74 @@ export const submitOAuthAppForReview = authActionClient
);
}
- await sendEmail({
- subject: `New OAuth App Submission: ${integration.name} by ${workspace.name}`,
- email: "[email protected]",
- react: message,
+ let plainCustomerId: string | null = null;
+
+ const plainCustomer = await plain.getCustomerByEmail({
+ email: user.email,
+ });
+
+ if (plainCustomer.data) {
+ plainCustomerId = plainCustomer.data.id;
+ } else {
+ const { data } = await upsertPlainCustomer({ user });
+ if (data) {
+ plainCustomerId = data.customer.id;
+ }
+ }
+
+ await plain.createThread({
+ customerIdentifier: {
+ customerId: plainCustomerId,
+ },
+ title: `Integration Submission: ${integration.name}`,
+ components: [
+ {
+ componentText: {
+ text: message,
+ },
+ },
+ {
+ componentDivider: {
+ dividerSpacingSize: ComponentDividerSpacingSize.L,
+ },
+ },
+ {
+ componentRow: {
+ rowMainContent: [
+ {
+ componentText: {
+ text: "Integration Slug",
+ },
+ },
+ ],
+ rowAsideContent: [
+ {
+ componentText: {
+ text: integration.slug,
+ },
+ },
+ ],
+ },
+ },
+ {
+ componentRow: {
+ rowMainContent: [
+ {
+ componentText: {
+ text: "Workspace Slug",
+ },
+ },
+ ],
+ rowAsideContent: [
+ {
+ componentText: {
+ text: workspace.slug,
+ },
+ },
+ ],
+ },
+ },
+ ],
});
return { ok: true };
diff --git a/apps/web/ui/modals/submit-oauth-app-modal.tsx b/apps/web/ui/modals/submit-oauth-app-modal.tsx
index 2c5c679d08..ca64aecbac 100644
--- a/apps/web/ui/modals/submit-oauth-app-modal.tsx
+++ b/apps/web/ui/modals/submit-oauth-app-modal.tsx
@@ -82,34 +82,23 @@ function SubmitOAuthAppModal({
workspaceId: workspace.id!,
});
}}
- className="flex flex-col space-y-6 bg-gray-50 px-4 py-8 text-left sm:px-16"
+ className="flex flex-col gap-4 bg-gray-50 px-4 pb-8 pt-6 text-left sm:px-16"
>
- <div>
- <TextareaAutosize
- id="message"
- name="message"
- minRows={5}
- value={message}
- onChange={(e) => setMessage(e.target.value)}
- className="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-gray-500 focus:ring-gray-500 sm:text-sm"
- maxLength={1000}
- />
- </div>
-
- <div className="flex flex-col space-y-2 sm:flex-row sm:justify-end sm:space-x-2 sm:space-y-0">
- <Button
- text="Cancel"
- variant="secondary"
- onClick={() => setShowSubmitOAuthAppModal(false)}
- disabled={isExecuting}
- />
- <Button
- text={isExecuting ? "Submitting..." : "Submit"}
- loading={isExecuting}
- disabled={message.trim().length === 0}
- type="submit"
- />
- </div>
+ <TextareaAutosize
+ id="message"
+ name="message"
+ minRows={5}
+ value={message}
+ onChange={(e) => setMessage(e.target.value)}
+ className="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-gray-500 focus:ring-gray-500 sm:text-sm"
+ maxLength={1000}
+ />
+ <Button
+ text={isExecuting ? "Submitting..." : "Submit"}
+ loading={isExecuting}
+ disabled={message.trim().length === 0}
+ type="submit"
+ />
</form>
</Modal>
);