- added download application pdf button for submitted applications;
- fixed adding files for call;
This commit is contained in:
@@ -35,11 +35,11 @@ const Checkboxes = ({
|
||||
|
||||
const properConfig = (config) => {
|
||||
let newConfig = klona(config);
|
||||
if (config.minLength) {
|
||||
newConfig = wrap(newConfig).set(['validate', 'minChecks'], (v) => minChecks(v, config.minLength)).value();
|
||||
if (config.min) {
|
||||
newConfig = wrap(newConfig).set(['validate', 'minChecks'], (v) => minChecks(v, config.min)).value();
|
||||
}
|
||||
if (config.maxLength) {
|
||||
newConfig = wrap(newConfig).set(['validate', 'maxChecks'], (v) => maxChecks(v, config.maxLength)).value();
|
||||
if (config.max) {
|
||||
newConfig = wrap(newConfig).set(['validate', 'maxChecks'], (v) => maxChecks(v, config.max)).value();
|
||||
}
|
||||
|
||||
return newConfig;
|
||||
|
||||
@@ -60,9 +60,8 @@ const Fileupload = ({
|
||||
const callback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
setStateFieldData(data.data);
|
||||
const files = inputRef.current.getFiles();
|
||||
inputRef.current.setUploadedFiles(files);
|
||||
setDataFn(fieldName, data.data, { shouldValidate: true });
|
||||
const uploadedFiles = inputRef.current.getUploadedFiles();
|
||||
setDataFn(fieldName, [...uploadedFiles, ...data.data], { shouldValidate: true });
|
||||
inputRef.current.setFiles([]);
|
||||
saveFormCallback();
|
||||
}
|
||||
@@ -116,7 +115,6 @@ const Fileupload = ({
|
||||
if (data.status === 'SUCCESS') {
|
||||
setStateFieldData(prevState => {
|
||||
const newFiles = prevState.filter(o => o.id !== id);
|
||||
inputRef.current.setUploadedFiles(newFiles);
|
||||
setDataFn(fieldName, newFiles, { shouldValidate: true });
|
||||
saveFormCallback();
|
||||
return newFiles;
|
||||
|
||||
@@ -54,8 +54,8 @@ const FileuploadAsync = ({
|
||||
const callback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
setStateFieldData(data.data);
|
||||
const files = inputRef.current.getFiles();
|
||||
inputRef.current.setUploadedFiles(files);
|
||||
const uploadedFiles = inputRef.current.getUploadedFiles();
|
||||
setDataFn(fieldName, [...uploadedFiles, ...data.data], { shouldValidate: true });
|
||||
inputRef.current.setFiles([]);
|
||||
}
|
||||
}
|
||||
@@ -108,7 +108,7 @@ const FileuploadAsync = ({
|
||||
if (data.status === 'SUCCESS') {
|
||||
setStateFieldData(prevState => {
|
||||
const newFiles = prevState.filter(o => o.id !== id);
|
||||
inputRef.current.setUploadedFiles(newFiles);
|
||||
setDataFn(fieldName, newFiles, { shouldValidate: true });
|
||||
return newFiles;
|
||||
});
|
||||
}
|
||||
@@ -123,6 +123,13 @@ const FileuploadAsync = ({
|
||||
}
|
||||
|
||||
const onBeforeSelect = (e) => {
|
||||
const files = inputRef.current.getFiles();
|
||||
const uploadedfiles = inputRef.current.getUploadedFiles();
|
||||
|
||||
if (!multiple && (uploadedfiles.length > 0 || files.length > 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (e.originalEvent.target.files) {
|
||||
return !isEmpty(e.originalEvent.target.files)
|
||||
? validateFileInputType(e.originalEvent.target.files)
|
||||
@@ -147,11 +154,9 @@ const FileuploadAsync = ({
|
||||
|
||||
useEffect(() => {
|
||||
if (inputRef.current) {
|
||||
const properValue = multiple
|
||||
? defaultValue
|
||||
: !isEmpty(defaultValue) ? [defaultValue] : [];
|
||||
inputRef.current.setUploadedFiles(properValue);
|
||||
inputRef.current.setUploadedFiles(defaultValue);
|
||||
}
|
||||
setStateFieldData(defaultValue);
|
||||
}, [defaultValue]);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -171,13 +176,6 @@ const FileuploadAsync = ({
|
||||
setFormatsForInput(properMime.join(','))
|
||||
}, [accept]);
|
||||
|
||||
useEffect(() => {
|
||||
if (inputRef.current) {
|
||||
inputRef.current.setUploadedFiles(stateFieldData);
|
||||
}
|
||||
setDataFn(fieldName, [...stateFieldData], { shouldValidate: true });
|
||||
}, [stateFieldData])
|
||||
|
||||
return (
|
||||
sourceId && sourceId !== 0
|
||||
? <>
|
||||
|
||||
Reference in New Issue
Block a user