The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
import { useParams } from 'react-router-dom';
import { useQuery } from '@apollo/client/react';
import { SettingsPath } from 'twenty-shared/types';
import { getSettingsPath } from 'twenty-shared/utils';
import { AI_ADMIN_PATH } from '@/settings/admin-panel/ai/constants/AiAdminPath';
import { useApolloAdminClient } from '@/settings/admin-panel/apollo/hooks/useApolloAdminClient';
import { SettingsAdminChatThreadMessageList } from '@/settings/admin-panel/components/SettingsAdminChatThreadMessageList';
import { GET_ADMIN_CHAT_THREAD_MESSAGES } from '@/settings/admin-panel/graphql/queries/getAdminChatThreadMessages';
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
import { SettingsSkeletonLoader } from '@/settings/components/SettingsSkeletonLoader';
import { SettingsPageLayout } from '@/settings/components/layout/SettingsPageLayout';
import { type GetAdminChatThreadMessagesQuery } from '~/generated-admin/graphql';
import { Section } from 'twenty-ui/components/layout';
import { useLingui } from '@lingui/react/macro';
export const SettingsAdminWorkspaceChatThread = () => {
const { t } = useLingui();
const { workspaceId, threadId } = useParams<{
workspaceId: string;
threadId: string;
}>();
const apolloAdminClient = useApolloAdminClient();
const { data, loading: isLoading } =
useQuery<GetAdminChatThreadMessagesQuery>(GET_ADMIN_CHAT_THREAD_MESSAGES, {
client: apolloAdminClient,
variables: { workspaceId, threadId },
skip: !workspaceId || !threadId,
});
const thread = data?.getAdminChatThreadMessages?.thread;
const messages = data?.getAdminChatThreadMessages?.messages ?? [];
const threadTitle = thread?.title || t`Untitled`;
if (isLoading) {
return <SettingsSkeletonLoader />;
}
return (
<SettingsPageLayout
links={[
{
children: t`Other`,
href: getSettingsPath(SettingsPath.AdminPanel),
},
{
children: t`Admin Panel - AI`,
href: AI_ADMIN_PATH,
},
{
children: t`Workspace`,
href: getSettingsPath(SettingsPath.AdminPanelWorkspaceDetail, {
workspaceId: workspaceId ?? '',
}),
},
{
children: threadTitle,
},
]}
>
<SettingsPageContainer>
<Section.Root>
<Section.Header
title={threadTitle}
description={t`Chat conversation`}
/>
<SettingsAdminChatThreadMessageList messages={messages} />
</Section.Root>
</SettingsPageContainer>
</SettingsPageLayout>
);
};