MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / AddIntegration

Function AddIntegration

apps/start/src/modals/add-integration.tsx:22–105  ·  view source on GitHub ↗
(props: Props)

Source from the content-addressed store, hash-verified

20 type: IIntegrationConfig['type'];
21}
22export default function AddIntegration(props: Props) {
23 const { organizationId } = useAppParams();
24 const trpc = useTRPC();
25 const query = useQuery(
26 trpc.integration.get.queryOptions(
27 {
28 id: props.id ?? '',
29 },
30 {
31 enabled: !!props.id,
32 },
33 ),
34 );
35
36 const integration = INTEGRATIONS.find((i) => i.type === props.type);
37
38 const renderCard = () => {
39 if (!integration) {
40 return null;
41 }
42 return (
43 <div className="card bg-def-100">
44 <IntegrationCardContent {...integration} />
45 </div>
46 );
47 };
48
49 const navigate = useNavigate();
50 const client = useQueryClient();
51 const handleSuccess = () => {
52 toast.success('Integration created');
53 popModal();
54 client.invalidateQueries(trpc.integration.list.pathFilter());
55 client.invalidateQueries(
56 trpc.integration.get.queryFilter({ id: props.id }),
57 );
58 navigate({
59 to: '/$organizationId/integrations/installed',
60 params: {
61 organizationId,
62 },
63 });
64 };
65
66 const renderForm = () => {
67 if (props.id && query.isLoading) {
68 return null;
69 }
70
71 switch (integration?.type) {
72 case 'webhook':
73 return (
74 <WebhookIntegrationForm
75 defaultValues={query.data}
76 onSuccess={handleSuccess}
77 />
78 );
79 case 'discord':

Callers

nothing calls this directly

Calls 3

useAppParamsFunction · 0.90
renderCardFunction · 0.85
renderFormFunction · 0.85

Tested by

no test coverage detected