Skip to content

Commit a0843e9

Browse files
author
FalkWolsky
committed
Handling empty Tickets Table
1 parent efd7f25 commit a0843e9

File tree

3 files changed

+32
-16
lines changed

3 files changed

+32
-16
lines changed

client/packages/lowcoder/src/api/subscriptionApi.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -136,22 +136,30 @@ export const searchCustomersSubscriptions = async (Customer: LowcoderSearchCusto
136136
method: "post",
137137
headers: lcHeaders
138138
};
139+
139140
try {
140141
const result = await SubscriptionApi.secureRequest(apiBody);
141142

142-
if (result?.data?.data?.length > 0) {
143-
return result?.data?.data;
144-
}
145-
else if (result.data.success == "false" && result.data.reason == "customerNotFound") {
146-
return [];
147-
}
148-
else if (result.data.success == "false" && result.data.reason == "userSubscriptionNotFound") {
143+
if (!result || !result.data) {
149144
return [];
150145
}
151-
else if (result.data.success == "false" && result.data.reason == "orgSubscriptionNotFound") {
152-
return [];
153-
}
154-
return [];
146+
147+
// Filter out entries with `"success": "false"`
148+
const validEntries = result.data.filter((entry: any) => entry.success !== "false");
149+
150+
// Flatten the data arrays and filter out duplicates by `id`
151+
const uniqueSubscriptions = Object.values(
152+
validEntries.reduce((acc: Record<string, any>, entry: any) => {
153+
entry.data.forEach((subscription: any) => {
154+
if (!acc[subscription.id]) {
155+
acc[subscription.id] = subscription;
156+
}
157+
});
158+
return acc;
159+
}, {})
160+
);
161+
162+
return uniqueSubscriptions;
155163
} catch (error) {
156164
console.error("Error searching customer:", error);
157165
throw error;

client/packages/lowcoder/src/api/supportApi.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class SupportApi extends Api {
7070
const source = axios.CancelToken.source();
7171
const timeoutId = setTimeout(() => {
7272
source.cancel("Request timed out.");
73-
}, 2000);
73+
}, 10000);
7474

7575
// Request configuration with cancel token
7676
const requestConfig: AxiosRequestConfig = {
@@ -91,7 +91,7 @@ class SupportApi extends Api {
9191
const retrySource = axios.CancelToken.source();
9292
const retryTimeoutId = setTimeout(() => {
9393
retrySource.cancel("Retry request timed out.");
94-
}, 2000);
94+
}, 15000);
9595

9696
response = await axiosInstance.request({
9797
...requestConfig,
@@ -128,7 +128,14 @@ export const searchCustomerTickets = async (orgID : string, currentUserId : stri
128128
};
129129
try {
130130
const result = await SupportApi.secureRequest(apiBody);
131-
return result.data as TicketList;
131+
132+
if (!result || !result.data) {
133+
return [];
134+
}
135+
136+
const validEntries = result.data.filter((entry: any) => entry.success !== "false");
137+
138+
return validEntries as TicketList;
132139
} catch (error) {
133140
console.error("Error searching Support Tickets: ", error);
134141
throw error;

client/packages/lowcoder/src/pages/support/supportDetail.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,9 @@ export function SupportDetail() {
279279
const ticketData = await getTicket(ticketId);
280280
if (ticketData && ticketData.length === 1) {
281281
setTicket(ticketData[0]);
282-
283-
setNewDescription(convertJiraToHtml(ticketData[0].fields.description) || '');
282+
if (ticketData[0].fields.description) {
283+
setNewDescription(convertJiraToHtml(ticketData[0].fields.description) || '');
284+
}
284285
} else {
285286
setError(trans("support.ticketNotFound"));
286287
}

0 commit comments

Comments
 (0)