@tap-payments/auth-jsconnect 2.1.41-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 (52) hide show
  1. package/build/@types/app.d.ts +0 -4
  2. package/build/@types/form.d.ts +6 -3
  3. package/build/api/entity.d.ts +8 -0
  4. package/build/api/entity.js +15 -0
  5. package/build/api/index.d.ts +2 -6
  6. package/build/api/index.js +1 -3
  7. package/build/api/lead.d.ts +0 -4
  8. package/build/assets/locales/ar.json +1 -5
  9. package/build/assets/locales/en.json +1 -7
  10. package/build/components/FileInput/DragAndDrop.js +1 -1
  11. package/build/components/ProgressBar/CircularProgressBar.d.ts +1 -3
  12. package/build/components/ProgressBar/CircularProgressBar.js +2 -2
  13. package/build/constants/assets.d.ts +0 -1
  14. package/build/constants/assets.js +0 -1
  15. package/build/constants/validation.d.ts +0 -1
  16. package/build/constants/validation.js +0 -1
  17. package/build/features/app/bank/bankStore.js +1 -1
  18. package/build/features/app/business/businessStore.d.ts +9 -7
  19. package/build/features/app/business/businessStore.js +67 -29
  20. package/build/features/app/connect/connectStore.d.ts +1 -1
  21. package/build/features/app/connect/connectStore.js +29 -66
  22. package/build/features/app/individual/individualStore.d.ts +16 -4
  23. package/build/features/app/individual/individualStore.js +89 -11
  24. package/build/features/business/screens/BusinessType/Article.js +13 -10
  25. package/build/features/business/screens/BusinessType/BusinessType.js +4 -2
  26. package/build/features/business/screens/BusinessType/LicenseCertificate.js +50 -12
  27. package/build/features/business/screens/BusinessType/validation.d.ts +6 -3
  28. package/build/features/business/screens/BusinessType/validation.js +11 -1
  29. package/build/features/connect/screens/Merchant/BrandList.js +2 -15
  30. package/build/features/connect/screens/Merchant/Merchant.js +5 -24
  31. package/build/features/connect/screens/Merchant/validation.d.ts +0 -6
  32. package/build/features/connect/screens/Merchant/validation.js +1 -5
  33. package/build/features/individual/screens/AdditionalIndividualInfo/AdditionalIndividualInfo.js +4 -18
  34. package/build/features/individual/screens/AdditionalIndividualInfo/CivilIDFile.js +62 -11
  35. package/build/features/individual/screens/AdditionalIndividualInfo/SignatureFile.js +59 -11
  36. package/build/features/individual/screens/AdditionalIndividualInfo/validation.d.ts +12 -6
  37. package/build/features/individual/screens/AdditionalIndividualInfo/validation.js +23 -2
  38. package/build/features/shared/UploadFile/UploadFile.js +1 -1
  39. package/build/theme/typography.js +1 -1
  40. package/package.json +1 -1
  41. package/build/api/file.d.ts +0 -13
  42. package/build/api/file.js +0 -24
  43. package/build/features/connect/screens/Merchant/Segments.d.ts +0 -8
  44. package/build/features/connect/screens/Merchant/Segments.js +0 -79
  45. package/build/features/connect/screens/Merchant/TeamSize.d.ts +0 -8
  46. package/build/features/connect/screens/Merchant/TeamSize.js +0 -79
  47. package/build/features/shared/UploadMultipleFile/UploadFile.d.ts +0 -38
  48. package/build/features/shared/UploadMultipleFile/UploadFile.js +0 -184
  49. package/build/features/shared/UploadMultipleFile/UploadMultipleFile.d.ts +0 -27
  50. package/build/features/shared/UploadMultipleFile/UploadMultipleFile.js +0 -147
  51. package/build/features/shared/UploadMultipleFile/index.d.ts +0 -2
  52. package/build/features/shared/UploadMultipleFile/index.js +0 -2
