panel 2 courier api restore
This commit is contained in:
parent
981567f813
commit
ca93e4bc26
@ -425,8 +425,8 @@ export default function CourrierPage() {
|
|||||||
const { data: session } = useSession();
|
const { data: session } = useSession();
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [accounts, setAccounts] = useState<Account[]>([
|
const [accounts, setAccounts] = useState<Account[]>([
|
||||||
{ id: 0, name: 'All', email: '', color: 'bg-gray-500' },
|
{ id: 0, name: 'All', email: '', color: 'bg-gray-400' },
|
||||||
{ id: 1, name: 'Mail', email: 'alma@governance-labs.org', color: 'bg-blue-500' }
|
{ id: 1, name: '', email: '', color: 'bg-blue-500' }
|
||||||
]);
|
]);
|
||||||
const [selectedAccount, setSelectedAccount] = useState<Account | null>(null);
|
const [selectedAccount, setSelectedAccount] = useState<Account | null>(null);
|
||||||
const [currentView, setCurrentView] = useState<MailFolder>('INBOX');
|
const [currentView, setCurrentView] = useState<MailFolder>('INBOX');
|
||||||
@ -648,6 +648,17 @@ export default function CourrierPage() {
|
|||||||
loadInitialData();
|
loadInitialData();
|
||||||
}, [router, currentView, page, emailsPerPage]);
|
}, [router, currentView, page, emailsPerPage]);
|
||||||
|
|
||||||
|
// At the initialization, update the account with the email from session
|
||||||
|
useEffect(() => {
|
||||||
|
if (session?.user?.email) {
|
||||||
|
setAccounts(prev => prev.map(account =>
|
||||||
|
account.id === 1
|
||||||
|
? { ...account, name: session.user.email, email: session.user.email }
|
||||||
|
: account
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}, [session?.user?.email]);
|
||||||
|
|
||||||
// Get account color
|
// Get account color
|
||||||
const getAccountColor = (accountId: number) => {
|
const getAccountColor = (accountId: number) => {
|
||||||
const account = accounts.find(acc => acc.id === accountId);
|
const account = accounts.find(acc => acc.id === accountId);
|
||||||
@ -1751,18 +1762,17 @@ export default function CourrierPage() {
|
|||||||
<div className="flex flex-col items-start">
|
<div className="flex flex-col items-start">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<div className={`w-2.5 h-2.5 rounded-full ${account.color}`}></div>
|
<div className={`w-2.5 h-2.5 rounded-full ${account.color}`}></div>
|
||||||
<span className="font-medium">{account.name}</span>
|
<span className="font-medium text-gray-700">{account.name || 'Mail Account'}</span>
|
||||||
</div>
|
</div>
|
||||||
|
{account.id !== 0 && account.email && (
|
||||||
<span className="text-xs text-gray-500 ml-4">{account.email}</span>
|
<span className="text-xs text-gray-500 ml-4">{account.email}</span>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
{/* Show folders for email accounts (not for "All" account) */}
|
{/* Show folders for email accounts (not for "All" account) without the "Folders" header */}
|
||||||
{account.id !== 0 && (
|
{account.id !== 0 && (
|
||||||
<div className="pl-4 mt-1 mb-2 space-y-0.5 border-l border-gray-200">
|
<div className="pl-4 mt-1 mb-2 space-y-0.5 border-l border-gray-200">
|
||||||
<div className="px-2 py-1 text-xs text-gray-500 font-medium flex justify-between items-center">
|
|
||||||
<span>Folders</span>
|
|
||||||
</div>
|
|
||||||
{account.folders && account.folders.length > 0 ? (
|
{account.folders && account.folders.length > 0 ? (
|
||||||
account.folders.map((folder) => (
|
account.folders.map((folder) => (
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user