* add org to create workflow button * add save button for testing in dev mode * add select all to multi select dropdown * fix select all * pass isOrg to WorkflowDetailsPage * add checkbox to apply to all including future * fix count text on select * WIP schema * shows teams in dropdown * add team option to UI * [WIP] refactor for update handler * filter out "all" from activeOn * fix type error * create more helper functions * create reusable function for scheduling all booking reminders * finish update workflows for orgs (without testing) * fix isAuthorized check for orgs * fix getting newActiveOn * move all helper functions to util file * more code clean up * fix deleting reminders for org workflows * fix adding and editing steps * update form data when workflow is saved * code clean up * fixing creating/deleting reminders when user is member of several teams * fix setting activeOn for teams in useffect * add on delete cascade * make multiSelectSchenbox searchable * set activeOn correctly when checkbox true * WIP * fix type errors in MultiSelectCheckboxes * implemented scheduling org-wide workfow notifications (not yet tested) * fix type errors * type error * add missing changes from merge conflict * remote not needed include statement * fix type errors * code clean up + some todo comments * support org workflows for cancelled workflows * delete reminders from removed members * remove reminders if isActiveOnAll is turned off * fix unti test and type error * code clean up * create basis for testing to book org team event * create org workflow with active team * fix getting active org workflows on team + test setup * fix creating workflow step for tests * fix first org test * add test for user event type with org workflow active * use deleteAllWorkflowReminders everywhere * add test for deleteRemindersFromRemovedActiveOn * fix type errors * make all tests pass * fix type error * fix getSchedule test * code clean up * add missing import * fix type error * fix tests * code clean up * fix imports * update reminders when trigger was changed * check for teamId before userId in reminderScheduler * move getOrgIdFromMemberOrTeamId to different folder * code clean up * fix tests * test setup for scheduleBookingReminders * fix typo * add tests for scheduleBookingReminders * fix prisma default import * fix workflowStep type * add scheduleBookingReminders test for sms * return dummy sid for scheduleSMS testMode * clean up + fixes * add lost changes from merge * get teamId and userId from incoming evt object * removing not needed select * add org support for scheduleMandatory email reminder * add other teams to dropdown * move getAllWorkflows to seperate file and call it in parent function * include org wide workflows in createNewSeat * some fixes + code clean up * add new team to select text count when including future teams is checked * fix upsert and remove sms reminder field * correctly update activeOn if 'including future ...' is enabled * list active Org workflows in event workflows settings * fix sms reminder field in all handlers * add helper function to check if step was edited * fix active on badge on workflow * fix type error * fix double reminders * add teamId: null for userWorkflow query * fix activeOnAll with managed event types * add missing teamId in getAllWorkflows * add a dafaut to prisma param * fix managed event types on select all user workflows * code clean up * better variable name * small fixes in update handler * fix test name to match function name * add info badge * fix workflow count in event type settings * fix getting bookings from children manged event types * delete reminders when user is not part of any time no more * implement feedback * fix disbale workflow in event type settings * fix remove member * create new function getAllWorkflowsFromEventType * add some removed code * use promise.allSettled when deleting workflow reminders * create new function deleteWorkflowRemindersOfRemovedMember.ts * fix userId param * delete org worklfows when team is disbanded * don't trigger active on all workflow if not part of any team * fix active on count badge * add test for deleteWorkflowRemidnersOfRemovedMember * trigger workflow also if not member of any subteam * fix failing test * remove unused code * use testId for go back button * fixes for managed event types & activateEventTypeHandler * code clean up * don't activate workflow on locked managed event type * fix type error * type error * more type fixes * feedback --------- Co-authored-by: CarinaWolli <wollencarina@gmail.com> Co-authored-by: Hariom Balhara <hariombalhara@gmail.com> Co-authored-by: Keith Williams <keithwillcode@gmail.com> Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
280 lines
9.7 KiB
TypeScript
280 lines
9.7 KiB
TypeScript
import authedProcedure from "../../../procedures/authedProcedure";
|
|
import { router } from "../../../trpc";
|
|
import { ZActivateEventTypeInputSchema } from "./activateEventType.schema";
|
|
import { ZCreateInputSchema } from "./create.schema";
|
|
import { ZDeleteInputSchema } from "./delete.schema";
|
|
import { ZFilteredListInputSchema } from "./filteredList.schema";
|
|
import { ZGetInputSchema } from "./get.schema";
|
|
import { ZGetAllActiveWorkflowsInputSchema } from "./getAllActiveWorkflows.schema";
|
|
import { ZGetVerifiedEmailsInputSchema } from "./getVerifiedEmails.schema";
|
|
import { ZGetVerifiedNumbersInputSchema } from "./getVerifiedNumbers.schema";
|
|
import { ZListInputSchema } from "./list.schema";
|
|
import { ZSendVerificationCodeInputSchema } from "./sendVerificationCode.schema";
|
|
import { ZUpdateInputSchema } from "./update.schema";
|
|
import { ZVerifyEmailCodeInputSchema } from "./verifyEmailCode.schema";
|
|
import { ZVerifyPhoneNumberInputSchema } from "./verifyPhoneNumber.schema";
|
|
|
|
type WorkflowsRouterHandlerCache = {
|
|
list?: typeof import("./list.handler").listHandler;
|
|
get?: typeof import("./get.handler").getHandler;
|
|
create?: typeof import("./create.handler").createHandler;
|
|
delete?: typeof import("./delete.handler").deleteHandler;
|
|
update?: typeof import("./update.handler").updateHandler;
|
|
activateEventType?: typeof import("./activateEventType.handler").activateEventTypeHandler;
|
|
sendVerificationCode?: typeof import("./sendVerificationCode.handler").sendVerificationCodeHandler;
|
|
verifyPhoneNumber?: typeof import("./verifyPhoneNumber.handler").verifyPhoneNumberHandler;
|
|
getVerifiedNumbers?: typeof import("./getVerifiedNumbers.handler").getVerifiedNumbersHandler;
|
|
getWorkflowActionOptions?: typeof import("./getWorkflowActionOptions.handler").getWorkflowActionOptionsHandler;
|
|
filteredList?: typeof import("./filteredList.handler").filteredListHandler;
|
|
getVerifiedEmails?: typeof import("./getVerifiedEmails.handler").getVerifiedEmailsHandler;
|
|
verifyEmailCode?: typeof import("./verifyEmailCode.handler").verifyEmailCodeHandler;
|
|
getAllActiveWorkflows?: typeof import("./getAllActiveWorkflows.handler").getAllActiveWorkflowsHandler;
|
|
};
|
|
|
|
const UNSTABLE_HANDLER_CACHE: WorkflowsRouterHandlerCache = {};
|
|
|
|
export const workflowsRouter = router({
|
|
list: authedProcedure.input(ZListInputSchema).query(async ({ ctx, input }) => {
|
|
if (!UNSTABLE_HANDLER_CACHE.list) {
|
|
UNSTABLE_HANDLER_CACHE.list = await import("./list.handler").then((mod) => mod.listHandler);
|
|
}
|
|
|
|
// Unreachable code but required for type safety
|
|
if (!UNSTABLE_HANDLER_CACHE.list) {
|
|
throw new Error("Failed to load handler");
|
|
}
|
|
|
|
return UNSTABLE_HANDLER_CACHE.list({
|
|
ctx,
|
|
input,
|
|
});
|
|
}),
|
|
|
|
get: authedProcedure.input(ZGetInputSchema).query(async ({ ctx, input }) => {
|
|
if (!UNSTABLE_HANDLER_CACHE.get) {
|
|
UNSTABLE_HANDLER_CACHE.get = await import("./get.handler").then((mod) => mod.getHandler);
|
|
}
|
|
|
|
// Unreachable code but required for type safety
|
|
if (!UNSTABLE_HANDLER_CACHE.get) {
|
|
throw new Error("Failed to load handler");
|
|
}
|
|
|
|
return UNSTABLE_HANDLER_CACHE.get({
|
|
ctx,
|
|
input,
|
|
});
|
|
}),
|
|
|
|
create: authedProcedure.input(ZCreateInputSchema).mutation(async ({ ctx, input }) => {
|
|
if (!UNSTABLE_HANDLER_CACHE.create) {
|
|
UNSTABLE_HANDLER_CACHE.create = await import("./create.handler").then((mod) => mod.createHandler);
|
|
}
|
|
|
|
// Unreachable code but required for type safety
|
|
if (!UNSTABLE_HANDLER_CACHE.create) {
|
|
throw new Error("Failed to load handler");
|
|
}
|
|
|
|
return UNSTABLE_HANDLER_CACHE.create({
|
|
ctx,
|
|
input,
|
|
});
|
|
}),
|
|
|
|
delete: authedProcedure.input(ZDeleteInputSchema).mutation(async ({ ctx, input }) => {
|
|
if (!UNSTABLE_HANDLER_CACHE.delete) {
|
|
UNSTABLE_HANDLER_CACHE.delete = await import("./delete.handler").then((mod) => mod.deleteHandler);
|
|
}
|
|
|
|
// Unreachable code but required for type safety
|
|
if (!UNSTABLE_HANDLER_CACHE.delete) {
|
|
throw new Error("Failed to load handler");
|
|
}
|
|
|
|
return UNSTABLE_HANDLER_CACHE.delete({
|
|
ctx,
|
|
input,
|
|
});
|
|
}),
|
|
|
|
update: authedProcedure.input(ZUpdateInputSchema).mutation(async ({ ctx, input }) => {
|
|
if (!UNSTABLE_HANDLER_CACHE.update) {
|
|
UNSTABLE_HANDLER_CACHE.update = await import("./update.handler").then((mod) => mod.updateHandler);
|
|
}
|
|
|
|
// Unreachable code but required for type safety
|
|
if (!UNSTABLE_HANDLER_CACHE.update) {
|
|
throw new Error("Failed to load handler");
|
|
}
|
|
|
|
return UNSTABLE_HANDLER_CACHE.update({
|
|
ctx,
|
|
input,
|
|
});
|
|
}),
|
|
|
|
activateEventType: authedProcedure.input(ZActivateEventTypeInputSchema).mutation(async ({ ctx, input }) => {
|
|
if (!UNSTABLE_HANDLER_CACHE.activateEventType) {
|
|
UNSTABLE_HANDLER_CACHE.activateEventType = await import("./activateEventType.handler").then(
|
|
(mod) => mod.activateEventTypeHandler
|
|
);
|
|
}
|
|
|
|
// Unreachable code but required for type safety
|
|
if (!UNSTABLE_HANDLER_CACHE.activateEventType) {
|
|
throw new Error("Failed to load handler");
|
|
}
|
|
|
|
return UNSTABLE_HANDLER_CACHE.activateEventType({
|
|
ctx,
|
|
input,
|
|
});
|
|
}),
|
|
|
|
sendVerificationCode: authedProcedure
|
|
.input(ZSendVerificationCodeInputSchema)
|
|
.mutation(async ({ ctx, input }) => {
|
|
if (!UNSTABLE_HANDLER_CACHE.sendVerificationCode) {
|
|
UNSTABLE_HANDLER_CACHE.sendVerificationCode = await import("./sendVerificationCode.handler").then(
|
|
(mod) => mod.sendVerificationCodeHandler
|
|
);
|
|
}
|
|
|
|
// Unreachable code but required for type safety
|
|
if (!UNSTABLE_HANDLER_CACHE.sendVerificationCode) {
|
|
throw new Error("Failed to load handler");
|
|
}
|
|
|
|
return UNSTABLE_HANDLER_CACHE.sendVerificationCode({
|
|
ctx,
|
|
input,
|
|
});
|
|
}),
|
|
|
|
verifyPhoneNumber: authedProcedure.input(ZVerifyPhoneNumberInputSchema).mutation(async ({ ctx, input }) => {
|
|
if (!UNSTABLE_HANDLER_CACHE.verifyPhoneNumber) {
|
|
UNSTABLE_HANDLER_CACHE.verifyPhoneNumber = await import("./verifyPhoneNumber.handler").then(
|
|
(mod) => mod.verifyPhoneNumberHandler
|
|
);
|
|
}
|
|
|
|
// Unreachable code but required for type safety
|
|
if (!UNSTABLE_HANDLER_CACHE.verifyPhoneNumber) {
|
|
throw new Error("Failed to load handler");
|
|
}
|
|
|
|
return UNSTABLE_HANDLER_CACHE.verifyPhoneNumber({
|
|
ctx,
|
|
input,
|
|
});
|
|
}),
|
|
|
|
getVerifiedNumbers: authedProcedure.input(ZGetVerifiedNumbersInputSchema).query(async ({ ctx, input }) => {
|
|
if (!UNSTABLE_HANDLER_CACHE.getVerifiedNumbers) {
|
|
UNSTABLE_HANDLER_CACHE.getVerifiedNumbers = await import("./getVerifiedNumbers.handler").then(
|
|
(mod) => mod.getVerifiedNumbersHandler
|
|
);
|
|
}
|
|
|
|
// Unreachable code but required for type safety
|
|
if (!UNSTABLE_HANDLER_CACHE.getVerifiedNumbers) {
|
|
throw new Error("Failed to load handler");
|
|
}
|
|
|
|
return UNSTABLE_HANDLER_CACHE.getVerifiedNumbers({
|
|
ctx,
|
|
input,
|
|
});
|
|
}),
|
|
|
|
getVerifiedEmails: authedProcedure.input(ZGetVerifiedEmailsInputSchema).query(async ({ ctx, input }) => {
|
|
if (!UNSTABLE_HANDLER_CACHE.getVerifiedEmails) {
|
|
UNSTABLE_HANDLER_CACHE.getVerifiedEmails = await import("./getVerifiedEmails.handler").then(
|
|
(mod) => mod.getVerifiedEmailsHandler
|
|
);
|
|
}
|
|
|
|
// Unreachable code but required for type safety
|
|
if (!UNSTABLE_HANDLER_CACHE.getVerifiedEmails) {
|
|
throw new Error("Failed to load handler");
|
|
}
|
|
|
|
return UNSTABLE_HANDLER_CACHE.getVerifiedEmails({
|
|
ctx,
|
|
input,
|
|
});
|
|
}),
|
|
|
|
verifyEmailCode: authedProcedure.input(ZVerifyEmailCodeInputSchema).mutation(async ({ ctx, input }) => {
|
|
if (!UNSTABLE_HANDLER_CACHE.verifyPhoneNumber) {
|
|
UNSTABLE_HANDLER_CACHE.verifyEmailCode = await import("./verifyEmailCode.handler").then(
|
|
(mod) => mod.verifyEmailCodeHandler
|
|
);
|
|
}
|
|
|
|
// Unreachable code but required for type safety
|
|
if (!UNSTABLE_HANDLER_CACHE.verifyEmailCode) {
|
|
throw new Error("Failed to load handler");
|
|
}
|
|
|
|
return UNSTABLE_HANDLER_CACHE.verifyEmailCode({
|
|
ctx,
|
|
input,
|
|
});
|
|
}),
|
|
|
|
getWorkflowActionOptions: authedProcedure.query(async ({ ctx }) => {
|
|
if (!UNSTABLE_HANDLER_CACHE.getWorkflowActionOptions) {
|
|
UNSTABLE_HANDLER_CACHE.getWorkflowActionOptions = await import(
|
|
"./getWorkflowActionOptions.handler"
|
|
).then((mod) => mod.getWorkflowActionOptionsHandler);
|
|
}
|
|
|
|
// Unreachable code but required for type safety
|
|
if (!UNSTABLE_HANDLER_CACHE.getWorkflowActionOptions) {
|
|
throw new Error("Failed to load handler");
|
|
}
|
|
|
|
return UNSTABLE_HANDLER_CACHE.getWorkflowActionOptions({
|
|
ctx,
|
|
});
|
|
}),
|
|
filteredList: authedProcedure.input(ZFilteredListInputSchema).query(async ({ ctx, input }) => {
|
|
if (!UNSTABLE_HANDLER_CACHE.filteredList) {
|
|
UNSTABLE_HANDLER_CACHE.filteredList = await import("./filteredList.handler").then(
|
|
(mod) => mod.filteredListHandler
|
|
);
|
|
}
|
|
|
|
// Unreachable code but required for type safety
|
|
if (!UNSTABLE_HANDLER_CACHE.filteredList) {
|
|
throw new Error("Failed to load handler");
|
|
}
|
|
|
|
return UNSTABLE_HANDLER_CACHE.filteredList({
|
|
ctx,
|
|
input,
|
|
});
|
|
}),
|
|
getAllActiveWorkflows: authedProcedure
|
|
.input(ZGetAllActiveWorkflowsInputSchema)
|
|
.query(async ({ ctx, input }) => {
|
|
if (!UNSTABLE_HANDLER_CACHE.getAllActiveWorkflows) {
|
|
UNSTABLE_HANDLER_CACHE.getAllActiveWorkflows = await import("./getAllActiveWorkflows.handler").then(
|
|
(mod) => mod.getAllActiveWorkflowsHandler
|
|
);
|
|
}
|
|
|
|
// Unreachable code but required for type safety
|
|
if (!UNSTABLE_HANDLER_CACHE.getAllActiveWorkflows) {
|
|
throw new Error("Failed to load handler");
|
|
}
|
|
|
|
return UNSTABLE_HANDLER_CACHE.getAllActiveWorkflows({
|
|
ctx,
|
|
input,
|
|
});
|
|
}),
|
|
});
|