Feature/round robin (#613)
* Heavy WIP * More WIP * Playing with backwards compat * Moar wip * wip * Email changes for group feature * Committing in redundant migrations for reference * Combine all WIP migrations into a single feature migration * Make backup of current version of radio area pending refactor * Improved accessibility through keyboard * Cleanup in seperate commit so I can cherrypick later * Added RadioArea component * wip * Ignore .yarn file * Kinda stable * Getting closer... * Hide header when there are only personal events * Added uid to event create, updated EventTypeDescription * Delete redundant migration * Committing new team related migrations * Optimising & implemented backwards compatibility * Removed now redundant pages * Undid prototyping to calendarClient I did not end up using * Properly typed Select & fixed lint throughout * How'd that get here, removed. * TODO: investigate why userData is not compatible with passed type * This likely matches the event type that is created for a user * Few bugfixes * Adding datepicker optimisations * Fixed new event type spacing, initial profile should always be there * Gave NEXT_PUBLIC_BASE_URL a try but I think it's not the right solution * Updated EventTypeDescription to account for long titles, added logo to team page. * Added logo to team query * Added cancel Cypress test because an upcoming merge contains changes * Fix for when the event type description is long * Turned Theme into the useTheme hook, and made it fully compatible with teams pages * Built AvatarGroup ui component + moved Avatar to ui * Give the avatar some space fom the description * Fixed timeZone selector * Disabled tooltip +1-... Co-authored-by: Bailey Pumfleet <pumfleet@hey.com>
This commit is contained in:
@@ -1,9 +1,59 @@
|
||||
import { hashPassword } from "../lib/auth";
|
||||
import { Prisma, PrismaClient } from "@prisma/client";
|
||||
import { Prisma, PrismaClient, UserPlan } from "@prisma/client";
|
||||
import dayjs from "dayjs";
|
||||
import { uuid } from "short-uuid";
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function createBookingForEventType(opts: {
|
||||
uid: string;
|
||||
title: string;
|
||||
slug: string;
|
||||
startTime: Date | string;
|
||||
endTime: Date | string;
|
||||
userEmail: string;
|
||||
}) {
|
||||
const eventType = await prisma.eventType.findFirst({
|
||||
where: {
|
||||
slug: opts.slug,
|
||||
},
|
||||
});
|
||||
|
||||
if (!eventType) {
|
||||
// should not happen
|
||||
throw new Error("Eventtype missing");
|
||||
}
|
||||
|
||||
const bookingData: Prisma.BookingCreateArgs["data"] = {
|
||||
uid: opts.uid,
|
||||
title: opts.title,
|
||||
startTime: opts.startTime,
|
||||
endTime: opts.endTime,
|
||||
user: {
|
||||
connect: {
|
||||
email: opts.userEmail,
|
||||
},
|
||||
},
|
||||
attendees: {
|
||||
create: {
|
||||
email: opts.userEmail,
|
||||
name: "Some name",
|
||||
timeZone: "Europe/London",
|
||||
},
|
||||
},
|
||||
eventType: {
|
||||
connect: {
|
||||
id: eventType.id,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
await prisma.booking.create({
|
||||
data: bookingData,
|
||||
});
|
||||
}
|
||||
|
||||
async function createUserAndEventType(opts: {
|
||||
user: Omit<Prisma.UserCreateArgs["data"], "password" | "email"> & { password: string; email: string };
|
||||
user: { email: string; password: string; username: string; plan: UserPlan };
|
||||
eventTypes: Array<Prisma.EventTypeCreateArgs["data"]>;
|
||||
}) {
|
||||
const userData: Prisma.UserCreateArgs["data"] = {
|
||||
@@ -24,16 +74,34 @@ async function createUserAndEventType(opts: {
|
||||
for (const rawData of opts.eventTypes) {
|
||||
const eventTypeData: Prisma.EventTypeCreateArgs["data"] = { ...rawData };
|
||||
eventTypeData.userId = user.id;
|
||||
await prisma.eventType.upsert({
|
||||
|
||||
const eventType = await prisma.eventType.findFirst({
|
||||
where: {
|
||||
userId_slug: {
|
||||
slug: eventTypeData.slug,
|
||||
userId: user.id,
|
||||
slug: eventTypeData.slug,
|
||||
users: {
|
||||
some: {
|
||||
id: eventTypeData.userId,
|
||||
},
|
||||
},
|
||||
},
|
||||
update: eventTypeData,
|
||||
create: eventTypeData,
|
||||
select: {
|
||||
id: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (eventType) {
|
||||
await prisma.eventType.update({
|
||||
where: {
|
||||
id: eventType.id,
|
||||
},
|
||||
data: eventTypeData,
|
||||
});
|
||||
} else {
|
||||
await prisma.eventType.create({
|
||||
data: eventTypeData,
|
||||
});
|
||||
}
|
||||
|
||||
console.log(
|
||||
`\t📆 Event type ${eventTypeData.slug}, length ${eventTypeData.length}: http://localhost:3000/${user.username}/${eventTypeData.slug}`
|
||||
);
|
||||
@@ -104,6 +172,16 @@ async function main() {
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
await createBookingForEventType({
|
||||
title: "30min",
|
||||
slug: "30min",
|
||||
startTime: dayjs().add(1, "day").toDate(),
|
||||
endTime: dayjs().add(1, "day").add(60, "minutes").toDate(),
|
||||
uid: uuid(),
|
||||
userEmail: "pro@example.com",
|
||||
});
|
||||
|
||||
await createUserAndEventType({
|
||||
user: {
|
||||
email: "trial@example.com",
|
||||
|
||||
Reference in New Issue
Block a user