Zomars/cal 748 paid bookings are failing (#1335)
* E2E video adjustments * Adds test to add Stripe integration * Type fix * WIP: Payment troubleshooting * Paid bookings shouldn't be confirmed by default * Runs stripe test only if installed * BookingListItem Adjustments * Pending paid bookings should be unconfirmed * Attempt to fix paid bookings * Type fixes * Type fixes * Tests fixes * Adds paid booking to seeder * Moves stripe tests to own file * Matches app locale to Stripe's * Fixes minimun price for testing * Stripe test fixes * Fixes stripe frame test * Added some Stripe TODOs
This commit is contained in:
1 parent
ca405743fb
commit
21103580f7
19 files changed
+201
-51
No files matched your search
@@ -5,8 +5,15 @@ import { getSession } from "@lib/auth";
|
||||
import prisma from "@lib/prisma";
|
||||
import { WorkingHours } from "@lib/types/schedule";
|
||||
|
||||
function handlePeriodType(periodType: string): PeriodType {
|
||||
return PeriodType[periodType.toUpperCase()];
|
||||
function isPeriodType(keyInput: string): keyInput is PeriodType {
|
||||
return Object.keys(PeriodType).includes(keyInput);
|
||||
}
|
||||
|
||||
function handlePeriodType(periodType: string): PeriodType | undefined {
|
||||
if (typeof periodType !== "string") return undefined;
|
||||
const passedPeriodType = periodType.toUpperCase();
|
||||
if (!isPeriodType(passedPeriodType)) return undefined;
|
||||
return PeriodType[passedPeriodType];
|
||||
}
|
||||
|
||||
function handleCustomInputs(customInputs: EventTypeCustomInput[], eventTypeId: number) {
|
||||
@@ -104,7 +111,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
}
|
||||
}
|
||||
|
||||
if (req.method == "PATCH" || req.method == "POST") {
|
||||
if (req.method === "PATCH" || req.method === "POST") {
|
||||
const data: Prisma.EventTypeCreateInput | Prisma.EventTypeUpdateInput = {
|
||||
title: req.body.title,
|
||||
slug: req.body.slug.trim(),
|
||||
@@ -116,7 +123,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
locations: req.body.locations,
|
||||
eventName: req.body.eventName,
|
||||
customInputs: handleCustomInputs(req.body.customInputs as EventTypeCustomInput[], req.body.id),
|
||||
periodType: req.body.periodType ? handlePeriodType(req.body.periodType) : undefined,
|
||||
periodType: handlePeriodType(req.body.periodType),
|
||||
periodDays: req.body.periodDays,
|
||||
periodStartDate: req.body.periodStartDate,
|
||||
periodEndDate: req.body.periodEndDate,
|
||||
@@ -179,8 +186,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
}
|
||||
|
||||
const availabilityToCreate = openingHours.map((openingHour) => ({
|
||||
startTime: openingHour.startTime,
|
||||
endTime: openingHour.endTime,
|
||||
startTime: new Date(openingHour.startTime),
|
||||
endTime: new Date(openingHour.endTime),
|
||||
days: openingHour.days,
|
||||
}));
|
||||
|
||||
|
||||
@@ -198,6 +198,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
}
|
||||
|
||||
const eventType = await prisma.eventType.findUnique({
|
||||
rejectOnNotFound: true,
|
||||
where: {
|
||||
id: eventTypeId,
|
||||
},
|
||||
@@ -331,7 +332,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
startTime: dayjs(evt.startTime).toDate(),
|
||||
endTime: dayjs(evt.endTime).toDate(),
|
||||
description: evt.description,
|
||||
confirmed: !eventType?.requiresConfirmation || !!rescheduleUid,
|
||||
confirmed: (!eventType.requiresConfirmation && !eventType.price) || !!rescheduleUid,
|
||||
location: evt.location,
|
||||
eventType: {
|
||||
connect: {
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import { NextPageContext } from "next";
|
||||
|
||||
import { getSession } from "@lib/auth";
|
||||
|
||||
function RedirectPage() {
|
||||
return null;
|
||||
}
|
||||
|
||||
export async function getServerSideProps(context) {
|
||||
export async function getServerSideProps(context: NextPageContext) {
|
||||
const session = await getSession(context);
|
||||
if (!session?.user?.id) {
|
||||
return { redirect: { permanent: false, destination: "/auth/login" } };
|
||||
|
||||
@@ -461,7 +461,7 @@ function ConnectOrDisconnectIntegrationButton(props: {
|
||||
<DisconnectIntegration
|
||||
id={credentialId}
|
||||
render={(btnProps) => (
|
||||
<Button {...btnProps} color="warn">
|
||||
<Button {...btnProps} color="warn" data-testid="integration-connection-button">
|
||||
{t("disconnect")}
|
||||
</Button>
|
||||
)}
|
||||
@@ -488,7 +488,7 @@ function ConnectOrDisconnectIntegrationButton(props: {
|
||||
<ConnectIntegration
|
||||
type={props.type}
|
||||
render={(btnProps) => (
|
||||
<Button color="secondary" {...btnProps}>
|
||||
<Button color="secondary" {...btnProps} data-testid="integration-connection-button">
|
||||
{t("connect")}
|
||||
</Button>
|
||||
)}
|
||||
|
||||
Reference in new issue
Block a user