migrate organizations from clerk to in-house

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-06-16 19:32:53 +02:00
parent 84ac68fe63
commit c7dbc2f7c4
27 changed files with 523 additions and 294 deletions

View File

@@ -1,7 +1,7 @@
import { clerkClient } from '@clerk/fastify';
import { z } from 'zod';
import { transformUser } from '@openpanel/db';
import { db } from '@openpanel/db';
import { createTRPCRouter, protectedProcedure } from '../trpc';
@@ -13,12 +13,23 @@ export const userRouter = createTRPCRouter({
lastName: z.string(),
})
)
.mutation(({ input, ctx }) => {
return clerkClient.users
.updateUser(ctx.session.userId, {
.mutation(async ({ input, ctx }) => {
const [updatedUser] = await Promise.all([
db.user.update({
where: {
id: ctx.session.userId,
},
data: {
firstName: input.firstName,
lastName: input.lastName,
},
}),
clerkClient.users.updateUser(ctx.session.userId, {
firstName: input.firstName,
lastName: input.lastName,
})
.then(transformUser);
}),
]);
return updatedUser;
}),
});