From 12bdc3318d40b95c549c288160032a7ab464becc Mon Sep 17 00:00:00 2001 From: Nwatu Desmond Date: Mon, 31 Aug 2026 12:51:12 +0100 Subject: [PATCH] feat: add feature 142 API helper --- lib/api/index.ts | 34 +++++++++++++++++++++++++++++----- lib/utils.ts | 4 ++++ 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/lib/api/index.ts b/lib/api/index.ts index d38cf53..ddd390a 100644 --- a/lib/api/index.ts +++ b/lib/api/index.ts @@ -30,10 +30,34 @@ export interface ProtocolStatus { [key: string]: unknown; } +import { helperFunction142 } from "@/lib/utils"; import type { InvestmentPosition } from "@/lib/portfolio"; const API_BASE = process.env.NEXT_PUBLIC_API_URL ?? "/api"; +export interface FeatureComponent142Input { + label?: string; + metadata?: Record; +} + +export interface FeatureComponent142State { + label: string; + metadata: Record; + ready: boolean; +} + +export function FeatureComponent142( + input: FeatureComponent142Input = {} +): FeatureComponent142State { + const label = helperFunction142(input.label ?? "New Feature 142"); + + return { + label, + metadata: input.metadata ?? {}, + ready: label.length > 0, + }; +} + export async function fetchInvoices( cursor?: string, paramsObj?: Record @@ -57,7 +81,7 @@ export async function fetchInvoiceDetail(id: string): Promise { } /** Protocol-wide status, including the minimum investment floor the contract - * enforces (issue #116) — must be read from here rather than hardcoded, since + * enforces (issue #116) ? must be read from here rather than hardcoded, since * it can change independently of any one invoice. */ export async function fetchProtocolStatus(): Promise { const res = await fetch(`${API_BASE}/protocol/status`); @@ -78,7 +102,7 @@ export async function investInInvoice( return res.json(); } -/** Submits the `transfer_position` contract call (issue #119) — sells an +/** Submits the `transfer_position` contract call (issue #119) ? sells an * investor's funded-invoice position to `buyer` for `salePriceXlm`. */ export async function transferInvoicePosition( invoiceId: string, @@ -286,7 +310,7 @@ export async function approveAdminInvoice( return res.json(); } -// ─── Settlement multi-sig (issue #118) ────────────────────────────────────── +// ??? Settlement multi-sig (issue #118) ?????????????????????????????????????? // // Two admins must act to settle a funded invoice: one proposes a repayment // amount, a second (different) admin approves and executes it. @@ -345,7 +369,7 @@ export async function proposeSettlement( } /** Approves and executes a pending settlement proposal. The backend is the - * source of truth for the "not your own proposal" rule — a 403 here (e.g. + * source of truth for the "not your own proposal" rule ? a 403 here (e.g. * the proposing admin retrying via another tab) surfaces as this error. */ export async function approveSettlement( invoiceId: string, @@ -1293,4 +1317,4 @@ export async function approveKeyPause( throw new Error(await readErrorMessage(res, "Failed to approve pause")); } return normalizeAdminKeyControl(await res.json()); -} +} \ No newline at end of file diff --git a/lib/utils.ts b/lib/utils.ts index a5ef193..a2651cd 100644 --- a/lib/utils.ts +++ b/lib/utils.ts @@ -4,3 +4,7 @@ import { twMerge } from "tailwind-merge"; export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); } +export function helperFunction142(value: unknown): string { + if (typeof value !== "string") return ""; + return value.trim().replace(/\s+/g, " "); +}