working leantime widget 38
This commit is contained in:
parent
9ef9f79e32
commit
cd7ff20e03
@ -65,15 +65,28 @@ export async function GET(request: NextRequest) {
|
||||
try {
|
||||
const session = await getServerSession(authOptions);
|
||||
|
||||
if (!session || !session.user?.email) {
|
||||
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
||||
if (!session) {
|
||||
return NextResponse.json(
|
||||
{ error: "Unauthorized", message: "No session found. Please sign in." },
|
||||
{ status: 401 }
|
||||
);
|
||||
}
|
||||
|
||||
if (!session.user?.email) {
|
||||
return NextResponse.json(
|
||||
{ error: "Unauthorized", message: "No email found in session. Please sign in again." },
|
||||
{ status: 401 }
|
||||
);
|
||||
}
|
||||
|
||||
// Get Leantime user ID
|
||||
const leantimeUserId = await getLeantimeUserId(session.user.email);
|
||||
|
||||
if (!leantimeUserId) {
|
||||
return NextResponse.json({ error: "User not found in Leantime" }, { status: 404 });
|
||||
return NextResponse.json(
|
||||
{ error: "User not found", message: "Could not find user in Leantime. Please check your email." },
|
||||
{ status: 404 }
|
||||
);
|
||||
}
|
||||
|
||||
// Get all tasks assigned to the user
|
||||
@ -184,7 +197,7 @@ export async function GET(request: NextRequest) {
|
||||
} catch (error) {
|
||||
console.error('Error fetching status labels:', error);
|
||||
return NextResponse.json(
|
||||
{ error: "Failed to fetch status labels" },
|
||||
{ error: "Failed to fetch status labels", message: error instanceof Error ? error.message : "Unknown error occurred" },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user