Skip to content

Commit

Permalink
Hotfix: createdCollectionID is sometimes undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
xKhronoz committed May 20, 2024
1 parent 4071fe2 commit 9dd7bdb
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions frontend/app/components/ui/query/query-document-upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export default function QueryDocumentUpload() {
const indexerApi = process.env.NEXT_PUBLIC_INDEXER_API;
const { data: session } = useSession();
const supabaseAccessToken = session?.supabaseAccessToken;
const [createdCollectionId, setCreatedCollectionId] = useState<string>('');
// NOTE: allowedTypes is an array of allowed MIME types for file uploads
// The allowedTypesString is a string of allowed file extensions for the file input
// Both must be kept in sync to ensure that the file input only accepts the allowed file types
Expand Down Expand Up @@ -94,6 +93,7 @@ export default function QueryDocumentUpload() {
};

const handleSubmit = (event: React.FormEvent) => {
let createdCollectionId = '';
event.preventDefault();
// Perform validation and submit logic here
console.log("Display Name:", displayName);
Expand Down Expand Up @@ -152,7 +152,8 @@ export default function QueryDocumentUpload() {
// Get the response data
const data = await response.json();
console.log('Insert New Collection Results:', data);
setCreatedCollectionId(data.collectionId);
createdCollectionId = await data.collectionId; // ensure that the collection_id is returned
console.log('Created Collection ID:', createdCollectionId);
// Show success dialog
Swal.fire({
title: 'Success!',
Expand Down Expand Up @@ -296,8 +297,6 @@ export default function QueryDocumentUpload() {
});
setisLoading(false);
});
// Reset createCollectionId state
setCreatedCollectionId('');
}
else {
setisLoading(false);
Expand Down

0 comments on commit 9dd7bdb

Please sign in to comment.