-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
187 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import useKaspa from "@/hooks/useKaspa" | ||
import useSettings from "@/hooks/useSettings" | ||
import { PlusIcon, SearchIcon } from "lucide-react" | ||
|
||
export default function Account () { | ||
const { kaspa, request } = useKaspa() | ||
const { settings, updateSetting } = useSettings() | ||
|
||
return ( | ||
<div className="collapse shadow-md"> | ||
<input type="radio" name="settings-accordion" /> | ||
<div className="collapse-title text-base font-bold">Account</div> | ||
<div className="collapse-content flex flex-col gap-3"> | ||
<div> | ||
<label className="form-control w-full"> | ||
<div className="label"> | ||
<span className="label-text">Node</span> | ||
<div className={`badge label-text-alt badge-outline badge-xs ${kaspa.connected ? 'badge-success' : 'badge-error'}`}> | ||
{kaspa.connected ? 'Connected' : 'Disconnected'} | ||
</div> | ||
</div> | ||
<select className="select select-ghost" value={settings.selectedNode} onChange={(e) => { | ||
const id = parseInt(e.target.value) | ||
|
||
updateSetting('selectedNode', id) | ||
request('node:connect', [ settings.nodes[id].address ]) | ||
}}> | ||
{settings.nodes.map((node, id) => { | ||
return ( | ||
<option key={id} value={id}>{node.name} - {node.address}</option> | ||
) | ||
})} | ||
</select> | ||
</label> | ||
<button className="btn btn-outline w-full" disabled> | ||
<PlusIcon /> | ||
Add Node | ||
</button> | ||
</div> | ||
<div> | ||
<div className="flex justify-between py-2 badge w-full"> | ||
<span className="font-medium text-xs">Receive addresses</span> | ||
<p className="tabular-nums font-mono">{kaspa.addresses[0].length}</p> | ||
</div> | ||
<div className="flex justify-between py-2 badge w-full"> | ||
<span className="font-medium text-xs">Change addresses</span> | ||
<p className="tabular-nums font-mono">{kaspa.addresses[1].length}</p> | ||
</div> | ||
<button className="btn btn-outline w-full" onClick={({ currentTarget }) => { | ||
currentTarget.disabled = true | ||
|
||
request('account:scan', []).then(() => { | ||
currentTarget.disabled = false | ||
}) | ||
}}> | ||
<SearchIcon /> | ||
Scan Addresses | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { currencies } from "@/contexts/Settings" | ||
import useSettings from "@/hooks/useSettings" | ||
import { DollarSignIcon } from "lucide-react" | ||
|
||
export default function General () { | ||
const { settings, updateSetting } = useSettings() | ||
|
||
return ( | ||
<div className="collapse shadow-md"> | ||
<input type="radio" name="settings-accordion" defaultChecked /> | ||
<div className="collapse-title text-base font-bold">General</div> | ||
<div className="collapse-content"> | ||
<button className="btn btn-outline w-full" onClick={() => { | ||
const tickers = Object.keys(currencies) | ||
const currentIndex = tickers.indexOf(settings.currency) | ||
const nextCurrency = tickers[(currentIndex + 1) % tickers.length] as keyof typeof currencies | ||
|
||
updateSetting('currency', nextCurrency) | ||
}}> | ||
<DollarSignIcon /> | ||
Currency: {settings.currency} | ||
</button> | ||
</div> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import useKaspa from "@/hooks/useKaspa" | ||
import { HammerIcon, XIcon } from "lucide-react" | ||
import { useEffect, useState } from "react" | ||
|
||
export default function Wallet () { | ||
const { request } = useKaspa() | ||
|
||
const [ count, setCount ] = useState<number>() | ||
|
||
useEffect(() => { | ||
if (count === undefined || count <= 0) return | ||
|
||
const timer = setInterval(() => { | ||
setCount(prevCount => prevCount ? prevCount - 1 : 0) | ||
}, 1000) | ||
|
||
return () => clearInterval(timer) | ||
}, [ count ]) | ||
|
||
return ( | ||
<div className="collapse shadow-md"> | ||
<input type="radio" name="settings-accordion" /> | ||
<div className="collapse-title text-base font-bold">Wallet</div> | ||
<div className="collapse-content"> | ||
{typeof count === 'undefined' && ( | ||
<button className="btn btn-error w-full" onClick={() => { | ||
setCount(10) | ||
}}> | ||
<HammerIcon /> | ||
Reset Wallet | ||
</button> | ||
)} | ||
{typeof count !== 'undefined' && ( | ||
<div className="flex flex-row gap-1"> | ||
<button className="btn btn-error w-40" disabled={count !== 0} onClick={() => { | ||
request('wallet:reset', []) | ||
}}> | ||
Are you sure? ({count}) | ||
</button> | ||
<button className="btn btn-circle" onClick={() => { | ||
setCount(undefined) | ||
}}> | ||
<XIcon /> | ||
</button> | ||
</div> | ||
)} | ||
</div> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters