refactor: update agent API schemas, standardize UI text styling, and enhance settlement credit ledger components
This commit is contained in:
@@ -98,6 +98,10 @@ function defaultRiskRowFromAmount(amount: number): DraftRiskRow {
|
||||
};
|
||||
}
|
||||
|
||||
function formatMinorToEditableMajor(minor: number, currencyCode: string): string {
|
||||
return formatAdminMinorDecimal(minor, currencyCode).replace(/,/g, "");
|
||||
}
|
||||
|
||||
export function RiskCapDocScreen() {
|
||||
const { t } = useTranslation(["config", "adminUsers", "common"]);
|
||||
const tRef = useTranslationRef(["config", "common"]);
|
||||
@@ -161,7 +165,7 @@ export function RiskCapDocScreen() {
|
||||
setDefaultCapStr("");
|
||||
return;
|
||||
}
|
||||
setDefaultCapStr(formatAdminMinorDecimal(defaultRow.cap_amount, amountCurrencyCode));
|
||||
setDefaultCapStr(formatMinorToEditableMajor(defaultRow.cap_amount, amountCurrencyCode));
|
||||
}
|
||||
|
||||
const loadDetail = useCallback(async (id: number) => {
|
||||
@@ -381,7 +385,12 @@ export function RiskCapDocScreen() {
|
||||
() => specialRows.filter(({ row }) => row.draw_id != null),
|
||||
[specialRows],
|
||||
);
|
||||
const defaultCapDisplay = defaultCapStr || formatAdminMinorDecimal(0, amountCurrencyCode);
|
||||
const defaultCapDisplay = detail
|
||||
? formatAdminMinorDecimal(
|
||||
draftRows.find(isDefaultRiskRow)?.cap_amount ?? 0,
|
||||
amountCurrencyCode,
|
||||
)
|
||||
: formatAdminMinorDecimal(0, amountCurrencyCode);
|
||||
|
||||
async function handleDeleteVersion(row: ConfigVersionSummary) {
|
||||
try {
|
||||
@@ -524,7 +533,7 @@ export function RiskCapDocScreen() {
|
||||
].map((card) => (
|
||||
<div key={card.key} className="rounded-xl border border-border/60 bg-background p-4 shadow-sm">
|
||||
<p className="text-xs text-muted-foreground">{card.label}</p>
|
||||
<p className="mt-1 font-mono text-lg font-semibold tabular-nums">{card.value}</p>
|
||||
<p className="mt-1 text-2xl font-semibold tabular-nums text-foreground">{card.value}</p>
|
||||
<p className="mt-2 text-xs leading-5 text-muted-foreground">{card.hint}</p>
|
||||
</div>
|
||||
))}
|
||||
@@ -539,15 +548,15 @@ export function RiskCapDocScreen() {
|
||||
id="default-cap"
|
||||
type="text"
|
||||
inputMode="decimal"
|
||||
className="w-[220px] font-mono tabular-nums"
|
||||
className="h-9 w-[220px] text-base font-semibold"
|
||||
disabled={saving}
|
||||
value={defaultCapStr}
|
||||
placeholder={t("riskCap.placeholders.defaultCap", { ns: "config" })}
|
||||
onChange={(e) => setDefaultCapStr(e.target.value)}
|
||||
/>
|
||||
) : (
|
||||
<ConfigReadonlyValue mono className="w-[220px]">
|
||||
{defaultCapStr || formatAdminMinorDecimal(0, amountCurrencyCode)}
|
||||
<ConfigReadonlyValue className="h-9 w-[220px] text-base font-semibold">
|
||||
{defaultCapDisplay}
|
||||
</ConfigReadonlyValue>
|
||||
)}
|
||||
</div>
|
||||
@@ -679,9 +688,9 @@ export function RiskCapDocScreen() {
|
||||
<Input
|
||||
type="text"
|
||||
inputMode="decimal"
|
||||
className="h-8 font-mono tabular-nums"
|
||||
className="h-8 tabular-nums"
|
||||
disabled={saving}
|
||||
value={formatAdminMinorDecimal(r.cap_amount, amountCurrencyCode)}
|
||||
value={formatMinorToEditableMajor(r.cap_amount, amountCurrencyCode)}
|
||||
placeholder={t("riskCap.placeholders.capAmount", { ns: "config" })}
|
||||
onChange={(e) =>
|
||||
updateRow(idx, {
|
||||
@@ -691,7 +700,7 @@ export function RiskCapDocScreen() {
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<ConfigReadonlyValue mono>
|
||||
<ConfigReadonlyValue>
|
||||
{formatAdminMinorDecimal(r.cap_amount, amountCurrencyCode)}
|
||||
</ConfigReadonlyValue>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user