Skip to content

Commit

Permalink
fix: 🐛 patch build bubble widget since resolve button
Browse files Browse the repository at this point in the history
  • Loading branch information
gmpetrov committed Oct 20, 2023
1 parent be8c5da commit ce05158
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 32 deletions.
5 changes: 2 additions & 3 deletions apps/dashboard/components/ChatBubble.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ import useChat from '@app/hooks/useChat';
import useStateReducer from '@app/hooks/useStateReducer';

import pickColorBasedOnBgColor from '@chaindesk/lib/pick-color-based-on-bgcolor';
import { ConversationStatusUnion } from '@chaindesk/lib/types/dtos';
import { AgentInterfaceConfig } from '@chaindesk/lib/types/models';
import type { Agent } from '@chaindesk/prisma';
import type { Agent, ConversationStatus } from '@chaindesk/prisma';

import ResolveButton from './ResolveButton';

Expand Down Expand Up @@ -366,7 +365,7 @@ function App(props: { agentId: string; initConfig?: AgentInterfaceConfig }) {
conversationStatus,
}: {
conversationId: string;
conversationStatus: ConversationStatusUnion;
conversationStatus: ConversationStatus;
}) => {
return (
<Box
Expand Down
13 changes: 5 additions & 8 deletions apps/dashboard/components/ResolveButton.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import CheckCircleIcon from '@mui/icons-material/CheckCircle';
import { Button, Chip, CircularProgress } from '@mui/joy';
import { memo, useState } from 'react';
import { useState } from 'react';

import {
ConversationStatus,
ConversationStatusUnion,
} from '@chaindesk/lib/types/dtos';
import type { ConversationStatus } from '@chaindesk/prisma';

import { API_URL } from './ChatBubble';

Expand All @@ -15,7 +12,7 @@ const ResolveButton = ({
createNewConversation,
}: {
conversationId: string;
conversationStatus: ConversationStatusUnion;
conversationStatus: ConversationStatus;
createNewConversation(): void;
}) => {
const [pending, setPending] = useState(false);
Expand All @@ -31,7 +28,7 @@ const ResolveButton = ({
'Content-Type': 'application/json',
},
body: JSON.stringify({
status: ConversationStatus.RESOLVED,
status: 'RESOLVED' as ConversationStatus,
}),
}
);
Expand All @@ -44,7 +41,7 @@ const ResolveButton = ({
setPending(false);
}
};
if (conversationStatus === ConversationStatus.RESOLVED || isResolved) {
if (conversationStatus === 'RESOLVED' || isResolved) {
return (
<Chip variant="soft" size="md" color="success">
Resolved !
Expand Down
14 changes: 6 additions & 8 deletions apps/dashboard/hooks/useChat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ import { ApiError, ApiErrorType } from '@chaindesk/lib/api-error';
import { fetcher } from '@chaindesk/lib/swr-fetcher';
import { SSE_EVENT } from '@chaindesk/lib/types';
import { Source } from '@chaindesk/lib/types/document';
import {
ChatResponse,
import type { ChatResponse, EvalAnswer } from '@chaindesk/lib/types/dtos';
import type {
ConversationChannel,
ConversationStatus,
ConversationStatusUnion,
EvalAnswer,
} from '@chaindesk/lib/types/dtos';
import type { ConversationChannel, Prisma } from '@chaindesk/prisma';
Prisma,
} from '@chaindesk/prisma';

import useRateLimit from './useRateLimit';
import useStateReducer from './useStateReducer';
Expand Down Expand Up @@ -61,8 +60,7 @@ const useChat = ({ endpoint, channel, queryBody, ...otherProps }: Props) => {
const [state, setState] = useStateReducer({
visitorId: '',
conversationId: '',
conversationStatus:
ConversationStatus.UNRESOLVED as ConversationStatusUnion,
conversationStatus: 'UNRESOLVED' as any,
hasMoreMessages: true,
prevConversationId: '',
mounted: false,
Expand Down
2 changes: 1 addition & 1 deletion packages/chat-bubble/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@databerry/chat-bubble",
"version": "1.0.89",
"version": "1.0.90",
"description": "Chaindesk Chat Bubble Widget",
"main": "chat-bubble.js",
"scripts": {},
Expand Down
14 changes: 2 additions & 12 deletions packages/lib/types/dtos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
AgentVisibility,
Conversation,
ConversationChannel,
ConversationStatus,
Message,
MessageEval,
PromptType,
Expand Down Expand Up @@ -307,18 +308,7 @@ export const CrispSchema = z.object({
export const CrispUpdateMetadataSchema = CrispSchema.extend({
aiStatus: z.nativeEnum(AIStatus),
});
export type ConversationStatusUnion = 'RESOLVED' | 'UNRESOLVED';

export enum ConversationStatus {
RESOLVED = 'RESOLVED',
UNRESOLVED = 'UNRESOLVED',
}

const conversationStatus = z.enum([
ConversationStatus.RESOLVED,
ConversationStatus.UNRESOLVED,
]);

export const ConversationStatusSchema = z.object({
status: conversationStatus,
status: z.nativeEnum(ConversationStatus),
});

0 comments on commit ce05158

Please sign in to comment.