From 5ed3b18a009d514ca50fc7963ea4d4db1dfc6a33 Mon Sep 17 00:00:00 2001 From: giancarlo Date: Thu, 18 Apr 2024 20:21:21 +0800 Subject: [PATCH] Refactor admin account page and email resend logic The changes include breaking out `is_personal_account` into its own constant for better readability in the Admin Account page. On the email resend logic, the code has been simplified, directly throwing an error when the response is not OK, thereby eliminating unnecessary conditional and assignment statements. --- .../features/admin/src/components/admin-account-page.tsx | 4 +++- packages/mailers/src/impl/resend/index.ts | 8 ++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/features/admin/src/components/admin-account-page.tsx b/packages/features/admin/src/components/admin-account-page.tsx index 2f8ae17fc..247e9bfb2 100644 --- a/packages/features/admin/src/components/admin-account-page.tsx +++ b/packages/features/admin/src/components/admin-account-page.tsx @@ -34,7 +34,9 @@ type Membership = Db['accounts_memberships']['Row']; export function AdminAccountPage(props: { account: Account & { memberships: Membership[] }; }) { - if (props.account.is_personal_account) { + const isPersonalAccount = props.account.is_personal_account; + + if (isPersonalAccount) { return ; } diff --git a/packages/mailers/src/impl/resend/index.ts b/packages/mailers/src/impl/resend/index.ts index 3dde5ded6..552c2b20c 100644 --- a/packages/mailers/src/impl/resend/index.ts +++ b/packages/mailers/src/impl/resend/index.ts @@ -43,12 +43,8 @@ export class ResendMailer implements Mailer { }), }); - if (res.ok) { - const data = await res.json(); - - return data; + if (!res.ok) { + throw new Error('Failed to send email'); } - - throw new Error('Failed to send email'); } }