diff --git a/src/client/routes/settings/workspace.tsx b/src/client/routes/settings/workspace.tsx index d352055..d37af05 100644 --- a/src/client/routes/settings/workspace.tsx +++ b/src/client/routes/settings/workspace.tsx @@ -46,7 +46,7 @@ export const Route = createFileRoute('/settings/workspace')({ }); const inviteFormSchema = z.object({ - email: z.string().email(), + emailOrId: z.string(), }); type InviteFormValues = z.infer; @@ -64,7 +64,7 @@ function PageComponent() { const form = useForm({ resolver: zodResolver(inviteFormSchema), defaultValues: { - email: '', + emailOrId: '', }, }); const inviteMutation = trpc.workspace.invite.useMutation({ @@ -80,7 +80,7 @@ function PageComponent() { async (values: InviteFormValues) => { await inviteMutation.mutateAsync({ workspaceId, - targetUserEmail: values.email, + emailOrId: values.emailOrId, }); form.reset(); @@ -148,12 +148,15 @@ function PageComponent() { ( - + diff --git a/src/server/trpc/routers/workspace.ts b/src/server/trpc/routers/workspace.ts index a105121..6e7f972 100644 --- a/src/server/trpc/routers/workspace.ts +++ b/src/server/trpc/routers/workspace.ts @@ -220,15 +220,22 @@ export const workspaceRouter = router({ ) .input( z.object({ - targetUserEmail: z.string(), + emailOrId: z.string(), }) ) .output(z.void()) .mutation(async ({ input }) => { - const { targetUserEmail, workspaceId } = input; - const targetUser = await prisma.user.findUnique({ + const { emailOrId, workspaceId } = input; + const targetUser = await prisma.user.findFirst({ where: { - email: targetUserEmail, + OR: [ + { + email: emailOrId, + }, + { + id: emailOrId, + }, + ], }, });