@tap-payments/auth-jsconnect 2.1.40-test → 2.1.42-test

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.
Files changed (40) hide show
  1. package/build/@types/form.d.ts +6 -3
  2. package/build/api/entity.d.ts +8 -0
  3. package/build/api/entity.js +15 -0
  4. package/build/api/index.d.ts +2 -6
  5. package/build/api/index.js +1 -3
  6. package/build/assets/locales/ar.json +1 -5
  7. package/build/assets/locales/en.json +1 -5
  8. package/build/components/FileInput/DragAndDrop.js +1 -1
  9. package/build/components/ProgressBar/CircularProgressBar.d.ts +1 -3
  10. package/build/components/ProgressBar/CircularProgressBar.js +2 -2
  11. package/build/constants/assets.d.ts +0 -1
  12. package/build/constants/assets.js +0 -1
  13. package/build/constants/validation.d.ts +0 -1
  14. package/build/constants/validation.js +0 -1
  15. package/build/features/app/bank/bankStore.js +1 -1
  16. package/build/features/app/business/businessStore.d.ts +9 -7
  17. package/build/features/app/business/businessStore.js +67 -29
  18. package/build/features/app/individual/individualStore.d.ts +16 -4
  19. package/build/features/app/individual/individualStore.js +89 -11
  20. package/build/features/business/screens/BusinessType/Article.js +13 -10
  21. package/build/features/business/screens/BusinessType/BusinessType.js +4 -2
  22. package/build/features/business/screens/BusinessType/LicenseCertificate.js +50 -12
  23. package/build/features/business/screens/BusinessType/validation.d.ts +6 -3
  24. package/build/features/business/screens/BusinessType/validation.js +11 -1
  25. package/build/features/individual/screens/AdditionalIndividualInfo/AdditionalIndividualInfo.js +4 -18
  26. package/build/features/individual/screens/AdditionalIndividualInfo/CivilIDFile.js +62 -11
  27. package/build/features/individual/screens/AdditionalIndividualInfo/SignatureFile.js +59 -11
  28. package/build/features/individual/screens/AdditionalIndividualInfo/validation.d.ts +12 -6
  29. package/build/features/individual/screens/AdditionalIndividualInfo/validation.js +23 -2
  30. package/build/features/shared/UploadFile/UploadFile.js +1 -1
  31. package/build/theme/typography.js +1 -1
  32. package/package.json +1 -1
  33. package/build/api/file.d.ts +0 -13
  34. package/build/api/file.js +0 -24
  35. package/build/features/shared/UploadMultipleFile/UploadFile.d.ts +0 -38
  36. package/build/features/shared/UploadMultipleFile/UploadFile.js +0 -184
  37. package/build/features/shared/UploadMultipleFile/UploadMultipleFile.d.ts +0 -27
  38. package/build/features/shared/UploadMultipleFile/UploadMultipleFile.js +0 -147
  39. package/build/features/shared/UploadMultipleFile/index.d.ts +0 -2
  40. package/build/features/shared/UploadMultipleFile/index.js +0 -2
