@@ -9,16 +9,13 @@ import clsx from 'clsx';
99import Image from 'next/image' ;
1010import { Menu } from '@gitroom/frontend/components/launches/menu/menu' ;
1111import {
12- AddProviderComponent ,
1312 ApiModal ,
1413 CustomVariables ,
15- UrlModal ,
1614} from '@gitroom/frontend/components/launches/add.provider.component' ;
1715import { useRouter } from 'next/navigation' ;
1816import { useVariables } from '@gitroom/react/helpers/variable.context' ;
19- import { string } from 'yup' ;
2017import { useToaster } from '@gitroom/react/toaster/toaster' ;
21- import { useModals } from '@mantine/modals ' ;
18+ import { Integration } from '@prisma/client ' ;
2219
2320export const ConnectChannels : FC = ( ) => {
2421 const fetch = useFetch ( ) ;
@@ -27,7 +24,6 @@ export const ConnectChannels: FC = () => {
2724 const [ identifier , setIdentifier ] = useState < any > ( undefined ) ;
2825 const [ popup , setPopups ] = useState < undefined | string [ ] > ( undefined ) ;
2926 const toaster = useToaster ( ) ;
30- const modal = useModals ( ) ;
3127 const [ showCustom , setShowCustom ] = useState < any > ( undefined ) ;
3228
3329 const getIntegrations = useCallback ( async ( ) => {
@@ -47,6 +43,22 @@ export const ConnectChannels: FC = () => {
4743 // []
4844 // );
4945
46+ const refreshChannel = useCallback (
47+ ( integration : Integration & { identifier : string } ) => async ( ) => {
48+ const { url } = await (
49+ await fetch (
50+ `/integrations/social/${ integration . identifier } ?refresh=${ integration . internalId } ` ,
51+ {
52+ method : 'GET' ,
53+ }
54+ )
55+ ) . json ( ) ;
56+
57+ window . location . href = url ;
58+ } ,
59+ [ ]
60+ ) ;
61+
5062 const addMessage = useCallback (
5163 ( event : MessageEvent < { msg : string ; success : boolean } > ) => {
5264 if ( ! event . data . msg ) {
@@ -346,6 +358,7 @@ export const ConnectChannels: FC = () => {
346358 mutate = { mutate }
347359 onChange = { update }
348360 id = { integration . id }
361+ refreshChannel = { refreshChannel }
349362 canEnable = {
350363 user ?. totalChannels ! > totalNonDisabledChannels &&
351364 integration . disabled
0 commit comments