@inspirer-dev/crm-dashboard 1.0.6 → 1.0.8
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.
|
@@ -20,6 +20,18 @@ import {
|
|
|
20
20
|
} from '@strapi/design-system';
|
|
21
21
|
import { Layouts } from '@strapi/admin/strapi-admin';
|
|
22
22
|
|
|
23
|
+
const getBackendUrl = (): string => {
|
|
24
|
+
// NOTE: do NOT use STRAPI_ADMIN_BACKEND_URL here — that is reserved for Strapi itself
|
|
25
|
+
// and will break admin if pointed to another service.
|
|
26
|
+
const raw = process.env.STRAPI_ADMIN_CRM_BACKEND_URL || 'http://localhost:3100';
|
|
27
|
+
|
|
28
|
+
if (!/^https?:\/\//i.test(raw)) {
|
|
29
|
+
return 'http://localhost:3100';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return raw.endsWith('/') ? raw.slice(0, -1) : raw;
|
|
33
|
+
};
|
|
34
|
+
|
|
23
35
|
interface CrmLog {
|
|
24
36
|
timestamp: string;
|
|
25
37
|
user_id: string;
|
|
@@ -61,8 +73,8 @@ const LogsTable: React.FC = () => {
|
|
|
61
73
|
if (filterUserId) params.set('userId', filterUserId);
|
|
62
74
|
if (filterStatus) params.set('status', filterStatus);
|
|
63
75
|
|
|
64
|
-
const backendUrl =
|
|
65
|
-
const res = await fetch(
|
|
76
|
+
const backendUrl = getBackendUrl();
|
|
77
|
+
const res = await fetch(new URL(`/crm/logs?${params}`, backendUrl).toString());
|
|
66
78
|
if (res.ok) {
|
|
67
79
|
const data = await res.json();
|
|
68
80
|
setLogs(data.data || []);
|
|
@@ -111,7 +123,7 @@ const LogsTable: React.FC = () => {
|
|
|
111
123
|
<SingleSelect
|
|
112
124
|
placeholder="Status"
|
|
113
125
|
value={filterStatus}
|
|
114
|
-
onChange={(val: string) => setFilterStatus(val)}
|
|
126
|
+
onChange={(val: string | number) => setFilterStatus(String(val))}
|
|
115
127
|
onClear={() => setFilterStatus('')}
|
|
116
128
|
>
|
|
117
129
|
<SingleSelectOption value="">All</SingleSelectOption>
|
|
@@ -224,8 +236,8 @@ const AntiSpamLogsTable: React.FC = () => {
|
|
|
224
236
|
pageSize: '20',
|
|
225
237
|
});
|
|
226
238
|
|
|
227
|
-
const backendUrl =
|
|
228
|
-
const res = await fetch(
|
|
239
|
+
const backendUrl = getBackendUrl();
|
|
240
|
+
const res = await fetch(new URL(`/crm/anti-spam-logs?${params}`, backendUrl).toString());
|
|
229
241
|
if (res.ok) {
|
|
230
242
|
const data = await res.json();
|
|
231
243
|
setLogs(data.data || []);
|
|
@@ -355,8 +367,8 @@ const StatsView: React.FC = () => {
|
|
|
355
367
|
const fetchStats = useCallback(async () => {
|
|
356
368
|
setLoading(true);
|
|
357
369
|
try {
|
|
358
|
-
const backendUrl =
|
|
359
|
-
const res = await fetch(
|
|
370
|
+
const backendUrl = getBackendUrl();
|
|
371
|
+
const res = await fetch(new URL('/crm/stats', backendUrl).toString());
|
|
360
372
|
if (res.ok) {
|
|
361
373
|
const data = await res.json();
|
|
362
374
|
setStats(Array.isArray(data) ? data : []);
|
|
@@ -16949,6 +16949,13 @@ const usersService = adminApi.enhanceEndpoints({
|
|
|
16949
16949
|
overrideExisting: false
|
|
16950
16950
|
});
|
|
16951
16951
|
const { useCreateUserMutation, useGetUsersQuery, useUpdateUserMutation, useDeleteManyUsersMutation, useGetRolesQuery, useCreateRoleMutation, useUpdateRoleMutation, useGetRolePermissionsQuery, useGetRolePermissionLayoutQuery, useUpdateRolePermissionsMutation } = usersService;
|
|
16952
|
+
const getBackendUrl = () => {
|
|
16953
|
+
const raw = process.env.STRAPI_ADMIN_CRM_BACKEND_URL || "http://localhost:3100";
|
|
16954
|
+
if (!/^https?:\/\//i.test(raw)) {
|
|
16955
|
+
return "http://localhost:3100";
|
|
16956
|
+
}
|
|
16957
|
+
return raw.endsWith("/") ? raw.slice(0, -1) : raw;
|
|
16958
|
+
};
|
|
16952
16959
|
const LogsTable = () => {
|
|
16953
16960
|
const [logs, setLogs] = useState([]);
|
|
16954
16961
|
const [loading, setLoading] = useState(false);
|
|
@@ -16965,8 +16972,8 @@ const LogsTable = () => {
|
|
|
16965
16972
|
});
|
|
16966
16973
|
if (filterUserId) params.set("userId", filterUserId);
|
|
16967
16974
|
if (filterStatus) params.set("status", filterStatus);
|
|
16968
|
-
const backendUrl =
|
|
16969
|
-
const res = await fetch(
|
|
16975
|
+
const backendUrl = getBackendUrl();
|
|
16976
|
+
const res = await fetch(new URL(`/crm/logs?${params}`, backendUrl).toString());
|
|
16970
16977
|
if (res.ok) {
|
|
16971
16978
|
const data = await res.json();
|
|
16972
16979
|
setLogs(data.data || []);
|
|
@@ -17012,7 +17019,7 @@ const LogsTable = () => {
|
|
|
17012
17019
|
{
|
|
17013
17020
|
placeholder: "Status",
|
|
17014
17021
|
value: filterStatus,
|
|
17015
|
-
onChange: (val) => setFilterStatus(val),
|
|
17022
|
+
onChange: (val) => setFilterStatus(String(val)),
|
|
17016
17023
|
onClear: () => setFilterStatus(""),
|
|
17017
17024
|
children: [
|
|
17018
17025
|
/* @__PURE__ */ jsx(SingleSelectOption, { value: "", children: "All" }),
|
|
@@ -17091,8 +17098,8 @@ const AntiSpamLogsTable = () => {
|
|
|
17091
17098
|
page: String(page),
|
|
17092
17099
|
pageSize: "20"
|
|
17093
17100
|
});
|
|
17094
|
-
const backendUrl =
|
|
17095
|
-
const res = await fetch(
|
|
17101
|
+
const backendUrl = getBackendUrl();
|
|
17102
|
+
const res = await fetch(new URL(`/crm/anti-spam-logs?${params}`, backendUrl).toString());
|
|
17096
17103
|
if (res.ok) {
|
|
17097
17104
|
const data = await res.json();
|
|
17098
17105
|
setLogs(data.data || []);
|
|
@@ -17185,8 +17192,8 @@ const StatsView = () => {
|
|
|
17185
17192
|
const fetchStats = useCallback(async () => {
|
|
17186
17193
|
setLoading(true);
|
|
17187
17194
|
try {
|
|
17188
|
-
const backendUrl =
|
|
17189
|
-
const res = await fetch(
|
|
17195
|
+
const backendUrl = getBackendUrl();
|
|
17196
|
+
const res = await fetch(new URL("/crm/stats", backendUrl).toString());
|
|
17190
17197
|
if (res.ok) {
|
|
17191
17198
|
const data = await res.json();
|
|
17192
17199
|
setStats(Array.isArray(data) ? data : []);
|
|
@@ -16970,6 +16970,13 @@ const usersService = adminApi.enhanceEndpoints({
|
|
|
16970
16970
|
overrideExisting: false
|
|
16971
16971
|
});
|
|
16972
16972
|
const { useCreateUserMutation, useGetUsersQuery, useUpdateUserMutation, useDeleteManyUsersMutation, useGetRolesQuery, useCreateRoleMutation, useUpdateRoleMutation, useGetRolePermissionsQuery, useGetRolePermissionLayoutQuery, useUpdateRolePermissionsMutation } = usersService;
|
|
16973
|
+
const getBackendUrl = () => {
|
|
16974
|
+
const raw = process.env.STRAPI_ADMIN_CRM_BACKEND_URL || "http://localhost:3100";
|
|
16975
|
+
if (!/^https?:\/\//i.test(raw)) {
|
|
16976
|
+
return "http://localhost:3100";
|
|
16977
|
+
}
|
|
16978
|
+
return raw.endsWith("/") ? raw.slice(0, -1) : raw;
|
|
16979
|
+
};
|
|
16973
16980
|
const LogsTable = () => {
|
|
16974
16981
|
const [logs, setLogs] = React.useState([]);
|
|
16975
16982
|
const [loading, setLoading] = React.useState(false);
|
|
@@ -16986,8 +16993,8 @@ const LogsTable = () => {
|
|
|
16986
16993
|
});
|
|
16987
16994
|
if (filterUserId) params.set("userId", filterUserId);
|
|
16988
16995
|
if (filterStatus) params.set("status", filterStatus);
|
|
16989
|
-
const backendUrl =
|
|
16990
|
-
const res = await fetch(
|
|
16996
|
+
const backendUrl = getBackendUrl();
|
|
16997
|
+
const res = await fetch(new URL(`/crm/logs?${params}`, backendUrl).toString());
|
|
16991
16998
|
if (res.ok) {
|
|
16992
16999
|
const data = await res.json();
|
|
16993
17000
|
setLogs(data.data || []);
|
|
@@ -17033,7 +17040,7 @@ const LogsTable = () => {
|
|
|
17033
17040
|
{
|
|
17034
17041
|
placeholder: "Status",
|
|
17035
17042
|
value: filterStatus,
|
|
17036
|
-
onChange: (val) => setFilterStatus(val),
|
|
17043
|
+
onChange: (val) => setFilterStatus(String(val)),
|
|
17037
17044
|
onClear: () => setFilterStatus(""),
|
|
17038
17045
|
children: [
|
|
17039
17046
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "", children: "All" }),
|
|
@@ -17112,8 +17119,8 @@ const AntiSpamLogsTable = () => {
|
|
|
17112
17119
|
page: String(page),
|
|
17113
17120
|
pageSize: "20"
|
|
17114
17121
|
});
|
|
17115
|
-
const backendUrl =
|
|
17116
|
-
const res = await fetch(
|
|
17122
|
+
const backendUrl = getBackendUrl();
|
|
17123
|
+
const res = await fetch(new URL(`/crm/anti-spam-logs?${params}`, backendUrl).toString());
|
|
17117
17124
|
if (res.ok) {
|
|
17118
17125
|
const data = await res.json();
|
|
17119
17126
|
setLogs(data.data || []);
|
|
@@ -17206,8 +17213,8 @@ const StatsView = () => {
|
|
|
17206
17213
|
const fetchStats = React.useCallback(async () => {
|
|
17207
17214
|
setLoading(true);
|
|
17208
17215
|
try {
|
|
17209
|
-
const backendUrl =
|
|
17210
|
-
const res = await fetch(
|
|
17216
|
+
const backendUrl = getBackendUrl();
|
|
17217
|
+
const res = await fetch(new URL("/crm/stats", backendUrl).toString());
|
|
17211
17218
|
if (res.ok) {
|
|
17212
17219
|
const data = await res.json();
|
|
17213
17220
|
setStats(Array.isArray(data) ? data : []);
|
package/dist/admin/index.js
CHANGED
package/dist/admin/index.mjs
CHANGED