From 28b42a09c25cd82d3e325c1aa4dd179e4dbcb641 Mon Sep 17 00:00:00 2001 From: Rupin Khandelwal Date: Tue, 25 Oct 2022 14:06:51 -0500 Subject: [PATCH] Calling WEbhooks api and updating Integrations --- packages/web/pages/settings/integrations.tsx | 23 ++++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/packages/web/pages/settings/integrations.tsx b/packages/web/pages/settings/integrations.tsx index 5c785deff..f28b08877 100644 --- a/packages/web/pages/settings/integrations.tsx +++ b/packages/web/pages/settings/integrations.tsx @@ -1,7 +1,7 @@ import { useEffect, useMemo, useState } from 'react' import { styled } from '@stitches/react' import { Toaster } from 'react-hot-toast' -import { DownloadSimple, Eye, Link, Plus } from 'phosphor-react' +import { DownloadSimple, Eye, Link } from 'phosphor-react' import Image from 'next/image' import { @@ -14,6 +14,7 @@ import { PrimaryLayout } from '../../components/templates/PrimaryLayout' import { applyStoredTheme } from '../../lib/themeUpdater' import { Button } from '../../components/elements/Button' import { useGetIntegrationsQuery } from '../../lib/networking/queries/useGetIntegrationsQuery' +import { useGetWebhooksQuery } from '../../lib/networking/queries/useGetWebhooksQuery' // Styles const Header = styled(Box, { @@ -43,11 +44,13 @@ type integrationsCard = { text: string icon?: JSX.Element style: string + action: () => void } } export default function Integrations(): JSX.Element { applyStoredTheme(false) const { integrations } = useGetIntegrationsQuery() + const { webhooks } = useGetWebhooksQuery() const [integrationsArray, setIntegrationsArray] = useState( Array() @@ -56,6 +59,7 @@ export default function Integrations(): JSX.Element { const readwiseConnected = useMemo(() => { return integrations.some((i) => i.type == 'READWISE') }, [integrations]) + useEffect(() => { setIntegrationsArray([ @@ -67,6 +71,7 @@ export default function Integrations(): JSX.Element { text: `Install Logseq Plugin`, icon: , style: 'ctaDarkYellow', + action: () => alert('You may already have it'), }, }, { @@ -76,21 +81,23 @@ export default function Integrations(): JSX.Element { button: { text: readwiseConnected ? 'Remove' : 'Connect to Readwise', icon: , - style: 'ctaDarkYellow', + style: readwiseConnected ? 'ctaWhite' : 'ctaDarkYellow', + action: () => alert('readwise'), }, }, { icon: '/static/icons/webhooks.svg', title: 'Webhooks', - subText: '## Webhooks', + subText: `${webhooks.length} Webhooks`, button: { text: 'View Webhooks', icon: , style: 'ctaWhite', + action: () => alert('readwise - Open new Page'), }, }, ]) - }, []) + }, [readwiseConnected, webhooks]) return ( @@ -152,7 +159,7 @@ export default function Integrations(): JSX.Element {

{item.title}

{item.subText}

- +