@beinformed/ui 1.19.5 → 1.20.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.
Files changed (84) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/esm/constants/Constants.js +5 -0
  3. package/esm/constants/Constants.js.map +1 -1
  4. package/esm/hooks/useContent.js +2 -6
  5. package/esm/hooks/useContent.js.map +1 -1
  6. package/esm/hooks/useI18n.js +10 -11
  7. package/esm/hooks/useI18n.js.map +1 -1
  8. package/esm/hooks/useModularUI.js +2 -3
  9. package/esm/hooks/useModularUI.js.map +1 -1
  10. package/esm/hooks/useModularUIRequest.js +2 -5
  11. package/esm/hooks/useModularUIRequest.js.map +1 -1
  12. package/esm/i18n/Message.js.map +1 -1
  13. package/esm/i18n/withMessage.js +2 -10
  14. package/esm/i18n/withMessage.js.map +1 -1
  15. package/esm/redux/_modularui/connector.js +3 -4
  16. package/esm/redux/_modularui/connector.js.map +1 -1
  17. package/esm/redux/_modularui/selectors.js +22 -5
  18. package/esm/redux/_modularui/selectors.js.map +1 -1
  19. package/esm/redux/_modularui/withModularUI.js +2 -10
  20. package/esm/redux/_modularui/withModularUI.js.map +1 -1
  21. package/esm/redux/actions/Application.js +26 -7
  22. package/esm/redux/actions/Application.js.map +1 -1
  23. package/esm/redux/selectors/i18n.js +16 -0
  24. package/esm/redux/selectors/i18n.js.map +1 -0
  25. package/esm/utils/datetime/DateTimeUtil.js +3 -1
  26. package/esm/utils/datetime/DateTimeUtil.js.map +1 -1
  27. package/lib/constants/Constants.js +8 -2
  28. package/lib/constants/Constants.js.flow +5 -0
  29. package/lib/constants/Constants.js.map +1 -1
  30. package/lib/hooks/__tests__/useAuthentication.spec.js.flow +0 -8
  31. package/lib/hooks/useContent.js +3 -7
  32. package/lib/hooks/useContent.js.flow +2 -2
  33. package/lib/hooks/useContent.js.map +1 -1
  34. package/lib/hooks/useI18n.js +12 -9
  35. package/lib/hooks/useI18n.js.flow +10 -11
  36. package/lib/hooks/useI18n.js.map +1 -1
  37. package/lib/hooks/useModularUI.js +3 -3
  38. package/lib/hooks/useModularUI.js.flow +3 -2
  39. package/lib/hooks/useModularUI.js.map +1 -1
  40. package/lib/hooks/useModularUIRequest.js +2 -4
  41. package/lib/hooks/useModularUIRequest.js.flow +8 -10
  42. package/lib/hooks/useModularUIRequest.js.map +1 -1
  43. package/lib/i18n/Message.js.flow +1 -1
  44. package/lib/i18n/Message.js.map +1 -1
  45. package/lib/i18n/withMessage.js +2 -8
  46. package/lib/i18n/withMessage.js.flow +3 -4
  47. package/lib/i18n/withMessage.js.map +1 -1
  48. package/lib/redux/_modularui/connector.js +3 -3
  49. package/lib/redux/_modularui/connector.js.flow +3 -2
  50. package/lib/redux/_modularui/connector.js.map +1 -1
  51. package/lib/redux/_modularui/selectors.js +26 -6
  52. package/lib/redux/_modularui/selectors.js.flow +19 -1
  53. package/lib/redux/_modularui/selectors.js.map +1 -1
  54. package/lib/redux/_modularui/withModularUI.js +3 -9
  55. package/lib/redux/_modularui/withModularUI.js.flow +3 -5
  56. package/lib/redux/_modularui/withModularUI.js.map +1 -1
  57. package/lib/redux/actions/Application.js +31 -8
  58. package/lib/redux/actions/Application.js.flow +6 -8
  59. package/lib/redux/actions/Application.js.map +1 -1
  60. package/lib/redux/actions/__tests__/Application.spec.js.flow +1 -5
  61. package/lib/redux/actions/__tests__/Authorization.spec.js.flow +1 -1
  62. package/lib/redux/selectors/i18n.js +28 -0
  63. package/lib/redux/selectors/i18n.js.flow +15 -0
  64. package/lib/redux/selectors/i18n.js.map +1 -0
  65. package/lib/utils/datetime/DateTimeUtil.js +3 -1
  66. package/lib/utils/datetime/DateTimeUtil.js.flow +1 -1
  67. package/lib/utils/datetime/DateTimeUtil.js.map +1 -1
  68. package/package.json +1 -1
  69. package/src/constants/Constants.js +5 -0
  70. package/src/hooks/__tests__/useAuthentication.spec.js +0 -8
  71. package/src/hooks/useContent.js +2 -2
  72. package/src/hooks/useI18n.js +10 -11
  73. package/src/hooks/useModularUI.js +3 -2
  74. package/src/hooks/useModularUIRequest.js +8 -10
  75. package/src/i18n/Message.js +1 -1
  76. package/src/i18n/withMessage.js +3 -4
  77. package/src/redux/_modularui/connector.js +3 -2
  78. package/src/redux/_modularui/selectors.js +19 -1
  79. package/src/redux/_modularui/withModularUI.js +3 -5
  80. package/src/redux/actions/Application.js +6 -8
  81. package/src/redux/actions/__tests__/Application.spec.js +1 -5
  82. package/src/redux/actions/__tests__/Authorization.spec.js +1 -1
  83. package/src/redux/selectors/i18n.js +15 -0
  84. package/src/utils/datetime/DateTimeUtil.js +1 -1
