diff --git a/admin-spa/src/components/settings/GenericGatewayForm.tsx b/admin-spa/src/components/settings/GenericGatewayForm.tsx index ace1343..88e8ae1 100644 --- a/admin-spa/src/components/settings/GenericGatewayForm.tsx +++ b/admin-spa/src/components/settings/GenericGatewayForm.tsx @@ -13,7 +13,7 @@ import { } from '@/components/ui/select'; import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'; import { Alert, AlertDescription } from '@/components/ui/alert'; -import { ExternalLink, AlertTriangle, Plus, Trash2 } from 'lucide-react'; +import { ExternalLink, AlertTriangle, Plus, Trash2, Edit2, ChevronDown, ChevronUp } from 'lucide-react'; interface GatewayField { id: string; @@ -258,6 +258,9 @@ export function GenericGatewayForm({ gateway, onSave, onCancel, hideFooter = fal accounts = value; } + // Track which account is being edited (-1 = none, index = editing) + const [editingIndex, setEditingIndex] = React.useState(-1); + const addAccount = () => { const newAccounts = [...accounts, { account_name: '', @@ -268,11 +271,13 @@ export function GenericGatewayForm({ gateway, onSave, onCancel, hideFooter = fal bic: '' }]; handleFieldChange(field.id, newAccounts); + setEditingIndex(newAccounts.length - 1); // Auto-expand new account }; const removeAccount = (index: number) => { const newAccounts = accounts.filter((_, i) => i !== index); handleFieldChange(field.id, newAccounts); + setEditingIndex(-1); }; const updateAccount = (index: number, key: keyof BankAccount, val: string) => { @@ -282,7 +287,7 @@ export function GenericGatewayForm({ gateway, onSave, onCancel, hideFooter = fal }; return ( -
+
-
- {accounts.map((account, index) => ( -
-
-

Account {index + 1}

- +
+ {accounts.map((account, index) => { + const isEditing = editingIndex === index; + const displayText = account.bank_name && account.account_number && account.account_name + ? `${account.bank_name}: ${account.account_number} - ${account.account_name}` + : 'New Account (click to edit)'; + + return ( +
+ {/* Compact view */} + {!isEditing && ( +
+ +
+ + +
+
+ )} + + {/* Expanded edit form */} + {isEditing && ( +
+
+

Account {index + 1}

+ +
+ +
+
+ + updateAccount(index, 'account_name', e.target.value)} + placeholder="e.g., Business Account" + className="h-9" + /> +
+ +
+ + updateAccount(index, 'account_number', e.target.value)} + placeholder="e.g., 12345678" + className="h-9" + /> +
+ +
+ + updateAccount(index, 'bank_name', e.target.value)} + placeholder="e.g., Bank Central Asia" + className="h-9" + /> +
+ +
+ + updateAccount(index, 'sort_code', e.target.value)} + placeholder="e.g., 12-34-56" + className="h-9" + /> +
+ +
+ + updateAccount(index, 'iban', e.target.value)} + placeholder="e.g., GB29 NWBK 6016 1331 9268 19" + className="h-9" + /> +
+ +
+ + updateAccount(index, 'bic', e.target.value)} + placeholder="e.g., NWBKGB2L" + className="h-9" + /> +
+
+ +
+ +
+
+ )}
- -
-
- - updateAccount(index, 'account_name', e.target.value)} - placeholder="e.g., Business Account" - className="h-9" - /> -
- -
- - updateAccount(index, 'account_number', e.target.value)} - placeholder="e.g., 12345678" - className="h-9" - /> -
- -
- - updateAccount(index, 'bank_name', e.target.value)} - placeholder="e.g., Bank Central Asia" - className="h-9" - /> -
- -
- - updateAccount(index, 'sort_code', e.target.value)} - placeholder="e.g., 12-34-56" - className="h-9" - /> -
- -
- - updateAccount(index, 'iban', e.target.value)} - placeholder="e.g., GB29 NWBK 6016 1331 9268 19" - className="h-9" - /> -
- -
- - updateAccount(index, 'bic', e.target.value)} - placeholder="e.g., NWBKGB2L" - className="h-9" - /> -
-
-
- ))} + ); + })}