Skip to content

Commit

Permalink
Disable upload file button when no file
Browse files Browse the repository at this point in the history
  • Loading branch information
davidxw committed Aug 11, 2023
1 parent bf1c8f5 commit 3c3e295
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
31 changes: 31 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Next.js: debug server-side",
"type": "node-terminal",
"request": "launch",
"cwd": "${workspaceFolder}/src",
"command": "npm run dev"
},
{
"name": "Next.js: debug client-side",
"type": "chrome",
"request": "launch",
"cwd": "${workspaceFolder}/src",
"url": "http://localhost:3000"
},
{
"name": "Next.js: debug full stack",
"type": "node-terminal",
"request": "launch",
"cwd": "${workspaceFolder}/src",
"command": "npm run dev",
"serverReadyAction": {
"pattern": "started server on .+, url: (https?://.+)",
"uriFormat": "%s",
"action": "debugWithChrome"
}
}
]
}
6 changes: 5 additions & 1 deletion src/features/chat/chat-ui/chat-empty-state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ interface Prop {
}

export const EmptyState: FC<Prop> = (props) => {

const [showFileUpload, setShowFileUpload] = useState<ChatType>("simple");
const [isFileNull, setIsFileNull] = useState(true);

const onSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
Expand All @@ -31,6 +33,7 @@ export const EmptyState: FC<Prop> = (props) => {

const onChatTypeChange = (value: ChatType) => {
setShowFileUpload(value);
setIsFileNull(true);
props.onChatTypeChange(value);
};

Expand Down Expand Up @@ -85,11 +88,12 @@ export const EmptyState: FC<Prop> = (props) => {
required
disabled={props.isUploadingFile}
placeholder="Describe the purpose of the document"
onChange={(e) => {setIsFileNull(e.currentTarget.value === null)}}
/>
<Button
type="submit"
value="Upload"
disabled={props.isUploadingFile}
disabled={!(!isFileNull && !props.isUploadingFile)}
className="flex items-center gap-1"
>
{props.isUploadingFile ? (
Expand Down

0 comments on commit 3c3e295

Please sign in to comment.