Skip to content

Commit af528ba

Browse files
committed
Fix ticket submission endpoint
1 parent 526e60b commit af528ba

File tree

6 files changed

+55
-14
lines changed

6 files changed

+55
-14
lines changed

index.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ interface QABotProps {
99
isLoggedIn?: boolean;
1010
loginUrl?: string;
1111
welcome?: string;
12+
/** User's email address (when logged in) */
13+
userEmail?: string;
14+
/** User's display name (when logged in) */
15+
userName?: string;
16+
/** User's ACCESS ID (when logged in) */
17+
accessId?: string;
1218
[key: string]: any; // Allow additional props
1319
}
1420

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@snf/access-qa-bot",
3-
"version": "2.4.3",
3+
"version": "2.4.4",
44
"private": false,
55
"homepage": ".",
66
"description": "ACCESS Q&A Bot React Component with support ticket creation, feedback collection, and ProForma integration",

src/config/constants.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ export const DEFAULT_CONFIG = {
77
API_ENDPOINT: 'https://access-ai.ccs.uky.edu/api/query',
88
//API_ENDPOINT: 'https://access-ai.ccs.uky.edu:543/api/query',
99

10-
// Netlify function URL
11-
netlifyBaseUrl: (typeof process !== 'undefined' && process.env) ? process.env.REACT_APP_NETLIFY_BASE_URL : 'https://access-ai.ccs.uky.edu/api/query',
10+
// Netlify function URL - this should point to the Netlify functions endpoint for ticket submission
11+
// NOT the Q&A API endpoint
12+
netlifyBaseUrl: (typeof process !== 'undefined' && process.env) ? process.env.REACT_APP_NETLIFY_BASE_URL : 'https://access-jsm-api.netlify.app',
1213

1314
ERRORS: {
1415
API_UNAVAILABLE: 'Unable to contact the Q&A Bot. Please try again later.',

src/utils/api-utils.js

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,38 @@ export const sendPreparedDataToProxy = async (submissionData, endpointName) => {
118118
});
119119

120120
if (!response.ok) {
121-
const errorText = await response.text();
122-
console.error('| ❌ Post data to proxy failed:', response.status, errorText);
121+
let errorMessage = '';
122+
try {
123+
const errorText = await response.text();
124+
console.error('| ❌ Post data to proxy failed:', response.status, errorText);
125+
126+
// Try to parse as JSON to get a better error message
127+
try {
128+
const errorJson = JSON.parse(errorText);
129+
errorMessage = errorJson.message || errorJson.error || errorText;
130+
} catch {
131+
// If not JSON, use the text as-is
132+
errorMessage = errorText;
133+
}
134+
} catch {
135+
errorMessage = `HTTP ${response.status} ${response.statusText}`;
136+
}
137+
138+
// Add user-friendly message for common HTTP errors
139+
if (response.status === 403) {
140+
errorMessage = 'The ticket service is temporarily unavailable. Please try again later or contact support directly.';
141+
} else if (response.status === 404) {
142+
errorMessage = 'Ticket service not found. Please try again later.';
143+
} else if (response.status === 500) {
144+
errorMessage = 'Server error. Please try again later.';
145+
} else if (response.status === 401) {
146+
errorMessage = 'Authentication error with the ticket service. Please contact support.';
147+
}
148+
123149
return {
124150
success: false,
125151
status: response.status,
126-
error: errorText
152+
error: errorMessage
127153
};
128154
}
129155

src/utils/flows/main-menu-flow.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
export const createMainMenuFlow = ({
1111
welcome,
1212
setTicketForm = () => {},
13-
setFeedbackForm = () => {}
13+
setFeedbackForm = () => {} // eslint-disable-line no-unused-vars -- Temporarily disabled feedback flow
1414
}) => {
1515
return {
1616
start: {

src/utils/flows/tickets/ticket-flow-utils.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,23 @@ export const createSubmissionHandler = (setTicketForm) => {
7777
* @returns {string} Success message with clickable URL
7878
*/
7979
export const generateSuccessMessage = (submissionResult, ticketType = 'ticket') => {
80-
if (submissionResult && !submissionResult.success) {
81-
return `We apologize, but there was an error submitting your ${ticketType}: ${submissionResult.error}\n\nPlease try again or contact our support team directly.`;
82-
} else if (submissionResult && submissionResult.success && submissionResult.ticketUrl && submissionResult.ticketKey) {
80+
// Handle null/undefined submission result as an error
81+
if (!submissionResult) {
82+
return `We apologize, but there was an error submitting your ${ticketType}.\n\nPlease try again or contact our support team directly.`;
83+
}
84+
85+
// Handle explicit failure
86+
if (!submissionResult.success) {
87+
return `We apologize, but there was an error submitting your ${ticketType}: ${submissionResult.error || 'Unknown error'}\n\nPlease try again or contact our support team directly.`;
88+
}
89+
90+
// Handle success with ticket URL and key
91+
if (submissionResult.ticketUrl && submissionResult.ticketKey) {
8392
return `Your ${ticketType} has been submitted successfully.\n\nTicket: <a href="${submissionResult.ticketUrl}" target="_blank">${submissionResult.ticketKey}</a>\n\nOur support team will review your request and respond accordingly. Thank you for contacting ACCESS.`;
84-
} else if (submissionResult && submissionResult.success) {
85-
return `Your ${ticketType} has been submitted successfully.\n\nOur support team will review your request and respond accordingly. Thank you for contacting ACCESS.`;
86-
} else {
87-
return `Your ${ticketType} has been submitted successfully.\n\nOur support team will review your request and respond accordingly. Thank you for contacting ACCESS.`;
8893
}
94+
95+
// Handle success without ticket URL (but this might indicate a partial failure)
96+
return `Your ${ticketType} has been submitted successfully.\n\nOur support team will review your request and respond accordingly. Thank you for contacting ACCESS.`;
8997
};
9098

9199
/**

0 commit comments

Comments
 (0)