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
6 changed files
with
105 additions
and
21 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
58 changes: 58 additions & 0 deletions
58
_pages/profile/[id]/submission-details-card/vouch-button.js
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,58 @@ | ||
import { | ||
Box, | ||
Button, | ||
Popup, | ||
Text, | ||
useContract, | ||
useWeb3, | ||
} from "@kleros/components"; | ||
import { Warning } from "@kleros/icons"; | ||
import { useMemo } from "react"; | ||
|
||
export default function VouchButton({ submissionID }) { | ||
const [accounts] = useWeb3("eth", "getAccounts"); | ||
const [vouched, , status, reCall] = useContract( | ||
"proofOfHumanity", | ||
"vouches", | ||
useMemo(() => ({ args: [accounts?.[0], submissionID] }), [ | ||
accounts, | ||
submissionID, | ||
]) | ||
); | ||
const { send, loading } = useContract( | ||
"proofOfHumanity", | ||
vouched ? "removeVouch" : "addVouch" | ||
); | ||
const text = status !== "pending" && `${vouched ? "" : "Remove "}Vouch`; | ||
return ( | ||
<Popup | ||
trigger={ | ||
<Button | ||
sx={{ | ||
marginY: 2, | ||
width: "100%", | ||
}} | ||
> | ||
{text} | ||
</Button> | ||
} | ||
modal | ||
> | ||
<Box sx={{ padding: 2 }}> | ||
<Warning /> | ||
<Text sx={{ marginBottom: 2 }}> | ||
Make sure the person exists and that you have physically encountered | ||
them. Note that in the case of a dispute, if a submission is rejected | ||
for reason “Duplicate” or “Does not exist”, everyone who had vouched | ||
for it will get removed from the registry. | ||
</Text> | ||
<Button | ||
onClick={() => send(submissionID).then(reCall)} | ||
loading={loading} | ||
> | ||
{text} | ||
</Button> | ||
</Box> | ||
</Popup> | ||
); | ||
} |
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
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,19 @@ | ||
import { SVG } from "@kleros/components"; | ||
|
||
export default function Warning({ size = 16, ...rest }) { | ||
return ( | ||
<SVG | ||
width={size} | ||
height={size} | ||
viewBox="0 0 18 16" | ||
fill="none" | ||
xmlns="http://www.w3.org/2000/svg" | ||
{...rest} | ||
> | ||
<path | ||
d="M17.7974 13.7504C18.3742 14.7502 17.6502 16 16.4981 16H1.5017C0.347415 16 -0.373272 14.7483 0.202415 13.7504L7.70073 0.749531C8.27782 -0.25075 9.72323 -0.248937 10.2993 0.749531L17.7974 13.7504ZM9.00001 11.0625C8.2061 11.0625 7.56251 11.7061 7.56251 12.5C7.56251 13.2939 8.2061 13.9375 9.00001 13.9375C9.79391 13.9375 10.4375 13.2939 10.4375 12.5C10.4375 11.7061 9.79391 11.0625 9.00001 11.0625ZM7.63523 5.89544L7.86704 10.1454C7.87788 10.3443 8.04232 10.5 8.24148 10.5H9.75854C9.9577 10.5 10.1221 10.3443 10.133 10.1454L10.3648 5.89544C10.3765 5.68063 10.2055 5.5 9.99035 5.5H8.00963C7.79451 5.5 7.62351 5.68063 7.63523 5.89544Z" | ||
fill="#ff9900" | ||
/> | ||
</SVG> | ||
); | ||
} |