Skip to content

Commit

Permalink
Change all button onClick to onPress
Browse files Browse the repository at this point in the history
  • Loading branch information
ariady-putra committed Jan 17, 2025
1 parent 088049c commit 547b323
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 15 deletions.
11 changes: 9 additions & 2 deletions offchain/app/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export default function Home() {
try {
const errorString = JSON.stringify(error);
const errorJSON = JSON.parse(errorString);

return errorJSON;
} catch {
return {};
Expand All @@ -41,10 +40,18 @@ export default function Home() {
const { failure } = cause ?? {};

const failureCause = failure?.cause;

let failureTrace: string | undefined;
try {
failureTrace = eval(failureCause).replaceAll(" Trace ", " \n ");
} catch {
failureTrace = undefined;
}

const failureInfo = failureCause?.info;
const failureMessage = failureCause?.message;

setResult(`${failureInfo ?? failureMessage ?? info ?? message ?? error}`);
setResult(`${failureTrace ?? failureInfo ?? failureMessage ?? info ?? message ?? error}`);
console.error(failureCause ?? { error });
}

Expand Down
2 changes: 1 addition & 1 deletion offchain/components/WalletConnectors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function WalletConnectors(props: { onConnectWallet: (wallet: Wall
{wallets.map((wallet, w) => (
<Button
key={`wallet.${w}`}
onClick={() => onConnectWallet(wallet)}
onPress={() => onConnectWallet(wallet)}
className="bg-gradient-to-tr from-pink-500 to-yellow-500 text-white shadow-lg capitalize"
radius="full"
>
Expand Down
10 changes: 5 additions & 5 deletions offchain/components/actions/OwnerDry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default function OwnerDry(props: {
</ModalBody>
<ModalFooter>
<Button
onClick={() => onDeposit(lovelace).then(onClose)}
onPress={() => onDeposit(lovelace).then(onClose)}
className="bg-gradient-to-tr from-pink-500 to-yellow-500 text-white shadow-lg"
radius="full"
>
Expand Down Expand Up @@ -136,7 +136,7 @@ export default function OwnerDry(props: {
<ModalFooter>
<div className="relative">
<Button
onClick={() => onDelegateStake({ poolID, dRep }).then(onClose)}
onPress={() => onDelegateStake({ poolID, dRep }).then(onClose)}
isDisabled={isDRepCredential(dRep) && !dRepCredentialHash}
className={`bg-gradient-to-tr from-pink-500 to-yellow-500 text-white shadow-lg
${isDRepCredential(dRep) && dRepID && !dRepCredentialHash && "invisible"}`}
Expand All @@ -163,15 +163,15 @@ export default function OwnerDry(props: {

<DepositButton />

<Button onClick={onWithdrawStake} className="bg-gradient-to-tr from-slate-500 to-emerald-500 text-white shadow-lg" radius="full">
<Button onPress={onWithdrawStake} className="bg-gradient-to-tr from-slate-500 to-emerald-500 text-white shadow-lg" radius="full">
Withdraw Stake Rewards
</Button>

<Button onClick={onWithdraw} className="bg-gradient-to-tr from-primary-500 to-teal-500 text-white shadow-lg" radius="full">
<Button onPress={onWithdraw} className="bg-gradient-to-tr from-primary-500 to-teal-500 text-white shadow-lg" radius="full">
Withdraw from Spend
</Button>

<Button onClick={onUnregisterStake} className="bg-gradient-to-tr from-slate-500 to-emerald-500 text-white shadow-lg" radius="full">
<Button onPress={onUnregisterStake} className="bg-gradient-to-tr from-slate-500 to-emerald-500 text-white shadow-lg" radius="full">
Deregister Stake
</Button>
</div>
Expand Down
14 changes: 7 additions & 7 deletions offchain/components/actions/Withdraw0.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ export default function Withdraw0(props: {
showMonthAndYearPickers
minValue={now}
defaultValue={now}
onChange={(value) => setSpendableAfter(BigInt(value.toDate().getTime()))}
onChange={(value) => setSpendableAfter((spendableAfter) => (value ? BigInt(value.toDate().getTime()) : spendableAfter))}
/>
</ModalBody>
<ModalFooter>
<Button
onClick={() => onCreate({ spendableAfter, spendableBy }).then(onClose).catch(onError)}
onPress={() => onCreate({ spendableAfter, spendableBy }).then(onClose).catch(onError)}
className="bg-gradient-to-tr from-pink-500 to-yellow-500 text-white shadow-lg"
radius="full"
>
Expand Down Expand Up @@ -203,7 +203,7 @@ export default function Withdraw0(props: {
</ModalBody>
<ModalFooter>
<Button
onClick={() => collectDeposit().then(onDeposit).then(onClose).catch(onError)}
onPress={() => collectDeposit().then(onDeposit).then(onClose).catch(onError)}
className="bg-gradient-to-tr from-pink-500 to-yellow-500 text-white shadow-lg"
radius="full"
>
Expand Down Expand Up @@ -239,7 +239,7 @@ export default function Withdraw0(props: {
</ModalBody>
<ModalFooter>
<Button
onClick={() => onWithdraw(fromSender).then(onClose).catch(onError)}
onPress={() => onWithdraw(fromSender).then(onClose).catch(onError)}
className="bg-gradient-to-tr from-pink-500 to-yellow-500 text-white shadow-lg"
radius="full"
>
Expand Down Expand Up @@ -326,7 +326,7 @@ export default function Withdraw0(props: {
<ModalFooter>
<div className="relative">
<Button
onClick={() => onDelegateStake({ poolID, dRep }).then(onClose).catch(onError)}
onPress={() => onDelegateStake({ poolID, dRep }).then(onClose).catch(onError)}
isDisabled={isDRepCredential(dRep) && !dRepCredentialHash}
className={`bg-gradient-to-tr from-pink-500 to-yellow-500 text-white shadow-lg
${isDRepCredential(dRep) && dRepID && !dRepCredentialHash && "invisible"}`}
Expand Down Expand Up @@ -355,13 +355,13 @@ export default function Withdraw0(props: {

<DepositButton />

<Button onClick={onWithdrawStake} className="bg-gradient-to-tr from-slate-500 to-emerald-500 text-white shadow-lg" radius="full">
<Button onPress={onWithdrawStake} className="bg-gradient-to-tr from-slate-500 to-emerald-500 text-white shadow-lg" radius="full">
Withdraw Stake Rewards
</Button>

<WithdrawButton />

<Button onClick={onUnregisterStake} className="bg-gradient-to-tr from-slate-500 to-emerald-500 text-white shadow-lg" radius="full">
<Button onPress={onUnregisterStake} className="bg-gradient-to-tr from-slate-500 to-emerald-500 text-white shadow-lg" radius="full">
Deregister Stake
</Button>
</div>
Expand Down

0 comments on commit 547b323

Please sign in to comment.