Skip to content

Commit

Permalink
Fix missing data in file uploads (#1746)
Browse files Browse the repository at this point in the history
* fix(collection-flow): file uploading missing data (file type, name, etc.)

* fix(collection-flow): updated fix

* fix: fixed bug nullish file in onChange

---------

Co-authored-by: Alon Peretz <Alonp99@gmail.com>
Co-authored-by: Illia Rudniev <cheskmr@gmail.com>
  • Loading branch information
3 people authored Dec 4, 2023
1 parent a92196e commit c1d4c84
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,25 @@ export const FileUploaderField = forwardRef(
placeholder,
}: DocumentUploadFieldProps) => {
const { fileId: uploadedFileId, isUploading, uploadFile } = useFileUploading(_uploadFile);
const { file } = useFileRepository(fileStorage, fileId || undefined);
const { file, registerFile } = useFileRepository(fileStorage, fileId || undefined);
const inputRef = useRef<HTMLInputElement>(null);
//@ts-ignore
useFileAssigner(inputRef, file);

useEffect(() => {
if (!uploadedFileId) return;
if (!uploadedFileId || !file) return;

registerFile(file, uploadedFileId);
onChange(uploadedFileId);
}, [uploadedFileId]);
}, [uploadedFileId, file]);

const handleChange = useCallback(
async (event: React.ChangeEvent<HTMLInputElement>) => {
void uploadFile(event.target.files?.[0] as File);
const file = event.target.files?.[0];
if (!file) return;

const uploadResult = await uploadFile(file);
registerFile(file, uploadResult.fileId);
},
[uploadFile],
);
Expand Down
2 changes: 1 addition & 1 deletion services/workflows-service/prisma/data-migrations

0 comments on commit c1d4c84

Please sign in to comment.