export const uploadFileToStorage = async ( foldName: string, dataUrl: string ) => { return new Promise((resolve, reject) => { const timestamp = Number( new Date()) const fileName = `/documents/ ${ foldName } - ${ timestamp.toString() } ` const storageRef = firebaseApp.storage().ref(fileName) const uploadTask = storageRef.putString(dataUrl, 'data_url' ) uploadTask.on( firebaseApp.storage.TaskEvent.STATE_CHANGED, snapshot => {}, error => { reject(error.message) }, () => { storageRef.getDownloadURL().then(url => { resolve(url) }) } ) }) } onSubmit = { (values, { setSubmitting, resetForm }) => { setMessage(i18next.t( 'PROCESSING' )) const copy = { ...values } await Promise.all( inputFieldsForAdditionalForm .filter(field => field.type === 'file' ) ...