
UI/UX designer/prototyper/developer in San Diego. Tennis & automobile enthusiast. π³βπ him/his. @devuxer@mastodon.social
- Tweets3.4K
- Following253
- Followers129
- Likes4.3K

ALT async function handler(req: NextApiRequest, res: NextApiResponse) { try { await requireMaintenanceModeOff(prisma); await authorizeViaCookie(req, prisma, true, "Admin", "Officer"); const { paidOn, expiresOn, ...partialPayload } = getValidatedPayload(req); await prisma.membershipPayment.create({ data: { ...partialPayload, paidOn: standardDateStringToDate(paidOn), expiresOn: standardDateStringToDate(expiresOn), isVerified: true, }, }); sendSuccessStatus(res); } catch (e) { sendError(res, e); } }

ALT export function getValidatedPayload(req: NextApiRequest) { const { amountDueOrPaid, paidOn, paymentMethod, notes, expiresOn } = req.body; if (!isInRangeInteger(amountDueOrPaid, 1)) throw new InvalidInputError("Amount Due Or Paid"); if (!isDateString(paidOn)) throw new InvalidInputError("Paid On"); if (!isPaymentMethod(paymentMethod)) throw new InvalidInputError("Payment Method"); if (!isOptionalString(notes)) throw new InvalidInputError("Notes"); if (!isDateString(expiresOn)) throw new InvalidInputError("Paid On"); return { amountDueOrPaid, paidOn, paymentMethod, notes, expiresOn }; }
![export type Payload = ResolvedReturnType<typeof handler>[number]; export default withSentry(handler as NextApiHandler); async function handler(req: NextApiRequest, res: NextApiResponse) { try { await authorizeViaCookie(req, prisma, true, "Officer", "Admin"); const memberId = getValidatedId(req, "memberId"); const result = ( await prisma.membershipPayment.findMany({ where: { memberId }, include: { member: { select: { profileName: true }, }, }, orderBy: { paidOn: "desc" }, }) ).map(x => ({ ...x, paidOn: x.paidOn ? prismaDateToStandardDateString(x.paidOn) : null, expiresOn: prismaDateToStandardDateString(x.expiresOn), })); res.send(result); return result; } catch (e) { sendError(res, e); } }](https://pbs.twimg.com/media/FZfoUPfUcAYWcAQ.png?name=small&format=webp)
ALT export type Payload = ResolvedReturnType<typeof handler>[number]; export default withSentry(handler as NextApiHandler); async function handler(req: NextApiRequest, res: NextApiResponse) { try { await authorizeViaCookie(req, prisma, true, "Officer", "Admin"); const memberId = getValidatedId(req, "memberId"); const result = ( await prisma.membershipPayment.findMany({ where: { memberId }, include: { member: { select: { profileName: true }, }, }, orderBy: { paidOn: "desc" }, }) ).map(x => ({ ...x, paidOn: x.paidOn ? prismaDateToStandardDateString(x.paidOn) : null, expiresOn: prismaDateToStandardDateString(x.expiresOn), })); res.send(result); return result; } catch (e) { sendError(res, e); } }






