courrier multi account restore compose
This commit is contained in:
parent
daf1fd5e92
commit
464a30c31b
@ -857,27 +857,13 @@ export default function CourrierPage() {
|
|||||||
console.log('Connection test successful:', testResult);
|
console.log('Connection test successful:', testResult);
|
||||||
|
|
||||||
// If connection test is successful, save the account
|
// If connection test is successful, save the account
|
||||||
const saveResponse = await fetch('/api/courrier/account', {
|
const realAccounts = accounts.filter(a => a.id !== 'loading-account');
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json'
|
|
||||||
},
|
|
||||||
body: JSON.stringify(formValues)
|
|
||||||
});
|
|
||||||
|
|
||||||
const saveResult = await saveResponse.json();
|
|
||||||
|
|
||||||
if (!saveResponse.ok) {
|
|
||||||
throw new Error(saveResult.error || 'Failed to add account');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update accounts list
|
|
||||||
const newAccountObj = {
|
const newAccountObj = {
|
||||||
id: `account-${Date.now()}`, // generate unique string ID
|
id: `account-${Date.now()}`,
|
||||||
name: formValues.display_name,
|
name: formValues.display_name,
|
||||||
email: formValues.email,
|
email: formValues.email,
|
||||||
color: colorPalette[(accounts.length) % colorPalette.length],
|
color: colorPalette[realAccounts.length % colorPalette.length],
|
||||||
folders: testResult.details.sampleFolders || ['INBOX', 'Sent', 'Drafts', 'Trash'] // Use discovered folders or defaults
|
folders: testResult.details.sampleFolders || ['INBOX', 'Sent', 'Drafts', 'Trash']
|
||||||
};
|
};
|
||||||
|
|
||||||
setAccounts(prev => [...prev, newAccountObj]);
|
setAccounts(prev => [...prev, newAccountObj]);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user