mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
34 lines
924 B
TypeScript
34 lines
924 B
TypeScript
import { AxiosPromise } from 'axios';
|
|
import { FC } from 'react';
|
|
|
|
import { FileUploadConfig } from '../../api/endpoints';
|
|
import { MessageBox, SingleUpload, useFileUpload } from '../../components';
|
|
|
|
interface UploadFirmwareProps {
|
|
uploadFirmware: (file: File, config?: FileUploadConfig) => AxiosPromise<void>;
|
|
}
|
|
|
|
const FirmwareFileUpload: FC<UploadFirmwareProps> = ({ uploadFirmware }) => {
|
|
const [uploadFile, cancelUpload, uploading, uploadProgress] = useFileUpload({ upload: uploadFirmware });
|
|
|
|
return (
|
|
<>
|
|
{!uploading && (
|
|
<MessageBox
|
|
message="Upload a new firmware (.bin) file below to replace the existing firmware"
|
|
level="warning"
|
|
my={2}
|
|
/>
|
|
)}
|
|
<SingleUpload
|
|
onDrop={uploadFile}
|
|
onCancel={cancelUpload}
|
|
uploading={uploading}
|
|
progress={uploadProgress}
|
|
/>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default FirmwareFileUpload;
|