Skip to content

Commit

Permalink
Minor cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
huyndo committed Nov 3, 2022
1 parent 87b6074 commit dc3a2ab
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { COMMANDS } from "../cmds"
import useCurrentUser from "../hooks/use-current-user"
import useConfig from "../hooks/use-config"
import { init } from "@onflow/fcl-wc"
import Loading from "./loading";
import Loading from "./loading"
import Image from "next/image"
import "../flow/config"

Expand All @@ -21,27 +21,26 @@ export default function Home() {
const currentUser = useCurrentUser()
const config = useConfig()
const [services, setServices] = useState([])
const [isLoading, setIsLoading] = useState(false);
const [isLoading, setIsLoading] = useState(false)
const discoveryWalletInputRef = useRef(null)
const [status, setStatus] = useState(null)

const renderCommand = (d) => {
const renderCommand = d => {
return (
<li key={d.LABEL}>
<button onClick={() => clickHandler(d)}>{d.LABEL}</button>
</li>
);
};
)
}

async function clickHandler(d) {
setIsLoading(true);
await d.CMD();
setIsLoading(false);
setIsLoading(true)
await d.CMD()
setIsLoading(false)
}

useEffect(() => {
const initAdapter = async () => {
const { FclWcServicePlugin, client } = await init({
const { FclWcServicePlugin } = await init({
projectId: WC_PROJECT_ID,
metadata: WC_METADATA,
includeBaseWC: true,
Expand Down Expand Up @@ -74,8 +73,7 @@ export default function Home() {

return (
<div>
<ul>{COMMANDS.map(cmd => renderCommand(cmd, setStatus))}</ul>
<pre>Status: {status ?? ""}</pre>
<ul>{COMMANDS.map(cmd => renderCommand(cmd))}</ul>
<div>
{services?.map(service => (
<span key={service.provider.address}>
Expand All @@ -93,12 +91,12 @@ export default function Home() {
</div>
<div style={{ marginTop: "12px" }}>
<label htmlFor="manual-wallet">
Manually set "discovery.wallet" config:{" "}
{'Manually set "discovery.wallet" config:'}
</label>
<input ref={discoveryWalletInputRef} name="manual-wallet"></input>
<button
onClick={async () =>
await fcl
onClick={() =>
fcl
.config()
.put("discovery.wallet", discoveryWalletInputRef?.current?.value)
}
Expand All @@ -107,7 +105,7 @@ export default function Home() {
</button>
</div>
<pre>{JSON.stringify({ currentUser, config }, null, 2)}</pre>
{isLoading ? <Loading/> : null}
{isLoading ? <Loading /> : null}
</div>
)
}

0 comments on commit dc3a2ab

Please sign in to comment.