mirror of
https://github.com/lukevella/rallly.git
synced 2025-07-23 11:17:26 +02:00
🌱 Create subscription
This commit is contained in:
parent
156e84c8b6
commit
b1c7e3a275
1 changed files with 26 additions and 1 deletions
|
@ -1,4 +1,5 @@
|
|||
import { prisma } from "@rallly/database";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
async function createUser({
|
||||
id,
|
||||
|
@ -14,6 +15,7 @@ async function createUser({
|
|||
space: {
|
||||
id: string;
|
||||
name: string;
|
||||
isPro: boolean;
|
||||
};
|
||||
}) {
|
||||
const user = await prisma.user.create({
|
||||
|
@ -23,11 +25,32 @@ async function createUser({
|
|||
email,
|
||||
timeZone,
|
||||
spaces: {
|
||||
create: space,
|
||||
create: {
|
||||
id: space.id,
|
||||
name: space.name,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (space.isPro) {
|
||||
await prisma.subscription.create({
|
||||
data: {
|
||||
id: "sub-1",
|
||||
spaceId: space.id,
|
||||
userId: user.id,
|
||||
active: true,
|
||||
amount: 700,
|
||||
currency: "USD",
|
||||
interval: "month",
|
||||
periodStart: new Date(),
|
||||
periodEnd: dayjs().add(1, "month").toDate(),
|
||||
priceId: "price_1M6ZJZGZJZJZJZJZJZJZJZJZ",
|
||||
status: "active",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
await prisma.spaceMember.create({
|
||||
data: {
|
||||
spaceId: space.id,
|
||||
|
@ -56,6 +79,7 @@ export async function seedUsers() {
|
|||
space: {
|
||||
id: "space-1",
|
||||
name: "Personal",
|
||||
isPro: false,
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -67,6 +91,7 @@ export async function seedUsers() {
|
|||
space: {
|
||||
id: "space-2",
|
||||
name: "Personal",
|
||||
isPro: true,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue