mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2026-12-06 00:37:23 +00:00
add slider reset for payment confirmation
This commit is contained in:
1 parent
722b1a743f
commit
24920117ae
1 file changed
+65
-24
@@ -86,6 +86,9 @@ export function TransactionCard({
|
|||||||
const [addressSliderValue, setAddressSliderValue] = useState([0]);
|
const [addressSliderValue, setAddressSliderValue] = useState([0]);
|
||||||
const [bitcoinSliderValue, setBitcoinSliderValue] = useState([0]);
|
const [bitcoinSliderValue, setBitcoinSliderValue] = useState([0]);
|
||||||
|
|
||||||
|
// State to track which slider is being actively held
|
||||||
|
const [activeSlider, setActiveSlider] = useState<string | null>(null);
|
||||||
|
|
||||||
// Handle slider value changes and auto-submit at 100%
|
// Handle slider value changes and auto-submit at 100%
|
||||||
const handleInvoiceSliderChange = (value: number[]) => {
|
const handleInvoiceSliderChange = (value: number[]) => {
|
||||||
setInvoiceSliderValue(value);
|
setInvoiceSliderValue(value);
|
||||||
@@ -114,6 +117,23 @@ export function TransactionCard({
|
|||||||
setAddressSliderValue([0]);
|
setAddressSliderValue([0]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handle slider release (reset on mouse/touch up)
|
||||||
|
const handleSliderMouseUp = (sliderId: string) => {
|
||||||
|
setActiveSlider(null);
|
||||||
|
// Reset the slider if it hasn't reached 100
|
||||||
|
if (sliderId === 'invoice' && invoiceSliderValue[0] !== 100) {
|
||||||
|
setInvoiceSliderValue([0]);
|
||||||
|
} else if (sliderId === 'address' && addressSliderValue[0] !== 100) {
|
||||||
|
setAddressSliderValue([0]);
|
||||||
|
} else if (sliderId === 'bitcoin' && bitcoinSliderValue[0] !== 100) {
|
||||||
|
setBitcoinSliderValue([0]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSliderMouseDown = (sliderId: string) => {
|
||||||
|
setActiveSlider(sliderId);
|
||||||
|
};
|
||||||
|
|
||||||
// Reset sliders when pending states change
|
// Reset sliders when pending states change
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!pendingInvoice) {
|
if (!pendingInvoice) {
|
||||||
@@ -245,14 +265,21 @@ export function TransactionCard({
|
|||||||
/>
|
/>
|
||||||
<div className="mt-6">
|
<div className="mt-6">
|
||||||
<div className="relative w-full">
|
<div className="relative w-full">
|
||||||
<Slider
|
<div
|
||||||
value={bitcoinSliderValue}
|
onMouseDown={() => handleSliderMouseDown('bitcoin')}
|
||||||
onValueChange={handleBitcoinSliderChange}
|
onMouseUp={() => handleSliderMouseUp('bitcoin')}
|
||||||
max={100}
|
onMouseLeave={() => handleSliderMouseUp('bitcoin')}
|
||||||
step={1}
|
onTouchEnd={() => handleSliderMouseUp('bitcoin')}
|
||||||
className="w-full h-12"
|
>
|
||||||
disabled={!bitcoinAmount || isLoading}
|
<Slider
|
||||||
/>
|
value={bitcoinSliderValue}
|
||||||
|
onValueChange={handleBitcoinSliderChange}
|
||||||
|
max={100}
|
||||||
|
step={1}
|
||||||
|
className="w-full h-12"
|
||||||
|
disabled={!bitcoinAmount || isLoading}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<div className="absolute inset-0 flex items-center justify-center pointer-events-none">
|
<div className="absolute inset-0 flex items-center justify-center pointer-events-none">
|
||||||
<span className="text-sm font-medium text-muted-foreground">
|
<span className="text-sm font-medium text-muted-foreground">
|
||||||
{bitcoinSliderValue[0] === 100 ? 'Confirmed!' : 'Slide to Confirm'}
|
{bitcoinSliderValue[0] === 100 ? 'Confirmed!' : 'Slide to Confirm'}
|
||||||
@@ -324,14 +351,21 @@ export function TransactionCard({
|
|||||||
<div className="space-y-8">
|
<div className="space-y-8">
|
||||||
<div className="mt-6">
|
<div className="mt-6">
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
<Slider
|
<div
|
||||||
value={invoiceSliderValue}
|
onMouseDown={() => handleSliderMouseDown('invoice')}
|
||||||
onValueChange={handleInvoiceSliderChange}
|
onMouseUp={() => handleSliderMouseUp('invoice')}
|
||||||
max={100}
|
onMouseLeave={() => handleSliderMouseUp('invoice')}
|
||||||
step={1}
|
onTouchEnd={() => handleSliderMouseUp('invoice')}
|
||||||
className="w-full h-12"
|
>
|
||||||
disabled={!activeMintUrl || isLoading}
|
<Slider
|
||||||
/>
|
value={invoiceSliderValue}
|
||||||
|
onValueChange={handleInvoiceSliderChange}
|
||||||
|
max={100}
|
||||||
|
step={1}
|
||||||
|
className="w-full h-12"
|
||||||
|
disabled={!activeMintUrl || isLoading}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<div className="absolute inset-0 flex items-center justify-center pointer-events-none">
|
<div className="absolute inset-0 flex items-center justify-center pointer-events-none">
|
||||||
<span className="text-sm font-medium text-muted-foreground">
|
<span className="text-sm font-medium text-muted-foreground">
|
||||||
{invoiceSliderValue[0] === 100 ? 'Confirmed!' : 'Slide to Confirm'}
|
{invoiceSliderValue[0] === 100 ? 'Confirmed!' : 'Slide to Confirm'}
|
||||||
@@ -358,14 +392,21 @@ export function TransactionCard({
|
|||||||
/>
|
/>
|
||||||
<div className="mt-6">
|
<div className="mt-6">
|
||||||
<div className="relative w-full">
|
<div className="relative w-full">
|
||||||
<Slider
|
<div
|
||||||
value={addressSliderValue}
|
onMouseDown={() => handleSliderMouseDown('address')}
|
||||||
onValueChange={handleAddressSliderChange}
|
onMouseUp={() => handleSliderMouseUp('address')}
|
||||||
max={100}
|
onMouseLeave={() => handleSliderMouseUp('address')}
|
||||||
step={1}
|
onTouchEnd={() => handleSliderMouseUp('address')}
|
||||||
className="w-full h-12"
|
>
|
||||||
disabled={!lightningAddressAmount || !activeMintUrl || isResolvingAddress || isLoading}
|
<Slider
|
||||||
/>
|
value={addressSliderValue}
|
||||||
|
onValueChange={handleAddressSliderChange}
|
||||||
|
max={100}
|
||||||
|
step={1}
|
||||||
|
className="w-full h-12"
|
||||||
|
disabled={!lightningAddressAmount || !activeMintUrl || isResolvingAddress || isLoading}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<div className="absolute inset-0 flex items-center justify-center pointer-events-none">
|
<div className="absolute inset-0 flex items-center justify-center pointer-events-none">
|
||||||
<span className="text-sm font-medium text-muted-foreground">
|
<span className="text-sm font-medium text-muted-foreground">
|
||||||
{addressSliderValue[0] === 100 ? 'Confirmed!' : 'Slide to Confirm'}
|
{addressSliderValue[0] === 100 ? 'Confirmed!' : 'Slide to Confirm'}
|
||||||
|
|||||||
Reference in new issue
Block a user