MCPcopy Create free account
hub / github.com/Linen-dev/linen.dev / IntegrationsModal

Function IntegrationsModal

apps/web/ui/IntegrationsModal/index.tsx:28–222  ·  view source on GitHub ↗
({
  permissions,
  open,
  close,
  api,
  channel,
}: IntegrationsModalProps)

Source from the content-addressed store, hash-verified

26}
27
28function IntegrationsModal({
29 permissions,
30 open,
31 close,
32 api,
33 channel,
34}: IntegrationsModalProps) {
35 const [integration, setIntegration] = useState<any>();
36 const [team, setTeam] = useState<any>();
37
38 useEffect(() => {
39 channel?.id &&
40 api
41 .getChannelIntegrations({
42 channelId: channel.id,
43 accountId: channel.accountId!,
44 })
45 .then(setIntegration)
46 .catch((e) => {
47 if (process.env.NODE_ENV === 'development') {
48 console.error(e);
49 }
50 });
51 }, [channel]);
52
53 useEffect(() => {
54 if (integration) {
55 const team = integration?.data?.teams?.find(
56 (t: any) => t?.id === integration?.externalId
57 );
58 setTeam(team);
59 }
60 }, [integration]);
61
62 const onLinearClick = async () => {
63 if (!channel) {
64 return;
65 }
66 await api
67 .postChannelIntegrations({
68 accountId: channel.accountId!,
69 channelId: channel.id,
70 type: channelsIntegrationType.LINEAR,
71 data: {
72 redirect_after: window.location.href,
73 },
74 })
75 .then(({ id }) => {
76 window.location.href = `${getLinenUrl()}/api/bridge/linear/setup?integrationId=${id}`;
77 })
78 .catch((e) => {
79 Toast.error('Something went wrong');
80 });
81 };
82
83 const onRemoveLinearClick = async () => {
84 if (!channel) {
85 return;

Callers

nothing calls this directly

Calls 3

RemoveFunction · 0.85
errorMethod · 0.65
findMethod · 0.45

Tested by

no test coverage detected