@tap-payments/auth-jsconnect 2.1.24-test → 2.1.26-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.
- package/build/@types/app.d.ts +17 -1
- package/build/@types/app.js +1 -0
- package/build/@types/form.d.ts +13 -2
- package/build/api/data.d.ts +8 -0
- package/build/api/data.js +16 -0
- package/build/api/entity.d.ts +2 -2
- package/build/api/index.d.ts +6 -0
- package/build/api/individual.d.ts +4 -0
- package/build/app/rootReducer.d.ts +1 -0
- package/build/app/rootReducer.js +3 -1
- package/build/app/store.d.ts +2 -0
- package/build/constants/api.d.ts +2 -0
- package/build/constants/api.js +5 -1
- package/build/constants/app.d.ts +7 -0
- package/build/constants/app.js +44 -0
- package/build/features/app/brand/brandStore.d.ts +97 -0
- package/build/features/app/brand/brandStore.js +618 -0
- package/build/features/app/entity/entityStore.js +52 -30
- package/build/features/brand/Brand.d.ts +7 -0
- package/build/features/brand/Brand.js +69 -0
- package/build/features/brand/index.d.ts +1 -0
- package/build/features/brand/index.js +1 -0
- package/build/features/brand/screens/BrandActivities/ActivitiesList.d.ts +91 -0
- package/build/features/brand/screens/BrandActivities/ActivitiesList.js +168 -0
- package/build/features/brand/screens/BrandActivities/BrandActivities.d.ts +5 -0
- package/build/features/brand/screens/BrandActivities/BrandActivities.js +72 -0
- package/build/features/brand/screens/BrandActivities/CustomerBase.d.ts +82 -0
- package/build/features/brand/screens/BrandActivities/CustomerBase.js +144 -0
- package/build/features/brand/screens/BrandActivities/ExpectedCustomers.d.ts +8 -0
- package/build/features/brand/screens/BrandActivities/ExpectedCustomers.js +98 -0
- package/build/features/brand/screens/BrandActivities/ExpectedSalesRange.d.ts +8 -0
- package/build/features/brand/screens/BrandActivities/ExpectedSalesRange.js +127 -0
- package/build/features/brand/screens/BrandActivities/OperationStartDate.d.ts +20 -0
- package/build/features/brand/screens/BrandActivities/OperationStartDate.js +45 -0
- package/build/features/brand/screens/BrandActivities/RefundPolicy.d.ts +36 -0
- package/build/features/brand/screens/BrandActivities/RefundPolicy.js +84 -0
- package/build/features/brand/screens/BrandActivities/TAC.d.ts +6 -0
- package/build/features/brand/screens/BrandActivities/TAC.js +87 -0
- package/build/features/brand/screens/BrandActivities/TransactionPolicy.d.ts +3 -0
- package/build/features/brand/screens/BrandActivities/TransactionPolicy.js +44 -0
- package/build/features/brand/screens/BrandActivities/index.d.ts +2 -0
- package/build/features/brand/screens/BrandActivities/index.js +2 -0
- package/build/features/brand/screens/BrandActivities/validation.d.ts +71 -0
- package/build/features/brand/screens/BrandActivities/validation.js +21 -0
- package/build/features/brand/screens/BrandInfo/BrandInfo.d.ts +5 -0
- package/build/features/brand/screens/BrandInfo/BrandInfo.js +72 -0
- package/build/features/brand/screens/BrandInfo/BrandName.d.ts +8 -0
- package/build/features/brand/screens/BrandInfo/BrandName.js +142 -0
- package/build/features/brand/screens/BrandInfo/SalesChannels.d.ts +5 -0
- package/build/features/brand/screens/BrandInfo/SalesChannels.js +30 -0
- package/build/features/brand/screens/BrandInfo/Segments.d.ts +8 -0
- package/build/features/brand/screens/BrandInfo/Segments.js +83 -0
- package/build/features/brand/screens/BrandInfo/TeamSize.d.ts +8 -0
- package/build/features/brand/screens/BrandInfo/TeamSize.js +83 -0
- package/build/features/brand/screens/BrandInfo/index.d.ts +2 -0
- package/build/features/brand/screens/BrandInfo/index.js +2 -0
- package/build/features/brand/screens/BrandInfo/validation.d.ts +41 -0
- package/build/features/brand/screens/BrandInfo/validation.js +106 -0
- package/build/features/brand/screens/ResetPasswordSuccess/ResetPasswordSuccess.d.ts +5 -0
- package/build/features/brand/screens/ResetPasswordSuccess/ResetPasswordSuccess.js +9 -0
- package/build/features/brand/screens/ResetPasswordSuccess/index.d.ts +3 -0
- package/build/features/brand/screens/ResetPasswordSuccess/index.js +2 -0
- package/build/features/brand/screens/Success/Success.d.ts +5 -0
- package/build/features/brand/screens/Success/Success.js +20 -0
- package/build/features/brand/screens/Success/index.d.ts +3 -0
- package/build/features/brand/screens/Success/index.js +2 -0
- package/build/features/brand/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.d.ts +3 -0
- package/build/features/brand/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +117 -0
- package/build/features/brand/screens/SuccessWithFlowButtons/index.d.ts +2 -0
- package/build/features/brand/screens/SuccessWithFlowButtons/index.js +2 -0
- package/build/features/brand/screens/Verify/OTPInput.d.ts +7 -0
- package/build/features/brand/screens/Verify/OTPInput.js +47 -0
- package/build/features/brand/screens/Verify/Verify.d.ts +5 -0
- package/build/features/brand/screens/Verify/Verify.js +91 -0
- package/build/features/brand/screens/Verify/index.d.ts +2 -0
- package/build/features/brand/screens/Verify/index.js +2 -0
- package/build/features/brand/screens/Verify/validation.d.ts +8 -0
- package/build/features/brand/screens/Verify/validation.js +4 -0
- package/build/features/business/screens/Activities/ActivitiesList.d.ts +1 -1
- package/build/features/business/screens/Customers/CustomerLocations.d.ts +1 -1
- package/build/features/connect/screens/Merchant/validation.js +2 -2
- package/build/features/entity/screens/EntityCapital/ActivityList.d.ts +1 -1
- package/build/features/entity/screens/EntityCapital/ActivityList.js +4 -1
- package/build/features/entity/screens/EntityName/EntityTypeList.d.ts +1 -1
- package/build/features/entity/screens/EntityName/EntityTypeList.js +3 -3
- package/build/features/featuresScreens.d.ts +1 -0
- package/build/features/featuresScreens.js +29 -0
- package/build/features/shared/Address/CountryList.d.ts +1 -1
- package/build/features/shared/Address/InputSelect.d.ts +1 -1
- package/build/features/shared/Input/Input.d.ts +1 -1
- package/build/hooks/useAppDispatch.d.ts +1 -0
- package/build/index.d.ts +3 -2
- package/build/index.js +4 -1
- package/package.json +1 -1
|
@@ -0,0 +1,72 @@
|
|
|
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, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { ScreenContainer } from '../../../../features/shared/Containers';
|
|
14
|
+
import React from 'react';
|
|
15
|
+
import { FormProvider, useForm } from 'react-hook-form';
|
|
16
|
+
import Form from '../../../../components/Form';
|
|
17
|
+
import { styled } from '@mui/material/styles';
|
|
18
|
+
import { useAppDispatch, useAppSelector, useLanguage, useSetFromDefaultValues } from '../../../../hooks';
|
|
19
|
+
import { yupResolver } from '@hookform/resolvers/yup';
|
|
20
|
+
import { BrandValidationSchema } from './validation';
|
|
21
|
+
import Button from '../../../shared/Button';
|
|
22
|
+
import { clearError, brandSelector, updateBrand } from '../../../app/brand/brandStore';
|
|
23
|
+
import { useTranslation } from 'react-i18next';
|
|
24
|
+
import BrandName from './BrandName';
|
|
25
|
+
import Segments from './Segments';
|
|
26
|
+
import SalesChannels from './SalesChannels';
|
|
27
|
+
import TeamSize from '../../../../features/brand/screens/BrandInfo/TeamSize';
|
|
28
|
+
import Collapse from '../../../../components/Collapse';
|
|
29
|
+
var FormStyled = styled(Form)(function () { return ({
|
|
30
|
+
display: 'flex',
|
|
31
|
+
flexDirection: 'column'
|
|
32
|
+
}); });
|
|
33
|
+
var BrandInfo = function (_a) {
|
|
34
|
+
var _b = React.useState(), listActive = _b[0], setListActive = _b[1];
|
|
35
|
+
var _c = React.useState(false), brandNameChecking = _c[0], setBrandNameChecking = _c[1];
|
|
36
|
+
var dispatch = useAppDispatch();
|
|
37
|
+
var _d = useAppSelector(brandSelector), data = _d.data, loading = _d.loading, error = _d.error;
|
|
38
|
+
var responseBody = data.brandData.responseBody;
|
|
39
|
+
var methods = useForm({
|
|
40
|
+
resolver: yupResolver(BrandValidationSchema),
|
|
41
|
+
defaultValues: data.brandData,
|
|
42
|
+
mode: 'onChange'
|
|
43
|
+
});
|
|
44
|
+
useSetFromDefaultValues(methods, data.brandData);
|
|
45
|
+
var onSubmit = function (data) {
|
|
46
|
+
dispatch(updateBrand(data));
|
|
47
|
+
};
|
|
48
|
+
var ListType;
|
|
49
|
+
(function (ListType) {
|
|
50
|
+
ListType["SegmentsList"] = "SegmentsList";
|
|
51
|
+
ListType["TeamSizeList"] = "TeamSizeList";
|
|
52
|
+
})(ListType || (ListType = {}));
|
|
53
|
+
React.useEffect(function () {
|
|
54
|
+
if (error)
|
|
55
|
+
dispatch(clearError());
|
|
56
|
+
}, [methods.formState.isValid]);
|
|
57
|
+
React.useEffect(function () {
|
|
58
|
+
if ((responseBody === null || responseBody === void 0 ? void 0 : responseBody.response_code) === '5')
|
|
59
|
+
methods.setError('brandName', { message: 'brand_name_already_exist' });
|
|
60
|
+
}, [responseBody]);
|
|
61
|
+
var t = useTranslation().t;
|
|
62
|
+
var isAr = useLanguage().isAr;
|
|
63
|
+
var brandErrChecks = !methods.formState.isValid || !!methods.formState.errors.brandName || !!error;
|
|
64
|
+
var disabled = brandErrChecks || brandNameChecking;
|
|
65
|
+
var handleMenuClick = function (flag) {
|
|
66
|
+
setListActive(flag);
|
|
67
|
+
};
|
|
68
|
+
var isSegmentsListActive = listActive === ListType.SegmentsList;
|
|
69
|
+
var isTeamSizeListActive = listActive === ListType.TeamSizeList;
|
|
70
|
+
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(BrandName, { show: !listActive, brandNameChecking: brandNameChecking, fetchingBrandName: setBrandNameChecking }), _jsx(Segments, { show: !isTeamSizeListActive, onListOpen: function () { return handleMenuClick(ListType.SegmentsList); }, onListClose: function () { return handleMenuClick(); } }), _jsx(TeamSize, { show: !isSegmentsListActive, onListOpen: function () { return handleMenuClick(ListType.TeamSizeList); }, onListClose: function () { return handleMenuClick(); } }), _jsxs(Collapse, __assign({ in: !listActive }, { children: [_jsx(SalesChannels, {}), _jsx(Button, __assign({ disableBack: true, disabled: disabled, isAr: isAr, error: t(error || ''), loading: loading }, { children: t('next') }))] }))] })) })) }));
|
|
71
|
+
};
|
|
72
|
+
export default BrandInfo;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
interface BrandNameProps {
|
|
3
|
+
show: boolean;
|
|
4
|
+
fetchingBrandName: (flag: boolean) => void;
|
|
5
|
+
brandNameChecking: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare const _default: React.MemoExoticComponent<({ show, brandNameChecking, fetchingBrandName }: BrandNameProps) => JSX.Element>;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,142 @@
|
|
|
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 } from "react/jsx-runtime";
|
|
49
|
+
import * as React from 'react';
|
|
50
|
+
import { useTranslation } from 'react-i18next';
|
|
51
|
+
import { useController, useFormContext } from 'react-hook-form';
|
|
52
|
+
import Box from '@mui/material/Box';
|
|
53
|
+
import axios from 'axios';
|
|
54
|
+
import { styled, alpha } from '@mui/material/styles';
|
|
55
|
+
import InfoIcon from '@mui/icons-material/Info';
|
|
56
|
+
import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined';
|
|
57
|
+
import { ScreenContainer } from '../../../shared/Containers';
|
|
58
|
+
import CircularProgress from '@mui/material/CircularProgress';
|
|
59
|
+
import Text from '../../../../components/Text';
|
|
60
|
+
import Input from '../../../shared/Input';
|
|
61
|
+
import ClearIcon from '../../../shared/ClearIcon';
|
|
62
|
+
import Tooltip from '../../../../components/Tooltip';
|
|
63
|
+
import Collapse from '../../../../components/Collapse';
|
|
64
|
+
import { removeAllOtherThanCharsNumbersAndSpace } from '../../../../utils';
|
|
65
|
+
import CheckIcon from '../../../shared/CheckIcon';
|
|
66
|
+
import { checkBrandNameAvailability, brandSelector } from '../../../app/brand/brandStore';
|
|
67
|
+
import { useAppDispatch, useAppSelector } from '../../../../hooks';
|
|
68
|
+
import { debounce } from 'lodash-es';
|
|
69
|
+
var LabelContainerStyled = styled(Box)(function (_a) {
|
|
70
|
+
var theme = _a.theme;
|
|
71
|
+
return ({
|
|
72
|
+
display: 'flex',
|
|
73
|
+
justifyContent: 'space-between',
|
|
74
|
+
padding: theme.spacing(0, 2.5, 1, 2.5)
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
var InputLabelStyled = styled(Text)(function (_a) {
|
|
78
|
+
var theme = _a.theme;
|
|
79
|
+
return (__assign(__assign({ color: alpha(theme.palette.text.primary, 0.6), fontWeight: theme.typography.fontWeightMedium }, theme.typography.caption), { lineHeight: theme.spacing(2.5) }));
|
|
80
|
+
});
|
|
81
|
+
var InfoOutlinedIconStyled = styled(InfoOutlinedIcon)(function (_a) {
|
|
82
|
+
var theme = _a.theme;
|
|
83
|
+
return ({
|
|
84
|
+
width: theme.spacing(2.75),
|
|
85
|
+
height: theme.spacing(2.125),
|
|
86
|
+
cursor: 'pointer',
|
|
87
|
+
color: alpha(theme.palette.text.primary, 0.4)
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
var InfoIconStyled = styled(InfoIcon)(function (_a) {
|
|
91
|
+
var theme = _a.theme;
|
|
92
|
+
return ({
|
|
93
|
+
width: theme.spacing(2.75),
|
|
94
|
+
height: theme.spacing(2.125),
|
|
95
|
+
cursor: 'pointer',
|
|
96
|
+
color: alpha(theme.palette.text.primary, 0.4)
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
var cancelToken = null;
|
|
100
|
+
var BrandName = function (_a) {
|
|
101
|
+
var _b;
|
|
102
|
+
var show = _a.show, brandNameChecking = _a.brandNameChecking, fetchingBrandName = _a.fetchingBrandName;
|
|
103
|
+
var dispatch = useAppDispatch();
|
|
104
|
+
var _c = React.useState(false), isHovered = _c[0], setIsHovered = _c[1];
|
|
105
|
+
var t = useTranslation().t;
|
|
106
|
+
var data = useAppSelector(brandSelector).data;
|
|
107
|
+
var control = useFormContext().control;
|
|
108
|
+
var brandControl = useController({ control: control, name: 'brandName' });
|
|
109
|
+
var brandNameValue = brandControl.field.value;
|
|
110
|
+
var error = (_b = brandControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
|
|
111
|
+
var checkBrand = debounce(function (value) { return __awaiter(void 0, void 0, void 0, function () {
|
|
112
|
+
var onSuccess;
|
|
113
|
+
return __generator(this, function (_a) {
|
|
114
|
+
if (cancelToken) {
|
|
115
|
+
cancelToken.cancel('Aborted');
|
|
116
|
+
}
|
|
117
|
+
cancelToken = axios.CancelToken.source();
|
|
118
|
+
onSuccess = function () { return fetchingBrandName(false); };
|
|
119
|
+
dispatch(checkBrandNameAvailability({ name: value, cancelToken: cancelToken.token, onSuccess: onSuccess }));
|
|
120
|
+
return [2];
|
|
121
|
+
});
|
|
122
|
+
}); }, 500);
|
|
123
|
+
var handleBrandNameChange = function (_a) {
|
|
124
|
+
var target = _a.target;
|
|
125
|
+
var value = removeAllOtherThanCharsNumbersAndSpace(target.value);
|
|
126
|
+
brandControl.field.onChange(value);
|
|
127
|
+
};
|
|
128
|
+
React.useEffect(function () {
|
|
129
|
+
var _a, _b, _c;
|
|
130
|
+
var isValid = brandNameValue && !error && brandNameValue.length > 2;
|
|
131
|
+
var brand = (_c = (_b = (_a = data.verify.responseBody) === null || _a === void 0 ? void 0 : _a.brand) === null || _b === void 0 ? void 0 : _b.name) === null || _c === void 0 ? void 0 : _c.en;
|
|
132
|
+
if (isValid && (brandNameValue === null || brandNameValue === void 0 ? void 0 : brandNameValue.toLowerCase()) != brand) {
|
|
133
|
+
fetchingBrandName(true);
|
|
134
|
+
checkBrand(brandNameValue);
|
|
135
|
+
}
|
|
136
|
+
}, [brandNameValue, error]);
|
|
137
|
+
var clearBrandName = function () {
|
|
138
|
+
brandControl.field.onChange('');
|
|
139
|
+
};
|
|
140
|
+
return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, __assign({ sx: { mt: 2.5, mb: 0 } }, { children: [_jsxs(LabelContainerStyled, { children: [_jsx(InputLabelStyled, { children: t('signup_brand_name_label') }), _jsx(Tooltip, __assign({ title: t('brand_name_hint'), onMouseOver: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); }, onTouchStartCapture: function () { return setIsHovered(true); } }, { children: isHovered ? _jsx(InfoIconStyled, {}) : _jsx(InfoOutlinedIconStyled, {}) }))] }), _jsx(Input, { onChange: handleBrandNameChange, value: brandNameValue || '', placeholder: t('signup_brand_name_placeholder'), warningType: 'alert', warningMessage: error && t(error), endAdornment: brandNameChecking ? (_jsx(CircularProgress, { size: 25, thickness: 5, sx: { height: 'auto !important' } })) : !error && brandNameValue ? (_jsx(CheckIcon, {})) : (brandNameValue && _jsx(ClearIcon, { onClick: clearBrandName })) })] })) })));
|
|
141
|
+
};
|
|
142
|
+
export default React.memo(BrandName);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useController, useFormContext } from 'react-hook-form';
|
|
4
|
+
import { useAppSelector, useAppDispatch } from '../../../../hooks';
|
|
5
|
+
import { brandSelector, clearError } from '../../../app/brand/brandStore';
|
|
6
|
+
import { mapSalesChannel } from '../../../../utils';
|
|
7
|
+
import SalesChannel from '../../../shared/SalesChannels';
|
|
8
|
+
var SalesChannels = function (_a) {
|
|
9
|
+
var _b;
|
|
10
|
+
var _c = useFormContext(), control = _c.control, setValue = _c.setValue;
|
|
11
|
+
var dispatch = useAppDispatch();
|
|
12
|
+
var _d = useController({ control: control, name: 'salesChannels' }), fieldState = _d.fieldState, field = _d.field;
|
|
13
|
+
var _e = useAppSelector(brandSelector), data = _e.data, error = _e.error;
|
|
14
|
+
var responseBody = data.verify.responseBody;
|
|
15
|
+
var _f = responseBody || {}, channelList = _f.channel_list, defaultSalesChannels = _f.salesChannels;
|
|
16
|
+
React.useEffect(function () {
|
|
17
|
+
if ((defaultSalesChannels === null || defaultSalesChannels === void 0 ? void 0 : defaultSalesChannels.length) > 0) {
|
|
18
|
+
var sales = mapSalesChannel(defaultSalesChannels);
|
|
19
|
+
field.onChange(sales);
|
|
20
|
+
}
|
|
21
|
+
}, [defaultSalesChannels]);
|
|
22
|
+
var selectedSalesChannels = React.useMemo(function () { return mapSalesChannel(field.value); }, [(field.value || []).length]);
|
|
23
|
+
var onChange = function (channels) {
|
|
24
|
+
if (error)
|
|
25
|
+
dispatch(clearError());
|
|
26
|
+
field.onChange(channels);
|
|
27
|
+
};
|
|
28
|
+
return (_jsx(_Fragment, { children: _jsx(SalesChannel, { error: (_b = fieldState.error) === null || _b === void 0 ? void 0 : _b.message, list: channelList, onChange: onChange, defaultValues: selectedSalesChannels }) }));
|
|
29
|
+
};
|
|
30
|
+
export default SalesChannels;
|
|
@@ -0,0 +1,83 @@
|
|
|
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 Collapse from '../../../../components/Collapse';
|
|
14
|
+
import { ScreenContainer } from '../../../../features/shared/Containers';
|
|
15
|
+
import Input from '../../../../features/shared/Input';
|
|
16
|
+
import { useAppSelector, useLanguage } from '../../../../hooks';
|
|
17
|
+
import React from 'react';
|
|
18
|
+
import { useTranslation } from 'react-i18next';
|
|
19
|
+
import { useController, useFormContext } from 'react-hook-form';
|
|
20
|
+
import { brandSelector } from '../../../../features/app/brand/brandStore';
|
|
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) }));
|
|
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(brandSelector).data;
|
|
48
|
+
var control = useFormContext().control;
|
|
49
|
+
var segmentsList = ((_b = data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.segmentsList) || [];
|
|
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) {
|
|
72
|
+
var _a, _b;
|
|
73
|
+
return ((_a = segment === null || segment === void 0 ? void 0 : segment.name) === null || _a === void 0 ? void 0 : _a.en.toLowerCase().includes(value.toLowerCase())) ||
|
|
74
|
+
((_b = segment === null || segment === void 0 ? void 0 : segment.name) === null || _b === void 0 ? void 0 : _b.ar.toLowerCase().includes(value.toLowerCase()));
|
|
75
|
+
});
|
|
76
|
+
setSegmentList(filteredList);
|
|
77
|
+
};
|
|
78
|
+
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', list: segmentList, onSelectItem: onSelectItem, renderItem: function (item) {
|
|
79
|
+
var _a, _b;
|
|
80
|
+
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, {})] }));
|
|
81
|
+
} })] }))] })) })));
|
|
82
|
+
};
|
|
83
|
+
export default Segments;
|
|
@@ -0,0 +1,83 @@
|
|
|
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 Collapse from '../../../../components/Collapse';
|
|
14
|
+
import { ScreenContainer } from '../../../../features/shared/Containers';
|
|
15
|
+
import Input from '../../../../features/shared/Input';
|
|
16
|
+
import { useAppSelector, useLanguage } from '../../../../hooks';
|
|
17
|
+
import React from 'react';
|
|
18
|
+
import { useTranslation } from 'react-i18next';
|
|
19
|
+
import { useController, useFormContext } from 'react-hook-form';
|
|
20
|
+
import { brandSelector } from '../../../../features/app/brand/brandStore';
|
|
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) }));
|
|
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(brandSelector).data;
|
|
48
|
+
var control = useFormContext().control;
|
|
49
|
+
var teamSizesList = ((_b = data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.teamSizeList) || [];
|
|
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) {
|
|
72
|
+
var _a, _b;
|
|
73
|
+
return ((_a = teamSize === null || teamSize === void 0 ? void 0 : teamSize.name) === null || _a === void 0 ? void 0 : _a.en.toLowerCase().includes(value.toLowerCase())) ||
|
|
74
|
+
((_b = teamSize === null || teamSize === void 0 ? void 0 : teamSize.name) === null || _b === void 0 ? void 0 : _b.ar.toLowerCase().includes(value.toLowerCase()));
|
|
75
|
+
});
|
|
76
|
+
setTeamSizeList(filteredList);
|
|
77
|
+
};
|
|
78
|
+
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', list: teamSizeList, onSelectItem: onSelectItem, renderItem: function (item) {
|
|
79
|
+
var _a, _b;
|
|
80
|
+
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, {})] }));
|
|
81
|
+
} })] }))] })) })));
|
|
82
|
+
};
|
|
83
|
+
export default TeamSize;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as yup from 'yup';
|
|
2
|
+
export declare const BrandValidationSchema: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
3
|
+
brandName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
4
|
+
segment: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
|
|
5
|
+
teamSize: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
|
|
6
|
+
salesChannels: import("yup/lib/array").RequiredArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
7
|
+
id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
8
|
+
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
9
|
+
id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
10
|
+
}>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
11
|
+
id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
12
|
+
}>>>, import("yup/lib/types").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
13
|
+
id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
14
|
+
}>>[] | undefined>;
|
|
15
|
+
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
16
|
+
brandName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
17
|
+
segment: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
|
|
18
|
+
teamSize: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
|
|
19
|
+
salesChannels: import("yup/lib/array").RequiredArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
20
|
+
id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
21
|
+
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
22
|
+
id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
23
|
+
}>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
24
|
+
id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
25
|
+
}>>>, import("yup/lib/types").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
26
|
+
id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
27
|
+
}>>[] | undefined>;
|
|
28
|
+
}>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
29
|
+
brandName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
30
|
+
segment: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
|
|
31
|
+
teamSize: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
|
|
32
|
+
salesChannels: import("yup/lib/array").RequiredArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
33
|
+
id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
34
|
+
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
35
|
+
id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
36
|
+
}>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
37
|
+
id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
38
|
+
}>>>, import("yup/lib/types").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
39
|
+
id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
40
|
+
}>>[] | undefined>;
|
|
41
|
+
}>>>;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
|
+
if (ar || !(i in from)) {
|
|
4
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
5
|
+
ar[i] = from[i];
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
|
+
};
|
|
10
|
+
import { REGEX_WEBSITE, REGEX_BRAND_NAME, LINKEDIN_URL, SOCIAL_USERNAME, DIGITS_ONLY, REGEX_ALPHANUMERIC } from '../../../../constants';
|
|
11
|
+
import * as yup from 'yup';
|
|
12
|
+
var validationSalesChannels = function (channels) {
|
|
13
|
+
if (channels === void 0) { channels = []; }
|
|
14
|
+
var dic = {};
|
|
15
|
+
var typeDic = {};
|
|
16
|
+
channels.forEach(function (channel) {
|
|
17
|
+
var _a, _b, _c;
|
|
18
|
+
if ((_a = channel.sub) === null || _a === void 0 ? void 0 : _a.length) {
|
|
19
|
+
var key_1 = (_b = channel.code) === null || _b === void 0 ? void 0 : _b.toLowerCase();
|
|
20
|
+
if (key_1)
|
|
21
|
+
dic[key_1] = [];
|
|
22
|
+
channel.sub.forEach(function (sub) {
|
|
23
|
+
dic[key_1].push(sub.address || '');
|
|
24
|
+
typeDic[sub.code] = sub.address || '';
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
var key = (_c = channel.code) === null || _c === void 0 ? void 0 : _c.toLowerCase();
|
|
29
|
+
if (key)
|
|
30
|
+
dic[key] = [channel.address || ''];
|
|
31
|
+
typeDic[key] = channel.address || '';
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
for (var key in dic) {
|
|
35
|
+
var values = dic[key];
|
|
36
|
+
var atLestOne = values.every(function (item) { return item === ''; });
|
|
37
|
+
if (atLestOne)
|
|
38
|
+
return "enter_at_least_one_".concat(key);
|
|
39
|
+
}
|
|
40
|
+
for (var key in typeDic) {
|
|
41
|
+
var value = typeDic[key];
|
|
42
|
+
if (key === 'website' && value && !value.match(REGEX_WEBSITE)) {
|
|
43
|
+
return 'invalid_url';
|
|
44
|
+
}
|
|
45
|
+
if (key === 'linkedin' && value && !value.match(LINKEDIN_URL)) {
|
|
46
|
+
return 'invalid_linkedin_profile_url';
|
|
47
|
+
}
|
|
48
|
+
if (key === 'facebook' && value && !value.match(SOCIAL_USERNAME)) {
|
|
49
|
+
return 'invalid_facebook_username';
|
|
50
|
+
}
|
|
51
|
+
if (key === 'instagram' && value && !value.match(SOCIAL_USERNAME)) {
|
|
52
|
+
return 'invalid_instagram_username';
|
|
53
|
+
}
|
|
54
|
+
if (key === 'twitter' && value && !value.match(SOCIAL_USERNAME)) {
|
|
55
|
+
return 'invalid_twitter_username';
|
|
56
|
+
}
|
|
57
|
+
if (key === 'physical_store' && value && value.length < 3) {
|
|
58
|
+
return 'invalid_physical_store_location';
|
|
59
|
+
}
|
|
60
|
+
if (key === 'ios' && value && !value.match(REGEX_ALPHANUMERIC)) {
|
|
61
|
+
return 'invalid_ios_app';
|
|
62
|
+
}
|
|
63
|
+
if (key === 'android' && value && !value.match(REGEX_ALPHANUMERIC)) {
|
|
64
|
+
return 'invalid_android_app';
|
|
65
|
+
}
|
|
66
|
+
if (key === 'call_center' && value && !value.match(DIGITS_ONLY)) {
|
|
67
|
+
return 'invalid_call_center_number';
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return true;
|
|
71
|
+
};
|
|
72
|
+
export var BrandValidationSchema = yup.object().shape({
|
|
73
|
+
brandName: yup
|
|
74
|
+
.string()
|
|
75
|
+
.test({
|
|
76
|
+
test: function (value) {
|
|
77
|
+
if ((value === null || value === void 0 ? void 0 : value.length) === 0)
|
|
78
|
+
return true;
|
|
79
|
+
if (value && value.length >= 3 && (value === null || value === void 0 ? void 0 : value.match(REGEX_BRAND_NAME)))
|
|
80
|
+
return true;
|
|
81
|
+
return this.createError({ message: 'enter_brand_name_english_chars_numbers_space' });
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
.required('enter_brand_name_english_chars_numbers_space'),
|
|
85
|
+
segment: yup.object().required('alert_choose_segment'),
|
|
86
|
+
teamSize: yup.object().required('alert_choose_teamSize'),
|
|
87
|
+
salesChannels: yup
|
|
88
|
+
.array()
|
|
89
|
+
.min(1, 'choose_atleast_one_channel')
|
|
90
|
+
.of(yup.object().shape({
|
|
91
|
+
id: yup.string().required('choose_atleast_one_channel')
|
|
92
|
+
}))
|
|
93
|
+
.test({
|
|
94
|
+
test: function (value) {
|
|
95
|
+
var length = (value === null || value === void 0 ? void 0 : value.length) || 0;
|
|
96
|
+
if (length === 0)
|
|
97
|
+
return true;
|
|
98
|
+
var channels = __spreadArray([], (value || []), true);
|
|
99
|
+
var result = validationSalesChannels(channels);
|
|
100
|
+
if (result === true)
|
|
101
|
+
return true;
|
|
102
|
+
return this.createError({ message: result });
|
|
103
|
+
}
|
|
104
|
+
})
|
|
105
|
+
.required('choose_atleast_one_channel')
|
|
106
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import SuccessScreen from '../../../shared/SuccessScreen';
|
|
5
|
+
var ResetPasswordSuccess = function (_a) {
|
|
6
|
+
var t = useTranslation().t;
|
|
7
|
+
return (_jsx(SuccessScreen, { title: t("reset_password_success_title"), description: t("reset_password_success_description"), showEmailProviders: true }));
|
|
8
|
+
};
|
|
9
|
+
export default React.memo(ResetPasswordSuccess);
|