Files
calendar/apps/web/pages/api/app-store/installed.ts
T
Leo GiovanettiGitHubOmar Lópezalannnckodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>Peer Richelsen
33a45a8af5 Installed Apps page revamp (#2751)
* First round of changes

* Some missing styling

* Last round of core changes

* Color tweaks

* Improving code readability

* Reverting unneeded changes

* Reverting yarn.lock

* Removing yarn.lock

* Empty state updated

* Fixing webhook test

* Cleaning up code

* Fixing test and simplifying code a bit

* Merging API Keys into developer section

* Unifying Empty Screen with monorepo version

* Cleaning up

* Installed apps logic consistency + cleaning up

* Type fixes

* Apply suggestions from code review

Co-authored-by: Omar López <zomars@me.com>
Co-authored-by: alannnc <alannnc@gmail.com>

* Improvements, still WIP

* Update apps/web/pages/apps/installed.tsx

Co-authored-by: Omar López <zomars@me.com>

* Apply suggestions from code review

Co-authored-by: Omar López <zomars@me.com>

* App active install status

* Apple Calendar setup, Daily.co preinstalled

* Final pass

* Minor tweaks

* Conflicts with migration ignored

* Fixing merge

* Fixing merge yet again

* Adopting main changes

* Removing unneeded data-testid

* Fixing reported bugs

* Simplifying webhook query

* Moving teams settings tab to second

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: zomars <zomars@me.com>
Co-authored-by: alannnc <alannnc@gmail.com>
Co-authored-by: Peer Richelsen <peeroke@gmail.com>
2022-06-01 14:24:41 -03:00

38 lines
1018 B
TypeScript

import type { NextApiRequest, NextApiResponse } from "next";
import prisma from "@calcom/prisma";
import { getSession } from "@lib/auth";
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
req.session = await getSession({ req });
if (req.method === "GET" && req.session && req.session.user.id && req.query) {
const { "app-credential-type": appCredentialType } = req.query;
if (!appCredentialType && Array.isArray(appCredentialType)) {
return res.status(400);
}
const userId = req.session.user.id;
try {
const installedApp = await prisma.credential.findMany({
where: {
type: appCredentialType as string,
userId: userId,
},
});
if (installedApp && !!installedApp.length) {
res.json({ count: installedApp.length });
} else {
res.status(404);
}
} catch (error) {
console.log(error);
res.status(500);
}
} else {
res.status(400);
}
res.end();
}