From dc8febe5f839fce1be64da80e7b9031514fea6ea Mon Sep 17 00:00:00 2001 From: alma Date: Thu, 1 May 2025 21:08:50 +0200 Subject: [PATCH] courrier preview --- app/courrier/page.tsx | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/app/courrier/page.tsx b/app/courrier/page.tsx index a07938c9..eb582624 100644 --- a/app/courrier/page.tsx +++ b/app/courrier/page.tsx @@ -665,9 +665,30 @@ export default function CourrierPage() { setLoading(false); } }} - onEditAccount={(account) => { - setAccountToEdit(account as any); - setShowEditModal(true); + onEditAccount={async (account) => { + try { + // Get the latest account data from accounts array + const updatedAccount = accounts.find(a => a.id === account.id); + if (updatedAccount) { + setAccountToEdit(updatedAccount as any); + setShowEditModal(true); + } else { + toast({ + title: "Error", + description: "Could not find account data", + variant: "destructive", + duration: 3000 + }); + } + } catch (error) { + console.error("Error preparing account edit:", error); + toast({ + title: "Error", + description: "Failed to load account settings", + variant: "destructive", + duration: 3000 + }); + } }} onDeleteAccount={(account) => { setAccountToDelete(account as any); @@ -964,6 +985,8 @@ export default function CourrierPage() { ? {...account, name: displayName, color: color} : account )); + // Clear accountToEdit to ensure fresh data on next edit + setAccountToEdit(null); } catch (err) { toast({ title: 'Error', description: err instanceof Error ? err.message : 'Failed to update account settings', variant: 'destructive' }); } finally {