Skip to content

Commit

Permalink
Merge pull request #131 from OpenAssistantGPT/feat/handle-file-upload
Browse files Browse the repository at this point in the history
feat: use toast correctly and export it
  • Loading branch information
marcolivierbouch authored Oct 18, 2024
2 parents 2a1873b + 0387c04 commit 9f5d09d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changeset/chilled-cars-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'openassistantgpt': patch
'@openassistantgpt/ui': patch
---

Export toast to be able to use them in app
11 changes: 9 additions & 2 deletions packages/ui/components/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { cn } from '@/lib/utils';

import { useAssistant, Message } from '@openassistantgpt/react';
import { ChangeEvent, useCallback, useEffect, useRef, useState } from 'react';
import { toast } from '@/components/ui/use-toast';
import { useToast } from '@/components/ui/use-toast';

import {
Tooltip,
TooltipContent,
Expand Down Expand Up @@ -48,7 +49,7 @@ export function OpenAssistantGPTChat({
...props
}: ChatbotProps) {
let inputFileRef = useRef<HTMLInputElement>(null);

const { toast } = useToast()
const { formRef, onKeyDown } = useEnterSubmit();

const {
Expand Down Expand Up @@ -167,6 +168,12 @@ export function OpenAssistantGPTChat({
name: pathname,
contentType: contentType,
};
} else if (response.status === 413) {
toast({
title: 'Error',
description: 'File size is too large, please try a smaller file.',
variant: 'destructive',
});
} else {
const { error } = await response.json();
toast({
Expand Down
2 changes: 2 additions & 0 deletions packages/ui/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ import { ChatbotConfig } from './chatbot';

export { type ChatbotConfig };
export { OpenAssistantGPTChat };
export { useToast } from "@/components/ui/use-toast"

0 comments on commit 9f5d09d

Please sign in to comment.