@apptimate/core-lib 6.4.0 → 6.5.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apptimate/core-lib",
3
- "version": "6.4.0",
3
+ "version": "6.5.0",
4
4
  "main": "src/index.ts",
5
5
  "types": "src/index.ts",
6
6
  "publishConfig": {
@@ -72,9 +72,14 @@ export const getAttendanceDays = async (employeeId: string | number, startDate:
72
72
  if (workforceId) params.workforce_id = workforceId;
73
73
  const queryParams = new URLSearchParams(params);
74
74
 
75
- const url = employeeId === 'me'
76
- ? `${BASE_URL}/ess/me/attendance/days?${queryParams.toString()}`
77
- : `${BASE_URL}/attendance/days?${queryParams.toString()}`;
75
+ let url = '';
76
+ if (employeeId === 0 && (projectId || workforceId)) {
77
+ url = `${process.env.NEXT_PUBLIC_API_URL}/api/construction/workforce/attendance-days?${queryParams.toString()}`;
78
+ } else {
79
+ url = employeeId === 'me'
80
+ ? `${BASE_URL}/ess/me/attendance/days?${queryParams.toString()}`
81
+ : `${BASE_URL}/attendance/days?${queryParams.toString()}`;
82
+ }
78
83
 
79
84
  const response = await sendRequest({ url, method: "GET" });
80
85
  return response.responseData as IApiResponse;
@@ -57,9 +57,18 @@ export function buildBrowserProxyUrl(rawUrl: string): string {
57
57
  }
58
58
 
59
59
  try {
60
+ // If rawUrl is undefined/api/... (due to missing process.env), fix it
61
+ if (rawUrl.startsWith('undefined/')) {
62
+ rawUrl = rawUrl.replace('undefined/', '/');
63
+ }
64
+
60
65
  const parsedUrl = new URL(rawUrl, window.location.origin);
61
66
 
62
67
  if (parsedUrl.origin === window.location.origin) {
68
+ if (parsedUrl.pathname.startsWith('/api/') && !parsedUrl.pathname.startsWith('/api/proxy') && !parsedUrl.pathname.startsWith('/api/session')) {
69
+ const proxyPath = parsedUrl.pathname.replace(/^\/+/, '');
70
+ return `/api/proxy/${proxyPath}${parsedUrl.search}`;
71
+ }
63
72
  return parsedUrl.toString();
64
73
  }
65
74