From 76e65f4f799dc9a9677e37fae5a76524bbdbb242 Mon Sep 17 00:00:00 2001 From: alisaza Date: Sat, 5 Sep 2026 16:31:02 +0330 Subject: [PATCH] refactor: improve code readability and validation structure - Added a new line for better readability in the BankAccountsPage component when showing alert messages. - Refactored the test case for isRequestHostAllowed to enhance clarity. - Improved formatting in the CreateBankAccountFormValidation schema for the nationalCode field. --- app/(dashboard)/bank-accounts/page.tsx | 1 + lib/security/requestHost.test.ts | 13 ++++++------- validation/withdrawal.ts | 5 ++++- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/app/(dashboard)/bank-accounts/page.tsx b/app/(dashboard)/bank-accounts/page.tsx index 8422817..3a64068 100644 --- a/app/(dashboard)/bank-accounts/page.tsx +++ b/app/(dashboard)/bank-accounts/page.tsx @@ -128,6 +128,7 @@ const BankAccountsPage = () => { } const userName = formatPersonName(row.user?.firstName, row.user?.lastName) || row.iban + showAlert(`حساب «${userName}» تأیید شود؟`, () => runAction(row.id, () => axiosInstance.patch(API_ROUTES.BANK_ACCOUNTS.ADMIN_APPROVE(row.id)), 'حساب بانکی تأیید شد') ) diff --git a/lib/security/requestHost.test.ts b/lib/security/requestHost.test.ts index a899587..181296e 100644 --- a/lib/security/requestHost.test.ts +++ b/lib/security/requestHost.test.ts @@ -3,13 +3,12 @@ import { describe, expect, it } from 'vitest' import { isRequestHostAllowed } from '@/lib/security/requestHost' describe('isRequestHostAllowed', () => { - it.each([ - 'backoffice.ghabilee.ir', - 'backoffice.ghabilee.ir:443', - 'BACKOFFICE.GHABILEE.IR', - ])('allows a canonical production host: %s', (host) => { - expect(isRequestHostAllowed(host, 'production')).toBe(true) - }) + it.each(['backoffice.ghabilee.ir', 'backoffice.ghabilee.ir:443', 'BACKOFFICE.GHABILEE.IR'])( + 'allows a canonical production host: %s', + (host) => { + expect(isRequestHostAllowed(host, 'production')).toBe(true) + } + ) it.each([ null, diff --git a/validation/withdrawal.ts b/validation/withdrawal.ts index 947c773..e066037 100644 --- a/validation/withdrawal.ts +++ b/validation/withdrawal.ts @@ -16,7 +16,10 @@ export const CreateBankAccountFormValidation = (requiresNationalCode: boolean) = .trim() .transform((value) => toEnglishDigits(value).toUpperCase().replace(/\s+/g, '')) .refine((value) => /^IR\d{24}$/.test(value), v.ibanInvalid), - nationalCode: z.string().trim().transform((value) => toEnglishDigits(value)), + nationalCode: z + .string() + .trim() + .transform((value) => toEnglishDigits(value)), }) .superRefine((value, ctx) => { if (!requiresNationalCode) return