import Head from 'next/head'; import prisma from '../../lib/prisma'; import { getIntegrationName, getIntegrationType } from '../../lib/integrations'; import Shell from '../../components/Shell'; import { useState } from 'react'; import { useRouter } from 'next/router'; import { useSession, getSession } from 'next-auth/client'; export default function integration(props) { const router = useRouter(); const [session, loading] = useSession(); const [showAPIKey, setShowAPIKey] = useState(false); if (loading) { return

Loading...

; } function toggleShowAPIKey() { setShowAPIKey(!showAPIKey); } async function deleteIntegrationHandler(event) { event.preventDefault(); const response = await fetch('/api/integrations', { method: 'DELETE', body: JSON.stringify({id: props.integration.id}), headers: { 'Content-Type': 'application/json' } }); router.push('/integrations'); } return(
{getIntegrationName(props.integration.type)} | Integrations | Calendso

Integration Details

Information about your {getIntegrationName(props.integration.type)} integration.

Integration name
{getIntegrationName(props.integration.type)}
Integration type
{getIntegrationType(props.integration.type)}
API Key
{!showAPIKey ? •••••••• :
}

Delete this integration

Once you delete this integration, it will be permanently removed.

); } export async function getServerSideProps(context) { 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 } }