mirror of
https://github.com/lukevella/rallly.git
synced 2025-04-30 10:46:35 +02:00
🐛 Fix issue prevent poll settings from being applied (#841)
This commit is contained in:
parent
8619b97a2c
commit
3e616d1e41
1 changed files with 3 additions and 15 deletions
|
@ -9,6 +9,7 @@ import utc from "dayjs/plugin/utc";
|
||||||
import * as ics from "ics";
|
import * as ics from "ics";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
|
import { getSubscriptionStatus } from "../../utils/auth";
|
||||||
import { getTimeZoneAbbreviation } from "../../utils/date";
|
import { getTimeZoneAbbreviation } from "../../utils/date";
|
||||||
import { nanoid } from "../../utils/nanoid";
|
import { nanoid } from "../../utils/nanoid";
|
||||||
import {
|
import {
|
||||||
|
@ -43,19 +44,6 @@ const getPollIdFromAdminUrlId = async (urlId: string) => {
|
||||||
return res.id;
|
return res.id;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getPro = async (userId: string) => {
|
|
||||||
return Boolean(
|
|
||||||
await prisma.userPaymentData.findFirst({
|
|
||||||
where: {
|
|
||||||
userId,
|
|
||||||
endDate: {
|
|
||||||
gt: new Date(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const polls = router({
|
export const polls = router({
|
||||||
demo,
|
demo,
|
||||||
participants,
|
participants,
|
||||||
|
@ -86,7 +74,7 @@ export const polls = router({
|
||||||
const participantUrlId = nanoid();
|
const participantUrlId = nanoid();
|
||||||
const pollId = 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({
|
const poll = await prisma.poll.create({
|
||||||
select: {
|
select: {
|
||||||
|
@ -186,7 +174,7 @@ export const polls = router({
|
||||||
.mutation(async ({ ctx, input }) => {
|
.mutation(async ({ ctx, input }) => {
|
||||||
const pollId = await getPollIdFromAdminUrlId(input.urlId);
|
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) {
|
if (input.optionsToDelete && input.optionsToDelete.length > 0) {
|
||||||
await prisma.option.deleteMany({
|
await prisma.option.deleteMany({
|
||||||
|
|
Loading…
Add table
Reference in a new issue