mirror of
https://github.com/hanzoai/ui.git
synced 2026-11-20 22:36:27 +00:00
The workspace declared pkg/* and pkgs/* both, so one repo had two names for one concept and a package's home was a coin toss. The shared build tooling already lived in pkg/ui/scripts and pkgs reached back into it two levels up; now it is a sibling. hanzo.yml gates on pkg/ui, so the published library stays where CI already looks and the rest joins it. The publish glob follows: one root, one pattern, nothing invisible to it. Co-authored-by: Hanzo Dev <[email protected]>
87 lines
1.7 KiB
TypeScript
87 lines
1.7 KiB
TypeScript
'use client'
|
|
|
|
/**
|
|
* TopupButton — drop-in trigger button for HanzoTopup.
|
|
*
|
|
* Usage:
|
|
* <TopupButton userId="user_123" token={iamToken} defaultAmount={50_00} />
|
|
*/
|
|
|
|
import React, { useState } from 'react'
|
|
import type { TopupConfig } from '../types'
|
|
import { HanzoTopup } from './HanzoTopup'
|
|
|
|
export interface TopupButtonProps extends Partial<TopupConfig> {
|
|
/** Required: the user's account ID */
|
|
userId: string
|
|
|
|
/** Button label. Defaults to "Add Funds" */
|
|
label?: string
|
|
|
|
/** Additional inline style for the trigger button */
|
|
buttonStyle?: React.CSSProperties
|
|
|
|
/** Additional class name for the trigger button */
|
|
className?: string
|
|
}
|
|
|
|
export function TopupButton({
|
|
userId,
|
|
token,
|
|
baseUrl,
|
|
squareAppId,
|
|
squareLocationId,
|
|
squareEnv,
|
|
defaultAmount,
|
|
currency,
|
|
onSuccess,
|
|
onError,
|
|
label = 'Add Funds',
|
|
buttonStyle,
|
|
className,
|
|
}: TopupButtonProps) {
|
|
const [open, setOpen] = useState(false)
|
|
|
|
const config: TopupConfig = {
|
|
userId,
|
|
token,
|
|
baseUrl,
|
|
squareAppId,
|
|
squareLocationId,
|
|
squareEnv,
|
|
defaultAmount,
|
|
currency,
|
|
onSuccess,
|
|
onError,
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<button
|
|
type="button"
|
|
className={className}
|
|
onClick={() => setOpen(true)}
|
|
style={{
|
|
padding: '8px 16px',
|
|
borderRadius: '8px',
|
|
backgroundColor: 'rgb(250,250,250)',
|
|
color: 'rgb(9,9,11)',
|
|
fontSize: '14px',
|
|
fontWeight: '500',
|
|
border: 'none',
|
|
cursor: 'pointer',
|
|
...buttonStyle,
|
|
}}
|
|
>
|
|
{label}
|
|
</button>
|
|
|
|
<HanzoTopup
|
|
config={config}
|
|
open={open}
|
|
onOpenChange={setOpen}
|
|
/>
|
|
</>
|
|
)
|
|
}
|