@@ -39,7 +39,9 @@ var BaseDateTimeUtil = /*#__PURE__*/function () {
39
39
  (0, _createClass2.default)(BaseDateTimeUtil, [{
40
40
  key: "getLocale",
41
41
  value: function getLocale() {
42
- var locale = (0, _Cookies.getCookie)("locale") || "en";
42
+ var _getCookie;
43
+
44
+ var locale = (_getCookie = (0, _Cookies.getCookie)("locale")) !== null && _getCookie !== void 0 ? _getCookie : "en";
43
45
 
44
46
  if (locale === "nl") {
45
47
  return _locale.nl;
@@ -63,7 +63,7 @@ class BaseDateTimeUtil {
63
63
  /**
64
64
  */
65
65
  getLocale(): typeof nl | typeof enGB {
66
- const locale = getCookie("locale") || "en";
66
+ const locale = getCookie("locale") ?? "en";
67
67
 
68
68
  if (locale === "nl") {
69
69
  return nl;
@@ -1 +1 @@
1
- {"version":3,"file":"DateTimeUtil.js","names":["BaseDateTimeUtil","isoFormat","_isoFormat","locale","getCookie","nl","enGB","weekStartsOn","getSetting","DEFAULT_WEEK_STARTS_ON","firstWeekContainsDate","DEFAULT_FIRST_WEEK_CONTAINS_DATE","date","inputFormat","getOptions","parse","Date","targetFormat","parsedDate","toDate","isValid","format","getLocale","sourceFormat","toISO","realDate","formattedValue","isOutsideRange","isBefore","isAfter","replace","toUpperCase","inputDate","afterISODate","isSame","beforeISODate","compareDate","getTime","isSameDay","SATURDAY_NUMBER","SUNDAY_NUMBER","weekDay","getDay","amount","addSeconds","addMinutes","addHours","addDays","addWeeks","addMonths","addYears","subSeconds","subMinutes","subHours","subDays","subWeeks","subMonths","subYears","startOfMonth","endOfMonth","startOfWeek","getHours","getMinutes","getWeek","year","setYear","month","setMonth","hour","setHours","minute","setMinutes","second","setSeconds","milliseconds","setMilliseconds","hours","minutes","seconds","set","DateUtil","ISO_DATE_FORMAT","DateTimeUtil","ISO_DATETIME_FORMAT","TimeUtil","ISO_TIME_FORMAT","TimestampUtil","ISO_TIMESTAMP_FORMAT"],"sources":["../../../src/utils/datetime/DateTimeUtil.js"],"sourcesContent":["// @flow\nimport {\n parse,\n format,\n isValid,\n isAfter,\n isBefore,\n isSameDay,\n addSeconds,\n addMinutes,\n addHours,\n addDays,\n addWeeks,\n addMonths,\n addYears,\n subSeconds,\n subMinutes,\n subHours,\n subDays,\n subWeeks,\n subMonths,\n subYears,\n startOfMonth,\n endOfMonth,\n startOfWeek,\n getHours,\n getMinutes,\n getDay,\n getWeek,\n setMilliseconds,\n setSeconds,\n setMinutes,\n setHours,\n setMonth,\n setYear,\n set,\n} from \"date-fns\";\nimport { nl, enGB } from \"date-fns/locale\";\n\nimport { getCookie } from \"../browser/Cookies\";\n\nimport { getSetting } from \"../../constants/Settings\";\n\nimport {\n ISO_DATE_FORMAT,\n ISO_DATETIME_FORMAT,\n ISO_TIME_FORMAT,\n ISO_TIMESTAMP_FORMAT,\n DEFAULT_WEEK_STARTS_ON,\n DEFAULT_FIRST_WEEK_CONTAINS_DATE,\n} from \"../../constants\";\n\n/**\n * @hideconstructor\n */\nclass BaseDateTimeUtil {\n _isoFormat: string;\n\n constructor(isoFormat: string) {\n this._isoFormat = isoFormat;\n }\n\n /**\n */\n getLocale(): typeof nl | typeof enGB {\n const locale = getCookie(\"locale\") || \"en\";\n\n if (locale === \"nl\") {\n return nl;\n }\n\n return enGB;\n }\n\n // returns the options defined in settings\n getOptions(): {\n weekStartsOn: 0 | 1 | 2 | 3 | 4 | 5 | 6,\n firstWeekContainsDate: 1 | 2 | 3 | 4 | 5 | 6 | 7,\n } {\n // indicates on what day the week starts\n const weekStartsOn = getSetting(\n \"CALENDAR_WEEK_STARTS_ON\",\n DEFAULT_WEEK_STARTS_ON\n );\n\n // indicates which date indicates the first week of the year\n const firstWeekContainsDate = getSetting(\n \"CALENDAR_FIRST_WEEK_CONTAINS_DATE\",\n DEFAULT_FIRST_WEEK_CONTAINS_DATE\n );\n\n return { weekStartsOn, firstWeekContainsDate };\n }\n\n /**\n */\n toDate(date: string, inputFormat: string = this._isoFormat): Date {\n const { weekStartsOn, firstWeekContainsDate } = this.getOptions();\n\n return parse(date, inputFormat, new Date(), {\n weekStartsOn,\n firstWeekContainsDate,\n });\n }\n\n /**\n */\n toFormat(date: string | Date, targetFormat: string): string {\n const { weekStartsOn } = this.getOptions();\n\n const parsedDate = typeof date === \"string\" ? this.toDate(date) : date;\n\n if (isValid(parsedDate)) {\n return format(parsedDate, targetFormat, {\n weekStartsOn,\n locale: this.getLocale(),\n });\n }\n\n return \"Invalid Date\";\n }\n\n /**\n */\n toISO(date: string | Date, sourceFormat: string = this._isoFormat): string {\n const { weekStartsOn } = this.getOptions();\n\n const parsedDate =\n typeof date === \"string\" ? this.toDate(date, sourceFormat) : date;\n\n if (isValid(parsedDate)) {\n return format(parsedDate, this._isoFormat, {\n weekStartsOn,\n });\n }\n\n return \"Invalid Date\";\n }\n\n /**\n */\n now(): string {\n return this.toISO(new Date());\n }\n\n /**\n */\n convertFormat(sourceFormat: string): string {\n return sourceFormat ? sourceFormat : this._isoFormat;\n }\n\n /**\n * VALIDATION\n */\n hasFormat(date: string, sourceFormat: string): boolean {\n const { weekStartsOn } = this.getOptions();\n\n const realDate = this.toDate(date, sourceFormat);\n if (isValid(realDate)) {\n const formattedValue = format(realDate, sourceFormat, {\n weekStartsOn,\n });\n\n const isOutsideRange =\n isBefore(realDate, new Date(1000, 1, 1)) ||\n isAfter(realDate, new Date(9999, 11, 31));\n if (isOutsideRange) {\n return false;\n }\n\n return (\n formattedValue.replace(/0/gu, \"\").toUpperCase() ===\n date.replace(/0/gu, \"\").toUpperCase()\n );\n }\n\n return false;\n }\n\n /**\n */\n isValid(date: string, inputFormat: string = this._isoFormat): boolean {\n return isValid(this.toDate(date, inputFormat));\n }\n\n /**\n */\n isAfter(\n inputDate: string,\n afterISODate: ?string,\n inputFormat: string = this._isoFormat\n ): boolean {\n return (\n afterISODate != null &&\n isAfter(this.toDate(inputDate, inputFormat), this.toDate(afterISODate))\n );\n }\n\n /**\n */\n isSameOrAfter(\n inputDate: string,\n afterISODate: ?string,\n inputFormat: string = this._isoFormat\n ): boolean {\n return (\n afterISODate != null &&\n (this.isAfter(inputDate, afterISODate, inputFormat) ||\n this.isSame(inputDate, afterISODate, inputFormat))\n );\n }\n\n /**\n */\n isBefore(\n inputDate: string,\n beforeISODate: ?string,\n inputFormat: string = this._isoFormat\n ): boolean {\n return (\n beforeISODate != null &&\n isBefore(this.toDate(inputDate, inputFormat), this.toDate(beforeISODate))\n );\n }\n\n /**\n */\n isSameOrBefore(\n inputDate: string,\n beforeISODate: ?string,\n inputFormat: string = this._isoFormat\n ): boolean {\n return (\n beforeISODate != null &&\n (this.isBefore(inputDate, beforeISODate, inputFormat) ||\n this.isSame(inputDate, beforeISODate, inputFormat))\n );\n }\n\n /**\n */\n isSame(\n inputDate: string,\n compareDate: ?string,\n inputFormat: string = this._isoFormat\n ): boolean {\n return (\n compareDate != null &&\n this.toDate(inputDate, inputFormat).getTime() ===\n this.toDate(compareDate).getTime()\n );\n }\n\n /**\n */\n isSameDay(\n inputDate: string,\n compareDate: string,\n inputFormat: string = this._isoFormat\n ): boolean {\n return (\n compareDate != null &&\n isSameDay(\n this.toDate(inputDate, inputFormat),\n this.toDate(compareDate, inputFormat)\n )\n );\n }\n\n /**\n */\n isOther(\n inputDate: string,\n compareDate: ?string,\n inputFormat: string = this._isoFormat\n ): boolean {\n return !this.isSame(inputDate, compareDate, inputFormat);\n }\n\n /**\n */\n isWeekend(inputDate: string): boolean {\n const SATURDAY_NUMBER = 6;\n const SUNDAY_NUMBER = 0;\n const weekDay = getDay(this.toDate(inputDate));\n\n return weekDay === SATURDAY_NUMBER || weekDay === SUNDAY_NUMBER;\n }\n\n /**\n * CALCULATIONS\n */\n addSeconds(date: string, amount: number): string {\n return this.toISO(addSeconds(this.toDate(date), amount));\n }\n\n /**\n */\n addMinutes(date: string, amount: number): string {\n return this.toISO(addMinutes(this.toDate(date), amount));\n }\n\n /**\n */\n addHours(date: string, amount: number): string {\n return this.toISO(addHours(this.toDate(date), amount));\n }\n\n /**\n */\n addDays(date: string, amount: number): string {\n return this.toISO(addDays(this.toDate(date), amount));\n }\n\n /**\n */\n addWeeks(date: string, amount: number): string {\n return this.toISO(addWeeks(this.toDate(date), amount));\n }\n\n /**\n */\n addMonths(date: string, amount: number): string {\n return this.toISO(addMonths(this.toDate(date), amount));\n }\n\n /**\n */\n addYears(date: string, amount: number): string {\n return this.toISO(addYears(this.toDate(date), amount));\n }\n\n /**\n */\n subtractSeconds(date: string, amount: number): string {\n return this.toISO(subSeconds(this.toDate(date), amount));\n }\n\n /**\n */\n subtractMinutes(date: string, amount: number): string {\n return this.toISO(subMinutes(this.toDate(date), amount));\n }\n\n /**\n */\n subtractHours(date: string, amount: number): string {\n return this.toISO(subHours(this.toDate(date), amount));\n }\n\n /**\n */\n subtractDays(date: string, amount: number): string {\n return this.toISO(subDays(this.toDate(date), amount));\n }\n\n /**\n */\n subtractWeeks(date: string, amount: number): string {\n return this.toISO(subWeeks(this.toDate(date), amount));\n }\n\n /**\n */\n subtractMonths(date: string, amount: number): string {\n return this.toISO(subMonths(this.toDate(date), amount));\n }\n\n /**\n */\n subtractYears(date: string, amount: number): string {\n return this.toISO(subYears(this.toDate(date), amount));\n }\n\n /**\n * GETTERS\n */\n startOfMonth(date: string, inputFormat: string = this._isoFormat): string {\n return this.toISO(startOfMonth(this.toDate(date, inputFormat)));\n }\n\n /**\n */\n endOfMonth(date: string, inputFormat: string = this._isoFormat): string {\n return this.toISO(endOfMonth(this.toDate(date, inputFormat)));\n }\n\n /**\n */\n startOfWeek(date: string, inputFormat: string = this._isoFormat): string {\n const { weekStartsOn } = this.getOptions();\n\n return this.toISO(\n startOfWeek(this.toDate(date, inputFormat), {\n weekStartsOn,\n })\n );\n }\n\n /**\n */\n getHours(date: string | Date): number {\n const parsedDate = typeof date === \"string\" ? this.toDate(date) : date;\n return getHours(parsedDate);\n }\n\n /**\n */\n getMinutes(date: string | Date): number {\n const parsedDate = typeof date === \"string\" ? this.toDate(date) : date;\n return getMinutes(parsedDate);\n }\n\n /**\n */\n getWeek(date: string): number {\n const { weekStartsOn, firstWeekContainsDate } = this.getOptions();\n\n return getWeek(this.toDate(date), {\n weekStartsOn,\n firstWeekContainsDate,\n });\n }\n\n /**\n * SETTERS\n */\n setYear(date: string, year: number): string {\n return this.toISO(setYear(this.toDate(date), year));\n }\n\n /**\n */\n setMonth(date: string, month: number): string {\n return this.toISO(setMonth(this.toDate(date), month));\n }\n\n /**\n */\n setHour(date: string, hour: number): string {\n return this.toISO(setHours(this.toDate(date), hour));\n }\n\n /**\n */\n setMinute(date: string, minute: number): string {\n return this.toISO(setMinutes(this.toDate(date), minute));\n }\n\n /**\n */\n setSecond(date: string, second: number): string {\n return this.toISO(setSeconds(this.toDate(date), second));\n }\n\n /**\n */\n setMilliseconds(date: string, milliseconds: number): string {\n return this.toISO(setMilliseconds(this.toDate(date), milliseconds));\n }\n\n /**\n */\n setTime(\n date: string,\n hours: number,\n minutes: number,\n seconds: number,\n milliseconds: number\n ): string {\n return this.toISO(\n set(this.toDate(date), {\n hours,\n minutes,\n seconds,\n milliseconds,\n })\n );\n }\n}\n\n/**\n * DateUtil\n */\nconst DateUtil: BaseDateTimeUtil = new BaseDateTimeUtil(ISO_DATE_FORMAT);\n\n/**\n * DateTimeUtil\n */\nconst DateTimeUtil: BaseDateTimeUtil = new BaseDateTimeUtil(\n ISO_DATETIME_FORMAT\n);\n\n/**\n * TimeUtil\n */\nconst TimeUtil: BaseDateTimeUtil = new BaseDateTimeUtil(ISO_TIME_FORMAT);\n\n/**\n * TimestampUtil\n */\nconst TimestampUtil: BaseDateTimeUtil = new BaseDateTimeUtil(\n ISO_TIMESTAMP_FORMAT\n);\n\nexport { DateUtil, DateTimeUtil, TimeUtil, TimestampUtil };\n"],"mappings":";;;;;;;;;;;;;;;AACA;;AAoCA;;AAEA;;AAEA;;AAEA;;AASA;AACA;AACA;IACMA,gB;EAGJ,0BAAYC,SAAZ,EAA+B;IAAA;IAAA;IAC7B,KAAKC,UAAL,GAAkBD,SAAlB;EACD;EAED;AACF;;;;;WACE,qBAAqC;MACnC,IAAME,MAAM,GAAG,IAAAC,kBAAA,EAAU,QAAV,KAAuB,IAAtC;;MAEA,IAAID,MAAM,KAAK,IAAf,EAAqB;QACnB,OAAOE,UAAP;MACD;;MAED,OAAOC,YAAP;IACD,C,CAED;;;;WACA,sBAGE;MACA;MACA,IAAMC,YAAY,GAAG,IAAAC,oBAAA,EACnB,yBADmB,EAEnBC,iCAFmB,CAArB,CAFA,CAOA;;MACA,IAAMC,qBAAqB,GAAG,IAAAF,oBAAA,EAC5B,mCAD4B,EAE5BG,2CAF4B,CAA9B;MAKA,OAAO;QAAEJ,YAAY,EAAZA,YAAF;QAAgBG,qBAAqB,EAArBA;MAAhB,CAAP;IACD;IAED;AACF;;;;WACE,gBAAOE,IAAP,EAAkE;MAAA,IAA7CC,WAA6C,uEAAvB,KAAKX,UAAkB;;MAChE,uBAAgD,KAAKY,UAAL,EAAhD;MAAA,IAAQP,YAAR,oBAAQA,YAAR;MAAA,IAAsBG,qBAAtB,oBAAsBA,qBAAtB;;MAEA,OAAO,IAAAK,cAAA,EAAMH,IAAN,EAAYC,WAAZ,EAAyB,IAAIG,IAAJ,EAAzB,EAAqC;QAC1CT,YAAY,EAAZA,YAD0C;QAE1CG,qBAAqB,EAArBA;MAF0C,CAArC,CAAP;IAID;IAED;AACF;;;;WACE,kBAASE,IAAT,EAA8BK,YAA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imeUtil","isoFormat","_isoFormat","locale","getCookie","nl","enGB","weekStartsOn","getSetting","DEFAULT_WEEK_STARTS_ON","firstWeekContainsDate","DEFAULT_FIRST_WEEK_CONTAINS_DATE","date","inputFormat","getOptions","parse","Date","targetFormat","parsedDate","toDate","isValid","format","getLocale","sourceFormat","toISO","realDate","formattedValue","isOutsideRange","isBefore","isAfter","replace","toUpperCase","inputDate","afterISODate","isSame","beforeISODate","compareDate","getTime","isSameDay","SATURDAY_NUMBER","SUNDAY_NUMBER","weekDay","getDay","amount","addSeconds","addMinutes","addHours","addDays","addWeeks","addMonths","addYears","subSeconds","subMinutes","subHours","subDays","subWeeks","subMonths","subYears","startOfMonth","endOfMonth","startOfWeek","getHours","getMinutes","getWeek","year","setYear","month","setMonth","hour","setHours","minute","setMinutes","second","setSeconds","milliseconds","setMilliseconds","hours","minutes","seconds","set","DateUtil","ISO_DATE_FORMAT","DateTimeUtil","ISO_DATETIME_FORMAT","TimeUtil","ISO_TIME_FORMAT","TimestampUtil","ISO_TIMESTAMP_FORMAT"],"sources":["../../../src/utils/datetime/DateTimeUtil.js"],"sourcesContent":["// @flow\nimport {\n parse,\n format,\n isValid,\n isAfter,\n isBefore,\n isSameDay,\n addSeconds,\n addMinutes,\n addHours,\n addDays,\n addWeeks,\n addMonths,\n addYears,\n subSeconds,\n subMinutes,\n subHours,\n subDays,\n subWeeks,\n subMonths,\n subYears,\n startOfMonth,\n endOfMonth,\n startOfWeek,\n getHours,\n getMinutes,\n getDay,\n getWeek,\n setMilliseconds,\n setSeconds,\n setMinutes,\n setHours,\n setMonth,\n setYear,\n set,\n} from \"date-fns\";\nimport { nl, enGB } from \"date-fns/locale\";\n\nimport { getCookie } from \"../browser/Cookies\";\n\nimport { getSetting } from \"../../constants/Settings\";\n\nimport {\n ISO_DATE_FORMAT,\n ISO_DATETIME_FORMAT,\n ISO_TIME_FORMAT,\n ISO_TIMESTAMP_FORMAT,\n DEFAULT_WEEK_STARTS_ON,\n DEFAULT_FIRST_WEEK_CONTAINS_DATE,\n} from \"../../constants\";\n\n/**\n * @hideconstructor\n */\nclass BaseDateTimeUtil {\n _isoFormat: string;\n\n constructor(isoFormat: string) {\n this._isoFormat = isoFormat;\n }\n\n /**\n */\n getLocale(): typeof nl | typeof enGB {\n const locale = getCookie(\"locale\") ?? \"en\";\n\n if (locale === \"nl\") {\n return nl;\n }\n\n return enGB;\n }\n\n // returns the options defined in settings\n getOptions(): {\n weekStartsOn: 0 | 1 | 2 | 3 | 4 | 5 | 6,\n firstWeekContainsDate: 1 | 2 | 3 | 4 | 5 | 6 | 7,\n } {\n // indicates on what day the week starts\n const weekStartsOn = getSetting(\n \"CALENDAR_WEEK_STARTS_ON\",\n DEFAULT_WEEK_STARTS_ON\n );\n\n // indicates which date indicates the first week of the year\n const firstWeekContainsDate = getSetting(\n \"CALENDAR_FIRST_WEEK_CONTAINS_DATE\",\n DEFAULT_FIRST_WEEK_CONTAINS_DATE\n );\n\n return { weekStartsOn, firstWeekContainsDate };\n }\n\n /**\n */\n toDate(date: string, inputFormat: string = this._isoFormat): Date {\n const { weekStartsOn, firstWeekContainsDate } = this.getOptions();\n\n return parse(date, inputFormat, new Date(), {\n weekStartsOn,\n firstWeekContainsDate,\n });\n }\n\n /**\n */\n toFormat(date: string | Date, targetFormat: string): string {\n const { weekStartsOn } = this.getOptions();\n\n const parsedDate = typeof date === \"string\" ? this.toDate(date) : date;\n\n if (isValid(parsedDate)) {\n return format(parsedDate, targetFormat, {\n weekStartsOn,\n locale: this.getLocale(),\n });\n }\n\n return \"Invalid Date\";\n }\n\n /**\n */\n toISO(date: string | Date, sourceFormat: string = this._isoFormat): string {\n const { weekStartsOn } = this.getOptions();\n\n const parsedDate =\n typeof date === \"string\" ? this.toDate(date, sourceFormat) : date;\n\n if (isValid(parsedDate)) {\n return format(parsedDate, this._isoFormat, {\n weekStartsOn,\n });\n }\n\n return \"Invalid Date\";\n }\n\n /**\n */\n now(): string {\n return this.toISO(new Date());\n }\n\n /**\n */\n convertFormat(sourceFormat: string): string {\n return sourceFormat ? sourceFormat : this._isoFormat;\n }\n\n /**\n * VALIDATION\n */\n hasFormat(date: string, sourceFormat: string): boolean {\n const { weekStartsOn } = this.getOptions();\n\n const realDate = this.toDate(date, sourceFormat);\n if (isValid(realDate)) {\n const formattedValue = format(realDate, sourceFormat, {\n weekStartsOn,\n });\n\n const isOutsideRange =\n isBefore(realDate, new Date(1000, 1, 1)) ||\n isAfter(realDate, new Date(9999, 11, 31));\n if (isOutsideRange) {\n return false;\n }\n\n return (\n formattedValue.replace(/0/gu, \"\").toUpperCase() ===\n date.replace(/0/gu, \"\").toUpperCase()\n );\n }\n\n return false;\n }\n\n /**\n */\n isValid(date: string, inputFormat: string = this._isoFormat): boolean {\n return isValid(this.toDate(date, inputFormat));\n }\n\n /**\n */\n isAfter(\n inputDate: string,\n afterISODate: ?string,\n inputFormat: string = this._isoFormat\n ): boolean {\n return (\n afterISODate != null &&\n isAfter(this.toDate(inputDate, inputFormat), this.toDate(afterISODate))\n );\n }\n\n /**\n */\n isSameOrAfter(\n inputDate: string,\n afterISODate: ?string,\n inputFormat: string = this._isoFormat\n ): boolean {\n return (\n afterISODate != null &&\n (this.isAfter(inputDate, afterISODate, inputFormat) ||\n this.isSame(inputDate, afterISODate, inputFormat))\n );\n }\n\n /**\n */\n isBefore(\n inputDate: string,\n beforeISODate: ?string,\n inputFormat: string = this._isoFormat\n ): boolean {\n return (\n beforeISODate != null &&\n isBefore(this.toDate(inputDate, inputFormat), this.toDate(beforeISODate))\n );\n }\n\n /**\n */\n isSameOrBefore(\n inputDate: string,\n beforeISODate: ?string,\n inputFormat: string = this._isoFormat\n ): boolean {\n return (\n beforeISODate != null &&\n (this.isBefore(inputDate, beforeISODate, inputFormat) ||\n this.isSame(inputDate, beforeISODate, inputFormat))\n );\n }\n\n /**\n */\n isSame(\n inputDate: string,\n compareDate: ?string,\n inputFormat: string = this._isoFormat\n ): boolean {\n return (\n compareDate != null &&\n this.toDate(inputDate, inputFormat).getTime() ===\n this.toDate(compareDate).getTime()\n );\n }\n\n /**\n */\n isSameDay(\n inputDate: string,\n compareDate: string,\n inputFormat: string = this._isoFormat\n ): boolean {\n return (\n compareDate != null &&\n isSameDay(\n this.toDate(inputDate, inputFormat),\n this.toDate(compareDate, inputFormat)\n )\n );\n }\n\n /**\n */\n isOther(\n inputDate: string,\n compareDate: ?string,\n inputFormat: string = this._isoFormat\n ): boolean {\n return !this.isSame(inputDate, compareDate, inputFormat);\n }\n\n /**\n */\n isWeekend(inputDate: string): boolean {\n const SATURDAY_NUMBER = 6;\n const SUNDAY_NUMBER = 0;\n const weekDay = getDay(this.toDate(inputDate));\n\n return weekDay === SATURDAY_NUMBER || weekDay === SUNDAY_NUMBER;\n }\n\n /**\n * CALCULATIONS\n */\n addSeconds(date: string, amount: number): string {\n return this.toISO(addSeconds(this.toDate(date), amount));\n }\n\n /**\n */\n addMinutes(date: string, amount: number): string {\n return this.toISO(addMinutes(this.toDate(date), amount));\n }\n\n /**\n */\n addHours(date: string, amount: number): string {\n return this.toISO(addHours(this.toDate(date), amount));\n }\n\n /**\n */\n addDays(date: string, amount: number): string {\n return this.toISO(addDays(this.toDate(date), amount));\n }\n\n /**\n */\n addWeeks(date: string, amount: number): string {\n return this.toISO(addWeeks(this.toDate(date), amount));\n }\n\n /**\n */\n addMonths(date: string, amount: number): string {\n return this.toISO(addMonths(this.toDate(date), amount));\n }\n\n /**\n */\n addYears(date: string, amount: number): string {\n return this.toISO(addYears(this.toDate(date), amount));\n }\n\n /**\n */\n subtractSeconds(date: string, amount: number): string {\n return this.toISO(subSeconds(this.toDate(date), amount));\n }\n\n /**\n */\n subtractMinutes(date: string, amount: number): string {\n return this.toISO(subMinutes(this.toDate(date), amount));\n }\n\n /**\n */\n subtractHours(date: string, amount: number): string {\n return this.toISO(subHours(this.toDate(date), amount));\n }\n\n /**\n */\n subtractDays(date: string, amount: number): string {\n return this.toISO(subDays(this.toDate(date), amount));\n }\n\n /**\n */\n subtractWeeks(date: string, amount: number): string {\n return this.toISO(subWeeks(this.toDate(date), amount));\n }\n\n /**\n */\n subtractMonths(date: string, amount: number): string {\n return this.toISO(subMonths(this.toDate(date), amount));\n }\n\n /**\n */\n subtractYears(date: string, amount: number): string {\n return this.toISO(subYears(this.toDate(date), amount));\n }\n\n /**\n * GETTERS\n */\n startOfMonth(date: string, inputFormat: string = this._isoFormat): string {\n return this.toISO(startOfMonth(this.toDate(date, inputFormat)));\n }\n\n /**\n */\n endOfMonth(date: string, inputFormat: string = this._isoFormat): string {\n return this.toISO(endOfMonth(this.toDate(date, inputFormat)));\n }\n\n /**\n */\n startOfWeek(date: string, inputFormat: string = this._isoFormat): string {\n const { weekStartsOn } = this.getOptions();\n\n return this.toISO(\n startOfWeek(this.toDate(date, inputFormat), {\n weekStartsOn,\n })\n );\n }\n\n /**\n */\n getHours(date: string | Date): number {\n const parsedDate = typeof date === \"string\" ? this.toDate(date) : date;\n return getHours(parsedDate);\n }\n\n /**\n */\n getMinutes(date: string | Date): number {\n const parsedDate = typeof date === \"string\" ? this.toDate(date) : date;\n return getMinutes(parsedDate);\n }\n\n /**\n */\n getWeek(date: string): number {\n const { weekStartsOn, firstWeekContainsDate } = this.getOptions();\n\n return getWeek(this.toDate(date), {\n weekStartsOn,\n firstWeekContainsDate,\n });\n }\n\n /**\n * SETTERS\n */\n setYear(date: string, year: number): string {\n return this.toISO(setYear(this.toDate(date), year));\n }\n\n /**\n */\n setMonth(date: string, month: number): string {\n return this.toISO(setMonth(this.toDate(date), month));\n }\n\n /**\n */\n setHour(date: string, hour: number): string {\n return this.toISO(setHours(this.toDate(date), hour));\n }\n\n /**\n */\n setMinute(date: string, minute: number): string {\n return this.toISO(setMinutes(this.toDate(date), minute));\n }\n\n /**\n */\n setSecond(date: string, second: number): string {\n return this.toISO(setSeconds(this.toDate(date), second));\n }\n\n /**\n */\n setMilliseconds(date: string, milliseconds: number): string {\n return this.toISO(setMilliseconds(this.toDate(date), milliseconds));\n }\n\n /**\n */\n setTime(\n date: string,\n hours: number,\n minutes: number,\n seconds: number,\n milliseconds: number\n ): string {\n return this.toISO(\n set(this.toDate(date), {\n hours,\n minutes,\n seconds,\n milliseconds,\n })\n );\n }\n}\n\n/**\n * DateUtil\n */\nconst DateUtil: BaseDateTimeUtil = new BaseDateTimeUtil(ISO_DATE_FORMAT);\n\n/**\n * DateTimeUtil\n */\nconst DateTimeUtil: BaseDateTimeUtil = new BaseDateTimeUtil(\n ISO_DATETIME_FORMAT\n);\n\n/**\n * TimeUtil\n */\nconst TimeUtil: BaseDateTimeUtil = new BaseDateTimeUtil(ISO_TIME_FORMAT);\n\n/**\n * TimestampUtil\n */\nconst TimestampUtil: BaseDateTimeUtil = new BaseDateTimeUtil(\n ISO_TIMESTAMP_FORMAT\n);\n\nexport { DateUtil, DateTimeUtil, TimeUtil, TimestampUtil };\n"],"mappings":";;;;;;;;;;;;;;;AACA;;AAoCA;;AAEA;;AAEA;;AAEA;;AASA;AACA;AACA;IACMA,gB;EAGJ,0BAAYC,SAAZ,EAA+B;IAAA;IAAA;IAC7B,KAAKC,UAAL,GAAkBD,SAAlB;EACD;EAED;AACF;;;;;WACE,qBAAqC;MAAA;;MACnC,IAAME,MAAM,iBAAG,IAAAC,kBAAA,EAAU,QAAV,CAAH,mDAA0B,IAAtC;;MAEA,IAAID,MAAM,KAAK,IAAf,EAAqB;QACnB,OAAOE,UAAP;MACD;;MAED,OAAOC,YAAP;IACD,C,CAED;;;;WACA,sBAGE;MACA;MACA,IAAMC,YAAY,GAAG,IAAAC,oBAAA,EACnB,yBADmB,EAEnBC,iCAFmB,CAArB,CAFA,CAOA;;MACA,IAAMC,qBAAqB,GAAG,IAAAF,oBAAA,EAC5B,mCAD4B,EAE5BG,2CAF4B,CAA9B;MAKA,OAAO;QAAEJ,YAAY,EAAZA,YAAF;QAAgBG,qBAAqB,EAArBA;MAAhB,CAAP;IACD;IAED;AACF;;;;WACE,gBAAOE,IAAP,EAAkE;MAAA,IAA7CC,WAA6C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AA0B,GAAG,IAAIhF,gBAAJ,CAAqBiF,0BAArB,CAAnC;AAEA;AACA;AACA;;;AACA,IAAMC,YAA8B,GAAG,IAAIlF,gBAAJ,CACrCmF,8BADqC,CAAvC;AAIA;AACA;AACA;;;AACA,IAAMC,QAA0B,GAAG,IAAIpF,gBAAJ,CAAqBqF,0BAArB,CAAnC;AAEA;AACA;AACA;;;AACA,IAAMC,aAA+B,GAAG,IAAItF,gBAAJ,CACtCuF,+BADsC,CAAxC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beinformed/ui",
3
- "version": "1.19.5",
3
+ "version": "1.20.2",
4
4
  "description": "Toolbox for be informed javascript layouts",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "bugs": "http://support.beinformed.com",
@@ -56,6 +56,11 @@ export const CAPTCHA_PATH = `${BASE}/captchaServices`;
56
56
  */
57
57
  export const LOGIN_PATH = "/signin";
58
58
 
59
+ /**
60
+ * Path to administrator login page / component
61
+ */
62
+ export const ADMINISTRATOR_LOGIN_PATH = null;
63
+
59
64
  /**
60
65
  * Path to logout page / component
61
66
  */
@@ -61,10 +61,6 @@ describe("authentication hooks", () => {
61
61
 
62
62
  expect(store.getActions()).toStrictEqual([
63
63
  { type: "START_PROGRESS" },
64
- {
65
- type: "MODULARUI/REMOVE_KEY",
66
- payload: "application(/)(en)",
67
- },
68
64
  {
69
65
  type: "MODULARUI/STATUS",
70
66
  payload: { key: "application(/)(en)", status: "LOADING" },
@@ -112,10 +108,6 @@ describe("authentication hooks", () => {
112
108
  expect(store.getActions()).toStrictEqual([
113
109
  { type: "START_PROGRESS" },
114
110
  { type: "MODULARUI/RESET" },
115
- {
116
- type: "MODULARUI/REMOVE_KEY",
117
- payload: "application(/)(en)",
118
- },
119
111
  {
120
112
  type: "MODULARUI/STATUS",
121
113
  payload: { key: "application(/)(en)", status: "LOADING" },
@@ -1,11 +1,11 @@
1
1
  // @flow
2
2
  import { useState, useEffect } from "react";
3
- import { useSelector } from "react-redux";
4
3
 
5
4
  import SourceReferenceCollection from "../models/concepts/SourceReferenceCollection";
6
5
  import ModularUIRequest from "../modularui/ModularUIRequest";
7
6
 
8
7
  import { useProgressIndicator } from "../hooks/useProgressIndicator";
8
+ import { useLocale } from "../hooks/useI18n";
9
9
 
10
10
  import type ContentModel from "../models/content/ContentModel";
11
11
 
@@ -17,7 +17,7 @@ export const useContentFromSourceReferences = (
17
17
  renderChildSections: boolean
18
18
  ): Array<ContentModel> => {
19
19
  const [content, setContent] = useState([]);
20
- const localeCode = useSelector((state) => state.i18n.locale ?? "en");
20
+ const localeCode = useLocale();
21
21
 
22
22
  const { start, finish } = useProgressIndicator();
23
23
 
@@ -3,18 +3,13 @@ import { useSelector } from "react-redux";
3
3
  import { createSelector } from "reselect";
4
4
  import memoize from "lodash/memoize";
5
5
 
6
- const getLocaleCode = (state) => state.i18n.locale || "en";
7
- const getLocales = (state) => state.i18n.locales;
6
+ import { getLocales, getLocale } from "../redux/selectors/i18n";
8
7
 
9
8
  const getMessage = createSelector(
10
- [getLocales, getLocaleCode],
9
+ [getLocales, getLocale],
11
10
  (locales, localeCode) =>
12
11
  memoize(
13
- (
14
- id?: string | null,
15
- defaultMessage?: string | null,
16
- placeholders?: Object
17
- ) =>
12
+ (id: string, defaultMessage?: string, placeholders?: Object) =>
18
13
  locales
19
14
  .getLocale(localeCode)
20
15
  .getMessage(id, defaultMessage, placeholders),
@@ -25,8 +20,8 @@ const getMessage = createSelector(
25
20
  /**
26
21
  */
27
22
  const useMessage = (
28
- id?: string | null,
29
- defaultMessage?: string | null,
23
+ id: string,
24
+ defaultMessage?: string,
30
25
  placeholders?: Object | null
31
26
  ): any => useSelector(getMessage)(id, defaultMessage, placeholders);
32
27
 
@@ -34,4 +29,8 @@ const useMessage = (
34
29
  */
35
30
  const useTranslate = (): ((...any) => any) => useSelector(getMessage);
36
31
 
37
- export { useTranslate, useMessage };
32
+ /**
33
+ */
34
+ const useLocale = (): string => useSelector(getLocale);
35
+
36
+ export { useTranslate, useMessage, useLocale };
@@ -7,14 +7,15 @@ import { loadModularUI, removeModelByKey } from "../redux/_modularui/actions";
7
7
 
8
8
  import useDeepCompareEffect from "./useDeepCompareEffect";
9
9
 
10
+ import { useLocale } from "./useI18n";
11
+
10
12
  import type Href from "../models/href/Href";
11
13
  import type { RequestBaseOptions } from "../utils";
12
14
 
13
15
  /**
14
16
  */
15
17
  const useKeyForHook = (modelKey: string, url: string) => {
16
- const locale = useSelector((state) => state.i18n.locale);
17
-
18
+ const locale = useLocale();
18
19
  return `${modelKey}(${url.split("?")[0]})(${locale})`;
19
20
  };
20
21
 
@@ -3,20 +3,18 @@ import { createSelector } from "reselect";
3
3
  import { useSelector } from "react-redux";
4
4
 
5
5
  import ModularUIRequest from "../modularui/ModularUIRequest";
6
+ import { getLocale } from "../redux/selectors/i18n";
6
7
 
7
8
  import type { RequestBaseOptions } from "../utils";
8
9
  import type Href from "../models/href/Href";
9
10
 
10
- const getModularUIRequest = createSelector(
11
- [(state) => state.i18n.locale ?? "en"],
12
- (localeCode) => {
13
- return (href: Href, options?: $Shape<RequestBaseOptions>) => {
14
- const request = new ModularUIRequest(href, options);
15
- request.locale = localeCode;
16
- return request;
17
- };
18
- }
19
- );
11
+ const getModularUIRequest = createSelector([getLocale], (localeCode) => {
12
+ return (href: Href, options?: $Shape<RequestBaseOptions>) => {
13
+ const request = new ModularUIRequest(href, options);
14
+ request.locale = localeCode;
15
+ return request;
16
+ };
17
+ });
20
18
 
21
19
  /**
22
20
  * Creates a ModularUIRequest with the locale as available in the redux store
@@ -6,7 +6,7 @@ import { useMessage } from "../hooks/useI18n";
6
6
 
7
7
  type MessageProps = {
8
8
  +className?: string,
9
- +id?: string | null,
9
+ +id: string,
10
10
  +defaultMessage?: string | null,
11
11
  +children?: string,
12
12
  +data?: Object | null,
@@ -4,6 +4,8 @@ import { connect } from "react-redux";
4
4
  import { createSelector } from "reselect";
5
5
  import memoize from "lodash/memoize";
6
6
 
7
+ import { getLocales, getLocale } from "../redux/selectors/i18n";
8
+
7
9
  import type { ReduxState } from "../redux/types";
8
10
  import type { ComponentType } from "react";
9
11
 
@@ -20,11 +22,8 @@ type Props = {
20
22
  ...
21
23
  };
22
24
 
23
- const getLocaleCode = (state) => state.i18n.locale || "en";
24
- const getLocales = (state) => state.i18n.locales;
25
-
26
25
  const getMessage = createSelector(
27
- [getLocales, getLocaleCode],
26
+ [getLocales, getLocale],
28
27
  (locales, localeCode) =>
29
28
  memoize(
30
29
  (id: string, defaultMessage?: string, placeholders?: Object) =>
@@ -1,6 +1,6 @@
1
1
  // @flow
2
2
  import { useEffect } from "react";
3
- import { useDispatch, useSelector } from "react-redux";
3
+ import { useDispatch } from "react-redux";
4
4
  import { useLocation } from "react-router";
5
5
 
6
6
  import { loadModularUI, reloadModel, removeModelByKey } from "./actions";
@@ -10,6 +10,7 @@ import { getDisplayName } from "../../react/utils";
10
10
 
11
11
  import { useUrl, useReload } from "./modularuiUtils";
12
12
  import { useModularUI } from "../../hooks/useModularUI";
13
+ import { useLocale } from "../../hooks/useI18n";
13
14
 
14
15
  import type { ComponentType, Node } from "react";
15
16
  import type { Location } from "react-router";
@@ -88,7 +89,7 @@ const connector = (
88
89
  }, [dispatch, modelKey]);
89
90
 
90
91
  // Create new properties object to inject modularui properties to own props
91
- const locale = useSelector((state) => state.i18n.locale);
92
+ const locale = useLocale();
92
93
  const newProps: InjectedProps = {
93
94
  modelKey,
94
95
  [propName]: modelEntry ? modelEntry.model : null,
@@ -150,7 +150,6 @@ export const keyByHref = (state: ReduxState, href: Href | string): ?string => {
150
150
 
151
151
  return Object.keys(state.modularui).find((key) => {
152
152
  const { model } = state.modularui[key];
153
-
154
153
  return model && model.selfhref && model.selfhref.equals(findHref);
155
154
  });
156
155
  }
@@ -158,6 +157,25 @@ export const keyByHref = (state: ReduxState, href: Href | string): ?string => {
158
157
  return null;
159
158
  };
160
159
 
160
+ /**
161
+ * Returns all model keys found in the store, restrict on href
162
+ */
163
+ export const allKeysByHref = (
164
+ state: ReduxState,
165
+ href: Href | string
166
+ ): Array<string> => {
167
+ if (state && state.modularui) {
168
+ const findHref = href instanceof Href ? href : new Href(href);
169
+
170
+ return Object.keys(state.modularui).filter((key) => {
171
+ const { model } = state.modularui[key];
172
+ return model && model.selfhref && model.selfhref.equals(findHref);
173
+ });
174
+ }
175
+
176
+ return [];
177
+ };
178
+
161
179
  /**
162
180
  */
163
181
  const getLocation = (state): string => state?.router?.location.pathname;
@@ -9,6 +9,8 @@ import { startProgress, finishProgress } from "../actions/ProgressIndicator";
9
9
 
10
10
  import { handleError } from "../actions/Error";
11
11
 
12
+ import { getLocale } from "../selectors/i18n";
13
+
12
14
  import { reloadModel } from "./actions";
13
15
 
14
16
  import type {
@@ -43,12 +45,8 @@ type Props = {
43
45
  ...DispatchProps,
44
46
  };
45
47
 
46
- /**
47
- */
48
- const getLocaleCode = (state) => state.i18n.locale ?? "en";
49
-
50
48
  const modularui = createSelector(
51
- [getLocaleCode],
49
+ [getLocale],
52
50
  (localeCode) =>
53
51
  (href, options = {}) => {
54
52
  const modularuiRequest = new ModularUIRequest(href, options);
@@ -1,7 +1,8 @@
1
1
  // @flow
2
2
  import { loadModularUI, removeModelByKey } from "../_modularui/actions";
3
- import { keyByHref } from "../_modularui/selectors";
3
+ import { allKeysByHref } from "../_modularui/selectors";
4
4
  import { ApplicationModel, Href } from "../../models";
5
+ import { getLocale } from "../selectors/i18n";
5
6
 
6
7
  import type { Dispatch, GetState, ThunkAction } from "../types";
7
8
 
@@ -9,15 +10,12 @@ import type { Dispatch, GetState, ThunkAction } from "../types";
9
10
  */
10
11
  export const reloadApplication =
11
12
  (): ThunkAction => (dispatch: Dispatch, getState: GetState) => {
12
- let modelKey = keyByHref(getState(), "/");
13
-
14
- if (!modelKey) {
15
- const locale = getState().i18n?.locale;
16
- modelKey = `application(/)(${locale})`;
13
+ const allKeys = allKeysByHref(getState(), "/");
14
+ for (const key of allKeys) {
15
+ dispatch(removeModelByKey(key));
17
16
  }
18
17
 
19
- dispatch(removeModelByKey(modelKey));
20
-
18
+ const modelKey = `application(/)(${getLocale(getState())})`;
21
19
  return dispatch(
22
20
  loadModularUI(modelKey, new Href("/", "Application"), {
23
21
  targetModel: ApplicationModel,
@@ -16,10 +16,6 @@ describe("application actions", () => {
16
16
  await store.dispatch(reloadApplication());
17
17
 
18
18
  expect(store.getActions()).toStrictEqual([
19
- {
20
- type: "MODULARUI/REMOVE_KEY",
21
- payload: "application(/)(en)",
22
- },
23
19
  {
24
20
  type: "MODULARUI/STATUS",
25
21
  payload: { key: "application(/)(en)", status: "LOADING" },
@@ -49,7 +45,7 @@ describe("application actions", () => {
49
45
  },
50
46
  {
51
47
  type: "MODULARUI/STATUS",
52
- payload: { key: "/", status: "LOADING" },
48
+ payload: { key: "application(/)(en)", status: "LOADING" },
53
49
  },
54
50
  { type: "START_PROGRESS" },
55
51
  expect.objectContaining({
@@ -45,7 +45,7 @@ describe("authorization actions", () => {
45
45
  },
46
46
  {
47
47
  type: "MODULARUI/STATUS",
48
- payload: { key: "/", status: "LOADING" },
48
+ payload: { key: "application(/)(en)", status: "LOADING" },
49
49
  },
50
50
  {
51
51
  type: "START_PROGRESS",
@@ -0,0 +1,15 @@
1
+ // @flow
2
+ import type Locales from "../../i18n/Locales";
3
+ import type { ReduxState } from "../types";
4
+
5
+ /**
6
+ * Retrieve the locale from state
7
+ */
8
+ export const getLocale = (state: ReduxState): string => {
9
+ return state.i18n?.locale ?? "en";
10
+ };
11
+
12
+ /**
13
+ * Retrieve all available locales in the store
14
+ */
15
+ export const getLocales = (state: ReduxState): Locales => state.i18n.locales;
@@ -63,7 +63,7 @@ class BaseDateTimeUtil {
63
63
  /**
64
64
  */
65
65
  getLocale(): typeof nl | typeof enGB {
66
- const locale = getCookie("locale") || "en";
66
+ const locale = getCookie("locale") ?? "en";
67
67
 
68
68
  if (locale === "nl") {
69
69
  return nl;