feat: Initial Diabetix application commit
- Add authentication with NextAuth v5 (credentials + email verification) - Implement dashboard with glycemia tracking and AI analysis - Add PDF report generation for Premium users - Implement Stripe integration for Premium subscriptions - Add responsive UI with Tailwind CSS and shadcn components - Database schema with Prisma ORM and PostgreSQL support - Real-time glycemia visualization with Recharts - Mobile-optimized entry form - User profile management with medical information - Subscription lifecycle management (create, cancel, webhook) - Email notifications with Resend - Feature gates for Free vs Premium plans Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
69
test-cancel-subscription.mjs
Normal file
69
test-cancel-subscription.mjs
Normal file
@@ -0,0 +1,69 @@
|
||||
import pkg from "@prisma/client";
|
||||
import bcrypt from "bcryptjs";
|
||||
|
||||
const { PrismaClient } = pkg;
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function main() {
|
||||
// Create or get a test user with PREMIUM plan
|
||||
const testEmail = "test.premium@example.com";
|
||||
const testPassword = "TestPassword123!";
|
||||
|
||||
// Check if user exists
|
||||
let user = await prisma.user.findUnique({
|
||||
where: { email: testEmail },
|
||||
});
|
||||
|
||||
if (!user) {
|
||||
const passwordHash = await bcrypt.hash(testPassword, 10);
|
||||
user = await prisma.user.create({
|
||||
data: {
|
||||
email: testEmail,
|
||||
name: "Test Premium User",
|
||||
passwordHash,
|
||||
plan: "PREMIUM",
|
||||
emailVerified: new Date(),
|
||||
},
|
||||
});
|
||||
console.log("Created test premium user:", user.email);
|
||||
} else {
|
||||
console.log("User already exists:", user.email);
|
||||
}
|
||||
|
||||
// Create a test subscription
|
||||
if (user.stripeId) {
|
||||
console.log("User already has stripeId:", user.stripeId);
|
||||
} else {
|
||||
const user2 = await prisma.user.update({
|
||||
where: { id: user.id },
|
||||
data: {
|
||||
stripeId: "cus_test_" + Date.now(),
|
||||
subscription: {
|
||||
create: {
|
||||
stripeId: "sub_test_" + Date.now(),
|
||||
stripePriceId: "price_test",
|
||||
stripeCustomerId: "cus_test_" + Date.now(),
|
||||
status: "active",
|
||||
currentPeriodEnd: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000),
|
||||
},
|
||||
},
|
||||
},
|
||||
include: { subscription: true },
|
||||
});
|
||||
console.log("Created subscription for user:", user2.email);
|
||||
}
|
||||
|
||||
console.log("\nTest user credentials:");
|
||||
console.log("Email:", testEmail);
|
||||
console.log("Password:", testPassword);
|
||||
}
|
||||
|
||||
main()
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
})
|
||||
.finally(async () => {
|
||||
await prisma.$disconnect();
|
||||
});
|
||||
Reference in New Issue
Block a user