
* Add vital integration * Tidy up client_user_id creation * Rename vital app to vitalother to follow name rules * Added env var * App vital reschedule * Fix on app structure and api calls * Implemented user identification from webhook * WIP fix api call and read me * Save vital settings via api * Now saving userVitalSettings and trigger reschedule on selected param * Added translations * Fix type for vitalSettings * Using api to get env vars required for url, fix display of vital settings * Fix hours placeholder, translation not working * Renames vital app * Update seed-app-store.ts * Update package.json * Update yarn.lock * Refactored env variables * Update README.md * Migrates to api_keys * Extracts AppConfiguration * vitalClient fixes * Update index.ts * Update metadata.ts * Update index.ts * Update metadata.ts * Added namespace vital for translations Co-authored-by: Maitham <maithamdib@gmail.com> Co-authored-by: zomars <zomars@me.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
41 lines
1,005 B
TypeScript
41 lines
1,005 B
TypeScript
import { Prisma } from "@prisma/client";
|
|
import type { NextApiRequest, NextApiResponse } from "next";
|
|
|
|
import prisma from "@calcom/prisma";
|
|
|
|
/**
|
|
* This is will generate a user token for a client_user_id`
|
|
* @param req
|
|
* @param res
|
|
*/
|
|
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|
try {
|
|
const userWithMetadata = await prisma.user.findFirst({
|
|
where: {
|
|
id: req?.session?.user.id,
|
|
},
|
|
select: {
|
|
id: true,
|
|
metadata: true,
|
|
},
|
|
});
|
|
|
|
await prisma.user.update({
|
|
where: {
|
|
id: req?.session?.user.id,
|
|
},
|
|
data: {
|
|
metadata: {
|
|
...(userWithMetadata?.metadata as Prisma.JsonObject),
|
|
vitalSettings: {
|
|
...((userWithMetadata?.metadata as Prisma.JsonObject)?.vitalSettings as Prisma.JsonObject),
|
|
connected: true,
|
|
},
|
|
},
|
|
},
|
|
});
|
|
return res.redirect("/apps/installed");
|
|
} catch (e) {
|
|
return res.status(500);
|
|
}
|
|
}
|