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.
This commit is contained in:
parent
871176ba92
commit
76e65f4f79
@ -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)), 'حساب بانکی تأیید شد')
|
||||
)
|
||||
|
||||
@ -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) => {
|
||||
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,
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user