argous 1.2.164 → 1.2.165
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/api/index.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export function endFileUpload(data: any): Promise<any>;
|
|
|
37
37
|
export function cancelFileUpload(data: any): Promise<any>;
|
|
38
38
|
export function getFileInfo(data: any): Promise<any>;
|
|
39
39
|
export function searchUsers(data: any): Promise<any>;
|
|
40
|
-
export function prepareFile(file: any): Promise<any>;
|
|
40
|
+
export function prepareFile(file: any, url: any): Promise<any>;
|
|
41
41
|
export function createDocument({ idUnidade, cdUnidade, idDocPai, path, dsKeyWords, dtValidade, idTipoDocumento, FileName, title, idRecebimento, tpPrivacidade, description, dsClassificacao, dsCategoria, dsSubCategoria, snSensivel }: {
|
|
42
42
|
idUnidade: any;
|
|
43
43
|
cdUnidade: any;
|
|
@@ -60,4 +60,4 @@ export function getFileFromLink({ URL: link }?: {
|
|
|
60
60
|
URL?: string | undefined;
|
|
61
61
|
}): Promise<string>;
|
|
62
62
|
export function getLink(idDocumento: any, nrRevisao: any, timeout: any): Promise<any>;
|
|
63
|
-
export function scanDocument(idDocumento: any, nrRevisao: any): Promise<any>;
|
|
63
|
+
export function scanDocument(idDocumento: any, nrRevisao: any, url: any): Promise<any>;
|
package/dist/api/index.js
CHANGED
|
@@ -656,7 +656,7 @@ var searchUsers = function (data) { return __awaiter(void 0, void 0, void 0, fun
|
|
|
656
656
|
});
|
|
657
657
|
}); };
|
|
658
658
|
exports.searchUsers = searchUsers;
|
|
659
|
-
var prepareFile = function (file) { return __awaiter(void 0, void 0, void 0, function () {
|
|
659
|
+
var prepareFile = function (file, url) { return __awaiter(void 0, void 0, void 0, function () {
|
|
660
660
|
var formData, res, _a, _b;
|
|
661
661
|
var _c;
|
|
662
662
|
return __generator(this, function (_d) {
|
|
@@ -664,7 +664,7 @@ var prepareFile = function (file) { return __awaiter(void 0, void 0, void 0, fun
|
|
|
664
664
|
case 0:
|
|
665
665
|
formData = new FormData();
|
|
666
666
|
formData.append('blob', file);
|
|
667
|
-
return [4 /*yield*/, fetch(
|
|
667
|
+
return [4 /*yield*/, fetch(url + "/argous/docs/upload.agdoc", {
|
|
668
668
|
method: 'POST',
|
|
669
669
|
headers: exports.headers(),
|
|
670
670
|
body: formData
|
|
@@ -743,11 +743,11 @@ var getLink = function (idDocumento, nrRevisao, timeout) { return __awaiter(void
|
|
|
743
743
|
});
|
|
744
744
|
}); };
|
|
745
745
|
exports.getLink = getLink;
|
|
746
|
-
var scanDocument = function (idDocumento, nrRevisao) { return __awaiter(void 0, void 0, void 0, function () {
|
|
746
|
+
var scanDocument = function (idDocumento, nrRevisao, url) { return __awaiter(void 0, void 0, void 0, function () {
|
|
747
747
|
var res;
|
|
748
748
|
return __generator(this, function (_a) {
|
|
749
749
|
switch (_a.label) {
|
|
750
|
-
case 0: return [4 /*yield*/, fetch(
|
|
750
|
+
case 0: return [4 /*yield*/, fetch(url + "argous/docs/scan.agdoc", {
|
|
751
751
|
method: 'post',
|
|
752
752
|
headers: exports.headers(),
|
|
753
753
|
body: JSON.stringify({ idDocumento: idDocumento, nrRevisao: nrRevisao })
|
|
@@ -189,26 +189,38 @@ var FilePreparer = function (_a, ref) {
|
|
|
189
189
|
var inputRef = react_1.useRef();
|
|
190
190
|
var _f = react_1.useState(false), loading = _f[0], setLoading = _f[1];
|
|
191
191
|
var _g = react_1.useState(initialFiles), files = _g[0], setFiles = _g[1];
|
|
192
|
+
var _h = react_1.useState(), motivo = _h[0], setMotivo = _h[1];
|
|
192
193
|
react_1.useEffect(function () {
|
|
193
194
|
if (valuePlaceHolder && !multiple)
|
|
194
195
|
setFiles(function (f) { return [__assign(__assign({}, f[0]), { name: valuePlaceHolder })]; });
|
|
195
196
|
}, [valuePlaceHolder, multiple]);
|
|
197
|
+
var handleChange = function (_, v, reason) {
|
|
198
|
+
setMotivo(reason);
|
|
199
|
+
inputRef.current.value = '';
|
|
200
|
+
setFiles(v || []);
|
|
201
|
+
onChange && onChange(multiple ? v || [] : (v || [])[0], motivo);
|
|
202
|
+
};
|
|
196
203
|
var preparaArquivo = react_1.useCallback(function (file) { return __awaiter(void 0, void 0, void 0, function () {
|
|
197
|
-
var reqs, i, res, resps;
|
|
204
|
+
var resultUrl, reqs, i, res, resps;
|
|
198
205
|
return __generator(this, function (_a) {
|
|
199
206
|
switch (_a.label) {
|
|
200
207
|
case 0:
|
|
201
208
|
if (!file)
|
|
202
209
|
return [2 /*return*/];
|
|
203
210
|
setLoading(true);
|
|
211
|
+
return [4 /*yield*/, api_1.fetchToArgous('agdocsurl', {})];
|
|
212
|
+
case 1:
|
|
213
|
+
resultUrl = _a.sent();
|
|
214
|
+
if (!resultUrl.status)
|
|
215
|
+
return [2 /*return*/];
|
|
204
216
|
reqs = [];
|
|
205
217
|
if (file.map)
|
|
206
218
|
reqs = file;
|
|
207
219
|
else
|
|
208
220
|
for (i = 0; i < file.length; i++)
|
|
209
221
|
reqs.push(file[i]);
|
|
210
|
-
return [4 /*yield*/, Promise.all(reqs.map(function (item) { return api_1.prepareFile(item.fileObject || item); }))];
|
|
211
|
-
case
|
|
222
|
+
return [4 /*yield*/, Promise.all(reqs.map(function (item) { return api_1.prepareFile(item.fileObject || item, resultUrl.docsUrl); }))];
|
|
223
|
+
case 2:
|
|
212
224
|
res = _a.sent();
|
|
213
225
|
resps = [];
|
|
214
226
|
res.forEach(function (item, i) {
|
|
@@ -224,18 +236,11 @@ var FilePreparer = function (_a, ref) {
|
|
|
224
236
|
}
|
|
225
237
|
});
|
|
226
238
|
}); }, [concat, files, motivo, multiple, onChange]);
|
|
227
|
-
var _h = react_1.useState(), motivo = _h[0], setMotivo = _h[1];
|
|
228
239
|
// useUpdateEffect(() => {
|
|
229
240
|
// onChange && onChange(multiple ? files : files[0], motivo);
|
|
230
241
|
// setMotivo(undefined);
|
|
231
242
|
// }, [files]);
|
|
232
243
|
react_1.useImperativeHandle(ref, function () { return ({ preparaArquivo: preparaArquivo, loading: loading, setLoading: setLoading }); }, [preparaArquivo, loading]);
|
|
233
|
-
var handleChange = function (_, v, reason) {
|
|
234
|
-
setMotivo(reason);
|
|
235
|
-
inputRef.current.value = '';
|
|
236
|
-
setFiles(v || []);
|
|
237
|
-
onChange && onChange(multiple ? v || [] : (v || [])[0], motivo);
|
|
238
|
-
};
|
|
239
244
|
var _j = lab_1.useAutocomplete({
|
|
240
245
|
value: files,
|
|
241
246
|
inputValue: files.length ? '' : placeholder || 'Selecione um arquivo',
|
package/lib/api/index.js
CHANGED
|
@@ -335,10 +335,10 @@ export const searchUsers = async (data) => {
|
|
|
335
335
|
return await res.json();
|
|
336
336
|
};
|
|
337
337
|
|
|
338
|
-
export const prepareFile = async file => {
|
|
338
|
+
export const prepareFile = async (file, url) => {
|
|
339
339
|
const formData = new FormData();
|
|
340
340
|
formData.append('blob', file);
|
|
341
|
-
const res = await fetch(`${
|
|
341
|
+
const res = await fetch(`${url}/argous/docs/upload.agdoc`, {
|
|
342
342
|
method: 'POST',
|
|
343
343
|
headers: headers(),
|
|
344
344
|
body: formData
|
|
@@ -392,8 +392,8 @@ export const getLink = async (idDocumento, nrRevisao, timeout) => {
|
|
|
392
392
|
})).json();
|
|
393
393
|
};
|
|
394
394
|
|
|
395
|
-
export const scanDocument = async (idDocumento, nrRevisao) => {
|
|
396
|
-
const res = await fetch(`${
|
|
395
|
+
export const scanDocument = async (idDocumento, nrRevisao, url) => {
|
|
396
|
+
const res = await fetch(`${url}argous/docs/scan.agdoc`, {
|
|
397
397
|
method: 'post',
|
|
398
398
|
headers: headers(),
|
|
399
399
|
body: JSON.stringify({ idDocumento, nrRevisao })
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { prepareFile } from '../../api';
|
|
1
|
+
import { fetchToArgous, prepareFile } from '../../api';
|
|
2
2
|
import { setError } from '../../utils/api';
|
|
3
3
|
import { Chip, CircularProgress, FilledInput, IconButton, makeStyles, TextField } from '@material-ui/core';
|
|
4
4
|
import { useAutocomplete } from '@material-ui/lab';
|
|
@@ -116,18 +116,28 @@ const FilePreparer = ({
|
|
|
116
116
|
|
|
117
117
|
const [loading, setLoading] = useState(false);
|
|
118
118
|
const [files, setFiles] = useState(initialFiles);
|
|
119
|
+
const [motivo, setMotivo] = useState();
|
|
119
120
|
|
|
120
121
|
useEffect(() => {
|
|
121
122
|
if (valuePlaceHolder && !multiple) setFiles(f => [{ ...f[0], name: valuePlaceHolder }]);
|
|
122
123
|
}, [valuePlaceHolder, multiple]);
|
|
123
124
|
|
|
125
|
+
const handleChange = (_, v, reason) => {
|
|
126
|
+
setMotivo(reason);
|
|
127
|
+
inputRef.current.value = '';
|
|
128
|
+
setFiles(v || []);
|
|
129
|
+
onChange && onChange(multiple ? v || [] : (v || [])[0], motivo);
|
|
130
|
+
};
|
|
131
|
+
|
|
124
132
|
const preparaArquivo = useCallback(async file => {
|
|
125
133
|
if (!file) return;
|
|
126
134
|
setLoading(true);
|
|
135
|
+
const resultUrl = await fetchToArgous('agdocsurl', { });
|
|
136
|
+
if (!resultUrl.status) return;
|
|
127
137
|
let reqs = [];
|
|
128
138
|
if (file.map) reqs = file;
|
|
129
|
-
else for (let i = 0; i < file.length; i++) reqs.push(file[i]);
|
|
130
|
-
const res = await Promise.all(reqs.map(item => prepareFile(item.fileObject || item)));
|
|
139
|
+
else for (let i = 0; i < file.length; i++) reqs.push(file[i]);
|
|
140
|
+
const res = await Promise.all(reqs.map(item => prepareFile(item.fileObject || item, resultUrl.docsUrl)));
|
|
131
141
|
let resps = [];
|
|
132
142
|
res.forEach((item, i) => {
|
|
133
143
|
if (item.idRecebimento) resps.push({ ...item, path: file[i].fullPath });
|
|
@@ -135,26 +145,15 @@ const FilePreparer = ({
|
|
|
135
145
|
});
|
|
136
146
|
setFiles(f => concat && multiple ? ([...f, ...resps]) : resps);
|
|
137
147
|
setLoading(false);
|
|
138
|
-
|
|
139
148
|
onChange && onChange(multiple ? concat ? [...files, ...resps] : resps : resps[0], motivo);
|
|
140
149
|
}, [concat, files, motivo, multiple, onChange]);
|
|
141
150
|
|
|
142
|
-
const [motivo, setMotivo] = useState();
|
|
143
|
-
|
|
144
151
|
// useUpdateEffect(() => {
|
|
145
152
|
// onChange && onChange(multiple ? files : files[0], motivo);
|
|
146
153
|
// setMotivo(undefined);
|
|
147
154
|
// }, [files]);
|
|
148
155
|
|
|
149
156
|
useImperativeHandle(ref, () => ({ preparaArquivo, loading, setLoading }), [preparaArquivo, loading]);
|
|
150
|
-
|
|
151
|
-
const handleChange = (_, v, reason) => {
|
|
152
|
-
setMotivo(reason);
|
|
153
|
-
inputRef.current.value = '';
|
|
154
|
-
setFiles(v || []);
|
|
155
|
-
|
|
156
|
-
onChange && onChange(multiple ? v || [] : (v || [])[0], motivo);
|
|
157
|
-
};
|
|
158
157
|
|
|
159
158
|
const {
|
|
160
159
|
getInputProps,
|