mirror of
https://github.com/lukevella/rallly.git
synced 2025-04-29 18:26:34 +02:00
38 lines
823 B
TypeScript
38 lines
823 B
TypeScript
import { prisma } from "@rallly/database";
|
|
import { z } from "zod";
|
|
|
|
import { publicProcedure, router } from "../trpc";
|
|
|
|
export const user = router({
|
|
getBilling: publicProcedure.query(async ({ ctx }) => {
|
|
return await prisma.userPaymentData.findUnique({
|
|
select: {
|
|
subscriptionId: true,
|
|
status: true,
|
|
planId: true,
|
|
endDate: true,
|
|
updateUrl: true,
|
|
cancelUrl: true,
|
|
},
|
|
where: {
|
|
userId: ctx.user.id,
|
|
},
|
|
});
|
|
}),
|
|
changeName: publicProcedure
|
|
.input(
|
|
z.object({
|
|
name: z.string().min(1).max(100),
|
|
}),
|
|
)
|
|
.mutation(async ({ input, ctx }) => {
|
|
await prisma.user.update({
|
|
where: {
|
|
id: ctx.user.id,
|
|
},
|
|
data: {
|
|
name: input.name,
|
|
},
|
|
});
|
|
}),
|
|
});
|