diff --git a/apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/support/_components/SupportCaseDetails.tsx b/apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/support/_components/SupportCaseDetails.tsx
index 645d8244aa4..97661aff9af 100644
--- a/apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/support/_components/SupportCaseDetails.tsx
+++ b/apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/support/_components/SupportCaseDetails.tsx
@@ -34,7 +34,7 @@ interface SupportCaseDetailsProps {
team: Team;
}
-export function SupportCaseDetails({ ticket, team }: SupportCaseDetailsProps) {
+function SupportCaseDetails({ ticket, team }: SupportCaseDetailsProps) {
const [replyMessage, setReplyMessage] = useState("");
const [isSubmittingReply, setIsSubmittingReply] = useState(false);
const [localMessages, setLocalMessages] = useState(ticket.messages || []);
@@ -42,6 +42,15 @@ export function SupportCaseDetails({ ticket, team }: SupportCaseDetailsProps) {
// rating/feedback
const [rating, setRating] = useState(0);
const [feedback, setFeedback] = useState("");
+ // non-blocking warning when status check fails
+ const [statusCheckFailed, setStatusCheckFailed] = useState(false);
+
+ // Helper function to handle status check errors consistently
+ const handleStatusCheckError = (_error: unknown) => {
+ // Set degraded state for warning banner
+ setStatusCheckFailed(true);
+ return;
+ };
// Check if feedback has already been submitted for this ticket
const feedbackStatusQuery = useQuery({
@@ -49,18 +58,25 @@ export function SupportCaseDetails({ ticket, team }: SupportCaseDetailsProps) {
queryFn: async () => {
const result = await checkFeedbackStatus(ticket.id);
if ("error" in result) {
- throw new Error(result.error);
+ handleStatusCheckError(result.error);
+ return false; // Non-blocking: allow feedback submission despite status check failure
}
+
+ // Clear degraded state on success
+ if (statusCheckFailed) setStatusCheckFailed(false);
+
return result.hasFeedback;
},
enabled: ticket.status === "closed",
staleTime: 60_000,
gcTime: 5 * 60_000,
+ retry: 1, // Reduce retries since we want non-blocking behavior
});
const feedbackSubmitted = feedbackStatusQuery.data ?? false;
const isLoading = feedbackStatusQuery.isLoading;
- const hasError = feedbackStatusQuery.isError;
+ // query never throws; use local degraded flag for the inline warning
+ const hasError = statusCheckFailed;
const handleStarClick = (starIndex: number) => {
setRating(starIndex + 1);
@@ -70,29 +86,36 @@ export function SupportCaseDetails({ ticket, team }: SupportCaseDetailsProps) {
const submitFeedbackMutation = useMutation({
mutationFn: async () => {
if (rating === 0) {
- throw new Error("Please select a rating");
+ const error = "Please select a rating";
+ throw new Error(error);
}
const result = await submitSupportFeedback({
rating,
feedback,
ticketId: ticket.id,
});
+
if ("error" in result) {
+ // Add more specific error information
+
throw new Error(result.error);
}
+
return result;
},
onSuccess: () => {
toast.success("Thank you for your feedback!");
+
setRating(0);
setFeedback("");
+
// mark as submitted immediately
queryClient.setQueryData(["feedbackStatus", ticket.id], true);
},
onError: (err) => {
- console.error("Failed to submit feedback:", err);
const msg = err instanceof Error ? err.message : String(err ?? "");
let message = "Failed to submit feedback. Please try again.";
+
if (/network|fetch/i.test(msg)) {
message = "Network error. Please check your connection and try again.";
} else if (
@@ -102,6 +125,7 @@ export function SupportCaseDetails({ ticket, team }: SupportCaseDetailsProps) {
} else if (/API Server error/i.test(msg)) {
message = "Server error. Please try again later.";
}
+
toast.error(message);
},
});
@@ -157,8 +181,7 @@ export function SupportCaseDetails({ ticket, team }: SupportCaseDetailsProps) {
}
setReplyMessage("");
- } catch (error) {
- console.error("Failed to send reply:", error);
+ } catch {
toast.error("Failed to send Message. Please try again.");
// Remove the optimistic message on error
@@ -233,73 +256,77 @@ export function SupportCaseDetails({ ticket, team }: SupportCaseDetailsProps) {
)}
- {ticket.status === "closed" && !isLoading && !feedbackSubmitted && (
-
-
- This ticket is closed. Give us a quick rating to let us know how
- we did!
-
- {hasError && (
-
- Couldn't verify prior feedback right now — you can still submit
- a rating.
+ {ticket.status === "closed" &&
+ !isLoading &&
+ (!feedbackSubmitted || hasError) && (
+
+
+ This ticket is closed. Give us a quick rating to let us know how
+ we did!
- )}
+ {hasError && (
+
+
+ Couldn't verify prior feedback right now — you can still
+ submit a rating.
+