Skip to content

Commit dd3e9db

Browse files
author
FalkWolsky
committed
Adapting Payload for Ticket System
1 parent 739431a commit dd3e9db

File tree

4 files changed

+32
-10
lines changed

4 files changed

+32
-10
lines changed

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,15 @@ class SupportApi extends Api {
118118

119119
// API Functions
120120

121-
export const searchCustomerTickets = async (orgID : string, currentUserId : string, domain : string) => {
121+
export const searchCustomerTickets = async (
122+
deploymentId : string,
123+
orgID : string,
124+
currentUserId : string
125+
) => {
122126

123127
const apiBody = {
124128
path: "webhook/support/get-issues",
125-
data: {"host" : domain, "orgId" : orgID, "userId" : currentUserId},
129+
data: {"hostId" : deploymentId, "orgId" : orgID, "userId" : currentUserId},
126130
method: "post",
127131
headers: lcHeaders
128132
};
@@ -159,11 +163,20 @@ export const getTicket = async (ticketKey : string) => {
159163
}
160164
};
161165

162-
export const createTicket = async (orgID : string, currentUserId : string, subscriptionId : string, domain : string, summary: string, description : string, errors : string) => {
166+
export const createTicket = async (
167+
domain: string,
168+
deploymentId : string,
169+
orgID : string,
170+
orgName : string,
171+
currentUserId : string,
172+
subscriptionId : string,
173+
summary: string,
174+
description : string,
175+
errors : string) => {
163176

164177
const apiBody = {
165178
path: "webhook/support/create-ticket",
166-
data: {"host" : domain, "orgId" : orgID, "userId" : currentUserId, "subscriptionId": subscriptionId, "summary" : summary, "description" : description, "errors" : errors},
179+
data: {"domain" : domain, "hostId" : deploymentId, "orgId" : orgID, "orgName" : orgName, "userId" : currentUserId, "subscriptionId": subscriptionId, "summary" : summary, "description" : description, "errors" : errors},
167180
method: "post",
168181
headers: lcHeaders
169182
};

client/packages/lowcoder/src/pages/ApplicationV2/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,9 @@ import { Support } from "pages/support";
6767
import { isEE } from "util/envUtils";
6868
import { getSubscriptions } from 'redux/selectors/subscriptionSelectors';
6969
import { SubscriptionProductsEnum } from '@lowcoder-ee/constants/subscriptionConstants';
70-
import { ReduxActionTypes } from '@lowcoder-ee/constants/reduxActionConstants';
7170

7271
// adding App Editor, so we can show Apps inside the Admin Area
7372
import AppEditor from "../editor/AppEditor";
74-
import { set } from "lodash";
7573
import { fetchDeploymentIdAction } from "@lowcoder-ee/redux/reduxActions/configActions";
7674
import { getDeploymentId } from "@lowcoder-ee/redux/selectors/configSelectors";
7775
import { SimpleSubscriptionContextProvider } from '@lowcoder-ee/util/context/SimpleSubscriptionContext';

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ import ReactQuill from "react-quill";
1515
import 'react-quill/dist/quill.snow.css';
1616
import { Spin } from "antd";
1717
import LoadingOutlined from "@ant-design/icons/LoadingOutlined";
18-
18+
import { useSimpleSubscriptionContext } from "@lowcoder-ee/util/context/SimpleSubscriptionContext";
19+
import { SubscriptionProductsEnum } from '@lowcoder-ee/constants/subscriptionConstants';
20+
import { getDeploymentId } from "@lowcoder-ee/redux/selectors/configSelectors";
21+
import { useSelector } from "react-redux";
1922

2023
const SupportWrapper = styled.div`
2124
display: flex;
@@ -129,7 +132,7 @@ const handleEditClick = (ticketId: string) => {
129132
};
130133

131134
export function SupportOverview() {
132-
const { orgID, currentUser, domain } = useUserDetails();
135+
const { orgID, orgName, currentUser, domain } = useUserDetails();
133136
const [supportTickets, setSupportTickets] = useState<any>([]);
134137
const [loading, setLoading] = useState<boolean>(true);
135138
const [error, setError] = useState<string | null>(null);
@@ -141,6 +144,12 @@ export function SupportOverview() {
141144
const [isSubmitting, setIsSubmitting] = useState<boolean>(false);
142145
const [isReloadDisabled, setIsReloadDisabled] = useState<boolean>(false); // State to disable/enable reload button
143146
const [lastReloadTime, setLastReloadTime] = useState<number | null>(null);
147+
const { subscriptions } = useSimpleSubscriptionContext();
148+
const deploymentId = useSelector(getDeploymentId);
149+
150+
const SupportSubscription = subscriptions.filter(
151+
sub => sub.product === SubscriptionProductsEnum.SUPPORT && sub.status === 'active'
152+
);
144153

145154
// Capture global errors using window.onerror
146155
useEffect(() => {
@@ -162,7 +171,7 @@ export function SupportOverview() {
162171
const fetchSupportTickets = async () => {
163172
setLoading(true); // Set loading to true while fetching data
164173
try {
165-
const ticketData = await searchCustomerTickets(orgID, currentUser.id, domain);
174+
const ticketData = await searchCustomerTickets(deploymentId, orgID, currentUser.id);
166175
setSupportTickets(ticketData);
167176
} catch (err) {
168177
setError("Failed to fetch support tickets.");
@@ -210,7 +219,7 @@ export function SupportOverview() {
210219

211220
setIsSubmitting(true);
212221
try {
213-
const result = await createTicket(orgID, currentUser.id, 'subscription-id', domain, summary, description, capturedErrors.join("\n"));
222+
const result = await createTicket(domain, deploymentId, orgID, orgName, currentUser.id, SupportSubscription[0]?.id, summary, description, capturedErrors.join("\n"));
214223
if (result) {
215224
showCreateForm(false);
216225
setSummary("");

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ export const useUserDetails = () => {
66
const user = useSelector(getUser);
77
const currentUser = useSelector(getCurrentUser);
88
const orgID = user.currentOrgId;
9+
const orgName = user.orgs.find(org => org.id === orgID)?.name || "";
910
const domain = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : "");
1011
const subscriptions = useSelector(getSubscriptions);
1112

1213
return {
1314
orgID,
15+
orgName,
1416
currentUser,
1517
domain,
1618
subscriptions

0 commit comments

Comments
 (0)