This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { FormHandles, SubmitHandler } from '@unform/core'; | |
| import { RefObject, useCallback, useState } from 'react'; | |
| import { ObjectSchema, ValidationError } from 'yup'; | |
| type Hook = <T>( | |
| args: Props<T>, | |
| ) => { | |
| validating: boolean; | |
| handleSubmit: SubmitHandler<T>; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import {eventChannel, END} from 'redux-saga' | |
| function createUploaderChannel(key, files){ | |
| return eventChannel(emit => { | |
| const onProgress = ({total, loaded}) => { | |
| const percentage = Math.round((loaded * 100) / total) | |
| emit(percentage) | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| upload(files) { | |
| const config = { | |
| onUploadProgress: function(progressEvent) { | |
| var percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total) | |
| console.log(percentCompleted) | |
| } | |
| } | |
| let data = new FormData() | |
| data.append('file', files[0]) |