@akinon/next 1.42.0-rc.7 → 1.42.0-rc.9

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @akinon/next
2
2
 
3
+ ## 1.42.0-rc.9
4
+
5
+ ## 1.42.0-rc.8
6
+
7
+ ### Minor Changes
8
+
9
+ - d409996: ZERO-2781: Refactor buildClientRequestUrl function to support caching and options
10
+
3
11
  ## 1.42.0-rc.7
4
12
 
5
13
  ## 1.42.0-rc.6
@@ -1,6 +1,7 @@
1
1
  import clsx from 'clsx';
2
2
  import { forwardRef, FocusEvent, useState, Ref } from 'react';
3
3
  import { Controller } from 'react-hook-form';
4
+
4
5
  // @ts-ignore
5
6
  import { PatternFormat, PatternFormatProps } from 'react-number-format';
6
7
  import { InputProps } from '../types';
@@ -1,4 +1,5 @@
1
1
  import { useMemo } from 'react';
2
+
2
3
  // @ts-ignore
3
4
  import { NumericFormat, NumericFormatProps } from 'react-number-format';
4
5
  import { getCurrency } from '@akinon/next/utils';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@akinon/next",
3
3
  "description": "Core package for Project Zero Next",
4
- "version": "1.42.0-rc.7",
4
+ "version": "1.42.0-rc.9",
5
5
  "private": false,
6
6
  "license": "MIT",
7
7
  "bin": {
@@ -30,7 +30,7 @@
30
30
  "set-cookie-parser": "2.6.0"
31
31
  },
32
32
  "devDependencies": {
33
- "@akinon/eslint-plugin-projectzero": "1.42.0-rc.7",
33
+ "@akinon/eslint-plugin-projectzero": "1.42.0-rc.9",
34
34
  "@types/react-redux": "7.1.30",
35
35
  "@types/set-cookie-parser": "2.4.7",
36
36
  "@typescript-eslint/eslint-plugin": "6.7.4",
package/utils/index.ts CHANGED
@@ -63,18 +63,33 @@ export function getTranslateFn(path: string, translations: any) {
63
63
 
64
64
  export function buildClientRequestUrl(
65
65
  path: string,
66
- options?: ClientRequestOptions
66
+ options?: ClientRequestOptions & { cache?: boolean }
67
67
  ) {
68
68
  let url = `/api/client${path}`;
69
69
 
70
+ let hasQuery = url.includes('?');
71
+
70
72
  if (options) {
71
- if (url.includes('?')) {
72
- url += '&';
73
- } else {
74
- url += '?';
73
+ const { cache, ...otherOptions } = options;
74
+
75
+ if (Object.keys(otherOptions).length > 0) {
76
+ if (hasQuery) {
77
+ url += '&';
78
+ } else {
79
+ url += '?';
80
+ hasQuery = true;
81
+ }
82
+ url += `options=${encodeURIComponent(JSON.stringify(otherOptions))}`;
75
83
  }
76
84
 
77
- url += `options=${encodeURIComponent(JSON.stringify(options))}`;
85
+ if (cache === false) {
86
+ if (hasQuery) {
87
+ url += '&';
88
+ } else {
89
+ url += '?';
90
+ }
91
+ url += `t=${Date.now()}`;
92
+ }
78
93
  }
79
94
 
80
95
  return url;