Skip to content

Commit 1a2937b

Browse files
committed
feat: connect channel
1 parent 7ca48df commit 1a2937b

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

apps/frontend/src/components/onboarding/connect.channels.tsx

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,13 @@ import clsx from 'clsx';
99
import Image from 'next/image';
1010
import { Menu } from '@gitroom/frontend/components/launches/menu/menu';
1111
import {
12-
AddProviderComponent,
1312
ApiModal,
1413
CustomVariables,
15-
UrlModal,
1614
} from '@gitroom/frontend/components/launches/add.provider.component';
1715
import { useRouter } from 'next/navigation';
1816
import { useVariables } from '@gitroom/react/helpers/variable.context';
19-
import { string } from 'yup';
2017
import { useToaster } from '@gitroom/react/toaster/toaster';
21-
import { useModals } from '@mantine/modals';
18+
import { Integration } from '@prisma/client';
2219

2320
export 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

Comments
 (0)