orc-shared 1.1.0-dev.9 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/applications.js +1 -1
- package/dist/actions/authentication.js +1 -1
- package/dist/actions/countries.js +1 -1
- package/dist/actions/locale.js +1 -1
- package/dist/actions/makeApiAction.js +73 -3
- package/dist/actions/makeOrcApiAction.js +2 -2
- package/dist/actions/metadata.js +295 -31
- package/dist/actions/navigation.js +3 -3
- package/dist/actions/requestState.js +78 -0
- package/dist/actions/requestsApi.js +58 -7
- package/dist/actions/scopes.js +1 -1
- package/dist/actions/timezones.js +1 -1
- package/dist/actions/toasts.js +1 -1
- package/dist/actions/versionInfo.js +1 -1
- package/dist/actions/view.js +1 -1
- package/dist/buildStore.js +7 -4
- package/dist/components/AppFrame/About.js +3 -3
- package/dist/components/AppFrame/ApplicationSelector/ApplicationDialog.js +115 -62
- package/dist/components/AppFrame/ApplicationSelector/index.js +45 -47
- package/dist/components/AppFrame/MenuItem.js +1 -1
- package/dist/components/AppFrame/Preferences.js +3 -3
- package/dist/components/AppFrame/Sidebar.js +1 -1
- package/dist/components/AppFrame/Topbar.js +1 -1
- package/dist/components/Authenticate.js +1 -1
- package/dist/components/CategoryList.js +1 -1
- package/dist/components/Checkbox.js +1 -1
- package/dist/components/DropMenu/Menu.js +1 -1
- package/dist/components/DropMenu/index.js +1 -1
- package/dist/components/Form/FieldList.js +3 -3
- package/dist/components/Form/Form.js +1 -1
- package/dist/components/Form/Inputs/Button.js +1 -1
- package/dist/components/Form/Inputs/FieldButtons.js +1 -1
- package/dist/components/Form/Inputs/Number.js +1 -1
- package/dist/components/Form/Inputs/ReadOnly.js +1 -1
- package/dist/components/Form/Inputs/SmallButton.js +1 -1
- package/dist/components/Form/Inputs/Text.js +1 -1
- package/dist/components/Form/Inputs/Time.js +1 -1
- package/dist/components/Form/Inputs/Toggles.js +1 -1
- package/dist/components/Form/Inputs/Translation.js +3 -3
- package/dist/components/List/HeadCell.js +1 -1
- package/dist/components/List/List.js +1 -1
- package/dist/components/List/Row.js +1 -1
- package/dist/components/List/enhanceColumnDefs.js +2 -2
- package/dist/components/MaterialUI/DataDisplay/List.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/Notification.js +2 -2
- package/dist/components/MaterialUI/DataDisplay/NotificationProps.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/Translations.js +3 -3
- package/dist/components/MaterialUI/DataDisplay/SelectionList.js +19 -6
- package/dist/components/MaterialUI/DataDisplay/Table.js +28 -10
- package/dist/components/MaterialUI/DataDisplay/TableProps.js +5 -2
- package/dist/components/MaterialUI/DataDisplay/TransferList.js +5 -2
- package/dist/components/MaterialUI/DataDisplay/chipProps.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/collapsableListProps.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/dividerProps.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/index.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/modalProps.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/useTableSelection.js +3 -3
- package/dist/components/MaterialUI/Feedback/useNotification.js +1 -1
- package/dist/components/MaterialUI/Inputs/Autocomplete.js +2 -2
- package/dist/components/MaterialUI/Inputs/AutocompleteProps.js +1 -1
- package/dist/components/MaterialUI/Inputs/CheckboxGroupProps.js +1 -1
- package/dist/components/MaterialUI/Inputs/CheckboxProps.js +1 -1
- package/dist/components/MaterialUI/Inputs/DatePicker.js +11 -0
- package/dist/components/MaterialUI/Inputs/InputBase.js +3 -2
- package/dist/components/MaterialUI/Inputs/InputBaseProps.js +1 -1
- package/dist/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +1 -1
- package/dist/components/MaterialUI/Inputs/RadioProps.js +1 -1
- package/dist/components/MaterialUI/Inputs/Select.js +2 -2
- package/dist/components/MaterialUI/Inputs/SelectProps.js +1 -1
- package/dist/components/MaterialUI/Inputs/Switch.js +3 -3
- package/dist/components/MaterialUI/Inputs/SwitchProps.js +1 -1
- package/dist/components/MaterialUI/Inputs/TimePicker.js +19 -8
- package/dist/components/MaterialUI/Inputs/createInput.js +3 -3
- package/dist/components/MaterialUI/Inputs/index.js +1 -1
- package/dist/components/MaterialUI/Inputs/standaloneRadioProps.js +1 -1
- package/dist/components/MaterialUI/Navigation/DropDownMenuProps.js +1 -1
- package/dist/components/MaterialUI/Navigation/TabBar.js +38 -33
- package/dist/components/MaterialUI/ScopeSelector/ScopeSelector.js +13 -5
- package/dist/components/MaterialUI/ScopeSelector/ScopeTreeView.js +8 -4
- package/dist/components/MaterialUI/ScopeSelector/TreeItem.js +9 -6
- package/dist/components/MaterialUI/Surfaces/ExpansionPanel.js +11 -2
- package/dist/components/MaterialUI/Surfaces/SectionExpansionPanel.js +10 -2
- package/dist/components/MaterialUI/Surfaces/expansionPanelProps.js +5 -2
- package/dist/components/MaterialUI/Surfaces/paperProps.js +1 -1
- package/dist/components/MaterialUI/muiThemes.js +21 -6
- package/dist/components/MaterialUI/textProps.js +1 -1
- package/dist/components/Modules.js +24 -2
- package/dist/components/MultiSelector.js +1 -1
- package/dist/components/Navigation/Bar.js +3 -3
- package/dist/components/Navigation/Tab.js +1 -1
- package/dist/components/Navigation/useNavigationState.js +30 -4
- package/dist/components/Placeholder.js +1 -1
- package/dist/components/Routing/FullPage.js +2 -0
- package/dist/components/Routing/Segment.js +4 -3
- package/dist/components/Routing/SegmentPage.js +8 -6
- package/dist/components/Routing/withWaypointing.js +10 -4
- package/dist/components/Scope/ScopeNode.js +1 -1
- package/dist/components/Scope/Selector.js +1 -1
- package/dist/components/Scope/index.js +11 -3
- package/dist/components/Scope/useScopeSelect.js +1 -1
- package/dist/components/Selector.js +1 -1
- package/dist/components/Sidepanel.js +1 -2
- package/dist/components/Spritesheet.js +1 -1
- package/dist/components/Switch.js +1 -1
- package/dist/components/Text.js +1 -1
- package/dist/components/ToastList.js +1 -1
- package/dist/components/Toolbar.js +1 -1
- package/dist/components/Treeview/Label.js +1 -1
- package/dist/components/Treeview/Leaf.js +1 -1
- package/dist/components/Treeview/Node.js +3 -3
- package/dist/components/Treeview/index.js +2 -2
- package/dist/components/Treeview/settings.js +1 -1
- package/dist/constants.js +26 -1
- package/dist/content/icons/html-templates.svg +3 -0
- package/dist/content/iconsSheet.svg +3 -0
- package/dist/getThemeOverrides.js +2 -2
- package/dist/hocs/withInfiniteScroll.js +1 -1
- package/dist/hocs/withUpdateHandler.js +2 -2
- package/dist/hooks/useDispatchWithModulesData.js +1 -1
- package/dist/hooks/useEditState.js +3 -3
- package/dist/hooks/useEntityLoader.js +182 -0
- package/dist/hooks/useFullEntityEditState.js +3 -3
- package/dist/hooks/useInfiniteScroll.js +104 -0
- package/dist/hooks/useLabelMessage.js +3 -3
- package/dist/hooks/useLoader.js +1 -0
- package/dist/hooks/useMultipleFieldEditState.js +2 -2
- package/dist/hooks/useNavigationHandler.js +1 -1
- package/dist/hooks/useNotificationRequestState.js +159 -0
- package/dist/hooks/useRequestState.js +146 -0
- package/dist/hooks/useSelectorAndUnwrap.js +1 -1
- package/dist/reducers/metadata.js +52 -26
- package/dist/reducers/requestStates.js +181 -0
- package/dist/schemas/countries.js +1 -1
- package/dist/schemas/definitions.js +1 -1
- package/dist/schemas/metadata.js +1 -1
- package/dist/schemas/productDefinitions.js +1 -1
- package/dist/schemas/timezones.js +1 -1
- package/dist/selectors/applications.js +1 -1
- package/dist/selectors/authentication.js +1 -2
- package/dist/selectors/countries.js +1 -1
- package/dist/selectors/locale.js +1 -1
- package/dist/selectors/metadata.js +117 -17
- package/dist/selectors/navigation.js +1 -1
- package/dist/selectors/requestStates.js +82 -0
- package/dist/selectors/requests.js +1 -1
- package/dist/selectors/scope.js +2 -1
- package/dist/selectors/versionInfo.js +1 -1
- package/dist/selectors/view.js +1 -1
- package/dist/sharedMessages.js +44 -0
- package/dist/spawnerMiddleware.js +1 -1
- package/dist/utils/displayModeHelper.js +1 -1
- package/dist/utils/flatten.js +2 -2
- package/dist/utils/localizationHelper.js +1 -1
- package/dist/utils/mapHelper.js +1 -1
- package/dist/utils/modelValidationHelper.js +2 -2
- package/dist/utils/parseHelper.js +1 -1
- package/dist/utils/propertyHelper.js +2 -2
- package/dist/utils/propertyValidator.js +1 -1
- package/dist/utils/setTranslation.js +27 -1
- package/dist/utils/setTranslationWithFallback.js +33 -3
- package/dist/utils/testUtils.js +6 -2
- package/dist/utils/timezoneHelper.js +111 -0
- package/dist/utils/unwrapImmutable.js +1 -1
- package/dist/utils/urlHelper.js +11 -1
- package/package.json +3 -7
- package/src/actions/makeApiAction.js +24 -1
- package/src/actions/makeApiAction.test.js +76 -3
- package/src/actions/metadata.js +130 -0
- package/src/actions/metadata.test.js +337 -5
- package/src/actions/requestState.js +8 -0
- package/src/actions/requestState.test.js +14 -0
- package/src/actions/requestsApi.js +30 -0
- package/src/buildStore.js +2 -0
- package/src/components/AppFrame/AppFrame.test.js +6 -16
- package/src/components/AppFrame/ApplicationSelector/ApplicationDialog.js +105 -82
- package/src/components/AppFrame/ApplicationSelector/ApplicationDialog.test.js +60 -23
- package/src/components/AppFrame/ApplicationSelector/ApplicationSelector.test.js +22 -89
- package/src/components/AppFrame/ApplicationSelector/index.js +34 -15
- package/src/components/AppFrame/Topbar.test.js +2 -4
- package/src/components/MaterialUI/DataDisplay/SelectionList.js +14 -6
- package/src/components/MaterialUI/DataDisplay/SelectionList.test.js +21 -11
- package/src/components/MaterialUI/DataDisplay/Table.js +29 -5
- package/src/components/MaterialUI/DataDisplay/Table.test.js +23 -0
- package/src/components/MaterialUI/DataDisplay/TableProps.js +2 -0
- package/src/components/MaterialUI/DataDisplay/TableProps.test.js +2 -0
- package/src/components/MaterialUI/DataDisplay/TransferList.js +3 -0
- package/src/components/MaterialUI/Inputs/DatePicker.js +11 -0
- package/src/components/MaterialUI/Inputs/InputBase.js +3 -1
- package/src/components/MaterialUI/Inputs/InputBase.test.js +38 -0
- package/src/components/MaterialUI/Inputs/TimePicker.js +9 -3
- package/src/components/MaterialUI/Inputs/TimePicker.test.js +263 -118
- package/src/components/MaterialUI/Navigation/TabBar.js +82 -78
- package/src/components/MaterialUI/Navigation/TabBar.test.js +129 -3
- package/src/components/MaterialUI/ScopeSelector/ScopeSelector.js +9 -3
- package/src/components/MaterialUI/ScopeSelector/ScopeSelector.test.js +29 -0
- package/src/components/MaterialUI/ScopeSelector/ScopeTreeView.js +4 -1
- package/src/components/MaterialUI/ScopeSelector/ScopeTreeView.test.js +52 -0
- package/src/components/MaterialUI/ScopeSelector/TreeItem.js +9 -6
- package/src/components/MaterialUI/ScopeSelector/TreeItem.test.js +63 -2
- package/src/components/MaterialUI/Surfaces/ExpansionPanel.js +14 -1
- package/src/components/MaterialUI/Surfaces/ExpansionPanel.test.js +16 -0
- package/src/components/MaterialUI/Surfaces/SectionExpansionPanel.js +11 -2
- package/src/components/MaterialUI/Surfaces/SectionExpansionPanel.test.js +36 -0
- package/src/components/MaterialUI/Surfaces/expansionPanelProps.js +2 -0
- package/src/components/MaterialUI/Surfaces/expansionPanelProps.test.js +2 -2
- package/src/components/MaterialUI/muiThemes.js +18 -3
- package/src/components/Modules.js +13 -1
- package/src/components/Modules.test.js +133 -1
- package/src/components/Navigation/Navigation.test.js +2 -0
- package/src/components/Navigation/useNavigationState.js +21 -1
- package/src/components/Navigation/useNavigationState.test.js +10 -0
- package/src/components/Routing/FullPage.js +2 -1
- package/src/components/Routing/FullPage.test.js +52 -0
- package/src/components/Routing/Segment.js +5 -2
- package/src/components/Routing/Segment.test.js +22 -1
- package/src/components/Routing/SegmentPage.js +12 -4
- package/src/components/Routing/SubPage.test.js +1 -1
- package/src/components/Routing/withWaypointing.js +19 -17
- package/src/components/Routing/withWaypointing.test.js +50 -0
- package/src/components/Scope/Scope.test.js +117 -0
- package/src/components/Scope/index.js +6 -10
- package/src/components/Sidepanel.js +0 -1
- package/src/components/Sidepanel.test.js +0 -3
- package/src/constants.js +18 -0
- package/src/content/icons/html-templates.svg +3 -0
- package/src/content/iconsSheet.svg +3 -0
- package/src/hooks/useEntityLoader.js +68 -0
- package/src/hooks/useEntityLoader.test.js +266 -0
- package/src/hooks/useInfiniteScroll.js +25 -0
- package/src/hooks/useInfiniteScroll.test.js +87 -0
- package/src/hooks/useLoader.js +1 -0
- package/src/hooks/useNotificationRequestState.js +78 -0
- package/src/hooks/useNotificationRequestState.test.js +264 -0
- package/src/hooks/useRequestState.js +57 -0
- package/src/hooks/useRequestState.test.js +217 -0
- package/src/reducers/metadata.js +76 -16
- package/src/reducers/metadata.test.js +458 -4
- package/src/reducers/requestStates.js +98 -0
- package/src/reducers/requestStates.test.js +399 -0
- package/src/selectors/authentication.js +0 -1
- package/src/selectors/locale.test.js +0 -2
- package/src/selectors/metadata.js +90 -19
- package/src/selectors/metadata.test.js +532 -123
- package/src/selectors/requestStates.js +12 -0
- package/src/selectors/requestStates.test.js +83 -0
- package/src/selectors/scope.js +1 -1
- package/src/sharedMessages.js +44 -0
- package/src/translations/en-US.json +12 -1
- package/src/translations/fr-CA.json +13 -2
- package/src/utils/modelValidationHelper.js +1 -1
- package/src/utils/setTranslation.js +16 -1
- package/src/utils/setTranslation.test.js +24 -0
- package/src/utils/setTranslationWithFallback.js +19 -2
- package/src/utils/setTranslationWithFallback.test.js +104 -6
- package/src/utils/testUtils.js +3 -1
- package/src/utils/timezoneHelper.js +140 -0
- package/src/utils/timezoneHelper.test.js +33 -0
- package/src/utils/urlHelper.js +6 -0
- package/src/translations/it-IT.json +0 -54
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createSelector } from "reselect";
|
|
2
|
+
import { castArray } from "lodash";
|
|
3
|
+
import { requestStateOperationMap } from "../constants";
|
|
4
|
+
|
|
5
|
+
const requestStateData = state => state.get("requestStates");
|
|
6
|
+
|
|
7
|
+
export const getRequestStateInfo = (operation, keys) => {
|
|
8
|
+
return createSelector(requestStateData, data => {
|
|
9
|
+
const firstSegment = requestStateOperationMap[operation];
|
|
10
|
+
return data.getIn([firstSegment, ...castArray(keys), "state"]) ?? {};
|
|
11
|
+
});
|
|
12
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import Immutable from "immutable";
|
|
2
|
+
import { getRequestStateInfo } from "./requestStates";
|
|
3
|
+
import { requestStateOperations } from "../constants";
|
|
4
|
+
|
|
5
|
+
describe("getRequestStateInfo", () => {
|
|
6
|
+
let state;
|
|
7
|
+
beforeEach(() => {
|
|
8
|
+
state = Immutable.fromJS({
|
|
9
|
+
requestStates: {
|
|
10
|
+
deletes: {
|
|
11
|
+
key1: {
|
|
12
|
+
key2: {
|
|
13
|
+
state: {
|
|
14
|
+
inProgress: true,
|
|
15
|
+
value: false,
|
|
16
|
+
error: false,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
updates: {
|
|
22
|
+
key3: {
|
|
23
|
+
state: {
|
|
24
|
+
inProgress: false,
|
|
25
|
+
value: true,
|
|
26
|
+
error: false,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("gets the info of a requestState from state", () => {
|
|
35
|
+
const expected = Immutable.fromJS({
|
|
36
|
+
inProgress: true,
|
|
37
|
+
value: false,
|
|
38
|
+
error: false,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
expect(
|
|
42
|
+
getRequestStateInfo,
|
|
43
|
+
"called with",
|
|
44
|
+
[requestStateOperations.delete, ["key1", "key2"]],
|
|
45
|
+
"called with",
|
|
46
|
+
[state],
|
|
47
|
+
"to equal",
|
|
48
|
+
expected,
|
|
49
|
+
);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("gets empty info of an unknown requestState from state", () => {
|
|
53
|
+
const expected = {};
|
|
54
|
+
|
|
55
|
+
expect(
|
|
56
|
+
getRequestStateInfo,
|
|
57
|
+
"called with",
|
|
58
|
+
[requestStateOperations.delete, ["key1"]],
|
|
59
|
+
"called with",
|
|
60
|
+
[state],
|
|
61
|
+
"to equal",
|
|
62
|
+
expected,
|
|
63
|
+
);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("gets the info of a requestState from state using a string instead of array for key", () => {
|
|
67
|
+
const expected = Immutable.fromJS({
|
|
68
|
+
inProgress: false,
|
|
69
|
+
value: true,
|
|
70
|
+
error: false,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
expect(
|
|
74
|
+
getRequestStateInfo,
|
|
75
|
+
"called with",
|
|
76
|
+
[requestStateOperations.update, ["key3"]],
|
|
77
|
+
"called with",
|
|
78
|
+
[state],
|
|
79
|
+
"to equal",
|
|
80
|
+
expected,
|
|
81
|
+
);
|
|
82
|
+
});
|
|
83
|
+
});
|
package/src/selectors/scope.js
CHANGED
|
@@ -13,7 +13,7 @@ import { getLocalization } from "../utils/localizationHelper";
|
|
|
13
13
|
|
|
14
14
|
const scopeData = state => state.get("scopes");
|
|
15
15
|
|
|
16
|
-
const localizedScopesSelector = createSelector(scopeData, currentLocaleOrDefault, (scopes, locale) =>
|
|
16
|
+
export const localizedScopesSelector = createSelector(scopeData, currentLocaleOrDefault, (scopes, locale) =>
|
|
17
17
|
scopes.map(scope =>
|
|
18
18
|
scope.withMutations(s => {
|
|
19
19
|
setTranslationWithFallbackField(locale, s, "id", "name");
|
package/src/sharedMessages.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { defineMessages } from "react-intl";
|
|
2
2
|
|
|
3
3
|
const sharedMessages = defineMessages({
|
|
4
|
+
appSelectorTitle: {
|
|
5
|
+
id: "orc-shared.appSelectorTitle",
|
|
6
|
+
defaultMessage: "Orckestra Commerce Cloud Applications List",
|
|
7
|
+
},
|
|
4
8
|
scopeFilterPlaceholder: {
|
|
5
9
|
id: "orc-shared.scopeFilterPlaceholder",
|
|
6
10
|
defaultMessage: "Type a scope name",
|
|
@@ -211,6 +215,46 @@ const sharedMessages = defineMessages({
|
|
|
211
215
|
id: "orc-shared.fieldMustBeValidPhoneExtension",
|
|
212
216
|
defaultMessage: "This field must be a valid phone extension",
|
|
213
217
|
},
|
|
218
|
+
embedded: {
|
|
219
|
+
id: "orc-shared.embedded",
|
|
220
|
+
defaultMessage: "Embedded",
|
|
221
|
+
},
|
|
222
|
+
shared: {
|
|
223
|
+
id: "orc-shared.shared",
|
|
224
|
+
defaultMessage: "Shared",
|
|
225
|
+
},
|
|
226
|
+
dataTypeText: {
|
|
227
|
+
id: "orc-shared.dataTypeText",
|
|
228
|
+
defaultMessage: "Text",
|
|
229
|
+
},
|
|
230
|
+
dataTypeBoolean: {
|
|
231
|
+
id: "orc-shared.dataTypeBoolean",
|
|
232
|
+
defaultMessage: "Yes/No Choice",
|
|
233
|
+
},
|
|
234
|
+
dataTypeDate: {
|
|
235
|
+
id: "orc-shared.dataTypeDate",
|
|
236
|
+
defaultMessage: "Date/Calendar",
|
|
237
|
+
},
|
|
238
|
+
dataTypeDecimal: {
|
|
239
|
+
id: "orc-shared.dataTypeDecimal",
|
|
240
|
+
defaultMessage: "Decimal Number",
|
|
241
|
+
},
|
|
242
|
+
dataTypeInteger: {
|
|
243
|
+
id: "orc-shared.dataTypeInteger",
|
|
244
|
+
defaultMessage: "Whole Number",
|
|
245
|
+
},
|
|
246
|
+
dataTypeEntityReference: {
|
|
247
|
+
id: "orc-shared.dataTypeEntityReference",
|
|
248
|
+
defaultMessage: "Profile Reference",
|
|
249
|
+
},
|
|
250
|
+
dataTypeLookup: {
|
|
251
|
+
id: "orc-shared.dataTypeLookup",
|
|
252
|
+
defaultMessage: "Lookup List",
|
|
253
|
+
},
|
|
254
|
+
errorUnknown: {
|
|
255
|
+
id: "orc-shared.errorUnknown",
|
|
256
|
+
defaultMessage: "Unknown Error",
|
|
257
|
+
},
|
|
214
258
|
});
|
|
215
259
|
|
|
216
260
|
export default sharedMessages;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
"orc-shared.add": "Add",
|
|
5
5
|
"orc-shared.allRightsReserved": "All rights reserved.",
|
|
6
6
|
"orc-shared.applyChanges": "Apply Changes",
|
|
7
|
+
"orc-shared.appSelectorTitle": "Orckestra Commerce Cloud Applications List",
|
|
7
8
|
"orc-shared.back": "Back",
|
|
8
9
|
"orc-shared.cancel": "Cancel",
|
|
9
10
|
"orc-shared.ccDescription": "The API-first commerce platform that makes omnichannel retail work.",
|
|
@@ -50,5 +51,15 @@
|
|
|
50
51
|
"orc-shared.status": "Status",
|
|
51
52
|
"orc-shared.unsavedChanges": "This entity has unsaved changes. All changes will be lost.\n\nAre you sure you want to close it?",
|
|
52
53
|
"orc-shared.valueName": "Value Name",
|
|
53
|
-
"orc-shared.yes": "Yes"
|
|
54
|
+
"orc-shared.yes": "Yes",
|
|
55
|
+
"orc-shared.embedded": "Embedded",
|
|
56
|
+
"orc-shared.shared": "Shared",
|
|
57
|
+
"orc-shared.dataTypeText": "Text",
|
|
58
|
+
"orc-shared.dataTypeBoolean": "Yes/No Choice",
|
|
59
|
+
"orc-shared.dataTypeDate": "Date/Calendar",
|
|
60
|
+
"orc-shared.dataTypeDecimal": "Decimal Number",
|
|
61
|
+
"orc-shared.dataTypeInteger": "Whole Number",
|
|
62
|
+
"orc-shared.dataTypeEntityReference": "Profile Reference",
|
|
63
|
+
"orc-shared.dataTypeLookup": "Lookup List",
|
|
64
|
+
"orc-shared.errorUnknown": "Unknown Error"
|
|
54
65
|
}
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
"orc-shared.add": "Ajouter",
|
|
5
5
|
"orc-shared.allRightsReserved": "Tout droits réservés.",
|
|
6
6
|
"orc-shared.applyChanges": "Appliquer les modifications",
|
|
7
|
-
"orc-shared.
|
|
7
|
+
"orc-shared.appSelectorTitle": "Orckestra Commerce Cloud : Liste des applications",
|
|
8
|
+
"orc-shared.back": "Précédent",
|
|
8
9
|
"orc-shared.cancel": "Annuler",
|
|
9
10
|
"orc-shared.ccDescription": "La plateforme de commerce « API-first » qui rend le commerce de détail omnicanal fluide.",
|
|
10
11
|
"orc-shared.ccName": "Orckestra Commerce Cloud",
|
|
@@ -50,5 +51,15 @@
|
|
|
50
51
|
"orc-shared.status": "Statut",
|
|
51
52
|
"orc-shared.unsavedChanges": "Ce dossier contient des modifications qui ne sont sauvegardées. Si vous quittez, les modifications seront perdues.\n\nVoulez vous vraiment quitter?",
|
|
52
53
|
"orc-shared.valueName": "Nom de la valeur",
|
|
53
|
-
"orc-shared.yes": "Oui"
|
|
54
|
+
"orc-shared.yes": "Oui",
|
|
55
|
+
"orc-shared.embedded": "Intégré",
|
|
56
|
+
"orc-shared.shared": "Partagé",
|
|
57
|
+
"orc-shared.dataTypeText": "Texte",
|
|
58
|
+
"orc-shared.dataTypeBoolean": "Choix Oui/Non",
|
|
59
|
+
"orc-shared.dataTypeDate": "Date/Calendrier",
|
|
60
|
+
"orc-shared.dataTypeDecimal": "Nombre décimal",
|
|
61
|
+
"orc-shared.dataTypeInteger": "Nombre entier",
|
|
62
|
+
"orc-shared.dataTypeEntityReference": "Profil de référence",
|
|
63
|
+
"orc-shared.dataTypeLookup": "Index des listes",
|
|
64
|
+
"orc-shared.errorUnknown": "Erreur inconnue"
|
|
54
65
|
}
|
|
@@ -11,7 +11,7 @@ export const validationRules = {
|
|
|
11
11
|
[validationErrorTypes.fieldMustBeValidEmail]: value => {
|
|
12
12
|
if (!value) return true;
|
|
13
13
|
const regexRule = new RegExp(
|
|
14
|
-
"^(([\\w-]+[\\.\\+]
|
|
14
|
+
"^(([\\w-]+[\\.\\+])+[\\w-]+|([a-zA-Z]{1}|[\\w-]{2,}))@((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\.([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\.([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\.([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|(([a-zA-Z0-9][a-zA-Z0-9\\.\\-]+[a-zA-Z0-9])|([a-zA-Z0-9]{1,}))\\.[a-zA-Z]{2,12})$",
|
|
15
15
|
);
|
|
16
16
|
return regexRule.test(value);
|
|
17
17
|
},
|
|
@@ -3,8 +3,23 @@ import { flatten } from "./flatten";
|
|
|
3
3
|
/* Replaces a locale string structure with the string for the given locale. */
|
|
4
4
|
const setTranslation = (locale, obj, ...field) => {
|
|
5
5
|
if (!obj || !obj.getIn(flatten([field]))) return obj;
|
|
6
|
+
let localeValue = obj.getIn(flatten([field, locale]));
|
|
7
|
+
if (!localeValue && locale.includes("-")) {
|
|
8
|
+
let fieldValue = obj.getIn(flatten([field]));
|
|
9
|
+
let fieldKeys = fieldValue.keys();
|
|
10
|
+
let language = locale.substring(0, locale.indexOf("-"));
|
|
11
|
+
|
|
12
|
+
for (let key of fieldKeys) {
|
|
13
|
+
if (key !== locale && key.startsWith(language)) {
|
|
14
|
+
localeValue = obj.getIn(flatten([field, key]));
|
|
15
|
+
if (localeValue) {
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
6
21
|
const value =
|
|
7
|
-
|
|
22
|
+
localeValue ||
|
|
8
23
|
obj
|
|
9
24
|
.getIn(flatten([field]))
|
|
10
25
|
.filter(i => i)
|
|
@@ -96,4 +96,28 @@ describe("setTranslation", () => {
|
|
|
96
96
|
hat: { name: "it-name" },
|
|
97
97
|
}),
|
|
98
98
|
));
|
|
99
|
+
|
|
100
|
+
it("returns first not empty match by language if language-culture not found", () =>
|
|
101
|
+
expect(
|
|
102
|
+
setTranslation,
|
|
103
|
+
"when called with",
|
|
104
|
+
[
|
|
105
|
+
"en-US",
|
|
106
|
+
Immutable.fromJS({
|
|
107
|
+
hat: {
|
|
108
|
+
name: {
|
|
109
|
+
"en-CA": "",
|
|
110
|
+
"fr-CA": "fr CA name",
|
|
111
|
+
"en-GB": "en GB name",
|
|
112
|
+
"it-IT": "it-name",
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
}),
|
|
116
|
+
["hat", "name"],
|
|
117
|
+
],
|
|
118
|
+
"to equal",
|
|
119
|
+
Immutable.fromJS({
|
|
120
|
+
hat: { name: "en GB name" },
|
|
121
|
+
}),
|
|
122
|
+
));
|
|
99
123
|
});
|
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
import { flatten } from "./flatten";
|
|
2
2
|
|
|
3
3
|
export const setTranslationWithFallbackValue = (locale, obj, fallbackValue, ...field) => {
|
|
4
|
-
if (!obj
|
|
5
|
-
|
|
4
|
+
if (!obj) return obj;
|
|
5
|
+
let localeValue = obj.getIn(flatten([field, locale]));
|
|
6
|
+
if (!localeValue && locale.includes("-")) {
|
|
7
|
+
let fieldValue = obj.getIn(flatten([field]));
|
|
8
|
+
if (fieldValue) {
|
|
9
|
+
let fieldKeys = fieldValue.keys();
|
|
10
|
+
let language = locale.substring(0, locale.indexOf("-"));
|
|
11
|
+
|
|
12
|
+
for (let key of fieldKeys) {
|
|
13
|
+
if (key !== locale && key.startsWith(language)) {
|
|
14
|
+
localeValue = obj.getIn(flatten([field, key]));
|
|
15
|
+
if (localeValue) {
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const value = localeValue || fallbackValue || "";
|
|
6
23
|
return obj.setIn(flatten([field]), value);
|
|
7
24
|
};
|
|
8
25
|
|
|
@@ -79,6 +79,7 @@ describe("setTranslationWithFallbackField", () => {
|
|
|
79
79
|
Immutable.fromJS({
|
|
80
80
|
name: "fallbackName",
|
|
81
81
|
hat: { name: {} },
|
|
82
|
+
pets: { name: "fallbackName" },
|
|
82
83
|
}),
|
|
83
84
|
));
|
|
84
85
|
});
|
|
@@ -138,23 +139,120 @@ describe("setTranslationWithFallbackValue", () => {
|
|
|
138
139
|
}),
|
|
139
140
|
));
|
|
140
141
|
|
|
141
|
-
it("returns same object if
|
|
142
|
+
it("returns same object if object does not exist", () =>
|
|
143
|
+
expect(
|
|
144
|
+
setTranslationWithFallbackValue,
|
|
145
|
+
"when called with",
|
|
146
|
+
["fr", null, "fallbakValue", ["pets", "name"]],
|
|
147
|
+
"to equal",
|
|
148
|
+
null,
|
|
149
|
+
));
|
|
150
|
+
|
|
151
|
+
it("returns value matched by language-culture when exist", () =>
|
|
142
152
|
expect(
|
|
143
153
|
setTranslationWithFallbackValue,
|
|
144
154
|
"when called with",
|
|
145
155
|
[
|
|
146
|
-
"
|
|
156
|
+
"en-US",
|
|
157
|
+
Immutable.fromJS({
|
|
158
|
+
hat: { name: { "en-US": "en-US Name", "en-GB": "en-GB Name" } },
|
|
159
|
+
}),
|
|
160
|
+
"fallbakValue",
|
|
161
|
+
["hat", "name"],
|
|
162
|
+
],
|
|
163
|
+
"to equal",
|
|
164
|
+
Immutable.fromJS({
|
|
165
|
+
hat: { name: "en-US Name" },
|
|
166
|
+
}),
|
|
167
|
+
));
|
|
168
|
+
|
|
169
|
+
it("returns value matched by language when match by language-culture does not exist", () =>
|
|
170
|
+
expect(
|
|
171
|
+
setTranslationWithFallbackValue,
|
|
172
|
+
"when called with",
|
|
173
|
+
[
|
|
174
|
+
"en-US",
|
|
175
|
+
Immutable.fromJS({
|
|
176
|
+
hat: { name: { "en-GB": "en-GB Name" } },
|
|
177
|
+
}),
|
|
178
|
+
"fallbakValue",
|
|
179
|
+
["hat", "name"],
|
|
180
|
+
],
|
|
181
|
+
"to equal",
|
|
182
|
+
Immutable.fromJS({
|
|
183
|
+
hat: { name: "en-GB Name" },
|
|
184
|
+
}),
|
|
185
|
+
));
|
|
186
|
+
|
|
187
|
+
it("returns first not empty value matched by language when match by language-culture does not exist", () =>
|
|
188
|
+
expect(
|
|
189
|
+
setTranslationWithFallbackValue,
|
|
190
|
+
"when called with",
|
|
191
|
+
[
|
|
192
|
+
"en-US",
|
|
193
|
+
Immutable.fromJS({
|
|
194
|
+
hat: { name: { "en-GB": "", "en-CA": "en-CA Name" } },
|
|
195
|
+
}),
|
|
196
|
+
"fallbakValue",
|
|
197
|
+
["hat", "name"],
|
|
198
|
+
],
|
|
199
|
+
"to equal",
|
|
200
|
+
Immutable.fromJS({
|
|
201
|
+
hat: { name: "en-CA Name" },
|
|
202
|
+
}),
|
|
203
|
+
));
|
|
204
|
+
|
|
205
|
+
it("returns value fallback value when match by language-culture and language does not exist", () =>
|
|
206
|
+
expect(
|
|
207
|
+
setTranslationWithFallbackValue,
|
|
208
|
+
"when called with",
|
|
209
|
+
[
|
|
210
|
+
"en-GB",
|
|
211
|
+
Immutable.fromJS({
|
|
212
|
+
hat: { name: { "fr-CA": "fr-CA Name" } },
|
|
213
|
+
}),
|
|
214
|
+
"fallbakValue",
|
|
215
|
+
["hat", "name"],
|
|
216
|
+
],
|
|
217
|
+
"to equal",
|
|
218
|
+
Immutable.fromJS({
|
|
219
|
+
hat: { name: "fallbakValue" },
|
|
220
|
+
}),
|
|
221
|
+
));
|
|
222
|
+
|
|
223
|
+
it("returns fallbak Value when field value is empty ", () =>
|
|
224
|
+
expect(
|
|
225
|
+
setTranslationWithFallbackValue,
|
|
226
|
+
"when called with",
|
|
227
|
+
[
|
|
228
|
+
"en-GB",
|
|
147
229
|
Immutable.fromJS({
|
|
148
|
-
name: "fallbackName",
|
|
149
230
|
hat: { name: {} },
|
|
150
231
|
}),
|
|
151
232
|
"fallbakValue",
|
|
152
|
-
["
|
|
233
|
+
["hat", "name"],
|
|
153
234
|
],
|
|
154
235
|
"to equal",
|
|
155
236
|
Immutable.fromJS({
|
|
156
|
-
name: "
|
|
157
|
-
|
|
237
|
+
hat: { name: "fallbakValue" },
|
|
238
|
+
}),
|
|
239
|
+
));
|
|
240
|
+
|
|
241
|
+
it("returns fallbakValue when field is undefined ", () =>
|
|
242
|
+
expect(
|
|
243
|
+
setTranslationWithFallbackValue,
|
|
244
|
+
"when called with",
|
|
245
|
+
[
|
|
246
|
+
"en-GB",
|
|
247
|
+
Immutable.fromJS({
|
|
248
|
+
hat: { name: {} },
|
|
249
|
+
}),
|
|
250
|
+
"fallbakValue",
|
|
251
|
+
["hat", "name2"],
|
|
252
|
+
],
|
|
253
|
+
"to equal",
|
|
254
|
+
Immutable.fromJS({
|
|
255
|
+
hat: { name: {}, name2: "fallbakValue" },
|
|
158
256
|
}),
|
|
159
257
|
));
|
|
160
258
|
});
|
package/src/utils/testUtils.js
CHANGED
|
@@ -185,7 +185,9 @@ export const TestWrapper = ({
|
|
|
185
185
|
const MuiThemeProviderWrapper = ({ children }) => {
|
|
186
186
|
if (muiThemeProvider == null) return children;
|
|
187
187
|
|
|
188
|
-
|
|
188
|
+
const theme = muiThemeProvider.theme ?? createMuiTheme();
|
|
189
|
+
|
|
190
|
+
return <MuiThemeProvider theme={theme}>{children}</MuiThemeProvider>;
|
|
189
191
|
};
|
|
190
192
|
|
|
191
193
|
const MemoryRouterWrapper = ({ children }) => {
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
export const getTimeZone = () => Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
2
|
+
|
|
3
|
+
export const getTimeZoneByName = name => {
|
|
4
|
+
for (let [key, value] of timeZonesList.entries()) {
|
|
5
|
+
if (value === name) return key;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
return getTimeZone();
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const getTimeZoneName = () => {
|
|
12
|
+
const customerTimezone = getTimeZone();
|
|
13
|
+
const timezoneName = timeZonesList.get(customerTimezone);
|
|
14
|
+
return timezoneName;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const timeZonesList = new Map([
|
|
18
|
+
["Africa/Bangui", "W. Central Africa Standard Time"],
|
|
19
|
+
["Africa/Cairo", "Egypt Standard Time"],
|
|
20
|
+
["Africa/Casablanca", "Morocco Standard Time"],
|
|
21
|
+
["Africa/Harare", "South Africa Standard Time"],
|
|
22
|
+
["Africa/Johannesburg", "South Africa Standard Time"],
|
|
23
|
+
["Africa/Lagos", "W. Central Africa Standard Time"],
|
|
24
|
+
["Africa/Monrovia", "Greenwich Standard Time"],
|
|
25
|
+
["Africa/Nairobi", "E. Africa Standard Time"],
|
|
26
|
+
["Africa/Windhoek", "Namibia Standard Time"],
|
|
27
|
+
["America/Anchorage", "Alaskan Standard Time"],
|
|
28
|
+
["America/Argentina/San_Juan", "Argentina Standard Time"],
|
|
29
|
+
["America/Asuncion", "Paraguay Standard Time"],
|
|
30
|
+
["America/Bahia", "Bahia Standard Time"],
|
|
31
|
+
["America/Bogota", "SA Pacific Standard Time"],
|
|
32
|
+
["America/Buenos_Aires", "Argentina Standard Time"],
|
|
33
|
+
["America/Caracas", "Venezuela Standard Time"],
|
|
34
|
+
["America/Cayenne", "SA Eastern Standard Time"],
|
|
35
|
+
["America/Chicago", "Central Standard Time"],
|
|
36
|
+
["America/Chihuahua", "Mountain Standard Time (Mexico)"],
|
|
37
|
+
["America/Cuiaba", "Central Brazilian Standard Time"],
|
|
38
|
+
["America/Denver", "Mountain Standard Time"],
|
|
39
|
+
["America/Fortaleza", "SA Eastern Standard Time"],
|
|
40
|
+
["America/Godthab", "Greenland Standard Time"],
|
|
41
|
+
["America/Guatemala", "Central America Standard Time"],
|
|
42
|
+
["America/Halifax", "Atlantic Standard Time"],
|
|
43
|
+
["America/Indianapolis", "US Eastern Standard Time"],
|
|
44
|
+
["America/Indiana/Indianapolis", "US Eastern Standard Time"],
|
|
45
|
+
["America/La_Paz", "SA Western Standard Time"],
|
|
46
|
+
["America/Los_Angeles", "Pacific Standard Time"],
|
|
47
|
+
["America/Mexico_City", "Mexico Standard Time"],
|
|
48
|
+
["America/Montevideo", "Montevideo Standard Time"],
|
|
49
|
+
["America/New_York", "Eastern Standard Time"],
|
|
50
|
+
["America/Noronha", "UTC-02"],
|
|
51
|
+
["America/Phoenix", "US Mountain Standard Time"],
|
|
52
|
+
["America/Regina", "Canada Central Standard Time"],
|
|
53
|
+
["America/Santa_Isabel", "Pacific Standard Time (Mexico)"],
|
|
54
|
+
["America/Santiago", "Pacific SA Standard Time"],
|
|
55
|
+
["America/Sao_Paulo", "E. South America Standard Time"],
|
|
56
|
+
["America/St_Johns", "Newfoundland Standard Time"],
|
|
57
|
+
["America/Tijuana", "Pacific Standard Time"],
|
|
58
|
+
["Antarctica/McMurdo", "New Zealand Standard Time"],
|
|
59
|
+
["Atlantic/South_Georgia", "UTC-02"],
|
|
60
|
+
["Asia/Almaty", "Central Asia Standard Time"],
|
|
61
|
+
["Asia/Amman", "Jordan Standard Time"],
|
|
62
|
+
["Asia/Baghdad", "Arabic Standard Time"],
|
|
63
|
+
["Asia/Baku", "Azerbaijan Standard Time"],
|
|
64
|
+
["Asia/Bangkok", "SE Asia Standard Time"],
|
|
65
|
+
["Asia/Beirut", "Middle East Standard Time"],
|
|
66
|
+
["Asia/Calcutta", "India Standard Time"],
|
|
67
|
+
["Asia/Colombo", "Sri Lanka Standard Time"],
|
|
68
|
+
["Asia/Damascus", "Syria Standard Time"],
|
|
69
|
+
["Asia/Dhaka", "Bangladesh Standard Time"],
|
|
70
|
+
["Asia/Dubai", "Arabian Standard Time"],
|
|
71
|
+
["Asia/Irkutsk", "North Asia East Standard Time"],
|
|
72
|
+
["Asia/Jerusalem", "Israel Standard Time"],
|
|
73
|
+
["Asia/Kabul", "Afghanistan Standard Time"],
|
|
74
|
+
["Asia/Kamchatka", "Kamchatka Standard Time"],
|
|
75
|
+
["Asia/Karachi", "Pakistan Standard Time"],
|
|
76
|
+
["Asia/Katmandu", "Nepal Standard Time"],
|
|
77
|
+
["Asia/Kolkata", "India Standard Time"],
|
|
78
|
+
["Asia/Krasnoyarsk", "North Asia Standard Time"],
|
|
79
|
+
["Asia/Kuala_Lumpur", "Singapore Standard Time"],
|
|
80
|
+
["Asia/Kuwait", "Arab Standard Time"],
|
|
81
|
+
["Asia/Magadan", "Magadan Standard Time"],
|
|
82
|
+
["Asia/Muscat", "Arabian Standard Time"],
|
|
83
|
+
["Asia/Novosibirsk", "N. Central Asia Standard Time"],
|
|
84
|
+
["Asia/Oral", "West Asia Standard Time"],
|
|
85
|
+
["Asia/Rangoon", "Myanmar Standard Time"],
|
|
86
|
+
["Asia/Riyadh", "Arab Standard Time"],
|
|
87
|
+
["Asia/Seoul", "Korea Standard Time"],
|
|
88
|
+
["Asia/Shanghai", "China Standard Time"],
|
|
89
|
+
["Asia/Singapore", "Singapore Standard Time"],
|
|
90
|
+
["Asia/Taipei", "Taipei Standard Time"],
|
|
91
|
+
["Asia/Tashkent", "West Asia Standard Time"],
|
|
92
|
+
["Asia/Tbilisi", "Georgian Standard Time"],
|
|
93
|
+
["Asia/Tehran", "Iran Standard Time"],
|
|
94
|
+
["Asia/Tokyo", "Tokyo Standard Time"],
|
|
95
|
+
["Asia/Ulaanbaatar", "Ulaanbaatar Standard Time"],
|
|
96
|
+
["Asia/Vladivostok", "Vladivostok Standard Time"],
|
|
97
|
+
["Asia/Yakutsk", "Yakutsk Standard Time"],
|
|
98
|
+
["Asia/Yekaterinburg", "Ekaterinburg Standard Time"],
|
|
99
|
+
["Asia/Yerevan", "Armenian Standard Time"],
|
|
100
|
+
["Atlantic/Azores", "Azores Standard Time"],
|
|
101
|
+
["Atlantic/Cape_Verde", "Cape Verde Standard Time"],
|
|
102
|
+
["Atlantic/Reykjavik", "Greenwich Standard Time"],
|
|
103
|
+
["Australia/Adelaide", "Cen. Australia Standard Time"],
|
|
104
|
+
["Australia/Brisbane", "E. Australia Standard Time"],
|
|
105
|
+
["Australia/Darwin", "AUS Central Standard Time"],
|
|
106
|
+
["Australia/Hobart", "Tasmania Standard Time"],
|
|
107
|
+
["Australia/Perth", "W. Australia Standard Time"],
|
|
108
|
+
["Australia/Sydney", "AUS Eastern Standard Time"],
|
|
109
|
+
["UTC", "UTC"],
|
|
110
|
+
["Etc/GMT+11", "UTC-11"],
|
|
111
|
+
["Etc/GMT+12", "Dateline Standard Time"],
|
|
112
|
+
["Etc/GMT+2", "UTC-02"],
|
|
113
|
+
["Etc/GMT-12", "UTC+12"],
|
|
114
|
+
["Europe/Amsterdam", "W. Europe Standard Time"],
|
|
115
|
+
["Europe/Athens", "GTB Standard Time"],
|
|
116
|
+
["Europe/Belgrade", "Central Europe Standard Time"],
|
|
117
|
+
["Europe/Berlin", "W. Europe Standard Time"],
|
|
118
|
+
["Europe/Brussels", "Romance Standard Time"],
|
|
119
|
+
["Europe/Budapest", "Central Europe Standard Time"],
|
|
120
|
+
["Europe/Dublin", "GMT Standard Time"],
|
|
121
|
+
["Europe/Helsinki", "FLE Standard Time"],
|
|
122
|
+
["Europe/Istanbul", "GTB Standard Time"],
|
|
123
|
+
["Europe/Kiev", "FLE Standard Time"],
|
|
124
|
+
["Europe/London", "GMT Standard Time"],
|
|
125
|
+
["Europe/Minsk", "E. Europe Standard Time"],
|
|
126
|
+
["Europe/Moscow", "Russian Standard Time"],
|
|
127
|
+
["Europe/Paris", "Romance Standard Time"],
|
|
128
|
+
["Europe/Sarajevo", "Central European Standard Time"],
|
|
129
|
+
["Europe/Warsaw", "Central European Standard Time"],
|
|
130
|
+
["Indian/Mauritius", "Mauritius Standard Time"],
|
|
131
|
+
["Pacific/Apia", "Samoa Standard Time"],
|
|
132
|
+
["Pacific/Auckland", "New Zealand Standard Time"],
|
|
133
|
+
["Pacific/Fiji", "Fiji Standard Time"],
|
|
134
|
+
["Pacific/Guadalcanal", "Central Pacific Standard Time"],
|
|
135
|
+
["Pacific/Guam", "West Pacific Standard Time"],
|
|
136
|
+
["Pacific/Honolulu", "Hawaiian Standard Time"],
|
|
137
|
+
["Pacific/Pago_Pago", "UTC-11"],
|
|
138
|
+
["Pacific/Port_Moresby", "West Pacific Standard Time"],
|
|
139
|
+
["Pacific/Tongatapu", "Tonga Standard Time"],
|
|
140
|
+
]);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { getTimeZone, getTimeZoneByName, getTimeZoneName } from "./timezoneHelper";
|
|
2
|
+
|
|
3
|
+
describe("Timezone Helper", () => {
|
|
4
|
+
beforeEach(() => {
|
|
5
|
+
jest.spyOn(Intl, "DateTimeFormat").mockImplementation(() => ({
|
|
6
|
+
resolvedOptions: () => ({
|
|
7
|
+
timeZone: "Europe/Amsterdam",
|
|
8
|
+
}),
|
|
9
|
+
}));
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
afterEach(() => {
|
|
13
|
+
jest.restoreAllMocks();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("Retrieves customer timezone", () => {
|
|
17
|
+
expect(getTimeZone, "called with", [], "to satisfy", "Europe/Amsterdam");
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("Retrieves timezone short name by passed name", () => {
|
|
21
|
+
const timezoneName = "Central America Standard Time";
|
|
22
|
+
expect(getTimeZoneByName, "called with", [timezoneName], "to satisfy", "America/Guatemala");
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("Returns user timezone if passed name is not found", () => {
|
|
26
|
+
const timezoneName = "Test Timezone";
|
|
27
|
+
expect(getTimeZoneByName, "called with", [timezoneName], "to satisfy", "Europe/Amsterdam");
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("Retrieves user timezone name", () => {
|
|
31
|
+
expect(getTimeZoneName, "called with", [], "to satisfy", "W. Europe Standard Time");
|
|
32
|
+
});
|
|
33
|
+
});
|
package/src/utils/urlHelper.js
CHANGED
|
@@ -26,3 +26,9 @@ export const tryGetNewEntityIdKey = url => {
|
|
|
26
26
|
if (match) return match[1];
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
|
+
|
|
30
|
+
export const resolveEntityId = (url, path, entityIdKey) => {
|
|
31
|
+
const newKey = tryGetNewEntityIdKey(url);
|
|
32
|
+
const key = entityIdKey === newKey ? entityIdKey : `:${entityIdKey}`;
|
|
33
|
+
return getValueFromUrlByKey(url, path, key);
|
|
34
|
+
};
|