chore: App router migration (/workflows) fix metadata and remove duplicate file for getStaticProps (#16452)

* Fix metadata

* add use client directive to workflow component
This commit is contained in:
Benny Joo authored and GitHub committed 2024-09-02 23:00:48 +05:30
1 parent 779eb19e7a
commit 55d75a9786
6 files changed
+67 -72

No files matched your search

@@ -1,3 +1,5 @@
"use client";
import { zodResolver } from "@hookform/resolvers/zod";
import type { WorkflowStep } from "@prisma/client";
import { useSession } from "next-auth/react";
@@ -0,0 +1,53 @@
import { z } from "zod";
import prisma from "@calcom/prisma";
export const ZGetInputSchema = z.object({
id: z.number(),
});
export type TGetInputSchema = z.infer<typeof ZGetInputSchema>;
export class WorkflowRepository {
static async getById({ id }: TGetInputSchema) {
return await prisma.workflow.findFirst({
where: {
id,
},
select: {
id: true,
name: true,
userId: true,
teamId: true,
isActiveOnAll: true,
team: {
select: {
id: true,
slug: true,
members: true,
name: true,
isOrganization: true,
},
},
time: true,
timeUnit: true,
activeOn: {
select: {
eventType: true,
},
},
activeOnTeams: {
select: {
team: true,
},
},
trigger: true,
steps: {
orderBy: {
stepNumber: "asc",
},
},
},
});
}
}
@@ -1,4 +1,4 @@
import { prisma } from "@calcom/prisma";
import { WorkflowRepository } from "@calcom/lib/server/repository/workflow";
import type { TrpcSessionUser } from "@calcom/trpc/server/trpc";
import { TRPCError } from "@trpc/server";
@@ -14,45 +14,7 @@ type GetOptions = {
};
export const getHandler = async ({ ctx, input }: GetOptions) => {
const workflow = await prisma.workflow.findFirst({
where: {
id: input.id,
},
select: {
id: true,
name: true,
userId: true,
teamId: true,
isActiveOnAll: true,
team: {
select: {
id: true,
slug: true,
members: true,
name: true,
isOrganization: true,
},
},
time: true,
timeUnit: true,
activeOn: {
select: {
eventType: true,
},
},
activeOnTeams: {
select: {
team: true,
},
},
trigger: true,
steps: {
orderBy: {
stepNumber: "asc",
},
},
},
});
const workflow = await WorkflowRepository.getById({ id: input.id });
const isUserAuthorized = await isAuthorized(workflow, ctx.user.id);
@@ -1,7 +1,2 @@
import { z } from "zod";
export const ZGetInputSchema = z.object({
id: z.number(),
});
export type TGetInputSchema = z.infer<typeof ZGetInputSchema>;
export { ZGetInputSchema } from "@calcom/lib/server/repository/workflow";
export type { TGetInputSchema } from "@calcom/lib/server/repository/workflow";