@@ -6,8 +6,10 @@ export declare const IndividualInfoValidationSchema: yup.ObjectSchema<import("yu
6
6
  sourceIncome: import("yup/lib/object").RequiredObjectSchema<ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<ObjectShape>>;
7
7
  monthlyIncome: import("yup/lib/object").OptionalObjectSchema<ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<ObjectShape>>;
8
8
  employerLocation: import("yup/lib/object").OptionalObjectSchema<Partial<Record<keyof CountryCode, yup.AnySchema<any, any, any> | import("yup/lib/Reference").default<unknown> | import("yup/lib/Lazy").default<any, any>>>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<Partial<Record<keyof CountryCode, yup.AnySchema<any, any, any> | import("yup/lib/Reference").default<unknown> | import("yup/lib/Lazy").default<any, any>>>>>;
9
- civilID: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined>;
10
- signatureFileId: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined>;
9
+ civilID: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
10
+ civilIDFile: any;
11
+ signatureFileId: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
12
+ signatureFile: any;
11
13
  isPEP: import("yup/lib/boolean").RequiredBooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject>;
12
14
  isInfluencer: import("yup/lib/boolean").RequiredBooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject>;
13
15
  }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<ObjectShape, {
@@ -15,8 +17,10 @@ export declare const IndividualInfoValidationSchema: yup.ObjectSchema<import("yu
15
17
  sourceIncome: import("yup/lib/object").RequiredObjectSchema<ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<ObjectShape>>;
16
18
  monthlyIncome: import("yup/lib/object").OptionalObjectSchema<ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<ObjectShape>>;
17
19
  employerLocation: import("yup/lib/object").OptionalObjectSchema<Partial<Record<keyof CountryCode, yup.AnySchema<any, any, any> | import("yup/lib/Reference").default<unknown> | import("yup/lib/Lazy").default<any, any>>>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<Partial<Record<keyof CountryCode, yup.AnySchema<any, any, any> | import("yup/lib/Reference").default<unknown> | import("yup/lib/Lazy").default<any, any>>>>>;
18
- civilID: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined>;
19
- signatureFileId: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined>;
20
+ civilID: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
21
+ civilIDFile: any;
22
+ signatureFileId: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
23
+ signatureFile: any;
20
24
  isPEP: import("yup/lib/boolean").RequiredBooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject>;
21
25
  isInfluencer: import("yup/lib/boolean").RequiredBooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject>;
22
26
  }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<ObjectShape, {
@@ -24,8 +28,10 @@ export declare const IndividualInfoValidationSchema: yup.ObjectSchema<import("yu
24
28
  sourceIncome: import("yup/lib/object").RequiredObjectSchema<ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<ObjectShape>>;
25
29
  monthlyIncome: import("yup/lib/object").OptionalObjectSchema<ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<ObjectShape>>;
26
30
  employerLocation: import("yup/lib/object").OptionalObjectSchema<Partial<Record<keyof CountryCode, yup.AnySchema<any, any, any> | import("yup/lib/Reference").default<unknown> | import("yup/lib/Lazy").default<any, any>>>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<Partial<Record<keyof CountryCode, yup.AnySchema<any, any, any> | import("yup/lib/Reference").default<unknown> | import("yup/lib/Lazy").default<any, any>>>>>;
27
- civilID: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined>;
28
- signatureFileId: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined>;
31
+ civilID: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
32
+ civilIDFile: any;
33
+ signatureFileId: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
34
+ signatureFile: any;
29
35
  isPEP: import("yup/lib/boolean").RequiredBooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject>;
30
36
  isInfluencer: import("yup/lib/boolean").RequiredBooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject>;
31
37
  }>>>;
@@ -1,4 +1,5 @@
1
1
  import * as yup from 'yup';
2
+ import { MAX_FILE_SIZE, VALID_FILE_FORMATS } from '../../../../constants';
2
3
  export var IndividualInfoValidationSchema = yup.object().shape({
3
4
  occupation: yup.object().required('alert_choose_occupation'),
4
5
  sourceIncome: yup.object().required('choose_any_source_of_income'),
@@ -19,8 +20,28 @@ export var IndividualInfoValidationSchema = yup.object().shape({
19
20
  return yup.object().optional();
20
21
  }
21
22
  }),
22
- civilID: yup.array().optional(),
23
- signatureFileId: yup.array().optional(),
23
+ civilID: yup.string().optional(),
24
+ civilIDFile: yup
25
+ .mixed()
26
+ .test({
27
+ test: function (value) {
28
+ if (!!value)
29
+ return VALID_FILE_FORMATS.includes(value === null || value === void 0 ? void 0 : value.type) && (value === null || value === void 0 ? void 0 : value.size) < MAX_FILE_SIZE ? true : this.createError({ message: 'alert_file_upload' });
30
+ return true;
31
+ }
32
+ })
33
+ .optional(),
34
+ signatureFileId: yup.string().optional(),
35
+ signatureFile: yup
36
+ .mixed()
37
+ .test({
38
+ test: function (value) {
39
+ if (!!value)
40
+ return VALID_FILE_FORMATS.includes(value === null || value === void 0 ? void 0 : value.type) && (value === null || value === void 0 ? void 0 : value.size) < MAX_FILE_SIZE ? true : this.createError({ message: 'alert_file_upload' });
41
+ return true;
42
+ }
43
+ })
44
+ .optional(),
24
45
  isPEP: yup.boolean().required('please_choose_relative_pep'),
25
46
  isInfluencer: yup.boolean().required('please_choose_are_you_influncer')
26
47
  });
@@ -86,6 +86,6 @@ var UploadFile = function (_a) {
86
86
  else
87
87
  setShowFile(false);
88
88
  }, [isFileUploaded]);
