From 3e616d1e41ff2afe5d0a4c9c1b273deca7e90682 Mon Sep 17 00:00:00 2001 From: Luke Vella Date: Wed, 6 Sep 2023 19:44:51 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20issue=20prevent=20poll=20s?= =?UTF-8?q?ettings=20from=20being=20applied=20(#841)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/backend/trpc/routers/polls.ts | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/packages/backend/trpc/routers/polls.ts b/packages/backend/trpc/routers/polls.ts index abbbe9b7c..51c1d5184 100644 --- a/packages/backend/trpc/routers/polls.ts +++ b/packages/backend/trpc/routers/polls.ts @@ -9,6 +9,7 @@ import utc from "dayjs/plugin/utc"; import * as ics from "ics"; import { z } from "zod"; +import { getSubscriptionStatus } from "../../utils/auth"; import { getTimeZoneAbbreviation } from "../../utils/date"; import { nanoid } from "../../utils/nanoid"; import { @@ -43,19 +44,6 @@ const getPollIdFromAdminUrlId = async (urlId: string) => { return res.id; }; -const getPro = async (userId: string) => { - return Boolean( - await prisma.userPaymentData.findFirst({ - where: { - userId, - endDate: { - gt: new Date(), - }, - }, - }), - ); -}; - export const polls = router({ demo, participants, @@ -86,7 +74,7 @@ export const polls = router({ const participantUrlId = nanoid(); const pollId = nanoid(); - const isPro = await getPro(ctx.user.id); + const { active: isPro } = await getSubscriptionStatus(ctx.user.id); const poll = await prisma.poll.create({ select: { @@ -186,7 +174,7 @@ export const polls = router({ .mutation(async ({ ctx, input }) => { const pollId = await getPollIdFromAdminUrlId(input.urlId); - const isPro = await getPro(ctx.user.id); + const { active: isPro } = await getSubscriptionStatus(ctx.user.id); if (input.optionsToDelete && input.optionsToDelete.length > 0) { await prisma.option.deleteMany({