updating buton location

This commit is contained in:
Jade Rowland 2023-12-10 11:37:18 -05:00
parent 6238be7f2c
commit 59a4cd9cf8
2 changed files with 4 additions and 2 deletions

View file

@ -1,43 +0,0 @@
import React, { useCallback, useState } from 'react';
import { registerSamplesFromDB, uploadSamplesToDB, userSamplesDBConfig } from './idbutils.mjs';
//choose a directory to locally import samples
export default function ImportSoundsButton({ onComplete }) {
let fileUploadRef = React.createRef();
const [isUploading, setIsUploading] = useState(false);
const onChange = useCallback(async () => {
if (!fileUploadRef.current.files?.length) {
return;
}
setIsUploading(true);
await uploadSamplesToDB(userSamplesDBConfig, fileUploadRef.current.files).then(() => {
registerSamplesFromDB(userSamplesDBConfig, () => {
onComplete();
setIsUploading(false);
});
});
});
return (
<label
style={{ alignItems: 'center' }}
className="flex bg-background ml-2 pl-2 pr-2 max-w-[300px] rounded-md hover:opacity-50"
>
<input
disabled={isUploading}
ref={fileUploadRef}
id="audio_file"
style={{ display: 'none' }}
type="file"
directory=""
webkitdirectory=""
multiple
accept="audio/*"
onChange={() => {
onChange();
}}
/>
{isUploading ? 'importing...' : 'import sounds'}
</label>
);
}