From 1a2937b518be690aaff4543c975174a27b432aa8 Mon Sep 17 00:00:00 2001 From: Nevo David Date: Fri, 20 Dec 2024 12:00:37 +0700 Subject: [PATCH] feat: connect channel --- .../onboarding/connect.channels.tsx | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/apps/frontend/src/components/onboarding/connect.channels.tsx b/apps/frontend/src/components/onboarding/connect.channels.tsx index 7dcaafd2..73b0d20e 100644 --- a/apps/frontend/src/components/onboarding/connect.channels.tsx +++ b/apps/frontend/src/components/onboarding/connect.channels.tsx @@ -9,16 +9,13 @@ import clsx from 'clsx'; import Image from 'next/image'; import { Menu } from '@gitroom/frontend/components/launches/menu/menu'; import { - AddProviderComponent, ApiModal, CustomVariables, - UrlModal, } from '@gitroom/frontend/components/launches/add.provider.component'; import { useRouter } from 'next/navigation'; import { useVariables } from '@gitroom/react/helpers/variable.context'; -import { string } from 'yup'; import { useToaster } from '@gitroom/react/toaster/toaster'; -import { useModals } from '@mantine/modals'; +import { Integration } from '@prisma/client'; export const ConnectChannels: FC = () => { const fetch = useFetch(); @@ -27,7 +24,6 @@ export const ConnectChannels: FC = () => { const [identifier, setIdentifier] = useState(undefined); const [popup, setPopups] = useState(undefined); const toaster = useToaster(); - const modal = useModals(); const [showCustom, setShowCustom] = useState(undefined); const getIntegrations = useCallback(async () => { @@ -47,6 +43,22 @@ export const ConnectChannels: FC = () => { // [] // ); + const refreshChannel = useCallback( + (integration: Integration & { identifier: string }) => async () => { + const { url } = await ( + await fetch( + `/integrations/social/${integration.identifier}?refresh=${integration.internalId}`, + { + method: 'GET', + } + ) + ).json(); + + window.location.href = url; + }, + [] + ); + const addMessage = useCallback( (event: MessageEvent<{ msg: string; success: boolean }>) => { if (!event.data.msg) { @@ -346,6 +358,7 @@ export const ConnectChannels: FC = () => { mutate={mutate} onChange={update} id={integration.id} + refreshChannel={refreshChannel} canEnable={ user?.totalChannels! > totalNonDisabledChannels && integration.disabled