diff --git a/src/client/components/feed/FeedApiGuide.tsx b/src/client/components/feed/FeedApiGuide.tsx index 86fda59..f918654 100644 --- a/src/client/components/feed/FeedApiGuide.tsx +++ b/src/client/components/feed/FeedApiGuide.tsx @@ -2,12 +2,57 @@ import { Card, CardContent, CardHeader } from '@/components/ui/card'; import React from 'react'; import { CodeBlock } from '../CodeBlock'; import { useTranslation } from '@i18next-toolkit/react'; +import { Tabs, TabsContent, TabsList, TabsTrigger } from '../ui/tabs'; export const FeedApiGuide: React.FC<{ channelId: string }> = React.memo( (props) => { const { t } = useTranslation(); - const code = `fetch('${window.location.origin}/open/feed/${props.channelId}/send', { + return ( + + +
{t('You can send any message into this channel with:')}
+
+ + + + curl + fetch + + + + + + + + + +
{t('OR')}
+ +
{t('Integrate with third party with webhook')}
+
+
+ ); + } +); +FeedApiGuide.displayName = 'FeedApiGuide'; + +function generateCurlCode(channelId: string) { + const code = `curl -X POST ${window.location.origin}/open/feed/${channelId}/send \\ +-H "Content-Type: application/json" \\ +-d '{ + "eventName": "test name", + "eventContent": "test content", + "tags": ["test"], + "source": "custom", + "important": false +}'`; + + return code; +} + +function generateFetchCode(channelId: string) { + const code = `fetch('${window.location.origin}/open/feed/${channelId}/send', { method: 'POST', headers: { 'Content-Type': 'application/json' @@ -21,20 +66,5 @@ export const FeedApiGuide: React.FC<{ channelId: string }> = React.memo( }) })`; - return ( - - -
{t('You can send any message into this channel with:')}
-
- - - -
{t('OR')}
- -
{t('Integrate with third party with webhook')}
-
-
- ); - } -); -FeedApiGuide.displayName = 'FeedApiGuide'; + return code; +}