@@ -607,6 +606,23 @@ const EventTypesPage = () => {
className="mb-4"
/>
)}
+ {!defaultCalendarConnected && (
+
{t("missing_connected_calendar") as string}>}
+ message={
+
+ You can connect your calendar from
+
+ here
+
+ .
+
+ }
+ />
+ )}
+
{data.eventTypeGroups.map((group, index) => (
{/* hide list heading when there is only one (current user) */}
@@ -616,6 +632,7 @@ const EventTypesPage = () => {
membershipCount={group.metadata.membershipCount}
/>
)}
+
{
);
};
+export async function getServerSideProps(context: GetServerSidePropsContext) {
+ const session = await getSession(context);
+ let defaultCalendarConnected = false;
+
+ if (session && session.user) {
+ const defaultCalendar = await prisma.destinationCalendar.findFirst({
+ where: {
+ userId: session.user.id,
+ credentialId: {
+ not: null,
+ },
+ },
+ });
+ defaultCalendarConnected = !!defaultCalendar;
+ }
+ return {
+ props: {
+ defaultCalendarConnected,
+ },
+ };
+}
+
export default EventTypesPage;
diff --git a/apps/web/public/static/locales/en/common.json b/apps/web/public/static/locales/en/common.json
index 5c6d1ad94c96a0..30db4090533f54 100644
--- a/apps/web/public/static/locales/en/common.json
+++ b/apps/web/public/static/locales/en/common.json
@@ -1028,13 +1028,15 @@
"current_username": "Current username",
"example_1": "Example 1",
"example_2": "Example 2",
- "additonal_input_label": "Additonal input label",
+ "additional_input_label": "Additional input label",
"company_size": "Company size",
"what_help_needed": "What do you need help with?",
"variable_format": "Variable format",
- "custom_input_as_variable_info": "Ignore all special characters of the additonal input label (use only letters and numbers), use uppercase for all letters and replace whitespaces with underscores.",
+ "custom_input_as_variable_info": "Ignore all special characters of the additional input label (use only letters and numbers), use uppercase for all letters and replace whitespaces with underscores.",
"using_additional_inputs_as_variables": "How to use additional inputs as variables?",
- "missing_connected_calendar": "No calendar connected",
"download_desktop_app": "Download desktop app",
- "set_ping_link": "Set Ping link"
+ "set_ping_link": "Set Ping link",
+ "missing_connected_calendar": "No default calendar connected",
+ "connect_your_calendar_and_link": "You can connect your calendar from <1>here1>.",
+ "default_calendar_selected": "Default calendar"
}
diff --git a/packages/app-store/ee/routing_forms/playwright/lib/testUtils.ts b/packages/app-store/ee/routing_forms/playwright/lib/testUtils.ts
index ad286c36d2ba1d..94b70265360a39 100644
--- a/packages/app-store/ee/routing_forms/playwright/lib/testUtils.ts
+++ b/packages/app-store/ee/routing_forms/playwright/lib/testUtils.ts
@@ -1,4 +1,4 @@
-import prisma from "@calcom/web/lib/prisma";
+import prisma from "@calcom/prisma";
export * from "@calcom/app-store/_apps-playwright/lib/testUtils";
export async function cleanUpForms() {
diff --git a/packages/prisma/migrations/20220817201039_/migration.sql b/packages/prisma/migrations/20220817201039_/migration.sql
new file mode 100644
index 00000000000000..d284a63cc6e8ed
--- /dev/null
+++ b/packages/prisma/migrations/20220817201039_/migration.sql
@@ -0,0 +1,17 @@
+-- DropForeignKey
+ALTER TABLE "DestinationCalendar" DROP CONSTRAINT "DestinationCalendar_credentialId_fkey";
+
+-- DropForeignKey
+ALTER TABLE "DestinationCalendar" DROP CONSTRAINT "DestinationCalendar_eventTypeId_fkey";
+
+-- DropForeignKey
+ALTER TABLE "DestinationCalendar" DROP CONSTRAINT "DestinationCalendar_userId_fkey";
+
+-- AddForeignKey
+ALTER TABLE "DestinationCalendar" ADD CONSTRAINT "DestinationCalendar_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE "DestinationCalendar" ADD CONSTRAINT "DestinationCalendar_eventTypeId_fkey" FOREIGN KEY ("eventTypeId") REFERENCES "EventType"("id") ON DELETE CASCADE ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE "DestinationCalendar" ADD CONSTRAINT "DestinationCalendar_credentialId_fkey" FOREIGN KEY ("credentialId") REFERENCES "Credential"("id") ON DELETE CASCADE ON UPDATE CASCADE;
diff --git a/packages/prisma/schema.prisma b/packages/prisma/schema.prisma
index 98cce2737c578f..97e5f7e8888725 100644
--- a/packages/prisma/schema.prisma
+++ b/packages/prisma/schema.prisma
@@ -85,6 +85,7 @@ model EventType {
model Credential {
id Int @id @default(autoincrement())
+ // @@type is deprecated
type String
key Json
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
@@ -111,13 +112,13 @@ model DestinationCalendar {
id Int @id @default(autoincrement())
integration String
externalId String
- user User? @relation(fields: [userId], references: [id])
+ user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
userId Int? @unique
booking Booking[]
- eventType EventType? @relation(fields: [eventTypeId], references: [id])
+ eventType EventType? @relation(fields: [eventTypeId], references: [id], onDelete: Cascade)
eventTypeId Int? @unique
credentialId Int?
- credential Credential? @relation(fields: [credentialId], references: [id])
+ credential Credential? @relation(fields: [credentialId], references: [id], onDelete: Cascade)
}
enum UserPermissionRole {
diff --git a/packages/types/AppGetServerSideProps.d.ts b/packages/types/AppGetServerSideProps.d.ts
index 546d76e7c7751b..e2f1d5ee7cbec3 100644
--- a/packages/types/AppGetServerSideProps.d.ts
+++ b/packages/types/AppGetServerSideProps.d.ts
@@ -1,7 +1,7 @@
import { GetServerSidePropsContext, GetServerSidePropsResult } from "next";
import { CalendsoSessionUser } from "next-auth";
-import prisma from "@calcom/web/lib/prisma";
+import prisma from "@calcom/prisma";
export type AppUser = CalendsoSessionUser | undefined;
export type AppPrisma = typeof prisma;