From ddd80d8c9ba3eac04b78a4b9d0b529f6e400dc3e Mon Sep 17 00:00:00 2001 From: Ajidokwu Sabo Date: Tue, 28 Jul 2026 18:41:57 +0100 Subject: [PATCH 1/4] feat: add memo input with byte counter and validation (#484) --- src/components/invoice/MemoInput.tsx | 57 ++++++++++++++++++++++++++++ src/lib/stellar.ts | 1 + 2 files changed, 58 insertions(+) create mode 100644 src/components/invoice/MemoInput.tsx diff --git a/src/components/invoice/MemoInput.tsx b/src/components/invoice/MemoInput.tsx new file mode 100644 index 0000000..6ffafd9 --- /dev/null +++ b/src/components/invoice/MemoInput.tsx @@ -0,0 +1,57 @@ +"use client"; + +import { useState, useCallback } from "react"; +import { MEMO_MAX_BYTES } from "@/lib/stellar"; + +interface MemoInputProps { + value: string; + onChange: (value: string) => void; + disabled?: boolean; + placeholder?: string; +} + +export default function MemoInput({ + value, + onChange, + disabled = false, + placeholder = "Add a memo (optional)", +}: MemoInputProps) { + const byteLength = new TextEncoder().encode(value).length; + const isAtLimit = byteLength >= MEMO_MAX_BYTES; + const isOverLimit = byteLength > MEMO_MAX_BYTES; + + const handleChange = (e: React.ChangeEvent) => { + onChange(e.target.value); + }; + + return ( +
+ +