argous 1.2.163 → 1.2.166

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.
@@ -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
@@ -657,27 +657,32 @@ var searchUsers = function (data) { return __awaiter(void 0, void 0, void 0, fun
657
657
  }); };
658
658
  exports.searchUsers = searchUsers;
659
659
  var prepareFile = function (file) { return __awaiter(void 0, void 0, void 0, function () {
660
- var formData, res, _a, _b;
661
- var _c;
662
- return __generator(this, function (_d) {
663
- switch (_d.label) {
660
+ var formData, _a, status, docsUrl, res, _b, _c;
661
+ var _d;
662
+ return __generator(this, function (_e) {
663
+ switch (_e.label) {
664
664
  case 0:
665
665
  formData = new FormData();
666
+ return [4 /*yield*/, exports.fetchToArgous('agdocsurl', {})];
667
+ case 1:
668
+ _a = _e.sent(), status = _a.status, docsUrl = _a.docsUrl;
669
+ if (!status)
670
+ return [2 /*return*/];
666
671
  formData.append('blob', file);
667
- return [4 /*yield*/, fetch(exports.api() + "docs/upload.agdoc", {
672
+ return [4 /*yield*/, fetch(docsUrl + "/argous/docs/upload.agdoc", {
668
673
  method: 'POST',
669
674
  headers: exports.headers(),
670
675
  body: formData
671
676
  })];
672
- case 1:
673
- res = _d.sent();
674
- _a = [{}];
675
- return [4 /*yield*/, res.json()];
676
677
  case 2:
677
- _b = [__assign.apply(void 0, _a.concat([_d.sent()]))];
678
- _c = { lastModified: file.lastModified, lastModifiedDate: file.lastModifiedDate, name: file.name, size: file.size, type: file.type, webkitRelativePath: file.webkitRelativePath };
678
+ res = _e.sent();
679
+ _b = [{}];
680
+ return [4 /*yield*/, res.json()];
681
+ case 3:
682
+ _c = [__assign.apply(void 0, _b.concat([_e.sent()]))];
683
+ _d = { lastModified: file.lastModified, lastModifiedDate: file.lastModifiedDate, name: file.name, size: file.size, type: file.type, webkitRelativePath: file.webkitRelativePath };
679
684
  return [4 /*yield*/, file.arrayBuffer()];
680
- case 3: return [2 /*return*/, __assign.apply(void 0, _b.concat([(_c.arrayBuffer = _d.sent(), _c)]))];
685
+ case 4: return [2 /*return*/, __assign.apply(void 0, _c.concat([(_d.arrayBuffer = _e.sent(), _d)]))];
681
686
  }
682
687
  });
683
688
  }); };
@@ -743,11 +748,11 @@ var getLink = function (idDocumento, nrRevisao, timeout) { return __awaiter(void
743
748
  });
744
749
  }); };
745
750
  exports.getLink = getLink;
746
- var scanDocument = function (idDocumento, nrRevisao) { return __awaiter(void 0, void 0, void 0, function () {
751
+ var scanDocument = function (idDocumento, nrRevisao, url) { return __awaiter(void 0, void 0, void 0, function () {
747
752
  var res;
748
753
  return __generator(this, function (_a) {
749
754
  switch (_a.label) {
750
- case 0: return [4 /*yield*/, fetch(exports.api() + "docs/scan.agdoc", {
755
+ case 0: return [4 /*yield*/, fetch(url + "argous/docs/scan.agdoc", {
751
756
  method: 'post',
752
757
  headers: exports.headers(),
753
758
  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 1:
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',
@@ -53,7 +53,7 @@ var ColorlibConnector = core_1.withStyles(function (theme) { return ({
53
53
  alternativeLabel: function (_a) {
54
54
  var orientation = _a.orientation;
55
55
  return orientation === 'vertical' ? {
56
- top: -38,
56
+ top: -28,
57
57
  transform: 'rotate(90deg)',
58
58
  left: 'calc(-50% + 40px)',
59
59
  right: 'calc(50% + 10px)',
package/lib/api/index.js CHANGED
@@ -335,10 +335,12 @@ 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) => {
339
339
  const formData = new FormData();
340
+ const { status, docsUrl } = await fetchToArgous('agdocsurl', { });
341
+ if (!status) return;
340
342
  formData.append('blob', file);
341
- const res = await fetch(`${api()}docs/upload.agdoc`, {
343
+ const res = await fetch(`${docsUrl}/argous/docs/upload.agdoc`, {
342
344
  method: 'POST',
343
345
  headers: headers(),
344
346
  body: formData
@@ -392,8 +394,8 @@ export const getLink = async (idDocumento, nrRevisao, timeout) => {
392
394
  })).json();
393
395
  };
394
396
 
395
- export const scanDocument = async (idDocumento, nrRevisao) => {
396
- const res = await fetch(`${api()}docs/scan.agdoc`, {
397
+ export const scanDocument = async (idDocumento, nrRevisao, url) => {
398
+ const res = await fetch(`${url}argous/docs/scan.agdoc`, {
397
399
  method: 'post',
398
400
  headers: headers(),
399
401
  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,
@@ -6,7 +6,7 @@ import { MdCheck, MdChevronLeft, MdChevronRight } from 'react-icons/md';
6
6
 
7
7
  const ColorlibConnector = withStyles(theme => ({
8
8
  alternativeLabel: ({ orientation }) => orientation === 'vertical' ? {
9
- top: -38,
9
+ top: -28,
10
10
  transform: 'rotate(90deg)',
11
11
  left: 'calc(-50% + 40px)',
12
12
  right: 'calc(50% + 10px)',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "argous",
3
- "version": "1.2.163",
3
+ "version": "1.2.166",
4
4
  "description": "Argous.",
5
5
  "main": "lib/index.js",
6
6
  "author": "Carlos Schneider",