89
- return (_jsxs(FeatureStyled, { children: [_jsxs(LabelContainerStyled, { children: [_jsx(InputLabelStyled, { children: label }), required && _jsx(Mandatory, {})] }), _jsx(Collapse, __assign({ in: !showFile || !!error }, { children: _jsx(InputContainerStyled, { children: _jsx(DragAndDrop, { title: title, subTitle: subTitle, description: dragDescription, fileExists: !!fileName, uploadingTitle: uploadingTitle, successTitle: successTitle, progress: progress, uploading: isUploading, uploadSuccess: isFileUploaded, onSuccess: handleFileChange, error: error, multiple: multiple }) }) })), _jsx(Collapse, __assign({ in: showFile && !error, timeout: 300 }, { children: _jsxs(InputContainerStyled, { children: [_jsxs(BoxStyled, { children: [_jsxs(Box, __assign({ sx: { display: 'flex' } }, { children: [_jsx(Icon, { src: ICONS_NAMES.DOC_ICON }), _jsx(Text, { children: fileName })] })), _jsx(Box, { children: _jsx(CheckIcon, {}) })] }), _jsx(UploadBoxStyled, __assign({ onClick: handleReset }, { children: _jsx(ClearIconStyled, {}) }))] }) }))] }));
89
+ return (_jsxs(FeatureStyled, { children: [_jsxs(LabelContainerStyled, { children: [_jsx(InputLabelStyled, { children: label }), required && _jsx(Mandatory, {})] }), _jsx(Collapse, __assign({ in: !showFile }, { children: _jsx(InputContainerStyled, { children: _jsx(DragAndDrop, { title: title, subTitle: subTitle, description: dragDescription, fileExists: !!fileName, uploadingTitle: uploadingTitle, successTitle: successTitle, progress: progress, uploading: isUploading, uploadSuccess: isFileUploaded, onSuccess: handleFileChange, error: error, multiple: multiple }) }) })), _jsx(Collapse, __assign({ in: showFile, timeout: 300 }, { children: _jsxs(InputContainerStyled, { children: [_jsxs(BoxStyled, { children: [_jsxs(Box, __assign({ sx: { display: 'flex' } }, { children: [_jsx(Icon, { src: ICONS_NAMES.DOC_ICON }), _jsx(Text, { children: fileName })] })), _jsx(Box, { children: _jsx(CheckIcon, {}) })] }), _jsx(UploadBoxStyled, __assign({ onClick: handleReset }, { children: _jsx(ClearIconStyled, {}) }))] }) }))] }));
90
90
  };
91
91
  export default UploadFile;
