panel 2 courier api restore
This commit is contained in:
parent
ca93e4bc26
commit
f3ed371b33
@ -546,6 +546,25 @@ export default function CourrierPage() {
|
||||
throw new Error(errorData.error || 'Failed to check credentials');
|
||||
}
|
||||
|
||||
try {
|
||||
// Try to get user email from credentials
|
||||
const credsData = await credResponse.json();
|
||||
if (credsData.email) {
|
||||
console.log('Got email from credentials:', credsData.email);
|
||||
setAccounts(prev => prev.map(account =>
|
||||
account.id === 1
|
||||
? {
|
||||
...account,
|
||||
name: credsData.email,
|
||||
email: credsData.email
|
||||
}
|
||||
: account
|
||||
));
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('Error getting email from credentials:', error);
|
||||
}
|
||||
|
||||
// First do a quick request just for folders
|
||||
try {
|
||||
const folderResponse = await fetch('/api/courrier?folder=INBOX&page=1&limit=1');
|
||||
@ -648,12 +667,16 @@ export default function CourrierPage() {
|
||||
loadInitialData();
|
||||
}, [router, currentView, page, emailsPerPage]);
|
||||
|
||||
// At the initialization, update the account with the email from session
|
||||
// Fix the type issue with the session email
|
||||
useEffect(() => {
|
||||
if (session?.user?.email) {
|
||||
setAccounts(prev => prev.map(account =>
|
||||
account.id === 1
|
||||
? { ...account, name: session.user.email, email: session.user.email }
|
||||
? {
|
||||
...account,
|
||||
name: session.user.email || 'Mail Account',
|
||||
email: session.user.email || ''
|
||||
}
|
||||
: account
|
||||
));
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user