import { useSession } from "next-auth/client";
import { useRouter } from "next/router";
import { getSession } from "@lib/auth";
import { getIntegrationName, getIntegrationType } from "@lib/integrations";
import prisma from "@lib/prisma";
import Loader from "@components/Loader";
import Shell from "@components/Shell";
export default function Integration(props) {
const router = useRouter();
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [session, loading] = useSession();
if (loading) {
return ;
}
async function deleteIntegrationHandler(event) {
event.preventDefault();
/*eslint-disable */
const response = await fetch("/api/integrations", {
method: "DELETE",
body: JSON.stringify({ id: props.integration.id }),
headers: {
"Content-Type": "application/json",
},
});
/*eslint-enable */
router.push("/integrations");
}
return (
Integration Details
Information about your {getIntegrationName(props.integration.type)} App.
- App name
- {getIntegrationName(props.integration.type)}
- App Category
- {getIntegrationType(props.integration.type)}
Delete this app
Once you delete this app, it will be permanently removed.
);
}
export async function getServerSideProps(context) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const session = await getSession(context);
const integration = await prisma.credential.findFirst({
where: {
id: parseInt(context.query.integration),
},
select: {
id: true,
type: true,
key: true,
},
});
return {
props: { integration }, // will be passed to the page component as props
};
}