refactor: Move Users Admin TRPC router from features package to trpc layer (#25816)

* move users admin router to trpc package

* users admin router

* update import path

* fix
This commit is contained in:
Benny Joo
2025-12-14 08:45:20 -03:00
committed by GitHub
parent 43b6c63294
commit a8f43da472
5 changed files with 47 additions and 32 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
import { userAdminRouter } from "@calcom/features/ee/users/server/trpc-router";
import { createNextApiHandler } from "@calcom/trpc/server/createNextApiHandler";
import { userAdminRouter } from "@calcom/trpc/server/routers/viewer/users/_router";
export default createNextApiHandler(userAdminRouter);
@@ -1,4 +1,3 @@
// eslint-disable-next-line no-restricted-imports
import { noop } from "lodash";
import { Controller, useForm } from "react-hook-form";
@@ -13,9 +12,24 @@ import { Button } from "@calcom/ui/components/button";
import { Form, EmailField, Select, Label, TextField } from "@calcom/ui/components/form";
import { ImageUploader } from "@calcom/ui/components/image-uploader";
import type { UserAdminRouterOutputs } from "../server/trpc-router";
type User = UserAdminRouterOutputs["get"]["user"];
interface User {
id: number;
name: string | null;
email: string;
username: string | null;
bio: string | null;
timeZone: string;
weekStart: string;
theme: string | null;
defaultScheduleId: number | null;
locale: string;
timeFormat: number;
allowDynamicBooking: boolean;
identityProvider: string;
role: string;
avatarUrl: string | null;
createdDate?: string | Date;
}
type Option<T extends string | number = string> = {
value: T;
@@ -33,7 +47,15 @@ type OptionValues = {
type FormValues = Pick<
User,
"avatarUrl" | "name" | "username" | "email" | "bio" | "createdDate" | "theme" | "defaultScheduleId" | "allowDynamicBooking"
| "avatarUrl"
| "name"
| "username"
| "email"
| "bio"
| "createdDate"
| "theme"
| "defaultScheduleId"
| "allowDynamicBooking"
> &
OptionValues;
@@ -1,39 +1,32 @@
"use client";
import { usePathname, useRouter } from "next/navigation";
import { z } from "zod";
import NoSSR from "@calcom/lib/components/NoSSR";
import { useParamsWithFallback } from "@calcom/lib/hooks/useParamsWithFallback";
import { getParserWithGeneric } from "@calcom/prisma/zod-utils";
import { trpc } from "@calcom/trpc/react";
import { showToast } from "@calcom/ui/components/toast";
import LicenseRequired from "../../common/components/LicenseRequired";
import { UserForm } from "../components/UserForm";
import { userBodySchema } from "../schemas/userBodySchema";
import type { UserAdminRouterOutputs } from "../server/trpc-router";
type User = UserAdminRouterOutputs["get"]["user"];
const userIdSchema = z.object({ id: z.coerce.number() });
const UsersEditPage = () => {
const params = useParamsWithFallback();
const input = userIdSchema.safeParse(params);
if (!input.success) return <div>Invalid input</div>;
const [data] = trpc.viewer.users.get.useSuspenseQuery({ userId: input.data.id });
const { user } = data;
return (
<LicenseRequired>
<NoSSR>
<UsersEditView user={user} />
</NoSSR>
</LicenseRequired>
);
};
interface User {
id: number;
name: string | null;
email: string;
username: string | null;
bio: string | null;
timeZone: string;
weekStart: string;
theme: string | null;
defaultScheduleId: number | null;
locale: string;
timeFormat: number;
allowDynamicBooking: boolean;
identityProvider: string;
role: string;
avatarUrl: string | null;
createdDate?: string | Date;
}
export const UsersEditView = ({ user }: { user: User }) => {
const pathname = usePathname();
@@ -1,4 +1,3 @@
import { userAdminRouter } from "@calcom/features/ee/users/server/trpc-router";
import { featureFlagRouter } from "@calcom/features/flags/server/router";
import { router } from "../../trpc";
@@ -39,6 +38,7 @@ import { slotsRouter } from "./slots/_router";
import { ssoRouter } from "./sso/_router";
import { viewerTeamsRouter } from "./teams/_router";
import { travelSchedulesRouter } from "./travelSchedules/_router";
import { userAdminRouter } from "./users/_router";
import { webhookRouter } from "./webhook/_router";
import { workflowsRouter } from "./workflows/_router";