mirror of
https://github.com/marcogll/TaxHacker_s23.git
synced 2026-01-13 21:35:19 +00:00
feat: stripe integration
This commit is contained in:
@@ -5,6 +5,7 @@ import { cache } from "react"
|
||||
export const SELF_HOSTED_USER = {
|
||||
email: "taxhacker@localhost",
|
||||
name: "Self-Hosted Mode",
|
||||
membershipPlan: "unlimited",
|
||||
}
|
||||
|
||||
export const getSelfHostedUser = cache(async () => {
|
||||
@@ -13,7 +14,7 @@ export const getSelfHostedUser = cache(async () => {
|
||||
})
|
||||
})
|
||||
|
||||
export const createSelfHostedUser = cache(async () => {
|
||||
export const getOrCreateSelfHostedUser = cache(async () => {
|
||||
return await prisma.user.upsert({
|
||||
where: { email: SELF_HOSTED_USER.email },
|
||||
update: SELF_HOSTED_USER,
|
||||
@@ -21,6 +22,14 @@ export const createSelfHostedUser = cache(async () => {
|
||||
})
|
||||
})
|
||||
|
||||
export function getOrCreateCloudUser(email: string, data: Prisma.UserCreateInput) {
|
||||
return prisma.user.upsert({
|
||||
where: { email },
|
||||
update: data,
|
||||
create: data,
|
||||
})
|
||||
}
|
||||
|
||||
export const getUserById = cache(async (id: string) => {
|
||||
return await prisma.user.findUnique({
|
||||
where: { id },
|
||||
@@ -33,6 +42,12 @@ export const getUserByEmail = cache(async (email: string) => {
|
||||
})
|
||||
})
|
||||
|
||||
export const getUserByStripeCustomerId = cache(async (customerId: string) => {
|
||||
return await prisma.user.findFirst({
|
||||
where: { stripeCustomerId: customerId },
|
||||
})
|
||||
})
|
||||
|
||||
export function updateUser(userId: string, data: Prisma.UserUpdateInput) {
|
||||
return prisma.user.update({
|
||||
where: { id: userId },
|
||||
|
||||
Reference in New Issue
Block a user