working leantime widget 4
This commit is contained in:
parent
c00963a533
commit
8217d7176a
@ -13,20 +13,45 @@ export async function GET() {
|
||||
console.log('Fetching status labels for user:', session.user.id);
|
||||
console.log('Using LEANTIME_TOKEN:', process.env.LEANTIME_TOKEN ? 'Present' : 'Missing');
|
||||
|
||||
// First, get the Leantime user ID for the current user
|
||||
const userResponse = await fetch('https://agilite.slm-lab.net/api/jsonrpc', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-API-Key': process.env.LEANTIME_TOKEN || '',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
method: 'leantime.rpc.Users.Users.getUserByEmail',
|
||||
jsonrpc: '2.0',
|
||||
id: 1,
|
||||
params: {
|
||||
email: session.user.email
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
const userData = await userResponse.json();
|
||||
console.log('User lookup response:', userData);
|
||||
|
||||
if (!userData.result || !userData.result.id) {
|
||||
throw new Error('Could not find Leantime user ID');
|
||||
}
|
||||
|
||||
const leantimeUserId = userData.result.id;
|
||||
|
||||
// Now fetch the status labels
|
||||
const response = await fetch('https://agilite.slm-lab.net/api/jsonrpc', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-API-Key': process.env.LEANTIME_TOKEN || '',
|
||||
'Accept': 'application/json',
|
||||
'Authorization': `Bearer ${session.accessToken}`,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
method: 'leantime.rpc.Tickets.Tickets.getAllStatusLabelsByUserId',
|
||||
jsonrpc: '2.0',
|
||||
id: 1,
|
||||
params: {
|
||||
userId: session.user.id,
|
||||
userId: leantimeUserId
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user