feat: pro subscriber email config (#417)

This commit is contained in:
MaheshtheDev 2025-09-10 03:33:45 +00:00
parent 1ffb9f9aa8
commit 96f1a97fd6
2 changed files with 32 additions and 2 deletions

View file

@ -18,6 +18,7 @@ import Link from "next/link"
import { useRouter } from "next/navigation"
import { useEffect, useState } from "react"
import { analytics } from "@/lib/analytics"
import { $fetch } from "@lib/api"
export function ProfileView() {
const router = useRouter()
@ -76,11 +77,30 @@ export function ProfileView() {
const handleUpgrade = async () => {
setIsLoading(true)
try {
await attach({
const upgradeResult = await attach({
productId: "consumer_pro",
successUrl: "https://app.supermemory.ai/",
})
window.location.reload()
if (
upgradeResult.statusCode === 200 &&
upgradeResult.data &&
"code" in upgradeResult.data
) {
const isProPlanActivated =
upgradeResult.data.code === "new_product_attached"
if (isProPlanActivated && session?.name && session?.email) {
try {
await $fetch("@post/emails/welcome/pro", {
body: {
email: session?.email,
firstName: session?.name,
},
})
} catch (error) {
console.error(error)
}
}
}
} catch (error) {
console.error(error)
setIsLoading(false)

View file

@ -191,6 +191,16 @@ export const apiSchema = createSchema({
"@get/waitlist/status": {
output: WaitlistStatusResponseSchema,
},
"@post/emails/welcome/pro": {
input: z.object({
email: z.string(),
firstName: z.string(),
}),
output: z.object({
message: z.string(),
}),
}
})
export const $fetch = createFetch({