@@ -1,79 +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 { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
13
- import { connectSelector } from '../../../app/connect/connectStore';
14
- import Collapse from '../../../../components/Collapse';
15
- import { ScreenContainer } from '../../../../features/shared/Containers';
16
- import Input from '../../../../features/shared/Input';
17
- import { useAppSelector, useLanguage } from '../../../../hooks';
18
- import React from 'react';
19
- import { useTranslation } from 'react-i18next';
20
- import { useController, useFormContext } from 'react-hook-form';
21
- import Search from '../../../../features/shared/Search';
22
- import SimpleList from '../../../../components/SimpleList';
23
- import ExpandIcon from '../../../../components/ExpandIcon';
24
- import Container from '@mui/material/Container';
25
- import { styled } from '@mui/material/styles';
26
- import Text from '../../../../components/Text';
27
- import CheckIcon from '@mui/icons-material/Check';
28
- var IncomeText = styled(Text, { shouldForwardProp: function (prop) { return prop !== 'isSelected'; } })(function (_a) {
29
- var theme = _a.theme, isSelected = _a.isSelected;
30
- return (__assign(__assign({ color: theme.palette.text.primary }, theme.typography.body2), { fontWeight: isSelected ? theme.typography.fontWeightMedium : theme.typography.fontWeightLight, paddingInlineStart: theme.spacing(1.25), textAlign: 'start' }));
31
- });
32
- var CheckIconStyled = styled(CheckIcon)(function (_a) {
33
- var theme = _a.theme;
34
- return ({
35
- color: theme.palette.success.main,
36
- display: 'flex',
37
- alignItems: 'flex-end'
38
- });
39
- });
40
- var Segments = function (_a) {
41
- var _b, _c, _d, _e;
42
- var show = _a.show, onListOpen = _a.onListOpen, onListClose = _a.onListClose;
43
- var _f = React.useState([]), segmentList = _f[0], setSegmentList = _f[1];
44
- var _g = React.useState(null), anchorEl = _g[0], setAnchorEl = _g[1];
45
- var t = useTranslation().t;
46
- var isAr = useLanguage().isAr;
47
- var data = useAppSelector(connectSelector).data;
48
- var control = useFormContext().control;
49
- var segmentsList = ((_b = data.individualData.responseBody) === null || _b === void 0 ? void 0 : _b.segments_list) || [];
50
- var segmentControl = useController({ control: control, name: 'segment' });
51
- var segment = segmentControl.field.value;
52
- var error = (_c = segmentControl.fieldState.error) === null || _c === void 0 ? void 0 : _c.message;
53
- React.useEffect(function () {
54
- if ((segmentsList === null || segmentsList === void 0 ? void 0 : segmentsList.length) > 0) {
55
- setSegmentList(segmentsList);
56
- }
57
- }, [segmentsList]);
58
- var onOpenList = function (event) {
59
- setAnchorEl(event.currentTarget);
60
- onListOpen === null || onListOpen === void 0 ? void 0 : onListOpen();
61
- };
62
- var onCloseList = function () {
63
- setAnchorEl(null);
64
- onListClose === null || onListClose === void 0 ? void 0 : onListClose();
65
- };
66
- var onSelectItem = function (segment) {
67
- onCloseList();
68
- segmentControl.field.onChange(segment);
69
- };
70
- var handleSearch = function (value) {
71
- var filteredList = segmentsList === null || segmentsList === void 0 ? void 0 : segmentsList.filter(function (segment) { var _a, _b; return ((_a = segment === null || segment === void 0 ? void 0 : segment.name) === null || _a === void 0 ? void 0 : _a.en.toLowerCase().includes(value.toLowerCase())) || ((_b = segment === null || segment === void 0 ? void 0 : segment.name) === null || _b === void 0 ? void 0 : _b.ar.toLowerCase().includes(value.toLowerCase())); });
72
- setSegmentList(filteredList);
73
- };
74
- return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, __assign({ sx: { mt: 2.5, mb: 0 } }, { children: [_jsx(Input, { required: true, label: t('segment_title'), readOnly: true, onClick: !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }), placeholder: t('choose_any_segment'), value: (isAr ? (_d = segment === null || segment === void 0 ? void 0 : segment.name) === null || _d === void 0 ? void 0 : _d.ar : (_e = segment === null || segment === void 0 ? void 0 : segment.name) === null || _e === void 0 ? void 0 : _e.en) || '', warningMessage: error && t(error) }), _jsxs(Collapse, __assign({ in: !!anchorEl }, { children: [_jsx(Search, { onSearchValue: handleSearch }), _jsx(SimpleList, { searchKeyPath: 'name.en', searchValuePath: ['name.en', 'name.ar'], list: segmentList, onSelectItem: onSelectItem, renderItem: function (item) {
75
- var _a, _b;
76
- return (_jsxs(_Fragment, { children: [_jsx(Container, { children: _jsx(IncomeText, __assign({ isSelected: item.id === (segment === null || segment === void 0 ? void 0 : segment.id) }, { children: isAr ? (_a = item === null || item === void 0 ? void 0 : item.name) === null || _a === void 0 ? void 0 : _a.ar : (_b = item === null || item === void 0 ? void 0 : item.name) === null || _b === void 0 ? void 0 : _b.en })) }), item.id === (segment === null || segment === void 0 ? void 0 : segment.id) && _jsx(CheckIconStyled, {})] }));
77
- } })] }))] })) })));
78
- };
79
- export default Segments;
@@ -1,8 +0,0 @@
1
- /// <reference types="react" />
2
- interface TeamSizeProps {
3
- show: boolean;
4
- onListOpen?: () => void;
5
- onListClose?: () => void;
6
- }
7
- declare const TeamSize: ({ show, onListOpen, onListClose }: TeamSizeProps) => JSX.Element;
8
- export default TeamSize;
@@ -1,79 +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 { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
13
- import { connectSelector } from '../../../app/connect/connectStore';
14
- import Collapse from '../../../../components/Collapse';
15
- import { ScreenContainer } from '../../../../features/shared/Containers';
16
- import Input from '../../../../features/shared/Input';
17
- import { useAppSelector, useLanguage } from '../../../../hooks';
18
- import React from 'react';
19
- import { useTranslation } from 'react-i18next';
20
- import { useController, useFormContext } from 'react-hook-form';
21
- import Search from '../../../../features/shared/Search';
22
- import SimpleList from '../../../../components/SimpleList';
23
- import ExpandIcon from '../../../../components/ExpandIcon';
24
- import Container from '@mui/material/Container';
25
- import { styled } from '@mui/material/styles';
26
- import Text from '../../../../components/Text';
27
- import CheckIcon from '@mui/icons-material/Check';
28
- var IncomeText = styled(Text, { shouldForwardProp: function (prop) { return prop !== 'isSelected'; } })(function (_a) {
29
- var theme = _a.theme, isSelected = _a.isSelected;
30
- return (__assign(__assign({ color: theme.palette.text.primary }, theme.typography.body2), { fontWeight: isSelected ? theme.typography.fontWeightMedium : theme.typography.fontWeightLight, paddingInlineStart: theme.spacing(1.25), textAlign: 'start' }));
31
- });
32
- var CheckIconStyled = styled(CheckIcon)(function (_a) {
33
- var theme = _a.theme;
34
- return ({
35
- color: theme.palette.success.main,
36
- display: 'flex',
37
- alignItems: 'flex-end'
38
- });
39
- });
40
- var TeamSize = function (_a) {
41
- var _b, _c, _d, _e;
42
- var show = _a.show, onListOpen = _a.onListOpen, onListClose = _a.onListClose;
43
- var _f = React.useState([]), teamSizeList = _f[0], setTeamSizeList = _f[1];
44
- var _g = React.useState(null), anchorEl = _g[0], setAnchorEl = _g[1];
45
- var t = useTranslation().t;
46
- var isAr = useLanguage().isAr;
47
- var data = useAppSelector(connectSelector).data;
48
- var control = useFormContext().control;
49
- var teamSizesList = ((_b = data.individualData.responseBody) === null || _b === void 0 ? void 0 : _b.team_size_list) || [];
50
- var teamSizeControl = useController({ control: control, name: 'teamSize' });
51
- var teamSize = teamSizeControl.field.value;
52
- var error = (_c = teamSizeControl.fieldState.error) === null || _c === void 0 ? void 0 : _c.message;
53
- React.useEffect(function () {
54
- if ((teamSizesList === null || teamSizesList === void 0 ? void 0 : teamSizesList.length) > 0) {
55
- setTeamSizeList(teamSizesList);
56
- }
57
- }, [teamSizesList]);
58
- var onOpenList = function (event) {
59
- setAnchorEl(event.currentTarget);
60
- onListOpen === null || onListOpen === void 0 ? void 0 : onListOpen();
61
- };
62
- var onCloseList = function () {
63
- setAnchorEl(null);
64
- onListClose === null || onListClose === void 0 ? void 0 : onListClose();
65
- };
66
- var onSelectItem = function (teamSize) {
67
- onCloseList();
68
- teamSizeControl.field.onChange(teamSize);
69
- };
70
- var handleSearch = function (value) {
71
- var filteredList = teamSizesList === null || teamSizesList === void 0 ? void 0 : teamSizesList.filter(function (teamSize) { var _a, _b; return ((_a = teamSize === null || teamSize === void 0 ? void 0 : teamSize.name) === null || _a === void 0 ? void 0 : _a.en.toLowerCase().includes(value.toLowerCase())) || ((_b = teamSize === null || teamSize === void 0 ? void 0 : teamSize.name) === null || _b === void 0 ? void 0 : _b.ar.toLowerCase().includes(value.toLowerCase())); });
72
- setTeamSizeList(filteredList);
73
- };
74
- return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, __assign({ sx: { mt: 2.5, mb: 0 } }, { children: [_jsx(Input, { required: true, label: t('team_size_title'), readOnly: true, onClick: !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }), placeholder: t('choose_team_size'), value: (isAr ? (_d = teamSize === null || teamSize === void 0 ? void 0 : teamSize.name) === null || _d === void 0 ? void 0 : _d.ar : (_e = teamSize === null || teamSize === void 0 ? void 0 : teamSize.name) === null || _e === void 0 ? void 0 : _e.en) || '', warningMessage: error && t(error) }), _jsxs(Collapse, __assign({ in: !!anchorEl }, { children: [_jsx(Search, { onSearchValue: handleSearch }), _jsx(SimpleList, { searchKeyPath: 'name.en', searchValuePath: ['name.en', 'name.ar'], list: teamSizeList, onSelectItem: onSelectItem, renderItem: function (item) {
75
- var _a, _b;
76
- return (_jsxs(_Fragment, { children: [_jsx(Container, { children: _jsx(IncomeText, __assign({ isSelected: item.id === (teamSize === null || teamSize === void 0 ? void 0 : teamSize.id) }, { children: isAr ? (_a = item === null || item === void 0 ? void 0 : item.name) === null || _a === void 0 ? void 0 : _a.ar : (_b = item === null || item === void 0 ? void 0 : item.name) === null || _b === void 0 ? void 0 : _b.en })) }), item.id === (teamSize === null || teamSize === void 0 ? void 0 : teamSize.id) && _jsx(CheckIconStyled, {})] }));
77
- } })] }))] })) })));
78
- };
79
- export default TeamSize;
@@ -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;