Skip to content

Commit 485eae9

Browse files
committed
Apply CodeRabbit feedback improvements
1 parent 200f00a commit 485eae9

File tree

1 file changed

+17
-3
lines changed
  • apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/support/apis

1 file changed

+17
-3
lines changed

apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/support/apis/feedback.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
"use server";
22

3+
type FeedbackSubmitResult = { success: true } | { error: string };
4+
type FeedbackStatusResult = { hasFeedback: boolean } | { error: string };
5+
36
export async function submitSupportFeedback({
47
rating,
58
feedback,
@@ -8,7 +11,7 @@ export async function submitSupportFeedback({
811
rating: number;
912
feedback?: string;
1013
ticketId: string;
11-
}) {
14+
}): Promise<FeedbackSubmitResult> {
1215
try {
1316
// Fail fast on missing configuration
1417
const siwaUrl =
@@ -25,6 +28,10 @@ export async function submitSupportFeedback({
2528
}
2629

2730
// Basic input validation/normalization
31+
if (!ticketId?.trim()) {
32+
return { error: "ticketId is required." };
33+
}
34+
2835
if (!Number.isInteger(rating) || rating < 1 || rating > 5) {
2936
return { error: "Rating must be an integer between 1 and 5." };
3037
}
@@ -37,7 +44,7 @@ export async function submitSupportFeedback({
3744
const payload = {
3845
rating: rating.toString(),
3946
feedback: normalizedFeedback,
40-
ticket_id: ticketId || null,
47+
ticket_id: ticketId,
4148
};
4249

4350
const ac = new AbortController();
@@ -65,8 +72,15 @@ export async function submitSupportFeedback({
6572
}
6673
}
6774

68-
export async function checkFeedbackStatus(ticketId: string) {
75+
export async function checkFeedbackStatus(
76+
ticketId: string,
77+
): Promise<FeedbackStatusResult> {
6978
try {
79+
// Basic input validation
80+
if (!ticketId?.trim()) {
81+
return { error: "ticketId is required." };
82+
}
83+
7084
// Fail fast on missing configuration
7185
const siwaUrl =
7286
process.env.SIWA_URL ?? process.env.NEXT_PUBLIC_SIWA_URL ?? "";

0 commit comments

Comments
 (0)