@@ -27,5 +27,5 @@ export var typography = {
27
27
  body2: { fontSize: '0.875rem' },
28
28
  button: { fontSize: '0.875rem' },
29
29
  caption: { fontSize: '0.75rem' },
30
- overline: { fontSize: '0.5rem' }
30
+ overline: { fontSize: '0.75rem' }
31
31
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.1.40-test",
3
+ "version": "2.1.42-test",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",
@@ -1,13 +0,0 @@
1
- import { AxiosRequestConfig } from 'axios';
2
- export declare type UploadFileBody = {
3
- file_link_create: boolean;
4
- file?: File;
5
- title: string | undefined;
6
- purpose: string;
7
- type?: string;
8
- };
9
- declare const fileService: {
10
- uploadFile: (data: UploadFileBody, config?: AxiosRequestConfig) => Promise<import("axios").AxiosResponse<any, any>>;
11
- uploadFileInfo: (data: UploadFileBody, config?: AxiosRequestConfig) => Promise<any>;
12
- };
13
- export { fileService };
package/build/api/file.js DELETED
@@ -1,24 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- import { ENDPOINT_PATHS } from '../constants';
13
- import instance, { httpClient } from './axios';
14
- var uploadFileInfo = function (data, config) {
15
- return httpClient(__assign({ method: 'post', url: "".concat(ENDPOINT_PATHS.FILES_PATH), data: data, headers: { 'Content-Type': 'multipart/form-data' } }, config));
16
- };
17
- var uploadFile = function (data, config) {
18
- return instance.post("".concat(ENDPOINT_PATHS.FILES_PATH), data, __assign({ headers: { 'Content-Type': 'multipart/form-data' } }, config));
19
- };
20
- var fileService = {
21
- uploadFile: uploadFile,
22
- uploadFileInfo: uploadFileInfo
23
- };
24
- export { fileService };
@@ -1,38 +0,0 @@
1
- import React from 'react';
2
- import { SxProps, Theme } from '@mui/material/styles';
3
- export declare const InputContainerStyled: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<Theme> & {
4
- children?: React.ReactNode;
5
- component?: React.ElementType<any> | undefined;
6
- ref?: React.Ref<unknown> | undefined;
7
- sx?: SxProps<Theme> | undefined;
8
- } & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
9
- ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
10
- }, keyof import("@mui/material/OverridableComponent").CommonProps | ("border" | "borderTop" | "borderRight" | "borderBottom" | "borderLeft" | "borderColor" | "borderRadius" | "display" | "displayPrint" | "overflow" | "textOverflow" | "visibility" | "whiteSpace" | "flexBasis" | "flexDirection" | "flexWrap" | "justifyContent" | "alignItems" | "alignContent" | "order" | "flex" | "flexGrow" | "flexShrink" | "alignSelf" | "justifyItems" | "justifySelf" | "gap" | "columnGap" | "rowGap" | "gridColumn" | "gridRow" | "gridAutoFlow" | "gridAutoColumns" | "gridAutoRows" | "gridTemplateColumns" | "gridTemplateRows" | "gridTemplateAreas" | "gridArea" | "bgcolor" | "color" | "zIndex" | "position" | "top" | "right" | "bottom" | "left" | "boxShadow" | "width" | "maxWidth" | "minWidth" | "height" | "maxHeight" | "minHeight" | "boxSizing" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "my" | "p" | "pt" | "pr" | "pb" | "pl" | "px" | "py" | "margin" | "marginTop" | "marginRight" | "marginBottom" | "marginLeft" | "marginX" | "marginY" | "padding" | "paddingTop" | "paddingRight" | "paddingBottom" | "paddingLeft" | "paddingX" | "paddingY" | "typography" | "fontFamily" | "fontSize" | "fontStyle" | "fontWeight" | "letterSpacing" | "lineHeight" | "textAlign" | "textTransform") | "ref" | "children" | "component" | "sx"> & import("@mui/system").MUIStyledCommonProps<Theme>, {}, {}>;
11
- export declare enum FileStatus {
12
- INIT = "init",
13
- UPLOADING = "uploading",
14
- SUCCESS = "success",
15
- ERROR = "error",
16
- ALREADY_UPLOADED = "already_uploaded"
17
- }
18
- export declare type FileInfo = {
19
- fileId: string;
20
- name: string;
21
- status: FileStatus;
22
- progress: number;
23
- error: string;
24
- };
25
- export declare type UploadFileProps = {
26
- index: number;
27
- purpose: string;
28
- file: File;
29
- title?: string;
30
- uploadedFiles: Array<FileInfo>;
31
- onSuccess: (index: number, file: FileInfo) => void;
32
- onFailure: (index: number, file: FileInfo) => void;
33
- onDelete: (index: number) => void;
34
- onProgress: (index: number, file: FileInfo) => void;
35
- sx?: SxProps<Theme> | undefined;
36
- };
37
- declare const UploadFile: ({ index, title, file, uploadedFiles, onSuccess, onFailure, onDelete, onProgress, sx, purpose }: UploadFileProps) => JSX.Element;
38
- export default UploadFile;
@@ -1,184 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
- return new (P || (P = Promise))(function (resolve, reject) {
15
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
- step((generator = generator.apply(thisArg, _arguments || [])).next());
19
- });
20
- };
21
- var __generator = (this && this.__generator) || function (thisArg, body) {
22
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
- function verb(n) { return function (v) { return step([n, v]); }; }
25
- function step(op) {
26
- if (f) throw new TypeError("Generator is already executing.");
27
- while (_) try {
28
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
- if (y = 0, t) op = [op[0] & 2, t.value];
30
- switch (op[0]) {
31
- case 0: case 1: t = op; break;
32
- case 4: _.label++; return { value: op[1], done: false };
33
- case 5: _.label++; y = op[1]; op = [0]; continue;
34
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
- default:
36
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
- if (t[2]) _.ops.pop();
41
- _.trys.pop(); continue;
42
- }
43
- op = body.call(thisArg, _);
44
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
- }
47
- };
48
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
49
- import React from 'react';
50
- import { useTranslation } from 'react-i18next';
51
- import { alpha, styled, useTheme } from '@mui/material/styles';
52
- import Box from '@mui/material/Box';
53
- import ClearIcon from '@mui/icons-material/Clear';
54
- import Collapse from '../../../components/Collapse';
55
- import { CircularProgress } from '../../../components/ProgressBar';
56
- import Text from '../../../components/Text';
57
- import Icon from '../../../components/Icon';
58
- import { maskFileName } from '../../../utils';
59
- import API from '../../../api';
60
- import { ICONS_NAMES, MAX_FILE_SIZE_FOUR_MB, VALID_FILE_FORMATS } from '../../../constants';
61
- import CheckIcon from '../../shared/CheckIcon';
62
- var BoxStyled = styled(Box)(function (_a) {
63
- var theme = _a.theme;
64
- return (__assign(__assign({ direction: theme.direction }, theme.typography.subtitle2), { color: theme.palette.primary.main, fontWeight: theme.typography.fontWeightBold, background: theme.palette.background.default, padding: theme.spacing(0, 2.5, 0), width: '88%', wordBreak: 'break-all', display: 'flex', justifyContent: 'space-between' }));
65
- });
66
- var UploadBoxStyled = styled(Box, { shouldForwardProp: function (prop) { return prop !== 'uploading'; } })(function (_a) {
67
- var theme = _a.theme, uploading = _a.uploading;
68
- return (__assign(__assign({}, theme.typography.caption), { background: uploading ? alpha(theme.palette.primary.main, 0.5) : theme.palette.primary.main, color: theme.palette.common.white, fontWeight: theme.typography.fontWeightRegular, cursor: 'pointer', width: '12%', display: 'flex', justifyContent: 'center', alignItems: 'center' }));
69
- });
70
- var ClearIconStyled = styled(ClearIcon)(function (_a) {
71
- var theme = _a.theme;
72
- return ({
73
- width: theme.spacing(3),
74
- height: theme.spacing(3),
75
- cursor: 'pointer',
76
- color: theme.palette.common.white
77
- });
78
- });
79
- export var InputContainerStyled = styled(Box)(function () { return ({
80
- display: 'flex',
81
- width: '100%',
82
- justifyContent: 'center'
83
- }); });
84
- var CenterBoxStyled = styled(Box)(function () { return ({
85
- display: 'flex',
86
- justifyContent: 'center',
87
- alignItems: 'center'
88
- }); });
89
- var WarningIconStyled = styled(Icon)(function (_a) {
90
- var theme = _a.theme;
91
- return ({
92
- width: theme.spacing(1.625),
93
- height: theme.spacing(1.625),
94
- marginInline: theme.spacing(0.5)
95
- });
96
- });
97
- var ErrorIconStyled = styled(Icon)(function (_a) {
98
- var theme = _a.theme;
99
- return ({
100
- width: theme.spacing(1.625),
101
- height: theme.spacing(1.625),
102
- marginInline: theme.spacing(0.5)
103
- });
104
- });
105
- var WarningContainer = styled(Box)(function (_a) {
106
- var theme = _a.theme;
107
- return (__assign({ background: alpha(theme.palette.warning.main, 0.1), paddingBlock: theme.spacing(1.5), paddingInlineStart: theme.spacing(2.5), flexDirection: 'row', display: 'flex', justifyContent: 'center', color: theme.palette.warning.light, padding: theme.spacing(0.5, 1), borderRadius: '101px', alignItems: 'center', marginTop: theme.spacing(1.25) }, theme.typography.caption));
108
- });
109
- export var FileStatus;
110
- (function (FileStatus) {
111
- FileStatus["INIT"] = "init";
112
- FileStatus["UPLOADING"] = "uploading";
113
- FileStatus["SUCCESS"] = "success";
114
- FileStatus["ERROR"] = "error";
115
- FileStatus["ALREADY_UPLOADED"] = "already_uploaded";
116
- })(FileStatus || (FileStatus = {}));
117
- var UploadFile = function (_a) {
118
- var index = _a.index, title = _a.title, file = _a.file, uploadedFiles = _a.uploadedFiles, onSuccess = _a.onSuccess, onFailure = _a.onFailure, onDelete = _a.onDelete, onProgress = _a.onProgress, sx = _a.sx, purpose = _a.purpose;
119
- var theme = useTheme();
120
- var t = useTranslation().t;
121
- var _b = file || {}, name = _b.name, size = _b.size, type = _b.type;
122
- var uploadedFile = (uploadedFiles === null || uploadedFiles === void 0 ? void 0 : uploadedFiles[index]) || {};
123
- var status = uploadedFile.status, progress = uploadedFile.progress, error = uploadedFile.error;
124
- var uploadFile = function () { return __awaiter(void 0, void 0, void 0, function () {
125
- var uploadPayload, onUploadProgress, data, fileId;
126
- return __generator(this, function (_a) {
127
- switch (_a.label) {
128
- case 0:
129
- uploadPayload = {
130
- file_link_create: true,
131
- title: title || (file === null || file === void 0 ? void 0 : file.name),
132
- purpose: purpose,
133
- file: file
134
- };
135
- onUploadProgress = function (progressEvent) {
136
- var progress = ((progressEvent === null || progressEvent === void 0 ? void 0 : progressEvent.loaded) / (progressEvent === null || progressEvent === void 0 ? void 0 : progressEvent.total)) * 100;
137
- uploadedFile = __assign(__assign({}, uploadedFile), { progress: Math.floor(progress), status: FileStatus.UPLOADING });
138
- onProgress(index, uploadedFile);
139
- };
140
- return [4, API.fileService.uploadFile(uploadPayload, { onUploadProgress: onUploadProgress })];
141
- case 1:
142
- data = (_a.sent()).data;
143
- fileId = (data || {}).id;
144
- if (fileId) {
145
- uploadedFile = __assign(__assign({}, uploadedFile), { status: FileStatus.SUCCESS, fileId: fileId });
146
- onSuccess(index, uploadedFile);
147
- }
148
- else {
149
- uploadedFile = __assign(__assign({}, uploadedFile), { progress: 0, status: FileStatus.ERROR, error: 'file_upload_error' });
150
- onFailure(index, uploadedFile);
151
- }
152
- return [2];
153
- }
154
- });
155
- }); };
156
- React.useEffect(function () {
157
- if (!file)
158
- return;
159
- else if (!VALID_FILE_FORMATS.includes(type)) {
160
- uploadedFile = __assign(__assign({}, uploadedFile), { status: FileStatus.ERROR, error: 'file_not_supported_alert' });
161
- onFailure(index, uploadedFile);
162
- }
163
- else if (size > MAX_FILE_SIZE_FOUR_MB) {
164
- uploadedFile = __assign(__assign({}, uploadedFile), { status: FileStatus.ERROR, error: 'file_size_alert' });
165
- onFailure(index, uploadedFile);
166
- }
167
- else if (status === FileStatus.ALREADY_UPLOADED) {
168
- uploadedFile = __assign(__assign({}, uploadedFile), { error: 'file_already_exist', progress: 0 });
169
- onFailure(index, uploadedFile);
170
- }
171
- else {
172
- if (uploadedFile.status !== FileStatus.UPLOADING && uploadedFile.status !== FileStatus.SUCCESS) {
173
- uploadFile();
174
- }
175
- }
176
- }, []);
177
- return (_jsx(Box, { children: _jsxs(InputContainerStyled, __assign({ sx: __assign({ borderTop: "1px solid ".concat(alpha(theme.palette.divider, 0.8)) }, sx) }, { children: [_jsxs(BoxStyled, { children: [_jsxs(Box, __assign({ sx: {
178
- display: 'flex',
179
- flexDirection: 'column',
180
- padding: theme.spacing(1.5, 0, 1.5),
181
- width: '100%'
182
- } }, { children: [_jsxs(Box, __assign({ sx: { display: 'flex', flexDirection: 'row' } }, { children: [_jsx(Icon, { src: ICONS_NAMES.DOC_ICON }), _jsx(Text, { children: maskFileName(name) })] })), _jsx(Box, __assign({ sx: { display: 'flex', flexDirection: 'row', justifyContent: 'center' } }, { children: _jsx(Collapse, __assign({ in: !!error, timeout: 400 }, { children: _jsxs(WarningContainer, { children: [_jsx(WarningIconStyled, { src: ICONS_NAMES.WARNING_ICON }), _jsx(Text, { children: t(error) })] }) })) }))] })), _jsx(CenterBoxStyled, { children: error ? (_jsx(ErrorIconStyled, { src: ICONS_NAMES.ERROR_ICON })) : status === FileStatus.SUCCESS ? (_jsx(CheckIcon, {})) : progress ? (_jsx(CircularProgress, { sx: { backgroundColor: alpha(theme.palette.primary.main, 0.05), borderRadius: '32px' }, textSx: { fontSize: theme.spacing(1.125) }, value: progress, size: 35 })) : (_jsx(_Fragment, {})) })] }), _jsx(UploadBoxStyled, __assign({ uploading: status === FileStatus.UPLOADING, onClick: status === FileStatus.UPLOADING ? undefined : function () { return onDelete(index); } }, { children: _jsx(ClearIconStyled, {}) }))] })) }, index));
183
- };
184
- export default UploadFile;
@@ -1,27 +0,0 @@
1
- import React from 'react';
2
- export declare const InputContainerStyled: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material/styles").Theme> & {
3
- children?: React.ReactNode;
4
- component?: React.ElementType<any> | undefined;
5
- ref?: React.Ref<unknown> | undefined;
6
- sx?: import("@mui/material/styles").SxProps<import("@mui/material/styles").Theme> | undefined;
7
- } & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
8
- ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
9
- }, keyof import("@mui/material/OverridableComponent").CommonProps | ("border" | "borderTop" | "borderRight" | "borderBottom" | "borderLeft" | "borderColor" | "borderRadius" | "display" | "displayPrint" | "overflow" | "textOverflow" | "visibility" | "whiteSpace" | "flexBasis" | "flexDirection" | "flexWrap" | "justifyContent" | "alignItems" | "alignContent" | "order" | "flex" | "flexGrow" | "flexShrink" | "alignSelf" | "justifyItems" | "justifySelf" | "gap" | "columnGap" | "rowGap" | "gridColumn" | "gridRow" | "gridAutoFlow" | "gridAutoColumns" | "gridAutoRows" | "gridTemplateColumns" | "gridTemplateRows" | "gridTemplateAreas" | "gridArea" | "bgcolor" | "color" | "zIndex" | "position" | "top" | "right" | "bottom" | "left" | "boxShadow" | "width" | "maxWidth" | "minWidth" | "height" | "maxHeight" | "minHeight" | "boxSizing" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "my" | "p" | "pt" | "pr" | "pb" | "pl" | "px" | "py" | "margin" | "marginTop" | "marginRight" | "marginBottom" | "marginLeft" | "marginX" | "marginY" | "padding" | "paddingTop" | "paddingRight" | "paddingBottom" | "paddingLeft" | "paddingX" | "paddingY" | "typography" | "fontFamily" | "fontSize" | "fontStyle" | "fontWeight" | "letterSpacing" | "lineHeight" | "textAlign" | "textTransform") | "ref" | "children" | "component" | "sx"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
10
- interface UploadMultipleFileProps {
11
- label: string;
12
- purpose: string;
13
- fileTitle?: string;
14
- required?: boolean;
15
- title: string;
16
- subTitle: string;
17
- dragDescription: string;
18
- uploadingTitle: string;
19
- successTitle: string;
20
- isSubmitting?: boolean;
21
- onFileUploaded: (fileIds: Array<string>) => void;
22
- fileUploadingStatus?: (uploading: boolean) => void;
23
- onDeleteFile: (fileIds: Array<string>) => void;
24
- maxLimit?: number;
25
- }
26
- declare const UploadMultipleFile: ({ label, required, title, subTitle, dragDescription, uploadingTitle, successTitle, isSubmitting, onFileUploaded, fileUploadingStatus, onDeleteFile, maxLimit, purpose, fileTitle }: UploadMultipleFileProps) => JSX.Element;
27
- export default UploadMultipleFile;
@@ -1,147 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
13
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
14
- if (ar || !(i in from)) {
15
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
16
- ar[i] = from[i];
17
- }
18
- }
19
- return to.concat(ar || Array.prototype.slice.call(from));
20
- };
21
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
22
- import React from 'react';
23
- import { useTranslation } from 'react-i18next';
24
- import { alpha, styled, useTheme } from '@mui/material/styles';
25
- import Box from '@mui/material/Box';
26
- import { DragAndDrop } from '../../../components/FileInput';
27
- import Collapse from '../../../components/Collapse';
28
- import { InputLabelStyled } from '../../shared/Input/Input';
29
- import { ScreenContainer } from '../../shared/Containers';
30
- import Mandatory from '../../shared/Mandatory';
31
- import UploadFile, { FileStatus } from './UploadFile';
32
- var FeatureStyled = styled(ScreenContainer)(function (_a) {
33
- var theme = _a.theme;
34
- return ({
35
- marginBlockStart: theme.spacing(0)
36
- });
37
- });
38
- var LabelContainerStyled = styled(Box)(function (_a) {
39
- var theme = _a.theme;
40
- return ({
41
- display: 'flex',
42
- justifyContent: 'space-between',
43
- padding: theme.spacing(0, 2.5, 1.25, 2.5),
44
- alignItems: 'center'
45
- });
46
- });
47
- export var InputContainerStyled = styled(Box)(function () { return ({
48
- display: 'flex',
49
- width: '100%',
50
- justifyContent: 'center'
51
- }); });
52
- var UploadCountBox = styled(Box)(function (_a) {
53
- var theme = _a.theme;
54
- return ({
55
- fontSize: theme.typography.overline.fontSize,
56
- padding: theme.spacing(0.375, 0.75, 0.375, 0.75),
57
- borderRadius: theme.spacing(5.625),
58
- backgroundColor: alpha(theme.palette.secondary.main, 0.4)
59
- });
60
- });
61
- var UploadMultipleFile = function (_a) {
62
- var label = _a.label, required = _a.required, title = _a.title, subTitle = _a.subTitle, dragDescription = _a.dragDescription, uploadingTitle = _a.uploadingTitle, successTitle = _a.successTitle, isSubmitting = _a.isSubmitting, onFileUploaded = _a.onFileUploaded, fileUploadingStatus = _a.fileUploadingStatus, onDeleteFile = _a.onDeleteFile, maxLimit = _a.maxLimit, purpose = _a.purpose, fileTitle = _a.fileTitle;
63
- var t = useTranslation().t;
64
- var theme = useTheme();
65
- var _b = React.useState(''), error = _b[0], setError = _b[1];
66
- var _c = React.useState([]), fileArray = _c[0], setFileArray = _c[1];
67
- var _d = React.useState([]), fileInfoArray = _d[0], setFileInfoArray = _d[1];
68
- var uploadedFileCount = React.useMemo(function () { return (fileInfoArray || []).filter(function (file) { return file.fileId; }).length; }, [fileInfoArray]);
69
- var handleFileChange = function (files) {
70
- if (!isSubmitting) {
71
- if ((files === null || files === void 0 ? void 0 : files.length) > 0) {
72
- setError('');
73
- if (maxLimit) {
74
- if (files.length > maxLimit) {
75
- setError(t('file_exceed_max_limit', { length: maxLimit }));
76
- return;
77
- }
78
- else if ((fileInfoArray || []).filter(function (f) { return f === null || f === void 0 ? void 0 : f.fileId; }).length + files.length > maxLimit) {
79
- setError(t('file_exceed_max_limit', { length: maxLimit }));
80
- return;
81
- }
82
- }
83
- files.forEach(function (file) {
84
- fileArray.push(file);
85
- var isFileAlreadyUploaded = (fileInfoArray || []).find(function (f) { return f.name === file.name && f.status === FileStatus.SUCCESS; });
86
- if (isFileAlreadyUploaded) {
87
- fileInfoArray.push({
88
- fileId: '',
89
- status: FileStatus.ALREADY_UPLOADED,
90
- progress: 0,
91
- error: '',
92
- name: file.name
93
- });
94
- }
95
- else {
96
- fileInfoArray.push({ fileId: '', status: FileStatus.INIT, progress: 0, error: '', name: file.name });
97
- }
98
- });
99
- setFileArray(__spreadArray([], fileArray, true));
100
- setFileInfoArray(__spreadArray([], fileInfoArray, true));
101
- }
102
- }
103
- };
104
- var handleDelete = function (index) {
105
- if (!isSubmitting) {
106
- if (fileInfoArray.length > 0) {
107
- setError('');
108
- fileArray.splice(index, 1);
109
- setFileArray(__spreadArray([], fileArray, true));
110
- fileInfoArray.splice(index, 1);
111
- setFileInfoArray(__spreadArray([], fileInfoArray, true));
112
- var fileIds = fileInfoArray.filter(function (f) { return f.fileId; }).map(function (f) { return f.fileId; });
113
- onDeleteFile(fileIds);
114
- }
115
- }
116
- };
117
- var handleSuccess = function (index, file) {
118
- if (fileInfoArray.length > 0) {
119
- fileInfoArray[index] = file;
120
- setFileInfoArray(__spreadArray([], fileInfoArray, true));
121
- var fileIds = fileInfoArray.filter(function (f) { return f.fileId; }).map(function (f) { return f.fileId; });
122
- onFileUploaded(fileIds);
123
- fileUploadingStatus === null || fileUploadingStatus === void 0 ? void 0 : fileUploadingStatus(false);
124
- }
125
- };
126
- var handleFailure = function (index, file) {
127
- if (fileInfoArray.length > 0) {
128
- fileInfoArray[index] = file;
129
- setFileInfoArray(__spreadArray([], fileInfoArray, true));
130
- fileUploadingStatus === null || fileUploadingStatus === void 0 ? void 0 : fileUploadingStatus(false);
131
- }
132
- };
133
- var handleProgress = function (index, file) {
134
- if (fileInfoArray.length > 0) {
135
- fileInfoArray[index] = file;
136
- setFileInfoArray(__spreadArray([], fileInfoArray, true));
137
- fileUploadingStatus === null || fileUploadingStatus === void 0 ? void 0 : fileUploadingStatus(true);
138
- }
139
- };
140
- var fileExists = fileInfoArray.length > 0;
141
- return (_jsxs(FeatureStyled, { children: [_jsxs(LabelContainerStyled, { children: [_jsx(InputLabelStyled, { children: label }), required && _jsx(Mandatory, {}), _jsx(Collapse, __assign({ in: !!uploadedFileCount, timeout: 100, unmountOnExit: true }, { children: _jsx(UploadCountBox, { children: "".concat(uploadedFileCount, " ").concat(t('uploaded_file')) }) }))] }), _jsx(InputContainerStyled, __assign({ sx: { mb: 2.5 } }, { children: _jsx(DragAndDrop, { title: title, subTitle: subTitle, description: dragDescription, fileExists: fileExists, uploadingTitle: uploadingTitle, successTitle: successTitle, onSuccess: handleFileChange, multiple: true, error: error }) })), _jsx(Collapse, __assign({ in: fileExists, timeout: 300 }, { children: (fileArray || []).map(function (file, index) {
142
- return (_jsx(UploadFile, { purpose: purpose, title: fileTitle, uploadedFiles: fileInfoArray, index: index, file: file, sx: {
143
- borderBottom: index === fileArray.length - 1 ? "1px solid ".concat(alpha(theme.palette.divider, 0.8)) : ''
144
- }, onSuccess: handleSuccess, onDelete: handleDelete, onFailure: handleFailure, onProgress: handleProgress }, index));
145
- }) }))] }));
146
- };
147
- export default UploadMultipleFile;
@@ -1,2 +0,0 @@
1
- import UploadMultipleFile from './UploadMultipleFile';
2
- export default UploadMultipleFile;
@@ -1,2 +0,0 @@
1
- import UploadMultipleFile from './UploadMultipleFile';
2
- export default UploadMultipleFile;