Skip to content

Commit d213226

Browse files
committed
6871: Avoid calling routes with null values
1 parent 63f335f commit d213226

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

assets/admin/components/screen/util/campaign-icon.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ function CampaignIcon({ id, delay = 1000 }) {
2828

2929
const { data: campaigns, isLoading } = useGetV2ScreensByIdCampaignsQuery(
3030
{ id },
31-
{ skip: !getData },
31+
{ skip: !getData || !id },
3232
);
3333
const { data: groups, isLoading: isLoadingScreenGroups } =
34-
useGetV2ScreensByIdScreenGroupsQuery({ id }, { skip: !getData });
34+
useGetV2ScreensByIdScreenGroupsQuery({ id }, { skip: !getData || !id });
3535

3636
useEffect(() => {
3737
if (campaigns) {

assets/admin/components/util/fetch-data-hook.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ function useFetchDataHook(apiCall, ids, params = {}, key = "id") {
1010
useEffect(() => {
1111
if (!ids || ids.length === 0) return;
1212

13+
// Filter out null/undefined/empty IDs
14+
const validIds = ids.filter((id) => id != null && id !== "");
15+
if (validIds.length === 0) return;
16+
17+
// Check if params contain invalid values
18+
const hasInvalidParams = Object.values(params).some(
19+
(value) => value === "" || value == null,
20+
);
21+
if (hasInvalidParams) return;
22+
1323
async function fetchItems() {
1424
setLoading(true);
1525

0 commit comments

Comments
 (0)