'use client'; import { useState, useCallback } from 'react'; import { useUser } from '../layout/user.context'; import { Button } from '@gitroom/react/form/button'; import copy from 'copy-to-clipboard'; import { useToaster } from '@gitroom/react/toaster/toaster'; import { useVariables } from '@gitroom/react/helpers/variable.context'; import { useT } from '@gitroom/react/translation/get.transation.service.client'; export const PublicComponent = () => { const user = useUser(); const { backendUrl } = useVariables(); const toaster = useToaster(); const [reveal, setReveal] = useState(false); const [reveal2, setReveal2] = useState(false); const copyToClipboard = useCallback(() => { toaster.show('API Key copied to clipboard', 'success'); copy(user?.publicApi!); }, [user]); const copyToClipboard2 = useCallback(() => { toaster.show('MCP copied to clipboard', 'success'); copy(`${backendUrl}/mcp/` + user?.publicApi + '/sse'); }, [user]); const t = useT(); if (!user || !user.publicApi) { return null; } return (

{t('public_api', 'Public API')}

{t( 'use_postiz_api_to_integrate_with_your_tools', 'Use Postiz API to integrate with your tools.' )}
{t( 'read_how_to_use_it_over_the_documentation', 'Read how to use it over the documentation.' )}
{t( 'check_n8n', 'Check out our N8N custom node for Postiz.' )}
{reveal ? ( user.publicApi ) : ( <>
{user.publicApi.slice(0, -5)}
{user.publicApi.slice(-5)}
)}
{!reveal ? ( ) : ( )}

{t('mcp', 'MCP')}

{t( 'connect_your_mcp_client_to_postiz_to_schedule_your_posts_faster', 'Connect Postiz MCP server to your client (Http streaming) to schedule your posts faster.' )}
{reveal2 ? ( `${backendUrl}/mcp/` + user.publicApi ) : ( <>
{(`${backendUrl}/mcp/` + user.publicApi).slice(0, -5)}
{(`${backendUrl}/mcp/` + user.publicApi).slice(-5)}
)}
{!reveal2 ? ( ) : ( )}
); };